definition.validateOperation(operation); AttributeTranslation translation = entry.getValue(); if (operation.hasDefined(sourceParameter.getName())) { ModelNode value = sourceParameter.validateOperation(operation); ModelNode targetValue = translation.getWriteTranslator().translate(context, value); Attribute targetAttribute = translation.getTargetAttribute();
/** * Finds a value in the given {@code operationObject} whose key matches this attribute's {@link #getName() name} and * validates it using this attribute's {@link #getValidator() validator}. * * @param operationObject model node of type {@link ModelType#OBJECT}, typically representing an operation request * * @return the value * @throws OperationFailedException if the value is not valid */ public ModelNode validateOperation(final ModelNode operationObject) throws OperationFailedException { return validateOperation(operationObject, false); }
/** * Finds a value in the given {@code operationObject} whose key matches this attribute's {@link #getName() name} and * validates it using this attribute's {@link #getValidator() validator}. * * @param operationObject model node of type {@link ModelType#OBJECT}, typically representing an operation request * * @return the value * @throws OperationFailedException if the value is not valid */ public ModelNode validateOperation(final ModelNode operationObject) throws OperationFailedException { return validateOperation(operationObject, false); }
/** * Finds a value in the given {@code operationObject} whose key matches this attribute's {@link #getName() name} and * validates it using this attribute's {@link #getValidator() validator}. * * @param operationObject model node of type {@link ModelType#OBJECT}, typically representing an operation request * * @return the value * @throws OperationFailedException if the value is not valid */ public ModelNode validateOperation(final ModelNode operationObject) throws OperationFailedException { return validateOperation(operationObject, false); }
/** * Finds a value in the given {@code operationObject} whose key matches this attribute's {@link #getName() name} and * validates it using this attribute's {@link #getValidator() validator}. * * @param operationObject model node of type {@link ModelType#OBJECT}, typically representing an operation request * * @return the value * @throws OperationFailedException if the value is not valid */ public ModelNode validateOperation(final ModelNode operationObject) throws OperationFailedException { return validateOperation(operationObject, false); }
@Override protected void validateValue(String name, ModelNode value) throws OperationFailedException { ModelNode mockOp = new ModelNode(); mockOp.get(name).set(value); ModelNode validated = attributeDefinition.validateOperation(mockOp); if (!value.equals(validated)) { value.set(validated); } } }
@Override protected void validateValue(String name, ModelNode value) throws OperationFailedException { ModelNode mockOp = new ModelNode(); mockOp.get(name).set(value); ModelNode validated = attributeDefinition.validateOperation(mockOp); if (!value.equals(validated)) { value.set(validated); } } }
@Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition definition : this.descriptor.getExtraParameters()) { definition.validateOperation(operation); } super.populateModel(operation, model); }
private ResultTransformer(ModelNode operation, PathAddress address) { this.multiTarget = address.isMultiTarget(); try { this.filter = WHERE_ATT.validateOperation(operation); this.select = SELECT_ATT.validateOperation(operation); // Use resolveModelAttribute for OPERATOR_ATT to pull out the default value this.operator = Operator.valueOf(OPERATOR_ATT.resolveModelAttribute(ExpressionResolver.SIMPLE, operation).asString()); } catch (OperationFailedException e) { // the validateOperation calls above would have already been invoked in QueryOperationHandler.execute // so this shouldn't happen throw new IllegalStateException(e); } }
private ResultTransformer(ModelNode operation, PathAddress address) { this.multiTarget = address.isMultiTarget(); try { this.filter = WHERE_ATT.validateOperation(operation); this.select = SELECT_ATT.validateOperation(operation); // Use resolveModelAttribute for OPERATOR_ATT to pull out the default value this.operator = Operator.valueOf(OPERATOR_ATT.resolveModelAttribute(ExpressionResolver.SIMPLE, operation).asString()); } catch (OperationFailedException e) { // the validateOperation calls above would have already been invoked in QueryOperationHandler.execute // so this shouldn't happen throw new IllegalStateException(e); } }
@Override public void validate(ModelNode operation) throws OperationFailedException { super.validate(operation); for (AttributeDefinition def : DEFINITION.getParameters()) { def.validateOperation(operation); } if( operation.hasDefined(ModelDescriptionConstants.RESOLVE_EXPRESSIONS)){ if(operation.get(ModelDescriptionConstants.RESOLVE_EXPRESSIONS).asBoolean(false) && !resolvable){ throw ControllerLogger.ROOT_LOGGER.unableToResolveExpressions(); } } } };
@Override public void validate(ModelNode operation) throws OperationFailedException { super.validate(operation); for (AttributeDefinition def : DEFINITION.getParameters()) { def.validateOperation(operation); } if( operation.hasDefined(ModelDescriptionConstants.RESOLVE_EXPRESSIONS)){ if(operation.get(ModelDescriptionConstants.RESOLVE_EXPRESSIONS).asBoolean(false) && !resolvable){ throw ControllerLogger.ROOT_LOGGER.unableToResolveExpressions(); } } } };
/** * Validates operation model against the definition and its parameters * * @param operation model node of type {@link ModelType#OBJECT}, representing an operation request * @throws OperationFailedException if the value is not valid * * @deprecated Not used by the WildFly management kernel; will be removed in a future release */ @Deprecated public void validateOperation(final ModelNode operation) throws OperationFailedException { if (operation.hasDefined(ModelDescriptionConstants.OPERATION_NAME) && deprecationData != null && deprecationData.isNotificationUseful()) { ControllerLogger.DEPRECATED_LOGGER.operationDeprecated(getName(), PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).toCLIStyleString()); } for (AttributeDefinition ad : this.parameters) { ad.validateOperation(operation); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS); final byte[] oldHash = ManagedDMRContentResourceDefinition.HASH.validateOperation(operation).asBytes(); final byte[] currentHash = resource.getModel().get(ManagedDMRContentResourceDefinition.HASH.getName()).asBytes(); if (!Arrays.equals(oldHash, currentHash)) { throw ManagedDMRContentLogger.ROOT_LOGGER.invalidHash(HashUtil.bytesToHexString(oldHash), PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)), HashUtil.bytesToHexString(currentHash)); } ModelNode model = new ModelNode(); contentAttribute.validateAndSet(operation, model); // IMPORTANT: Use writeModel, as this is what causes the content to be flushed to the content repo! resource.writeModel(model); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS); final byte[] oldHash = ManagedDMRContentResourceDefinition.HASH.validateOperation(operation).asBytes(); final byte[] currentHash = resource.getModel().get(ManagedDMRContentResourceDefinition.HASH.getName()).asBytes(); if (!Arrays.equals(oldHash, currentHash)) { throw ManagedDMRContentLogger.ROOT_LOGGER.invalidHash(HashUtil.bytesToHexString(oldHash), PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)), HashUtil.bytesToHexString(currentHash)); } ModelNode model = new ModelNode(); contentAttribute.validateAndSet(operation, model); // IMPORTANT: Use writeModel, as this is what causes the content to be flushed to the content repo! resource.writeModel(model); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); byte[] hash = HASH.validateOperation(operation).asBytesOrNull(); if (hash != null && fileRepository != null) { // Ensure the local repo has the files fileRepository.getDeploymentFiles(new ContentReference(address.toCLIStyleString(), hash)); } // Create and add the specialized resource type we use for this resource tree ManagedDMRContentTypeResource resource = new ManagedDMRContentTypeResource(address, childType, hash, contentRepository); context.addResource(PathAddress.EMPTY_ADDRESS, resource); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); byte[] hash = HASH.validateOperation(operation).asBytesOrNull(); if (hash != null && fileRepository != null) { // Ensure the local repo has the files fileRepository.getDeploymentFiles(new ContentReference(address.toCLIStyleString(), hash)); } // Create and add the specialized resource type we use for this resource tree ManagedDMRContentTypeResource resource = new ManagedDMRContentTypeResource(address, childType, hash, contentRepository); context.addResource(PathAddress.EMPTY_ADDRESS, resource); } }
@Override public void validate(ModelNode operation) throws OperationFailedException { super.validate(operation); for (AttributeDefinition def : DEFINITION.getParameters()) { def.validateOperation(operation); } if (operation.hasDefined(ModelDescriptionConstants.ATTRIBUTES_ONLY)) { if (operation.hasDefined(ModelDescriptionConstants.RECURSIVE)) { throw MESSAGES.cannotHaveBothParameters(ModelDescriptionConstants.ATTRIBUTES_ONLY, ModelDescriptionConstants.RECURSIVE); } if (operation.hasDefined(ModelDescriptionConstants.RECURSIVE_DEPTH)) { throw MESSAGES.cannotHaveBothParameters(ModelDescriptionConstants.ATTRIBUTES_ONLY, ModelDescriptionConstants.RECURSIVE_DEPTH); } } } };
@Override public void validate(final ModelNode operation) throws OperationFailedException { for(final AttributeDefinition definition : attributes) { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.required(definition.getName())); } if(has) { if(! definition.isAllowed(operation)) { throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.invalid(definition.getName())); } definition.validateOperation(operation); } } }
@Override public void validate(final ModelNode operation) throws OperationFailedException { for(final AttributeDefinition definition : attributes) { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.required(definition.getName())); } if(has) { if(! definition.isAllowed(operation)) { throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.invalid(definition.getName())); } definition.validateOperation(operation); } } }