private static String convertSingleOperation(ModelNode op) { try { String operation = op.get(Constants.OP).asString(); List<Property> address = op.get(Constants.OP_ADDR).asPropertyList(); return convertAddress(address) + ":" + operation + convertParameters(op); } catch (Exception e) { return op.asString(); } }
static String convert(ModelNode op) { try { String operation = op.get(Constants.OP).asString(); if (!Constants.COMPOSITE.equals(operation)) { return convertSingleOperation(op); } else { StringBuilder result = new StringBuilder("composite: "); boolean first = true; for (ModelNode singleOp : op.get(Constants.STEPS).asList()) { if (!first) { result.append(", "); } first = false; result.append(convertSingleOperation(singleOp)); } return result.toString(); } } catch (Exception e) { // just a safety measure if something goes wrong (either bad operation, // which will be rejected by the server later on, or an error in this class) return op.asString(); } }
private static String convertParameters(ModelNode op) { StringBuilder result = new StringBuilder(); boolean first = true; for (Property parameter : op.asPropertyList()) { String name = parameter.getName(); if (Constants.OP.equals(name) || Constants.OP_ADDR.equals(name) || Constants.OPERATION_HEADERS.equals(name)) { continue; } if (!first) { result.append(", "); } first = false; result.append(name).append("=").append(convertValue(parameter.getValue())); } if (result.length() > 0) { return "(" + result.toString() + ")"; } return ""; }
@Override public ModelNodeResult execute(ModelNode operation) throws IOException { checkClosed(); operation = adjustOperationForDomain.adjust(operation); log.debugf("Executing operation %s", ModelNodeOperationToCliString.convert(operation)); log.tracef("JSON format:%n%s", operation.toJSONString(false)); ModelNode result = client.execute(operation); return new ModelNodeResult(result); }
@Override public ModelNodeResult execute(Operation operation) throws IOException { checkClosed(); operation = adjustOperationForDomain.adjust(operation); log.debugf("Executing operation %s", ModelNodeOperationToCliString.convert(operation.getOperation())); log.tracef("JSON format:%n%s", operation.getOperation().toJSONString(false)); ModelNode result = client.execute(operation); return new ModelNodeResult(result); }
result.append(convertValue(element)); result.append(element.getName()).append(" => ").append(convertValue(element.getValue()));