@Override public ParameterValidatorBuilder configure(AttributeDefinition definition) { this.allowsExpressions = definition.isAllowExpression(); this.allowsUndefined = !definition.isRequired(); return this; }
if (param == INSTALL || param == DEBUG || param == ERROR || param == IGNORE_UNKNOWN_CONNECTIONS) { AttributeDefinition ad = param.getAttribute(); assert !ad.isRequired() : ad.getName(); // else someone changed something and we need to account for that if (model.hasDefined(ad.getName())) { allDefault = false;
@Override public ParameterValidatorBuilder configure(AttributeDefinition definition) { this.allowsExpressions = definition.isAllowExpression(); this.allowsUndefined = !definition.isRequired(); return this; }
boolean isRequired(final AttributeDefinition def, final ModelNode model) { final boolean required = def.isRequired(); return required ? ! hasAlternative(def.getAlternatives(), model, true) : required; }
boolean isRequired(final AttributeDefinition def, final ModelNode model) { final boolean required = def.isRequired(); return required ? ! hasAlternative(def.getAlternatives(), model, true) : required; }
@Override public void throwError() throws OperationFailedException { String[] alternatives = attr.getAlternatives(); if (alternatives == null) { throw ControllerLogger.ROOT_LOGGER.required(attributeName); } else { Set<String> requiredAlternatives = new HashSet<>(); for (int i = 0; i < alternatives.length; i++) { AttributeDefinition requiredAttr = getAttributeDefinition(alternatives[i], attributes); if (requiredAttr != null && requiredAttr.isRequired() && !requiredAttr.isResourceOnly()) { requiredAlternatives.add(alternatives[i]); } } throw ControllerLogger.ROOT_LOGGER.requiredWithAlternatives(attributeName, requiredAlternatives); } }} );
private boolean isRequired(final AttributeDefinition def, final Set<String> definedKeys) { return def.isRequired() && !def.isResourceOnly() && !hasAlternative(def.getAlternatives(), definedKeys); }
protected void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw new OperationFailedException(new ModelNode().set(MESSAGES.required(attributeName))); } if(has) { if(! definition.isAllowed(operation)) { throw new OperationFailedException(new ModelNode().set(MESSAGES.invalid(attributeName))); } definition.validateAndSet(operation, subModel); } else { // create the undefined node subModel.get(definition.getName()); } }
private boolean isRequired(final AttributeDefinition def, final Set<String> definedKeys) { return def.isRequired() && !def.isResourceOnly() && !hasAlternative(def.getAlternatives(), definedKeys); }
private void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw new OperationFailedException(new ModelNode(MESSAGES.required(attributeName))); } if(has) { if(! definition.isAllowed(operation)) { throw new OperationFailedException(new ModelNode(MESSAGES.invalid(attributeName))); } definition.validateAndSet(operation, subModel); } else { // create the undefined node subModel.get(definition.getName()); } }
private void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw new OperationFailedException(new ModelNode(MESSAGES.required(attributeName))); } if(has) { if(! definition.isAllowed(operation)) { throw new OperationFailedException(new ModelNode(MESSAGES.invalid(attributeName))); } definition.validateAndSet(operation, subModel); } else { // create the undefined node subModel.get(definition.getName()); } }
private boolean assertMetricValues(AttributeDefinition definition) { if (!definition.isRequired() && definition.getUndefinedMetricValue() != null) { assert false : "Nillable metric has an undefined metric value for '" + definition.getName() + "'"; } // BES 2015/08/28 The WFCORE-831 spec does not require this assertion. The requirement is that read-attribute // not return undefined, but AttributeDefinition.getUndefinedMetricValue() is not the only way to achieve this. // The read-attribute handler can simply always work. // if (!definition.isAllowNull() && definition.getUndefinedMetricValue() == null) { // assert false : "Non-nillable metric does not have an undefined metric value for '" + definition.getName() + "'"; // } if (definition.getDefaultValue() != null) { assert false : "Metrics cannot have a default value for '" + definition.getName() + "'"; } return true; }
private boolean assertMetricValues(AttributeDefinition definition) { if (!definition.isRequired() && definition.getUndefinedMetricValue() != null) { assert false : "Nillable metric has an undefined metric value for '" + definition.getName() + "'"; } // BES 2015/08/28 The WFCORE-831 spec does not require this assertion. The requirement is that read-attribute // not return undefined, but AttributeDefinition.getUndefinedMetricValue() is not the only way to achieve this. // The read-attribute handler can simply always work. // if (!definition.isAllowNull() && definition.getUndefinedMetricValue() == null) { // assert false : "Non-nillable metric does not have an undefined metric value for '" + definition.getName() + "'"; // } if (definition.getDefaultValue() != null) { assert false : "Metrics cannot have a default value for '" + definition.getName() + "'"; } return true; }
private static void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw ServerMessages.MESSAGES.attributeIsRequired(attributeName); } if(has) { if(! definition.isAllowed(operation)) { throw ServerMessages.MESSAGES.attributeNotAllowedWhenAlternativeIsPresent(attributeName, Arrays.asList(definition.getAlternatives())); } definition.validateAndSet(operation, subModel); } else { // create the undefined node subModel.get(definition.getName()); } }
private static void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw ServerMessages.MESSAGES.attributeIsRequired(attributeName); } if(has) { if(! definition.isAllowed(operation)) { throw ServerMessages.MESSAGES.attributeIsInvalid(attributeName); } definition.validateAndSet(operation, subModel); } else { // create the undefined node subModel.get(definition.getName()); } }
private static void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw ServerMessages.MESSAGES.attributeIsRequired(attributeName); } if(has) { if(! definition.isAllowed(operation)) { throw ServerMessages.MESSAGES.attributeIsInvalid(attributeName); } definition.validateAndSet(operation, subModel); } else { // create the undefined node subModel.get(definition.getName()); } }
protected void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw ControllerLogger.ROOT_LOGGER.required(attributeName); } if(has) { if(! definition.isAllowed(operation)) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalid(attributeName)); } definition.validateAndSet(operation, subModel); } else { // create the undefined node subModel.get(definition.getName()); } }
private void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw ControllerLogger.ROOT_LOGGER.required(attributeName); } if(has) { if(! definition.isAllowed(operation)) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalid(attributeName)); } definition.validateAndSet(operation, subModel); } else { // create the undefined node subModel.get(definition.getName()); } }
protected void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw ControllerLogger.ROOT_LOGGER.required(attributeName); } if(has) { if(! definition.isAllowed(operation)) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalid(attributeName)); } definition.validateAndSet(operation, subModel); } else { // create the undefined node subModel.get(definition.getName()); } }
@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); } } }