ContentResponseResult overallResult = ContentResponseResult.SUCCESS;
for (Object uncastedLog : logs) {
if (uncastedLog instanceof ActionHandlerMessageLog) {
ActionHandlerMessageLog messageLog = (ActionHandlerMessageLog) uncastedLog;
DeployPackageStep executedStep = messageLog.getStep();
steps.add(executedStep);
// The executed and unexecuted steps are link by their step key and the fact that the equals method
// uses this key (as such, their descriptions may be different). This is currently simply a counter.
// That counter is handled in different ways for translate v. logging an actual step. They should
// still map up, however this log message should output enough of a description for the reader
// to ensure that the unexecuted step being removed does correspond to the step found in the logs.
if (log.isDebugEnabled()) {
String executedStepKey = executedStep.getStepKey();
DeployPackageStep unexecutedStep = null;
for (DeployPackageStep s : unexecutedSteps) {
if (s.getStepKey().equals(executedStepKey)) {
unexecutedStep = s;
break;
}
}
if (unexecutedStep != null && log.isDebugEnabled()) {
log.debug("Mapped up steps:");
log.debug("Executed Step: " + executedStep);
log.debug("Unexecuted Step: " + unexecutedStep);
}
}
boolean unexecutedStepDeleted = unexecutedSteps.remove(executedStep);
if (!unexecutedStepDeleted) {
log.warn("Could not remove the following step from the unexecuted step list: " + executedStep);
}
// If any steps fail, mark the entire response as failed
if (executedStep.getStepResult() == ContentResponseResult.FAILURE) {
overallResult = ContentResponseResult.FAILURE;
}
}
}
// For every step that was supposed to run but didn't (those remaining in the unexecuted step list), tack
// them on to the end as not executed.
for (DeployPackageStep unexecutedStep : unexecutedSteps) {
unexecutedStep.setStepResult(ContentResponseResult.NOT_PERFORMED);
steps.add(unexecutedStep);
}
DeployIndividualPackageResponse response = new DeployIndividualPackageResponse(packageDetailsKey, overallResult);
response.setDeploymentSteps(steps);