op = name.substring(colonPos + 1);
} else {
what = ""; // dummy value
op = name;
}
Operation operation;
Address theAddress = new Address();
if (what.equals("server-group")) {
String groupName = parameters.getSimpleValue("name", "");
String profile = parameters.getSimpleValue("profile", "default");
theAddress.add("server-group", groupName);
operation = new Operation(op, theAddress);
operation.addAdditionalProperty("profile", profile);
} else if (what.equals("destination")) {
theAddress.add(address);
String newName = parameters.getSimpleValue("name", "");
String type = parameters.getSimpleValue("type", "jms-queue").toLowerCase();
theAddress.add(type, newName);
PropertyList jndiNamesProp = parameters.getList("entries");
if (jndiNamesProp == null || jndiNamesProp.getList().isEmpty()) {
OperationResult fail = new OperationResult();
fail.setErrorMessage("No jndi bindings given");
return fail;
}
List<String> jndiNames = new ArrayList<String>();
for (Property p : jndiNamesProp.getList()) {
PropertySimple ps = (PropertySimple) p;
jndiNames.add(ps.getStringValue());
}
operation = new Operation(op, theAddress);
operation.addAdditionalProperty("entries", jndiNames);
if (type.equals("jms-queue")) {
PropertySimple ps = (PropertySimple) parameters.get("durable");
if (ps != null) {
boolean durable = Boolean.parseBoolean(ps.getStringValue());
operation.addAdditionalProperty("durable", durable);
}
String selector = parameters.getSimpleValue("selector", "");
if (!selector.isEmpty())
operation.addAdditionalProperty("selector", selector);
}
} else if (what.equals("domain")) {
operation = new Operation(op, new Address());
} else if (what.equals("subsystem")) {
operation = new Operation(op, new Address(this.path));
} else {
// We have a generic operation so we pass it literally
// with the parameters it has.
operation = new Operation(op, new Address((path)));
for (Property prop : parameters.getProperties()) {
if (prop instanceof PropertySimple) {
PropertySimple ps = (PropertySimple) prop;
if (ps.getStringValue() != null) {
Object val = getObjectForProperty(ps, op);
operation.addAdditionalProperty(ps.getName(), val);
}
} else if (prop instanceof PropertyList) {
PropertyList pl = (PropertyList) prop;
List<Object> items = new ArrayList<Object>(pl.getList().size());
// Loop over the inner elements of the list
for (Property p2 : pl.getList()) {
if (p2 instanceof PropertySimple) {
PropertySimple ps = (PropertySimple) p2;
if (ps.getStringValue() != null) {
Object val = getObjectForPropertyList(ps, pl, op);
items.add(val);
}
}
}
operation.addAdditionalProperty(pl.getName(), items);
} else {
LOG.error("PropertyMap for " + prop.getName() + " not yet supported");
}
}
}