}
}
private void cleanupPreservedResources(DeploymentContext dc, Event event) {
if (Deployment.DEPLOYMENT_FAILURE.equals(event.type())) {
final DeployCommandParameters deployCommandParameters =
dc.getCommandParameters(DeployCommandParameters.class);
if (deployCommandParameters.origin == OpsParams.Origin.deploy ||
deployCommandParameters.origin == OpsParams.Origin.deploy_instance ||
deployCommandParameters.origin == OpsParams.Origin.create_application_ref) {
Properties properties = deployCommandParameters.properties;
String appName = deployCommandParameters.name();
cleanupPreservedResources(appName, properties);
}
} else if (Deployment.UNDEPLOYMENT_FAILURE.equals(event.type())) {
final UndeployCommandParameters undeployCommandParameters =
dc.getCommandParameters(UndeployCommandParameters.class);