static OperationResponse fromFailure(OperationFailedException ofe) { ModelNode responseNode = new ModelNode(); responseNode.get(OUTCOME).set(FAILED); responseNode.get(FAILURE_DESCRIPTION).set(ofe.getFailureDescription()); return OperationResponse.Factory.createSimple(responseNode); }
static OperationResponse fromFailure(OperationFailedException ofe) { ModelNode responseNode = new ModelNode(); responseNode.get(OUTCOME).set(FAILED); responseNode.get(FAILURE_DESCRIPTION).set(ofe.getFailureDescription()); return OperationResponse.Factory.createSimple(responseNode); }
@Override public void validateResolvedParameter(String parameterName, ModelNode value) throws OperationFailedException { try { delegate.validateResolved(value); } catch (OperationFailedException e) { throw new OperationFailedException(e.getMessage(), e.getCause(), new ModelNode().set(parameterName + ": " + e.getFailureDescription().asString())); } }
@Override public void validateResolvedParameter(String parameterName, ModelNode value) throws OperationFailedException { try { delegate.validateResolved(value); } catch (OperationFailedException e) { throw new OperationFailedException(e.getMessage(), e.getCause(), new ModelNode().set(parameterName + ": " + e.getFailureDescription().asString())); } }
/** * Creates and returns a {@link org.jboss.dmr.ModelNode} using the given {@code value} after first validating the node * against {@link org.jboss.as.controller.AttributeDefinition#getValidator() this object's validator}. * <p> * If {@code value} is {@code null} an {@link org.jboss.dmr.ModelType#UNDEFINED undefined} node will be returned. * </p> * * @param value the value. Will be {@link String#trim() trimmed} before use if not {@code null}. * @param reader {@link XMLStreamReader} from which the {@link XMLStreamReader#getLocation() location} from which * the attribute value was read can be obtained and used in any {@code XMLStreamException}, in case * the given value is invalid. * @return {@code ModelNode} representing the parsed value * @throws javax.xml.stream.XMLStreamException if {@code value} is not valid * @see #parseAndSetParameter(org.jboss.as.controller.AttributeDefinition, String, ModelNode, XMLStreamReader) */ public ModelNode parse(final AttributeDefinition attribute, final String value, final XMLStreamReader reader) throws XMLStreamException { try { return parse(attribute, value); } catch (OperationFailedException e) { throw new XMLStreamException(e.getFailureDescription().toString(), reader.getLocation()); } }
/** * Creates and returns a {@link org.jboss.dmr.ModelNode} using the given {@code value} after first validating the node * against {@link org.jboss.as.controller.AttributeDefinition#getValidator() this object's validator}. * <p> * If {@code value} is {@code null} an {@link org.jboss.dmr.ModelType#UNDEFINED undefined} node will be returned. * </p> * * @param value the value. Will be {@link String#trim() trimmed} before use if not {@code null}. * @param reader {@link XMLStreamReader} from which the {@link XMLStreamReader#getLocation() location} from which * the attribute value was read can be obtained and used in any {@code XMLStreamException}, in case * the given value is invalid. * @return {@code ModelNode} representing the parsed value * @throws javax.xml.stream.XMLStreamException if {@code value} is not valid * @see #parseAndSetParameter(org.jboss.as.controller.AttributeDefinition, String, ModelNode, XMLStreamReader) */ public ModelNode parse(final AttributeDefinition attribute, final String value, final XMLStreamReader reader) throws XMLStreamException { try { return parse(attribute, value); } catch (OperationFailedException e) { throw new XMLStreamException(e.getFailureDescription().toString(), reader.getLocation()); } }
/** * Creates and returns a {@link org.jboss.dmr.ModelNode} using the given {@code value} after first validating the node * against {@link org.jboss.as.controller.AttributeDefinition#getValidator() this object's validator}. * <p> * If {@code value} is {@code null} an {@link org.jboss.dmr.ModelType#UNDEFINED undefined} node will be returned. * </p> * * @param value the value. Will be {@link String#trim() trimmed} before use if not {@code null}. * @param reader {@link XMLStreamReader} from which the {@link XMLStreamReader#getLocation() location} from which * the attribute value was read can be obtained and used in any {@code XMLStreamException}, in case * the given value is invalid. * @return {@code ModelNode} representing the parsed value * @throws javax.xml.stream.XMLStreamException if {@code value} is not valid * @see #parseAndSetParameter(org.jboss.as.controller.AttributeDefinition, String, ModelNode, XMLStreamReader) */ public ModelNode parse(final AttributeDefinition attribute, final String value, final XMLStreamReader reader) throws XMLStreamException { try { return parse(attribute, value); } catch (OperationFailedException e) { throw new XMLStreamException(e.getFailureDescription().toString(), reader.getLocation()); } }
/** * Creates and returns a {@link org.jboss.dmr.ModelNode} using the given {@code value} after first validating the node * against {@link #getValidator() this object's validator}. * <p> * If {@code value} is {@code null} an {@link ModelType#UNDEFINED undefined} node will be returned. * </p> * * @param value the value. Will be {@link String#trim() trimmed} before use if not {@code null}. * @param reader {@link XMLStreamReader} from which the {@link XMLStreamReader#getLocation() location} from which * the attribute value was read can be obtained and used in any {@code XMLStreamException}, in case * the given value is invalid. * @return {@code ModelNode} representing the parsed value * * @throws javax.xml.stream.XMLStreamException if {@code value} is not valid * * @see #parseAndSetParameter(String, ModelNode, XMLStreamReader) */ public ModelNode parse(final String value, final XMLStreamReader reader) throws XMLStreamException { try { return parse(value); } catch (OperationFailedException e) { throw new XMLStreamException(e.getFailureDescription().toString(), reader.getLocation()); } }
/** * Creates and returns a {@link org.jboss.dmr.ModelNode} using the given {@code value} after first validating the node * against {@link #getElementValidator() this object's element validator}. * <p> * If {@code value} is {@code null} an {@link ModelType#UNDEFINED undefined} node will be returned. * </p> * * @param value the value. Will be {@link String#trim() trimmed} before use if not {@code null}. * @param reader {@link XMLStreamReader} from which the {@link XMLStreamReader#getLocation() location} from which * the attribute value was read can be obtained and used in any {@code XMLStreamException}, in case * the given value is invalid. * * @return {@code ModelNode} representing the parsed value * * @throws javax.xml.stream.XMLStreamException if {@code value} is not valid * * @see #parseAndAddParameterElement(String, ModelNode, XMLStreamReader) */ public ModelNode parse(final String value, final XMLStreamReader reader) throws XMLStreamException { try { return parse(value); } catch (OperationFailedException e) { throw new XMLStreamException(e.getFailureDescription().toString(), reader.getLocation()); } }
/** * Creates and returns a {@link org.jboss.dmr.ModelNode} using the given {@code value} after first validating the node * against {@link #getElementValidator() this object's element validator}. * <p> * If {@code value} is {@code null} an {@link ModelType#UNDEFINED undefined} node will be returned. * </p> * * @param value the value. Will be {@link String#trim() trimmed} before use if not {@code null}. * @param reader {@link XMLStreamReader} from which the {@link XMLStreamReader#getLocation() location} from which * the attribute value was read can be obtained and used in any {@code XMLStreamException}, in case * the given value is invalid. * * @return {@code ModelNode} representing the parsed value * * @throws javax.xml.stream.XMLStreamException if {@code value} is not valid * * @see #parseAndAddParameterElement(String, ModelNode, XMLStreamReader) */ public ModelNode parse(final String value, final XMLStreamReader reader) throws XMLStreamException { try { return parse(value); } catch (OperationFailedException e) { throw new XMLStreamException(e.getFailureDescription().toString(), reader.getLocation()); } }
@Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { try { delegate.validate(value); } catch (OperationFailedException e) { final ModelNode failureDescription = new ModelNode().add(ControllerLogger.ROOT_LOGGER.validationFailed(parameterName)); failureDescription.add(e.getFailureDescription()); throw new OperationFailedException(e.getMessage(), e.getCause(), failureDescription); } }
@Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { try { delegate.validate(value); } catch (OperationFailedException e) { final ModelNode failureDescription = new ModelNode().add(MESSAGES.validationFailed(parameterName)); failureDescription.add(e.getFailureDescription()); throw new OperationFailedException(e.getMessage(), e.getCause(), failureDescription); } }
@Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { try { delegate.validate(value); } catch (OperationFailedException e) { final ModelNode failureDescription = new ModelNode().add(ControllerLogger.ROOT_LOGGER.validationFailed(parameterName)); failureDescription.add(e.getFailureDescription()); throw new OperationFailedException(e.getMessage(), e.getCause(), failureDescription); } }
@Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { try { delegate.validate(value); } catch (OperationFailedException e) { final ModelNode failureDescription = new ModelNode().add(MESSAGES.validationFailed(parameterName)); failureDescription.add(e.getFailureDescription()); throw new OperationFailedException(e.getMessage(), e.getCause(), failureDescription); } }
/** * Creates and returns a {@link org.jboss.dmr.ModelNode} using the given {@code value} after first validating the node * against {@link #getValidator() this object's validator}. * <p> * If {@code value} is {@code null} an {@link ModelType#UNDEFINED undefined} node will be returned. * </p> * * @param value the value. Will be {@link String#trim() trimmed} before use if not {@code null}. * @param reader {@link XMLStreamReader} from which the {@link XMLStreamReader#getLocation() location} from which * the attribute value was read can be obtained and used in any {@code XMLStreamException}, in case * the given value is invalid. * @return {@code ModelNode} representing the parsed value * * @throws javax.xml.stream.XMLStreamException if {@code value} is not valid * * @see #parseAndSetParameter(String, ModelNode, XMLStreamReader) * @deprecated use {@link #getParser()} */ @Deprecated public ModelNode parse(final String value, final XMLStreamReader reader) throws XMLStreamException { try { return parse(this, this.getValidator(), value); } catch (OperationFailedException e) { throw new XMLStreamException(e.getFailureDescription().toString(), reader.getLocation()); } }
@Override public List<RemoteDomainControllerConnectionConfiguration> discover() { // Validate the host and port try { StaticDiscoveryResourceDefinition.HOST.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.HOST.getName(), new ModelNode(parameters.getHost())); StaticDiscoveryResourceDefinition.PORT.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.PORT.getName(), new ModelNode(parameters.getPort())); StaticDiscoveryResourceDefinition.PROTOCOL.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.PROTOCOL.getName(), new ModelNode(parameters.getProtocol())); } catch (OperationFailedException e) { throw new IllegalStateException(e.getFailureDescription().asString()); } return Collections.singletonList(this.parameters); }
@Override public List<RemoteDomainControllerConnectionConfiguration> discover() { // Validate the host and port try { StaticDiscoveryResourceDefinition.HOST.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.HOST.getName(), new ModelNode(parameters.getHost())); StaticDiscoveryResourceDefinition.PORT.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.PORT.getName(), new ModelNode(parameters.getPort())); StaticDiscoveryResourceDefinition.PROTOCOL.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.PROTOCOL.getName(), new ModelNode(parameters.getProtocol())); } catch (OperationFailedException e) { throw new IllegalStateException(e.getFailureDescription().asString()); } return Collections.singletonList(this.parameters); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode toResolve = EXPRESSION.validateOperation(operation); if (toResolve.getType() == ModelType.STRING) { toResolve = ParseUtils.parsePossibleExpression(toResolve.asString()); } try { ModelNode resolved = ExpressionResolver.SIMPLE.resolveExpressions(toResolve); ModelNode result = context.getResult(); if (resolved.isDefined()) { result.set(resolved.asString()); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } catch (SecurityException e) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noPermissionToResolveExpression(toResolve, e)); } catch (IllegalStateException e) { final ModelNode failureDescription = ControllerLogger.ROOT_LOGGER.cannotResolveExpression(toResolve.asString()).getFailureDescription(); deferFailureReporting(context, failureDescription); } catch (OperationFailedException e) { deferFailureReporting(context, e.getFailureDescription()); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode toResolve = EXPRESSION.validateOperation(operation); if (toResolve.getType() == ModelType.STRING) { toResolve = ParseUtils.parsePossibleExpression(toResolve.asString()); } try { ModelNode resolved = ExpressionResolver.SIMPLE.resolveExpressions(toResolve); ModelNode result = context.getResult(); if (resolved.isDefined()) { result.set(resolved.asString()); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } catch (SecurityException e) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noPermissionToResolveExpression(toResolve, e)); } catch (IllegalStateException e) { final ModelNode failureDescription = ControllerLogger.ROOT_LOGGER.cannotResolveExpression(toResolve.asString()).getFailureDescription(); deferFailureReporting(context, failureDescription); } catch (OperationFailedException e) { deferFailureReporting(context, e.getFailureDescription()); } }
/** * Creates and returns a {@link ModelNode} using the given {@code value} after first validating the node * against {@link #getValidator() this object's validator}. * <p> * If {@code value} is {@code null} and a {@link #getDefaultValue() default value} is available, the value of that * default value will be used. * </p> * * @param value the value. Will be {@link String#trim() trimmed} before use if not {@code null}. * @param location current location of the parser's {@link javax.xml.stream.XMLStreamReader}. Used for any exception * message * * @return {@code ModelNode} representing the parsed value * * @throws XMLStreamException if {@code value} is not valid */ public ModelNode parse(final String value, final Location location) throws XMLStreamException { ModelNode node = ParseUtils.parseAttributeValue(value, isAllowExpression(), getType()); try { elementValidator.validateParameter(getXmlName(), node); } catch (OperationFailedException e) { throw new XMLStreamException(e.getFailureDescription().toString(), location); } return node; }