final ModelNode steps = composite.get(Util.STEPS);
final ParsedCommandLine args = ctx.getParsedCommandLine();
final String name = this.name.getValue(args);
if(name == null) {
throw new OperationFormatException("Required argument name are missing.");
}
final ModelControllerClient client = ctx.getModelControllerClient();
DefaultOperationRequestBuilder builder;
final boolean keepContent;
try {
keepContent = this.keepContent.isPresent(args);
} catch (CommandFormatException e) {
throw new OperationFormatException(e.getLocalizedMessage());
}
if(ctx.isDomainMode()) {
final List<String> serverGroups;
if(allRelevantServerGroups.isPresent(args)) {
if(keepContent) {
serverGroups = Util.getAllEnabledServerGroups(name, client);
} else {
serverGroups = Util.getAllReferencingServerGroups(name, client);
}
} else {
final String serverGroupsStr = this.serverGroups.getValue(args);
if(serverGroupsStr == null) {
//throw new OperationFormatException("Either --all-relevant-server-groups or --server-groups must be specified.");
serverGroups = Collections.emptyList();
} else {
serverGroups = Arrays.asList(serverGroupsStr.split(","));
}
}
if(serverGroups.isEmpty()) {
if(keepContent) {
throw new OperationFormatException("None server group is specified or available.");
}
} else {
for (String group : serverGroups){
ModelNode groupStep = Util.configureDeploymentOperation(DEPLOYMENT_UNDEPLOY_OPERATION, name, group);
steps.add(groupStep);