org.jboss.as.controller.parsing.ParseUtils Java Examples

The following examples show how to use org.jboss.as.controller.parsing.ParseUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
void readSecureDeployment(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    String name = readRequiredAttribute(reader, Constants.XML.NAME);

    PathAddress addr = PathAddress.pathAddress(
            PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, KeycloakSamlExtension.SUBSYSTEM_NAME),
            PathElement.pathElement(Constants.Model.SECURE_DEPLOYMENT, name));
    ModelNode addSecureDeployment = Util.createAddOperation(addr);
    list.add(addSecureDeployment);

    Set<String> parsedElements = new HashSet<>();
    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();
        if (parsedElements.contains(tagName)) {
            // all sub-elements of the secure deployment type should occur only once.
            throw ParseUtils.unexpectedElement(reader);
        }
        if (tagName.equals(Constants.XML.SERVICE_PROVIDER)) {
            readServiceProvider(reader, list, addr);
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
        parsedElements.add(tagName);
    }
}
 
Example #2
Source File: JMXExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    list.add(createAddOperation());

    boolean gotConnector = false;

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String element = reader.getLocalName();
        switch (element) {
            case CommonAttributes.JMX_CONNECTOR: {
                if (gotConnector) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.JMX_CONNECTOR);
                }
                parseConnector(reader);
                gotConnector = true;
                break;
            }
            default: {
                throw ParseUtils.unexpectedElement(reader);
            }
        }
    }
}
 
Example #3
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
void readPrivateKey(XMLExtendedStreamReader reader, ModelNode addKeyStore) throws XMLStreamException {
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String name = reader.getAttributeLocalName(i);
        String value = reader.getAttributeValue(i);

        SimpleAttributeDefinition attr = KeyStorePrivateKeyDefinition.lookup(name);
        if (attr == null) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        }
        attr.parseAndSetParameter(value, addKeyStore, reader);
    }

    if (!addKeyStore.hasDefined(Constants.Model.PRIVATE_KEY_ALIAS)) {
        throw ParseUtils.missingRequired(reader, Constants.XML.PRIVATE_KEY_ALIAS);
    }
    if (!addKeyStore.hasDefined(Constants.Model.PRIVATE_KEY_PASSWORD)) {
        throw ParseUtils.missingRequired(reader, Constants.XML.PRIVATE_KEY_PASSWORD);
    }

    ParseUtils.requireNoContent(reader);
}
 
Example #4
Source File: DomainXml_11.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example #5
Source File: DomainXml_8.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example #6
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException {
    // Require no attributes
    ParseUtils.requireNoAttributes(reader);
    ModelNode addKeycloakSub = Util.createAddOperation(PathAddress.pathAddress(KeycloakExtension.PATH_SUBSYSTEM));
    list.add(addKeycloakSub);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        if (reader.getLocalName().equals(RealmDefinition.TAG_NAME)) {
            readRealm(reader, list);
        }
        else if (reader.getLocalName().equals(SecureDeploymentDefinition.TAG_NAME)) {
            readDeployment(reader, list);
        }
    }
}
 
Example #7
Source File: DomainXml_6.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example #8
Source File: OrderedChildResourceExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    list.add(Util.createAddOperation(PathAddress.pathAddress(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME)));

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String element = reader.getLocalName();
        switch (element) {
            case "child": {
                list.add(parseChild(reader));
                break;
            }
            default: {
                throw ParseUtils.unexpectedElement(reader);
            }
        }
    }
}
 
Example #9
Source File: DomainXml_9.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example #10
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException {
    // Require no attributes
    ParseUtils.requireNoAttributes(reader);
    ModelNode addKeycloakSub = Util.createAddOperation(PathAddress.pathAddress(KeycloakExtension.PATH_SUBSYSTEM));
    list.add(addKeycloakSub);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        if (reader.getLocalName().equals(RealmDefinition.TAG_NAME)) {
            readRealm(reader, list);
        }
        else if (reader.getLocalName().equals(SecureDeploymentDefinition.TAG_NAME)) {
            readDeployment(reader, list);
        }
        else if (reader.getLocalName().equals(SecureServerDefinition.TAG_NAME)) {
            readSecureServer(reader, list);
        }
    }
}
 
Example #11
Source File: JMXExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseSensitivity(ModelNode add, XMLExtendedStreamReader reader) throws XMLStreamException {
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        final String attribute = reader.getAttributeLocalName(i);
        switch (attribute) {
            case CommonAttributes.NON_CORE_MBEANS:
                JMXSubsystemRootResource.CORE_MBEAN_SENSITIVITY.parseAndSetParameter(value, add, reader);
                break;
            default:
                throw ParseUtils.unexpectedAttribute(reader, i);
        }
    }

    ParseUtils.requireNoContent(reader);
}
 
