addServerGroupUpdates(plan, au, sgda, model);
break;
}
case DEPLOY: {
logger.tracef("Deploy of deployment %s", dai.getDeploymentUnitUniqueName());
ServerGroupDeploymentStartStopUpdate sgdssu = new ServerGroupDeploymentStartStopUpdate(dai.getDeploymentUnitUniqueName(), true);
addServerGroupUpdates(plan, au, sgdssu, model);
break;
}
case FULL_REPLACE: {
logger.tracef("Full replace of deployment %s", dai.getDeploymentUnitUniqueName());
// Validate all relevant server groups are touched
String deploymentName = dai.getDeploymentUnitUniqueName();
Set<String> names = new LinkedHashSet<String>(model.getServerGroupNames());
for (Set<ServerGroupDeploymentPlan> ssgp : plan.getServerGroupDeploymentPlans()) {
for (ServerGroupDeploymentPlan sgdp : ssgp) {
names.remove(sgdp.getServerGroupName());
}
}
for (Iterator<String> it = names.iterator(); it.hasNext();) {
String name = it.next();
ServerGroupElement sge = model.getServerGroup(name);
if (sge.getDeployment(dai.getDeploymentUnitUniqueName()) == null) {
it.remove();
}
}
if (names.size() > 0) {
throw new IncompleteDeploymentReplaceException(deploymentName, names.toArray(new String[names.size()]));
}
DeploymentUnitElement deployment = model.getDeployment(dai.getDeploymentUnitUniqueName());
boolean start = deployment != null && deployment.isStart();
DomainDeploymentFullReplaceUpdate ddfru = new DomainDeploymentFullReplaceUpdate(deploymentName, dai.getNewContentFileName(), dai.getNewContentHash(), start);
au.domainUpdates.add(new DomainUpdate(ddfru, model, true));
break;
}
case REDEPLOY: {
logger.tracef("Redeploy of deployment %s", dai.getDeploymentUnitUniqueName());
DomainDeploymentRedeployUpdate ddru = new DomainDeploymentRedeployUpdate(dai.getDeploymentUnitUniqueName());
au.domainUpdates.add(new DomainUpdate(ddru, model, true));
break;
}
case REMOVE: {
logger.tracef("Remove of deployment %s", dai.getDeploymentUnitUniqueName());
ServerGroupDeploymentRemove sgdr = new ServerGroupDeploymentRemove(dai.getDeploymentUnitUniqueName());
addServerGroupUpdates(plan, au, sgdr, model);
// If no server group is using this, remove from domain
Set<String> names = model.getServerGroupNames();
for (Set<ServerGroupDeploymentPlan> ssgp : plan.getServerGroupDeploymentPlans()) {
for (ServerGroupDeploymentPlan sgdp : ssgp) {
names.remove(sgdp.getServerGroupName());
}
}
boolean left = false;
for (String name : names) {
ServerGroupElement sge = model.getServerGroup(name);
if (sge.getDeployment(dai.getDeploymentUnitUniqueName()) != null) {
left = true;
break;
}
}
if (!left) {
DomainDeploymentRemove ddr = new DomainDeploymentRemove(dai.getDeploymentUnitUniqueName());
au.domainUpdates.add(new DomainUpdate(ddr, model, true));
}
break;
}
case REPLACE: {
logger.tracef("Replace of deployment %s", dai.getDeploymentUnitUniqueName());
ServerGroupDeploymentReplaceUpdate sgdru = new ServerGroupDeploymentReplaceUpdate(dai.getDeploymentUnitUniqueName(), dai.getNewContentFileName(), dai.getNewContentHash(), dai.getReplacedDeploymentUnitUniqueName());
addServerGroupUpdates(plan, au, sgdru, model);
break;
}
case UNDEPLOY: {
logger.tracef("Undeploy of deployment %s", dai.getDeploymentUnitUniqueName());
ServerGroupDeploymentStartStopUpdate sgdssu = new ServerGroupDeploymentStartStopUpdate(dai.getDeploymentUnitUniqueName(), false);
addServerGroupUpdates(plan, au, sgdssu, model);
break;
}
default:
throw new IllegalStateException(String.format("Unknown %s %s", DeploymentAction.class.getSimpleName(), action.getType()));