for (String theGroup : serverGroups) {
Operation step = createServerGroupAssignmentStep("add", theGroup, runtimeName, enabled);
operation.addStep(step);
}
Result res = getASConnection().execute(operation, 120); // wait up to 2 minutes
if (res.isSuccess()) {
operationResult.setSimpleResult("Successfully deployed to server groups " + serverGroups);
//request the server to discover child resources to allow the discovery of the deployments
//on server groups immediately
requestDiscovery();
} else {
operationResult.setErrorMessage("Deployment to server groups failed: " + res.getFailureDescription());
}
} else if (name.equals("restart")) {
String serverGroup = parameters.getSimpleValue("server-group", "-not set-");
List<String> serverGroups = new ArrayList<String>();
List<String> assignedGroups = findAssignedServerGroups();
if (serverGroup.equals("__all")) {
serverGroups.addAll(assignedGroups);
} else {
if (!assignedGroups.contains(serverGroup)) {
operationResult.setErrorMessage("Deployment could not be restarted in server-group [" + serverGroup
+ "] because it is not assigned to it.");
return operationResult;
}
serverGroups.add(serverGroup);
}
if (serverGroups.isEmpty()) {
operationResult
.setErrorMessage("Deployment could not be restarted because it is not assigned to any server-group");
return operationResult;
}
CompositeOperation operation = new CompositeOperation();
for (String theGroup : serverGroups) {
Operation step = createServerGroupAssignmentStep("redeploy", theGroup, null, false);
operation.addStep(step);
}
Result res = getASConnection().execute(operation, 120); // wait up to 2 minutes
if (res.isSuccess()) {
operationResult.setSimpleResult("Successfully restarted in server groups " + serverGroups);
} else {
operationResult.setErrorMessage("Deployment restart in server groups failed: "
+ res.getFailureDescription());
}
} else {
operationResult.setErrorMessage("Unknown operation " + name);
}
return operationResult;