Example #12
Source File: DomainXml_7.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example #13
Source File: AccessControlXml.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseSensitiveClassifications(final XMLExtendedStreamReader reader, final ModelNode address,
        final List<ModelNode> list) throws XMLStreamException {

    ParseUtils.requireNoAttributes(reader);

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case SENSITIVE_CLASSIFICATION: {
                parseSensitivityClassification(reader, address, list);
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }
}
 
Example #14
Source File: PersistentResourceXMLDescription.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Parse xml from provided <code>reader</code> and add resulting operations to passed list
 * @param reader xml reader to parse from
 * @param parentAddress address of the parent, used as base for all child elements
 * @param list list of operations where result will be put to.
 * @throws XMLStreamException if any error occurs while parsing
 */
public void parse(final XMLExtendedStreamReader reader, PathAddress parentAddress, List<ModelNode> list) throws XMLStreamException {
    if (decoratorElement != null) {
        parseDecorator(reader, parentAddress, list);
        return;
    }
    if (xmlWrapperElement != null) {
        if (reader.getLocalName().equals(xmlWrapperElement)) {
            if (reader.hasNext() && reader.nextTag() == END_ELEMENT) { return; }
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
        parseInternal(reader, parentAddress, list);
        while (reader.nextTag() != END_ELEMENT && !reader.getLocalName().equals(xmlWrapperElement)) {
            parseInternal(reader, parentAddress, list);
        }
    } else {
        parseInternal(reader, parentAddress, list);
    }
}
 
Example #15
Source File: DomainXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example #16
Source File: DomainXml_12.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example #17
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
void readRoleIdentifiers(ModelNode addServiceProvider, XMLExtendedStreamReader reader) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();

        if (!Constants.XML.ATTRIBUTE.equals(tagName)) {
            throw ParseUtils.unexpectedElement(reader);
        }

        ParseUtils.requireSingleAttribute(reader, Constants.XML.NAME);
        String name = ParseUtils.readStringAttributeElement(reader, Constants.XML.NAME);

        ServiceProviderDefinition.ROLE_ATTRIBUTES.parseAndAddParameterElement(name, addServiceProvider, reader);
    }
}
 
Example #18
Source File: PersistentResourceXMLDescription.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseGroup(XMLExtendedStreamReader reader, ModelNode op, boolean wildcard) throws XMLStreamException {
    Map<String, AttributeDefinition> groupAttrs = attributesByGroup.get(reader.getLocalName());
    for (AttributeDefinition attrGroup : groupAttrs.values()) {
        if (op.hasDefined(attrGroup.getName())) {
            throw ParseUtils.unexpectedElement(reader);
        }
    }
    parseAttributes(reader, op, groupAttrs, wildcard);
    // Check if there are also element attributes inside a group
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        AttributeDefinition ad = groupAttrs.get(reader.getLocalName());
        if (ad != null) {
            ad.getParser().parseElement(ad, reader, op);
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
    }
}
 
Example #19
Source File: HostXml_8.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseServerSocketBindings(final XMLExtendedStreamReader reader, final ModelNode serverAddOperation) throws XMLStreamException {
    // Handle attributes

    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case SOCKET_BINDING_GROUP: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_GROUP.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                case DEFAULT_INTERFACE: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_DEFAULT_INTERFACE.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                case PORT_OFFSET: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_PORT_OFFSET.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }
    }

    // Handle elements
    requireNoContent(reader);

}
 
Example #20
Source File: AttributeParsers.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void parseElement(AttributeDefinition ad, XMLExtendedStreamReader reader, ModelNode addPermissionMapper) throws XMLStreamException {
    ParseUtils.requireSingleAttribute(reader, NAME);
    String name = reader.getAttributeValue(0);
    addPermissionMapper.get(ad.getName()).add(name);
    ParseUtils.requireNoContent(reader);
}
 
Example #21
Source File: BpmPlatformParser.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
  // Require no attributes
  ParseUtils.requireNoAttributes(reader);

  //Add the main subsystem 'add' operation
  final ModelNode subsystemAddress = new ModelNode();
  subsystemAddress.add(SUBSYSTEM, ModelConstants.SUBSYSTEM_NAME);
  subsystemAddress.protect();
  
  final ModelNode subsystemAdd = new ModelNode();
  subsystemAdd.get(OP).set(ADD);
  subsystemAdd.get(OP_ADDR).set(subsystemAddress);
  list.add(subsystemAdd);
  
  while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
  final Element element = Element.forName(reader.getLocalName());
  switch (element) {
        case PROCESS_ENGINES: {
          parseProcessEngines(reader, list, subsystemAddress);
          break;
        }
        case JOB_EXECUTOR: {
          parseJobExecutor(reader, list, subsystemAddress);		  
          break;
        }
        default: {
          throw unexpectedElement(reader);
        }
      }
  }
}
 
