// now start the normal undeploying
this.name = appName;
this._type = application.archiveType();
ExtendedDeploymentContext deploymentContext = null;
try {
deploymentContext = deployment.getBuilder(logger, this, report).source(source).build();
} catch (IOException e) {
logger.log(Level.SEVERE, "Cannot create context for undeployment ", e);
report.setMessage(localStrings.getLocalString("undeploy.contextcreation.failed","Cannot create context for undeployment : {0} ", e.getMessage()));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
final InterceptorNotifier notifier = new InterceptorNotifier(habitat, deploymentContext);
final DeployCommandSupplementalInfo suppInfo = new DeployCommandSupplementalInfo();
suppInfo.setDeploymentContext(deploymentContext);
report.setResultType(DeployCommandSupplementalInfo.class, suppInfo);
final Properties appProps = deploymentContext.getAppProps();
appProps.putAll(application.getDeployProperties());
if (properties!=null) {
appProps.putAll(properties);
}
deploymentContext.setModulePropsMap(
application.getModulePropertiesMap());
events.send(new Event<DeploymentContext>(Deployment.UNDEPLOYMENT_VALIDATION, deploymentContext), false);
if (report.getActionExitCode()==ActionReport.ExitCode.FAILURE) {
// if one of the validation listeners sets the action report
// status as failure, return
return;
}
// disable the application first for non-DAS target
if (env.isDas() && !DeploymentUtils.isDASTarget(target)) {
ActionReport subReport = report.addSubActionsReport();
CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("disable", subReport, context.getSubject());
try {
final ParameterMapExtractor extractor = new ParameterMapExtractor(this);
final ParameterMap parameters = extractor.extract(Collections.EMPTY_LIST);
parameters.set("DEFAULT", appName);
parameters.add(DeploymentProperties.IS_UNDEPLOY, Boolean.TRUE.toString());
inv.parameters(parameters).execute();
if (subReport.getActionExitCode().equals(
ActionReport.ExitCode.FAILURE)) {
// if disable application failed
// we should just return
report.setMessage(localStrings.getLocalString("disable.command.failed","{0} disabled failed", appName));
return;
}
if (DeploymentUtils.isDomainTarget(target)) {
List<String> targets = domain.getAllReferencedTargetsForApplication(appName);
// replicate command to all referenced targets
parameters.remove("isUndeploy");
notifier.ensureBeforeReported(ExtendedDeploymentContext.Phase.REPLICATION);
ClusterOperationUtil.replicateCommand("undeploy", FailurePolicy.Error, FailurePolicy.Warn,
FailurePolicy.Ignore, targets, context, parameters, habitat);
}
} catch (Exception e) {
report.failure(logger, e.getMessage());
return;
}
}
/*
* Extract the generated artifacts from the application's properties
* and record them in the DC. This will be useful, for example,
* during Deployer.clean.
*/
final Artifacts generatedArtifacts = DeploymentUtils.generatedArtifacts(application);
generatedArtifacts.record(deploymentContext);
if (info!=null) {
deployment.undeploy(appName, deploymentContext);
}
// check if it's directory deployment
boolean isDirectoryDeployed =
Boolean.valueOf(application.getDirectoryDeployed());
// we should try to unregister the application for both success
// and warning case
if (!report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
// so far I am doing this after the unload, maybe this should be moved before...
try {
// remove the "application" element
deployment.unregisterAppFromDomainXML(appName, target);
} catch(TransactionFailure e) {
logger.warning("Module " + appName + " not found in configuration");
}
//remove context from generated
deploymentContext.clean();
//if directory deployment then do not remove the directory
if ( (! keepreposdir) && !isDirectoryDeployed && source.exists()) {
/*
* Delete the repository directory as an archive so