@Override public ModelNode correctOperation(ModelNode operation) { ModelNode op = operation.clone(); for (String attr : attributes) { ModelNode value = op.get(attr); ModelNode checkOp = op.clone(); checkOp.protect(); if (checkValue(checkOp, attr, value, false)) { AttributesPathAddressConfig<?> complexChildConfig = complexAttributes.get(attr); if (complexChildConfig == null) { ModelNode resolved = correctValue(op.get(attr), false); op.get(attr).set(resolved); } else { op.get(attr).set(complexChildConfig.correctOperation(operation.get(attr))); } return op; } } return operation; }
@Override public boolean expectFailedWriteAttributeOperation(ModelNode operation) { if (!noWriteFailureAttributes.contains(operation.get(NAME).asString())) { for (AttributesPathAddressConfig<?> link : list) { if (link.expectFailedWriteAttributeOperation(operation)) { return true; } } } return false; }
public List<ModelNode> createWriteAttributeOperations(ModelNode operation) { List<ModelNode> list = new ArrayList<ModelNode>(); for (String attr : attributes) { if (operation.hasDefined(attr)) { //TODO Should we also allow undefined here? if (!readOnlyAttributes.contains(attr) && isAttributeWritable(attr)) { list.add(Util.getWriteAttributeOperation(PathAddress.pathAddress(operation.get(OP_ADDR)), attr, operation.get(attr))); } } } return list; }
protected abstract boolean checkValue(String attrName, ModelNode attribute, boolean isGeneratedWriteAttribute);
@Override public boolean expectFailedWriteAttributeOperation(ModelNode operation) { ModelNode checkOp = operation.clone(); checkOp.protect(); String name = operation.get(NAME).asString(); if (attributes.contains(name)) { return !noWriteFailureAttributes.contains(name) && checkValue(checkOp, name, operation.clone().get(VALUE), true); } return false; }
@Override public boolean canCorrectMore(ModelNode operation) { ModelNode op = operation.clone(); ModelNode checkOp = op.clone(); checkOp.protect(); for (String attr : attributes) { if (checkValue(checkOp, attr, op.get(attr), false)) { return true; } } return false; }
@Override public boolean canCorrectMore(ModelNode operation) { for (AttributesPathAddressConfig<?> link : list) { if (link.canCorrectMore(operation)) { return true; } } return false; }
@Override public ModelNode correctOperation(ModelNode operation) { for (AttributesPathAddressConfig<?> link : list) { ModelNode op = link.correctOperation(operation); if (!op.equals(operation)) { return op; } } return operation; }
@Override public boolean expectFailed(ModelNode operation) { for (AttributesPathAddressConfig<?> link : list) { if (link.expectFailed(operation)) { return true; } } return false; }
@Override public boolean expectFailed(ModelNode operation) { ModelNode op = operation.clone(); ModelNode checkOp = op.clone(); checkOp.protect(); for (String attr : attributes) { if (checkValue(checkOp, attr, op.get(attr), false)) { return true; } } return false; }
@Override public ModelNode correctWriteAttributeOperation(ModelNode operation) { ModelNode op = operation.clone(); ModelNode checkOp = op.clone(); checkOp.protect(); String name = operation.get(NAME).asString(); if (attributes.contains(name) && checkValue(checkOp, name, op.get(VALUE), true)) { op.get(VALUE).set(correctValue(op.get(VALUE), true)); return op; } return operation; }
@Override public ModelNode correctWriteAttributeOperation(ModelNode operation) { ModelNode op = operation.clone(); for (AttributesPathAddressConfig<?> link : list) { op = link.correctWriteAttributeOperation(op); } return op; }
private boolean childHasExpressions(AttributesPathAddressConfig<?> complexChildConfig, ModelNode attribute, boolean isGeneratedWriteAttribute) { for (String child : complexChildConfig.attributes) { if (complexChildConfig.checkValue(child, attribute.get(child), isGeneratedWriteAttribute)) { return true; } } return false; } }