/** * Finds a value in the given {@code operationObject} whose key matches this attribute's {@link #getName() name}, * validates it using this attribute's {@link #getValidator() validator}, and, stores it under this attribute's name in the given {@code model}. * * @param operationObject model node of type {@link ModelType#OBJECT}, typically representing an operation request * @param model model node in which the value should be stored * * @throws OperationFailedException if the value is not valid */ public final void validateAndSet(ModelNode operationObject, final ModelNode model) throws OperationFailedException { if (operationObject.hasDefined(name) && isDeprecated()) { ControllerLogger.DEPRECATED_LOGGER.attributeDeprecated(getName()); } // AS7-6224 -- convert expression strings to ModelType.EXPRESSION *before* correcting ModelNode newValue = convertParameterExpressions(operationObject.get(name)); final ModelNode correctedValue = correctValue(newValue, model.get(name)); if (!correctedValue.equals(operationObject.get(name))) { operationObject.get(name).set(correctedValue); } ModelNode node = validateOperation(operationObject, true); model.get(name).set(node); }
/** * Finds a value in the given {@code operationObject} whose key matches this attribute's {@link #getName() name}, * validates it using this attribute's {@link #getValidator() validator}, and, stores it under this attribute's name in the given {@code model}. * * @param operationObject model node of type {@link ModelType#OBJECT}, typically representing an operation request * @param model model node in which the value should be stored * * @throws OperationFailedException if the value is not valid */ public final void validateAndSet(ModelNode operationObject, final ModelNode model) throws OperationFailedException { if (operationObject.hasDefined(name) && isDeprecated()) { ControllerLogger.DEPRECATED_LOGGER.attributeDeprecated(getName()); } // AS7-6224 -- convert expression strings to ModelType.EXPRESSION *before* correcting ModelNode newValue = convertParameterExpressions(operationObject.get(name)); final ModelNode correctedValue = correctValue(newValue, model.get(name)); if (!correctedValue.equals(operationObject.get(name))) { operationObject.get(name).set(correctedValue); } ModelNode node = validateOperation(operationObject, true); model.get(name).set(node); }
@Override protected ModelNode convertParameterExpressions(ModelNode parameter) { ModelNode result = parameter; if (parameter.isDefined()) { boolean changeMade = false; ModelNode updated = new ModelNode().setEmptyObject(); for (AttributeDefinition ad : valueTypes) { String fieldName = ad.getName(); if (parameter.has(fieldName)) { ModelNode orig = parameter.get(fieldName); if (!orig.isDefined()) { updated.get(fieldName); // establish undefined } else { ModelNode converted = ad.convertParameterExpressions(orig); changeMade |= !orig.equals(converted); updated.get(fieldName).set(converted); } } } if (changeMade) { result = updated; } } return result; }
@Override protected ModelNode convertParameterExpressions(ModelNode parameter) { ModelNode result = parameter; if (parameter.isDefined()) { boolean changeMade = false; ModelNode updated = new ModelNode().setEmptyObject(); for (AttributeDefinition ad : valueTypes) { String fieldName = ad.getName(); if (parameter.has(fieldName)) { ModelNode orig = parameter.get(fieldName); if (!orig.isDefined()) { updated.get(fieldName); // establish undefined } else { ModelNode converted = ad.convertParameterExpressions(orig); changeMade |= !orig.equals(converted); updated.get(fieldName).set(converted); } } } if (changeMade) { result = updated; } } return result; }
@Override protected ModelNode convertParameterExpressions(ModelNode parameter) { ModelNode result = parameter; if (parameter.isDefined()) { boolean changeMade = false; ModelNode updated = new ModelNode().setEmptyObject(); for (AttributeDefinition ad : valueTypes) { String fieldName = ad.getName(); if (parameter.has(fieldName)) { ModelNode orig = parameter.get(fieldName); if (!orig.isDefined()) { updated.get(fieldName); // establish undefined } else { ModelNode converted = ad.convertParameterExpressions(orig); changeMade |= !orig.equals(converted); updated.get(fieldName).set(converted); } } } if (changeMade) { result = updated; } } return result; }
private ModelNode validateOperation(final ModelNode operationObject, final boolean immutableValue) throws OperationFailedException { ModelNode node = new ModelNode(); if(operationObject.has(name)) { node.set(operationObject.get(name)); } if (!immutableValue) { node = convertParameterExpressions(node); node = correctValue(node, node); } if (!node.isDefined() && defaultValue.isDefined()) { validator.validateParameter(name, defaultValue); } else { validator.validateParameter(name, node); } return node; }
@Override protected ModelNode convertParameterExpressions(ModelNode parameter) { ModelNode result = parameter; if (parameter.isDefined()) { boolean changeMade = false; ModelNode updated = new ModelNode().setEmptyObject(); for (AttributeDefinition ad : valueTypes) { String fieldName = ad.getName(); if (parameter.has(fieldName)) { ModelNode orig = parameter.get(fieldName); if (!orig.isDefined()) { updated.get(fieldName); // establish undefined } else { ModelNode converted = ad.convertParameterExpressions(orig); changeMade |= !orig.equals(converted); updated.get(fieldName).set(converted); } } } if (changeMade) { result = updated; } } return result; }
private ModelNode validateOperation(final ModelNode operationObject, final boolean immutableValue) throws OperationFailedException { ModelNode node = new ModelNode(); if(operationObject.has(name)) { node.set(operationObject.get(name)); } if (!immutableValue) { node = convertParameterExpressions(node); node = correctValue(node, node); } if (!node.isDefined() && defaultValue != null && defaultValue.isDefined()) { validator.validateParameter(name, defaultValue); } else { validator.validateParameter(name, node); } return convertToExpectedType(node); }
private ModelNode validateOperation(final ModelNode operationObject, final boolean immutableValue) throws OperationFailedException { ModelNode node = new ModelNode(); if(operationObject.has(name)) { node.set(operationObject.get(name)); } if (!immutableValue) { node = convertParameterExpressions(node); } if (!node.isDefined() && defaultValue.isDefined()) { if (!immutableValue) correctValue(node, node); validator.validateParameter(name, defaultValue); } else { if (!immutableValue) correctValue(node, node); validator.validateParameter(name, node); } return node; }
private ModelNode validateOperation(final ModelNode operationObject, final boolean immutableValue) throws OperationFailedException { ModelNode node = new ModelNode(); if(operationObject.has(name)) { node.set(operationObject.get(name)); } if (!immutableValue) { node = convertParameterExpressions(node); node = correctValue(node, node); } if (!node.isDefined() && defaultValue != null && defaultValue.isDefined()) { validator.validateParameter(name, defaultValue); } else { validator.validateParameter(name, node); } return convertToExpectedType(node); }
/** * Finds a value in the given {@code operationObject} whose key matches this attribute's {@link #getName() name}, * validates it using this attribute's {@link #getValidator() validator}, and, stores it under this attribute's name in the given {@code model}. * * @param operationObject model node of type {@link ModelType#OBJECT}, typically representing an operation request * @param model model node in which the value should be stored * * @throws OperationFailedException if the value is not valid */ public final void validateAndSet(ModelNode operationObject, final ModelNode model) throws OperationFailedException { if (operationObject.hasDefined(name) && deprecationData != null && deprecationData.isNotificationUseful()) { ControllerLogger.DEPRECATED_LOGGER.attributeDeprecated(getName(), PathAddress.pathAddress(operationObject.get(ModelDescriptionConstants.OP_ADDR)).toCLIStyleString()); } // AS7-6224 -- convert expression strings to ModelType.EXPRESSION *before* correcting ModelNode newValue = convertParameterExpressions(operationObject.get(name)); final ModelNode correctedValue = correctValue(newValue, model.get(name)); if (!correctedValue.equals(operationObject.get(name))) { operationObject.get(name).set(correctedValue); } ModelNode node = validateOperation(operationObject, true); if (node.getType() == ModelType.EXPRESSION && (referenceRecorder != null || flags.contains(AttributeAccess.Flag.EXPRESSIONS_DEPRECATED))) { ControllerLogger.DEPRECATED_LOGGER.attributeExpressionDeprecated(getName(), PathAddress.pathAddress(operationObject.get(ModelDescriptionConstants.OP_ADDR)).toCLIStyleString()); } model.get(name).set(node); }
/** * Finds a value in the given {@code operationObject} whose key matches this attribute's {@link #getName() name}, * validates it using this attribute's {@link #getValidator() validator}, and, stores it under this attribute's name in the given {@code model}. * * @param operationObject model node of type {@link ModelType#OBJECT}, typically representing an operation request * @param model model node in which the value should be stored * * @throws OperationFailedException if the value is not valid */ public final void validateAndSet(ModelNode operationObject, final ModelNode model) throws OperationFailedException { if (operationObject.hasDefined(name) && deprecationData != null && deprecationData.isNotificationUseful()) { ControllerLogger.DEPRECATED_LOGGER.attributeDeprecated(getName(), PathAddress.pathAddress(operationObject.get(ModelDescriptionConstants.OP_ADDR)).toCLIStyleString()); } // AS7-6224 -- convert expression strings to ModelType.EXPRESSION *before* correcting ModelNode newValue = convertParameterExpressions(operationObject.get(name)); final ModelNode correctedValue = correctValue(newValue, model.get(name)); if (!correctedValue.equals(operationObject.get(name))) { operationObject.get(name).set(correctedValue); } ModelNode node = validateOperation(operationObject, true); if (node.getType() == ModelType.EXPRESSION && (referenceRecorder != null || flags.contains(AttributeAccess.Flag.EXPRESSIONS_DEPRECATED))) { ControllerLogger.DEPRECATED_LOGGER.attributeExpressionDeprecated(getName(), PathAddress.pathAddress(operationObject.get(ModelDescriptionConstants.OP_ADDR)).toCLIStyleString()); } model.get(name).set(node); }