Example #22
Source File: DomainXml_7.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseHostApiVersion(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        Set<Attribute> required = EnumSet.of(Attribute.MAJOR_VERSION, Attribute.MINOR_VERSION);
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.MAJOR_VERSION) {
                required.remove(attribute);
                HostExcludeResourceDefinition.MANAGEMENT_MAJOR_VERSION.parseAndSetParameter(value, addOp, reader);
            } else if (attribute == Attribute.MINOR_VERSION) {
                required.remove(attribute);
                HostExcludeResourceDefinition.MANAGEMENT_MINOR_VERSION.parseAndSetParameter(value, addOp, reader);
            } else if (attribute == Attribute.MICRO_VERSION) {
                HostExcludeResourceDefinition.MANAGEMENT_MICRO_VERSION.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!required.isEmpty()) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }
 
Example #23
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void readHttpClient(final ModelNode addIdentityProvider, final XMLExtendedStreamReader reader) throws XMLStreamException {
    ModelNode httpClientNode = addIdentityProvider.get(Constants.Model.HTTP_CLIENT);
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String name = reader.getAttributeLocalName(i);
        String value = reader.getAttributeValue(i);

        SimpleAttributeDefinition attr = HttpClientDefinition.lookup(name);
        if (attr == null) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        }
        attr.parseAndSetParameter(value, httpClientNode, reader);
    }
    ParseUtils.requireNoContent(reader);
}
 
Example #24
Source File: OtherServicesSubsystemExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    // Require no content
    ParseUtils.requireNoContent(reader);
    list.add(Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME))));
}
 
Example #25
Source File: HostXml_10.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseServerSocketBindings(final XMLExtendedStreamReader reader, final ModelNode serverAddOperation) throws XMLStreamException {
    // Handle attributes

    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case SOCKET_BINDING_GROUP: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_GROUP.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                case DEFAULT_INTERFACE: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_DEFAULT_INTERFACE.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                case PORT_OFFSET: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_PORT_OFFSET.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }
    }

    // Handle elements
    requireNoContent(reader);

}
 
Example #26
Source File: DomainXml_9.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseHostApiVersion(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        Set<Attribute> required = EnumSet.of(Attribute.MAJOR_VERSION, Attribute.MINOR_VERSION);
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.MAJOR_VERSION) {
                required.remove(attribute);
                HostExcludeResourceDefinition.MANAGEMENT_MAJOR_VERSION.parseAndSetParameter(value, addOp, reader);
            } else if (attribute == Attribute.MINOR_VERSION) {
                required.remove(attribute);
                HostExcludeResourceDefinition.MANAGEMENT_MINOR_VERSION.parseAndSetParameter(value, addOp, reader);
            } else if (attribute == Attribute.MICRO_VERSION) {
                HostExcludeResourceDefinition.MANAGEMENT_MICRO_VERSION.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!required.isEmpty()) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }
 
Example #27
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private String readNameAttribute(XMLExtendedStreamReader reader) throws XMLStreamException {
    String name = null;
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String attr = reader.getAttributeLocalName(i);
        if (attr.equals("name")) {
            name = reader.getAttributeValue(i);
            continue;
        }
        throw ParseUtils.unexpectedAttribute(reader, i);
    }
    if (name == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton("name"));
    }
    return name;
}
 
Example #28
Source File: HostXml_6.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseServerSocketBindings(final XMLExtendedStreamReader reader, final ModelNode serverAddOperation) throws XMLStreamException {
    // Handle attributes

    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case SOCKET_BINDING_GROUP: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_GROUP.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                case DEFAULT_INTERFACE: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_DEFAULT_INTERFACE.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                case PORT_OFFSET: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_PORT_OFFSET.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }
    }

    // Handle elements
    requireNoContent(reader);

}
 
Example #29
Source File: NewExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    ParseUtils.requireNoContent(reader);

    ModelNode subsystemAdd = Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME)));
    subsystemAdd.get("test").set("Hello");
    subsystemAdd.get("properties", "one").set("A");
    subsystemAdd.get("properties", "two").set("B");

    list.add(subsystemAdd);
}
 
Example #30
Source File: DomainXml_8.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseHostApiVersion(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        Set<Attribute> required = EnumSet.of(Attribute.MAJOR_VERSION, Attribute.MINOR_VERSION);
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.MAJOR_VERSION) {
                required.remove(attribute);
                HostExcludeResourceDefinition.MANAGEMENT_MAJOR_VERSION.parseAndSetParameter(value, addOp, reader);
            } else if (attribute == Attribute.MINOR_VERSION) {
                required.remove(attribute);
                HostExcludeResourceDefinition.MANAGEMENT_MINOR_VERSION.parseAndSetParameter(value, addOp, reader);
            } else if (attribute == Attribute.MICRO_VERSION) {
                HostExcludeResourceDefinition.MANAGEMENT_MICRO_VERSION.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!required.isEmpty()) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }