static ModelNode resolveValue(final OperationContext context, final ModelNode operation, final AttributeDefinition attribute) throws OperationFailedException { final ModelNode value = new ModelNode(); if (operation.has(attribute.getName())) { value.set(operation.get(attribute.getName())); } return attribute.resolveValue(context, value); }
/** * {@inheritDoc} */ @Override public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException { context.startSubsystemElement(NamingExtension.NAMESPACE_2_0, false); ModelNode model = context.getModelNode(); // bindings if (model.hasDefined(BINDING)) { writer.writeStartElement(NamingSubsystemXMLElement.BINDINGS.getLocalName()); final ModelNode bindingModel = model.get(BINDING); this.writeBindings(writer, bindingModel); // </timer-service> writer.writeEndElement(); } if (model.hasDefined(SERVICE)) { final ModelNode service = model.get(SERVICE); if (service.has(REMOTE_NAMING)) { writer.writeEmptyElement(REMOTE_NAMING); } } // write the subsystem end element writer.writeEndElement(); }
@Override public boolean rejectOperation(ModelNode result) { // Check the host result for successful operations and see if we have to reject it if(result.get(RESULT).has(DOMAIN_RESULTS)) { final ModelNode domainResults = result.get(RESULT, DOMAIN_RESULTS); // Don't reject ignored operations if(domainResults.getType() == ModelType.STRING && IGNORED.equals(domainResults.asString())) { return false; } // The format of the prepared operation of the domain coordination step1 is different from a normal operation // a user would need to handle, therefore try to fix it up as good as possible final ModelNode userOp = new ModelNode(); userOp.get(OUTCOME).set(SUCCESS); userOp.get(RESULT).set(domainResults); return rejectPolicy.rejectOperation(userOp); } else { // This should only handle failed host operations return rejectPolicy.rejectOperation(result); } }
public void validate(ModelNode operation) throws OperationFailedException { for (Map.Entry<String, ParameterValidator> entry : validators.entrySet()) { String paramName = entry.getKey(); ModelNode paramVal = operation.has(paramName) ? operation.get(paramName) : new ModelNode(); entry.getValue().validateParameter(paramName, paramVal); } }
@Override public boolean isMarshallable(AttributeDefinition attribute, ModelNode resourceModel) { // Unfortunately, the xsd says default is true while the mgmt API default is false. // So, only marshal if the value != 'true' return !resourceModel.has(attribute.getName()) || resourceModel.get(attribute.getName()).getType() != ModelType.BOOLEAN || !resourceModel.get(attribute.getName()).asBoolean(); }
private Set<String> checkModelNode(ModelNode modelNode) { Set<String> problems = null; for (String attr : attributeNames) { if (modelNode.has(attr)) { if (modelNode.hasDefined(attr)) { if (problems == null) { problems = new HashSet<String>(); } problems.add(attr); } else { modelNode.remove(attr); } } } return problems; }
/** * <p> * Parses the ORB {@code initializers} section of the JacORB subsystem configuration according to the XSD version 1.1 * or higher. * </p> * * @param reader the {@code XMLExtendedStreamReader} used to read the configuration XML. * @param node the {@code ModelNode} that will hold the parsed ORB initializers configuration. * @throws javax.xml.stream.XMLStreamException * if an error occurs while parsing the XML. */ private void parseORBInitializersConfig(XMLExtendedStreamReader reader, ModelNode node) throws XMLStreamException { // parse the initializers config attributes. EnumSet<Attribute> attributes = EnumSet.of(Attribute.ORB_INIT_SECURITY, Attribute.ORB_INIT_TRANSACTIONS); this.parseAttributes(reader, node, attributes, null); // the initializers element doesn't have child elements. requireNoContent(reader); //if security="on" change it to security="identity" if(node.has(SECURITY) && node.get(SECURITY).asString().equals(JacORBSubsystemConstants.ON)) { node.get(SECURITY).set(SecurityAllowedValues.IDENTITY.toString()); } }
@Override public boolean rejectOperation(ModelNode result) { // Check the host result for successful operations and see if we have to reject it if(result.has(RESULT, DOMAIN_RESULTS)) { final ModelNode domainResults = result.get(RESULT, DOMAIN_RESULTS); // Don't reject ignored operations if(domainResults.getType() == ModelType.STRING && IGNORED.equals(domainResults.asString())) { return false; } // The format of the prepared operation of the domain coordination step1 is different from a normal operation // a user would need to handle, therefore try to fix it up as good as possible final ModelNode userOp = new ModelNode(); userOp.get(OUTCOME).set(SUCCESS); userOp.get(RESULT).set(domainResults); return rejectPolicy.rejectOperation(userOp); } else { // This should only handle failed host operations return rejectPolicy.rejectOperation(result); } }
public void validateResolved(ModelNode operation) throws OperationFailedException { for (Map.Entry<String, ParameterValidator> entry : validators.entrySet()) { String paramName = entry.getKey(); ModelNode paramVal = operation.has(paramName) ? operation.get(paramName) : new ModelNode(); entry.getValue().validateResolvedParameter(paramName, paramVal); } }
private ModelNode fixVaultConstraint(ModelNode modelNode) { if (modelNode.hasDefined("core-service","management","access","authorization","constraint","vault-expression")) { ModelNode target = modelNode.get("core-service","management","access","authorization","constraint","vault-expression"); if (target.has("default-requires-addressable")) { target.remove("default-requires-addressable"); } if (target.has("default-requires-read")) { target.remove("default-requires-read"); } if (target.has("default-requires-write")) { target.remove("default-requires-write"); } } return modelNode; } }
@Override public boolean isMarshallable(AttributeDefinition attribute, ModelNode resourceModel) { // Unfortunately, the xsd says default is true while the mgmt API default is false. // So, only marshal if the value != 'true' return !resourceModel.has(attribute.getName()) || resourceModel.get(attribute.getName()).getType() != ModelType.BOOLEAN || !resourceModel.get(attribute.getName()).asBoolean(); } @Override
private Set<String> checkModelNode(ModelNode modelNode) { Set<String> problems = null; for (String attr : attributeNames) { if (modelNode.has(attr)) { if (modelNode.hasDefined(attr)) { if (problems == null) { problems = new HashSet<String>(); } problems.add(attr); } else { modelNode.remove(attr); } } } return problems; }
private ModelNode getHostControllerResult(final ModelNode fullResult, final String... stepLabels) { ModelNode result = null; if (fullResult != null && fullResult.hasDefined(RESULT) && fullResult.get(RESULT).hasDefined(DOMAIN_RESULTS)) { ModelNode domainResults = fullResult.get(RESULT, DOMAIN_RESULTS); result = domainResults.get(stepLabels); if (result.has(OUTCOME) && !result.hasDefined(OUTCOME)) { if (result.hasDefined(FAILURE_DESCRIPTION)) { result.get(OUTCOME).set(FAILED); } else { result.get(OUTCOME).set(SUCCESS); } } } return result; }