// TODO: replace with composite operation
final List<DeploymentRecord> deployments = new ArrayList<DeploymentRecord>();
final Iterator<ServerGroupRecord> iterator = serverGroups.iterator();
while (iterator.hasNext()) {
final ServerGroupRecord group = iterator.next();
ModelNode operation = new ModelNode();
operation.get(ADDRESS).add("server-group", group.getGroupName());
operation.get(OP).set(READ_CHILDREN_RESOURCES_OPERATION);
operation.get(CHILD_TYPE).set("deployment");
dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(DMRResponse result) {
ModelNode response = ModelNode.fromBase64(result.getResponseText());
if (response.get("result").isDefined()) {
List<ModelNode> payload = response.get("result").asList();
for (ModelNode item : payload) {
Property property = item.asProperty();
ModelNode handler = property.getValue().asObject();
String name = property.getName();
try {
DeploymentRecord rec = factory.deployment().as();
rec.setName(name);
rec.setServerGroup(group.getGroupName());
rec.setRuntimeName(handler.get("runtime-name").asString());
rec.setEnabled(handler.get("enabled").asBoolean());
deployments.add(rec);
} catch (IllegalArgumentException e) {
Log.error("Failed to parse data source representation", e);