final String matchPattern, final MatchPatternStrategy matchPatternStrategy) {
return new StandaloneDeployment(client, content, name, type, matchPattern, matchPatternStrategy);
}
private DeploymentPlan createPlan(final DeploymentPlanBuilder builder) throws IOException, DeploymentFailureException {
DeploymentPlanBuilder planBuilder = builder;
List<String> existingDeployments = DeploymentInspector.getDeployments(client, name, matchPattern);
switch (type) {
case ADD: {
planBuilder = builder.add(name, content);
break;
}
case FORCE_ADD: {
if (existingDeployments.contains(name)) {
planBuilder = builder.replace(name, content);
} else {
planBuilder = builder.add(name, content);
}
break;
}
case DEPLOY: {
planBuilder = builder.add(name, content).andDeploy();
break;
}
case REDEPLOY: {
planBuilder = builder.replace(name, content).redeploy(name);
break;
}
case UNDEPLOY: {
validateExistingDeployments(existingDeployments);
planBuilder = undeployAndRemove(builder, existingDeployments);
break;
}
case FORCE_DEPLOY: {
if (existingDeployments.contains(name)) {
planBuilder = builder.replace(name, content).deploy(name);
} else {
planBuilder = builder.add(name, content).andDeploy();
}
break;
}
case UNDEPLOY_IGNORE_MISSING: {
validateExistingDeployments(existingDeployments);
if (!existingDeployments.isEmpty()) {
planBuilder = undeployAndRemove(builder, existingDeployments);
} else {
return null;
}
break;
}
}
return planBuilder.build();
}