try {
DeploymentData deploymentData = new DeploymentData(deploymentProps, baseDir, deployDir, allFiles,
allRawFilesToReplace, allArchives, allArchiveReplacePatterns, templateEngine, this.ignorePattern,
allArchivesExploded);
Deployer deployer = new Deployer(deploymentData);
DeployDifferences diffs = getProject().getDeployDifferences();
// we only want to emit audit trail when something is really going to happen on disk; don't log if doing a dry run
if (!dryRun) {
getProject().auditLog(AuditStatus.SUCCESS, "Deployer Started", "The deployer has started its work",
null, null);
}
if (revert) {
deployer.redeployAndRestoreBackupFiles(diffs, clean, dryRun);
} else {
deployer.deploy(diffs, clean, dryRun);
}
HandoverTarget handoverTarget = getProject().getHandoverTarget();
if (handoverTarget != null) {
for (HasHandover hasHandoverReference : contentToHandover) {
Handover handoverTag = hasHandoverReference.getHandover();
File source = getFileSource(hasHandoverReference, downloadedFilesToHandover, templateEngine);
FileInputStream contentStream = new FileInputStream(source);
HandoverInfo.Builder builder = new HandoverInfo.Builder();
builder.setContent(contentStream);
builder.setFilename(source.getName());
builder.setAction(handoverTag.getAction());
builder.setParams(handoverTag.getHandoverParams());
builder.setRevert(revert);
HandoverInfo handoverInfo = builder.createHandoverInfo();
if (!dryRun) {
try {
boolean handoverSuccess = handoverTarget.handoverContent(handoverInfo);
String informationMessage = "Source: " + source.getName() + ", " + handoverTag;
if (handoverSuccess) {
getProject().auditLog(AuditStatus.INFO, "Handover",
"Handover target reported success", informationMessage, null);
} else {
if (handoverTag.isFailonerror()) {
getProject().auditLog(AuditStatus.FAILURE, "Handover",
"Handover target reported a failure", informationMessage, null);
throw new Exception("Handover failed: " + handoverTag);
} else {
getProject().auditLog(AuditStatus.WARN, "Handover",
"Handover target reported a failure", informationMessage, null);
}
}
} finally {
safeClose(contentStream);
}
}
}
}
// we only want to emit audit trail when something is really going to happen on disk; don't log if doing a dry run
if (!dryRun) {
getProject().auditLog(AuditStatus.SUCCESS, "Deployer Finished",
"The deployer has finished its work", null, diffs.toString());
}
} catch (Throwable t) {
try {
getProject().auditLog(AuditStatus.FAILURE, "Deployer Failed",
"The deployer encountered an error and could not finished", ThrowableUtil.getAllMessages(t),