[java-identity-provider] 02/03: IDP-1595 Add constructor to BuildWar
Rod Widdowson
rdw at steadingsoftware.com
Mon Jul 13 13:31:13 UTC 2020
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=05ba38154bd1ed4dd711332840a07c993334334d
commit 05ba38154bd1ed4dd711332840a07c993334334d
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Jul 13 10:10:46 2020 +0100
IDP-1595 Add constructor to BuildWar
https://issues.shibboleth.net/jira/browse/IDP-1595
Allows use of the task by the plugin installer. Class API
but final so change is safe.
---
.../net/shibboleth/idp/installer/BuildWar.java | 39 ++++++++++++++++------
1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/BuildWar.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/BuildWar.java
index 17571a1e2..d4321e6fd 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/BuildWar.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/BuildWar.java
@@ -24,6 +24,8 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
+import javax.annotation.Nonnull;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Copy;
import org.apache.tools.ant.taskdefs.Jar;
@@ -32,7 +34,9 @@ import org.slf4j.LoggerFactory;
import net.shibboleth.idp.Version;
import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
+import net.shibboleth.utilities.java.support.logic.Constraint;
/**
* Code to build the war file during an install or on request.
@@ -52,19 +56,27 @@ public final class BuildWar extends AbstractInitializableComponent {
/** Log. */
private final Logger log = LoggerFactory.getLogger(BuildWar.class);
- /** Properties for the job. */
- private final InstallerProperties installerProps;
+ /** Location of the install for the job. */
+ private final Path targetDir;
/** Constructor.
* @param props The environment for the work.
* @param installState Where we are right now.
*/
- public BuildWar(final InstallerProperties props, final CurrentInstallState installState) {
+ public BuildWar(@Nonnull final InstallerProperties props, @Nonnull final CurrentInstallState installState) {
ComponentSupport.ifNotInitializedThrowUninitializedComponentException(props);
ComponentSupport.ifNotInitializedThrowUninitializedComponentException(installState);
- installerProps = props;
+ targetDir = props.getTargetDir();
+ }
+
+ /** Constructor.
+ * @param idpHome Where to install to.
+ */
+ public BuildWar(final Path idpHome) {
+ targetDir = Constraint.isNotNull(idpHome, "IdPHome should not be null");
}
+
/** Method to do a single overlay into webapp.
*
* @param from Where to copy from.
@@ -104,14 +116,13 @@ public final class BuildWar extends AbstractInitializableComponent {
*/
public void execute() throws BuildException {
ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
- final Path target = installerProps.getTargetDir();
- final Path warFile = target.resolve("war").resolve("idp.war");
+ final Path warFile = targetDir.resolve("war").resolve("idp.war");
log.info("Rebuilding {}, Version {}", warFile.toAbsolutePath(), Version.getVersion());
- InstallerSupport.deleteTree(target.resolve("webpapp"));
- final Path webAppTmp =target.resolve("webpapp.tmp");
+ InstallerSupport.deleteTree(targetDir.resolve("webpapp"));
+ final Path webAppTmp =targetDir.resolve("webpapp.tmp");
InstallerSupport.deleteTree(webAppTmp);
- final Path dist = target.resolve("dist");
+ final Path dist = targetDir.resolve("dist");
final Path distWebApp = dist.resolve("webapp");
final Copy initial = InstallerSupport.getCopyTask(distWebApp, webAppTmp);
initial.setPreserveLastModified(true);
@@ -121,7 +132,7 @@ public final class BuildWar extends AbstractInitializableComponent {
initial.execute();
overlayPluginWebapps(dist, webAppTmp);
- overlayWebapp(target.resolve("edit-webapp"), webAppTmp);
+ overlayWebapp(targetDir.resolve("edit-webapp"), webAppTmp);
final File warFileFile = warFile.toFile();
if (warFileFile.exists() && !warFile.toFile().delete()) {
@@ -133,4 +144,12 @@ public final class BuildWar extends AbstractInitializableComponent {
jarTask.execute();
InstallerSupport.deleteTree(webAppTmp);
}
+
+ /** {@inheritDoc} */
+ protected void doInitialize() throws ComponentInitializationException {
+ super.doInitialize();
+ if (!Files.exists(targetDir)) {
+ throw new ComponentInitializationException("Target Dir " + targetDir + " does not exist");
+ }
+ }
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list