Java Code Examples for org.jboss.as.controller.parsing.ParseUtils#missingRequired()

The following examples show how to use org.jboss.as.controller.parsing.ParseUtils#missingRequired() . 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 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, asSet(Constants.XML.PRIVATE_KEY_ALIAS));
    }
    if (!addKeyStore.hasDefined(Constants.Model.PRIVATE_KEY_PASSWORD)) {
        throw ParseUtils.missingRequired(reader, asSet(Constants.XML.PRIVATE_KEY_PASSWORD));
    }

    ParseUtils.requireNoContent(reader);
}
 
Example 2
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
void readCertificate(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 = KeyStoreCertificateDefinition.lookup(name);
        if (attr == null) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        }
        attr.parseAndSetParameter(value, addKeyStore, reader);
    }

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

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

        boolean policySet = false;

        for (int i = 0; i < reader.getAttributeCount(); i++) {
            String name = reader.getAttributeLocalName(i);
            String value = reader.getAttributeValue(i);

            if (Constants.XML.PRINCIPAL_NAME_MAPPING_POLICY.equals(name)) {
                policySet = true;
                ServiceProviderDefinition.PRINCIPAL_NAME_MAPPING_POLICY.parseAndSetParameter(value, addServiceProvider, reader);
            } else if (Constants.XML.PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME.equals(name)) {
                ServiceProviderDefinition.PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME.parseAndSetParameter(value, addServiceProvider, reader);
            } else {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }

        if (!policySet) {
            throw ParseUtils.missingRequired(reader, Constants.XML.PRINCIPAL_NAME_MAPPING_POLICY);
        }
        ParseUtils.requireNoContent(reader);
    }
 
Example 4
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 5
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void readKeyStore(ModelNode addKey, XMLExtendedStreamReader reader) throws XMLStreamException {
    ModelNode addKeyStore = addKey.get(Constants.Model.KEY_STORE);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String name = reader.getAttributeLocalName(i);
        String value = reader.getAttributeValue(i);

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

    if (!addKeyStore.hasDefined(Constants.Model.FILE) && !addKeyStore.hasDefined(Constants.Model.RESOURCE)) {
        throw new XMLStreamException("KeyStore element must have 'file' or 'resource' attribute set", reader.getLocation());
    }
    if (!addKeyStore.hasDefined(Constants.Model.PASSWORD)) {
        throw ParseUtils.missingRequired(reader, Constants.XML.PASSWORD);
    }

    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 keystore type should occur only once.
            throw ParseUtils.unexpectedElement(reader);
        }
        if (Constants.XML.PRIVATE_KEY.equals(tagName)) {
            readPrivateKey(reader, addKeyStore);
        } else if (Constants.XML.CERTIFICATE.equals(tagName)) {
            readCertificate(reader, addKeyStore);
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
        parsedElements.add(tagName);
    }
}
 
Example 6
Source File: JvmXml.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void parseLaunchCommand(final XMLExtendedStreamReader reader, ModelNode addOp)
        throws XMLStreamException {

    // Handle attributes
    boolean valueSet = 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);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case PREFIX: {
                    if (checkParseAndSetParameter(JvmAttributes.LAUNCH_COMMAND, value, addOp, reader)) {
                        throw ParseUtils.duplicateNamedElement(reader, reader.getLocalName());
                    }
                    valueSet = true;
                    break;
                }
                default:
                    throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
    }
    if (!valueSet) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.PREFIX));
    }
    // Handle elements
    requireNoContent(reader);
}
 
Example 7
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
/**
 * Read an attribute, and throw exception if attribute is not present
 */
String readRequiredAttribute(XMLExtendedStreamReader reader, String attrName) throws XMLStreamException {
    String value = null;
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String attr = reader.getAttributeLocalName(i);
        if (attr.equals(attrName)) {
            value = reader.getAttributeValue(i);
            break;
        }
    }
    if (value == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(attrName));
    }
    return value;
}
 
Example 8
Source File: JvmXml.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void parseAgentLib(final XMLExtendedStreamReader reader, ModelNode addOp)
        throws XMLStreamException {

    // Handle attributes
    boolean valueSet = 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);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case VALUE: {
                    if (checkParseAndSetParameter(JvmAttributes.AGENT_LIB, value, addOp, reader)){
                        throw ParseUtils.duplicateNamedElement(reader, reader.getLocalName());
                    }
                    valueSet = true;
                    break;
                }
                default:
                    throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
    }
    if (!valueSet) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.VALUE));
    }
    // Handle elements
    requireNoContent(reader);
}
 
Example 9
Source File: JvmXml.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void parseStack(final XMLExtendedStreamReader reader, ModelNode addOp)
        throws XMLStreamException {

    // Handle attributes
    boolean sizeSet = 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);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case SIZE: {
                    sizeSet = true;
                    if (checkParseAndSetParameter(JvmAttributes.STACK_SIZE, value, addOp, reader)){
                        throw ParseUtils.duplicateNamedElement(reader, reader.getLocalName());

                    }
                    break;
                }
                default:
                    throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
    }
    if (!sizeSet) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.SIZE));
    }
    // Handle elements
    requireNoContent(reader);
}
 
Example 10
Source File: JvmXml.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static void parseJvmOptions(final XMLExtendedStreamReader reader, final Namespace expectedNs, final ModelNode addOp)
        throws XMLStreamException {

    ModelNode options = new ModelNode();
    // Handle attributes
    ParseUtils.requireNoAttributes(reader);
    // Handle elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        final Element element = Element.forName(reader.getLocalName());
        if (element == Element.OPTION) {
            // Handle attributes
            ModelNode option = null;
            final int count = reader.getAttributeCount();
            for (int i = 0; i < count; i++) {
                final String attrValue = reader.getAttributeValue(i);
                if (!isNoNamespaceAttribute(reader, i)) {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                } else {
                    final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
                    switch (attribute) {
                        case VALUE: {
                            option = ParseUtils.parsePossibleExpression(attrValue);
                            break;
                        }
                        default:
                            throw ParseUtils.unexpectedAttribute(reader, i);
                    }
                }
            }
            if (option == null) {
                throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.NAME));
            }

            options.add(option);
            // Handle elements
            requireNoContent(reader);
        } else {
            throw unexpectedElement(reader);
        }
    }
    if (!options.isDefined()) {
        throw missingRequiredElement(reader, Collections.singleton(Element.OPTION));
    }
    addOp.get(JvmAttributes.JVM_OPTIONS).set(options);
}
 
Example 11
Source File: DeploymentScannerParser_2_0.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
void parseScanner(XMLExtendedStreamReader reader, final ModelNode address, List<ModelNode> list) throws XMLStreamException {
    // Handle attributes

    String name = DeploymentScannerExtension.DEFAULT_SCANNER_NAME;
    String path = null;
    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    final int attrCount = reader.getAttributeCount();
    for (int i = 0; i < attrCount; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final String attribute = reader.getAttributeLocalName(i);
        switch (attribute) {
            case PATH: {
                path = value;
                DeploymentScannerDefinition.PATH.parseAndSetParameter(value,operation,reader);
                break;
            }
            case NAME: {
                name = DeploymentScannerDefinition.NAME.parse(value,reader).asString();
                break;
            }
            case RELATIVE_TO: {
                DeploymentScannerDefinition.RELATIVE_TO.parseAndSetParameter(value,operation,reader);
                break;
            }
            case SCAN_INTERVAL: {
                DeploymentScannerDefinition.SCAN_INTERVAL.parseAndSetParameter(value,operation,reader);
                break;
            }
            case SCAN_ENABLED: {
                DeploymentScannerDefinition.SCAN_ENABLED.parseAndSetParameter(value,operation,reader);
                break;
            }
            case AUTO_DEPLOY_ZIPPED: {
                DeploymentScannerDefinition.AUTO_DEPLOY_ZIPPED.parseAndSetParameter(value,operation,reader);
                break;
            }
            case AUTO_DEPLOY_EXPLODED: {
                DeploymentScannerDefinition.AUTO_DEPLOY_EXPLODED.parseAndSetParameter(value,operation,reader);
                break;
            }
            case AUTO_DEPLOY_XML: {
                DeploymentScannerDefinition.AUTO_DEPLOY_XML.parseAndSetParameter(value,operation,reader);
                break;
            }
            case DEPLOYMENT_TIMEOUT: {
                DeploymentScannerDefinition.DEPLOYMENT_TIMEOUT.parseAndSetParameter(value,operation,reader);
                break;
            }
            case RUNTIME_FAILURE_CAUSES_ROLLBACK: {
                DeploymentScannerDefinition.RUNTIME_FAILURE_CAUSES_ROLLBACK.parseAndSetParameter(value,operation,reader);
                break;
            }
            default:
                throw ParseUtils.unexpectedAttribute(reader, i);
        }
    }
    if (name == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(CommonAttributes.NAME));
    }
    if (path == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(PATH));
    }
    requireNoContent(reader);
    operation.get(OP_ADDR).set(address).add(CommonAttributes.SCANNER, name);
    list.add(operation);
}
 
Example 12
Source File: DeploymentScannerParser_1_0.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
void parseScanner(XMLExtendedStreamReader reader, final ModelNode address, List<ModelNode> list) throws XMLStreamException {
    // Handle attributes
    Boolean enabled = null;
    Integer interval = null;
    String path = null;
    String name = DeploymentScannerExtension.DEFAULT_SCANNER_NAME;
    String relativeTo = null;
    Boolean autoDeployZipped = null;
    Boolean autoDeployExploded = null;
    Long deploymentTimeout = null;
    final int attrCount = reader.getAttributeCount();
    for (int i = 0; i < attrCount; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final String attribute = reader.getAttributeLocalName(i);
        switch (attribute) {
            case PATH: {
                path = value;
                break;
            }
            case NAME: {
                name = value;
                break;
            }
            case RELATIVE_TO: {
                relativeTo = value;
                break;
            }
            case SCAN_INTERVAL: {
                interval = Integer.parseInt(value);
                break;
            }
            case SCAN_ENABLED: {
                enabled = Boolean.parseBoolean(value);
                break;
            }
            case AUTO_DEPLOY_ZIPPED: {
                autoDeployZipped = Boolean.parseBoolean(value);
                break;
            }
            case AUTO_DEPLOY_EXPLODED: {
                autoDeployExploded = Boolean.parseBoolean(value);
                break;
            }
            case DEPLOYMENT_TIMEOUT: {
                deploymentTimeout = Long.parseLong(value);
                break;
            }
            default:
                throw ParseUtils.unexpectedAttribute(reader, i);
        }
    }
    if (name == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(CommonAttributes.NAME));
    }
    if (path == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(PATH));
    }
    requireNoContent(reader);

    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    operation.get(OP_ADDR).set(address).add(CommonAttributes.SCANNER, name);
    operation.get(PATH).set(path);
    if (interval != null) operation.get(CommonAttributes.SCAN_INTERVAL).set(interval.intValue());
    if (autoDeployZipped != null) operation.get(CommonAttributes.AUTO_DEPLOY_ZIPPED).set(autoDeployZipped.booleanValue());
    if (autoDeployExploded != null) operation.get(CommonAttributes.AUTO_DEPLOY_EXPLODED).set(autoDeployExploded.booleanValue());
    if (enabled != null) operation.get(CommonAttributes.SCAN_ENABLED).set(enabled.booleanValue());
    if(relativeTo != null) operation.get(CommonAttributes.RELATIVE_TO).set(relativeTo);
    if(deploymentTimeout != null) operation.get(CommonAttributes.DEPLOYMENT_TIMEOUT).set(deploymentTimeout);
    list.add(operation);
}
 
Example 13
Source File: HostXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * The only difference between version 1.5 and 1.6 of the schema were to make is possible to define discovery options, this
 * resulted in the host and port attributes becoming optional -this method also indicates if discovery options are required
 * where the host and port were not supplied.
 *
 * @param allowDiscoveryOptions i.e. are host and port potentially optional?
 * @return true if discovery options are required, i.e. no host and port set and the admin policy requires a config.
 */
private boolean parseRemoteDomainControllerAttributes_1_5(final XMLExtendedStreamReader reader, final ModelNode address,
                                                          final List<ModelNode> list, boolean allowDiscoveryOptions) throws XMLStreamException {

    final ModelNode update = new ModelNode();
    update.get(OP_ADDR).set(address);
    update.get(OP).set(RemoteDomainControllerAddHandler.OPERATION_NAME);

    // Handle attributes
    AdminOnlyDomainConfigPolicy adminOnlyPolicy = AdminOnlyDomainConfigPolicy.DEFAULT;
    boolean requireDiscoveryOptions = false;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case HOST: {
                    DomainControllerWriteAttributeHandler.HOST.parseAndSetParameter(value, update, reader);
                    break;
                }
                case PORT: {
                    DomainControllerWriteAttributeHandler.PORT.parseAndSetParameter(value, update, reader);
                    break;
                }
                case SECURITY_REALM: {
                    DomainControllerWriteAttributeHandler.SECURITY_REALM.parseAndSetParameter(value, update, reader);
                    break;
                }
                case USERNAME: {
                    DomainControllerWriteAttributeHandler.USERNAME.parseAndSetParameter(value, update, reader);
                    break;
                }
                case ADMIN_ONLY_POLICY: {
                    DomainControllerWriteAttributeHandler.ADMIN_ONLY_POLICY.parseAndSetParameter(value, update, reader);
                    ModelNode nodeValue = update.get(DomainControllerWriteAttributeHandler.ADMIN_ONLY_POLICY.getName());
                    if (nodeValue.getType() != ModelType.EXPRESSION) {
                        adminOnlyPolicy = AdminOnlyDomainConfigPolicy.getPolicy(nodeValue.asString());
                    }
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }
    }

    if (!update.hasDefined(DomainControllerWriteAttributeHandler.HOST.getName())) {
        if (allowDiscoveryOptions) {
            requireDiscoveryOptions = isRequireDiscoveryOptions(adminOnlyPolicy);
        } else {
            throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.HOST.getLocalName()));
        }
    }
    if (!update.hasDefined(DomainControllerWriteAttributeHandler.PORT.getName())) {
        if (allowDiscoveryOptions) {
            requireDiscoveryOptions = requireDiscoveryOptions || isRequireDiscoveryOptions(adminOnlyPolicy);
        } else {
            throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.PORT.getLocalName()));
        }
    }

    list.add(update);
    return requireDiscoveryOptions;
}
 
Example 14
Source File: HostXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseRemoteDomainControllerAttributes_1_3(final XMLExtendedStreamReader reader, final ModelNode address,
        final List<ModelNode> list) throws XMLStreamException {
    // Handle attributes
    String host = null;
    ModelNode port = null;
    String securityRealm = null;
    String username = null;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case HOST: {
                    host = value;
                    break;
                }
                case PORT: {
                    port = parsePossibleExpression(value);
                    if(port.getType() != ModelType.EXPRESSION) {
                        try {
                            int portNo = Integer.parseInt(value);
                            if (portNo < 1) {
                                throw ControllerLogger.ROOT_LOGGER.invalidPort(attribute.getLocalName(), value, reader.getLocation());
                            }
                        }catch(NumberFormatException e) {
                            throw ControllerLogger.ROOT_LOGGER.invalidPort(attribute.getLocalName(), value, reader.getLocation());
                        }
                    }
                    break;
                }
                case SECURITY_REALM: {
                    securityRealm = value;
                    break;
                }
                case USERNAME: {
                    username = value;
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }
    }
    if (host == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.HOST.getLocalName()));
    }
    if (port == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.PORT.getLocalName()));
    }

    final ModelNode update = new ModelNode();
    update.get(OP_ADDR).set(address);
    update.get(OP).set(RemoteDomainControllerAddHandler.OPERATION_NAME);
    update.get(HOST).set(parsePossibleExpression(host));
    update.get(PORT).set(port);
    if (securityRealm != null) {
        update.get(SECURITY_REALM).set(securityRealm);
    }
    if (username != null) {
        update.get(USERNAME).set(username);
    }
    list.add(update);
}
 
Example 15
Source File: HostXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseIgnoredResource(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> foundTypes) throws XMLStreamException {

        ModelNode op = new ModelNode();
        op.get(OP).set(ADD);

        String type = null;

        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            if (!isNoNamespaceAttribute(reader, i)) {
                throw unexpectedAttribute(reader, i);
            }
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case TYPE: {
                    if (!foundTypes.add(value)) {
                        throw HostControllerLogger.ROOT_LOGGER.duplicateIgnoredResourceType(Element.IGNORED_RESOURCE.getLocalName(), value, reader.getLocation());
                    }
                    type = value;
                    break;
                }
                case WILDCARD: {
                    IgnoredDomainTypeResourceDefinition.WILDCARD.parseAndSetParameter(value, op, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (type == null) {
            throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.TYPE.getLocalName()));
        }

        ModelNode addr = op.get(OP_ADDR).set(address);
        addr.add(CORE_SERVICE, IGNORED_RESOURCES);
        addr.add(IGNORED_RESOURCE_TYPE, type);

        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case INSTANCE: {
                    String name = ParseUtils.readStringAttributeElement(reader, NAME);
                    IgnoredDomainTypeResourceDefinition.NAMES.parseAndAddParameterElement(name, op, reader);
                    break;
                }
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(op);
    }
 
Example 16
Source File: HostXml_6.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseIgnoredResource(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> foundTypes) throws XMLStreamException {

        ModelNode op = new ModelNode();
        op.get(OP).set(ADD);

        String type = null;

        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            if (!isNoNamespaceAttribute(reader, i)) {
                throw unexpectedAttribute(reader, i);
            }
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case TYPE: {
                    if (!foundTypes.add(value)) {
                        throw HostControllerLogger.ROOT_LOGGER.duplicateIgnoredResourceType(Element.IGNORED_RESOURCE.getLocalName(), value, reader.getLocation());
                    }
                    type = value;
                    break;
                }
                case WILDCARD: {
                    IgnoredDomainTypeResourceDefinition.WILDCARD.parseAndSetParameter(value, op, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (type == null) {
            throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.TYPE.getLocalName()));
        }

        ModelNode addr = op.get(OP_ADDR).set(address);
        addr.add(CORE_SERVICE, IGNORED_RESOURCES);
        addr.add(IGNORED_RESOURCE_TYPE, type);

        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case INSTANCE: {
                    String name = ParseUtils.readStringAttributeElement(reader, NAME);
                    IgnoredDomainTypeResourceDefinition.NAMES.parseAndAddParameterElement(name, op, reader);
                    break;
                }
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(op);
    }
 
Example 17
Source File: HostXml_7.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseIgnoredResource(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> foundTypes) throws XMLStreamException {

        ModelNode op = new ModelNode();
        op.get(OP).set(ADD);

        String type = null;

        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            if (!isNoNamespaceAttribute(reader, i)) {
                throw unexpectedAttribute(reader, i);
            }
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case TYPE: {
                    if (!foundTypes.add(value)) {
                        throw HostControllerLogger.ROOT_LOGGER.duplicateIgnoredResourceType(Element.IGNORED_RESOURCE.getLocalName(), value, reader.getLocation());
                    }
                    type = value;
                    break;
                }
                case WILDCARD: {
                    IgnoredDomainTypeResourceDefinition.WILDCARD.parseAndSetParameter(value, op, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (type == null) {
            throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.TYPE.getLocalName()));
        }

        ModelNode addr = op.get(OP_ADDR).set(address);
        addr.add(CORE_SERVICE, IGNORED_RESOURCES);
        addr.add(IGNORED_RESOURCE_TYPE, type);

        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case INSTANCE: {
                    String name = ParseUtils.readStringAttributeElement(reader, NAME);
                    IgnoredDomainTypeResourceDefinition.NAMES.parseAndAddParameterElement(name, op, reader);
                    break;
                }
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(op);
    }
 
Example 18
Source File: HostXml_9.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseIgnoredResource(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> foundTypes) throws XMLStreamException {

        ModelNode op = new ModelNode();
        op.get(OP).set(ADD);

        String type = null;

        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            if (!isNoNamespaceAttribute(reader, i)) {
                throw unexpectedAttribute(reader, i);
            }
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case TYPE: {
                    if (!foundTypes.add(value)) {
                        throw HostControllerLogger.ROOT_LOGGER.duplicateIgnoredResourceType(Element.IGNORED_RESOURCE.getLocalName(), value, reader.getLocation());
                    }
                    type = value;
                    break;
                }
                case WILDCARD: {
                    IgnoredDomainTypeResourceDefinition.WILDCARD.parseAndSetParameter(value, op, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (type == null) {
            throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.TYPE.getLocalName()));
        }

        ModelNode addr = op.get(OP_ADDR).set(address);
        addr.add(CORE_SERVICE, IGNORED_RESOURCES);
        addr.add(IGNORED_RESOURCE_TYPE, type);

        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case INSTANCE: {
                    String name = ParseUtils.readStringAttributeElement(reader, NAME);
                    IgnoredDomainTypeResourceDefinition.NAMES.parseAndAddParameterElement(name, op, reader);
                    break;
                }
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(op);
    }
 
Example 19
Source File: HostXml_8.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseIgnoredResource(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> foundTypes) throws XMLStreamException {

        ModelNode op = new ModelNode();
        op.get(OP).set(ADD);

        String type = null;

        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            if (!isNoNamespaceAttribute(reader, i)) {
                throw unexpectedAttribute(reader, i);
            }
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case TYPE: {
                    if (!foundTypes.add(value)) {
                        throw HostControllerLogger.ROOT_LOGGER.duplicateIgnoredResourceType(Element.IGNORED_RESOURCE.getLocalName(), value, reader.getLocation());
                    }
                    type = value;
                    break;
                }
                case WILDCARD: {
                    IgnoredDomainTypeResourceDefinition.WILDCARD.parseAndSetParameter(value, op, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (type == null) {
            throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.TYPE.getLocalName()));
        }

        ModelNode addr = op.get(OP_ADDR).set(address);
        addr.add(CORE_SERVICE, IGNORED_RESOURCES);
        addr.add(IGNORED_RESOURCE_TYPE, type);

        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case INSTANCE: {
                    String name = ParseUtils.readStringAttributeElement(reader, NAME);
                    IgnoredDomainTypeResourceDefinition.NAMES.parseAndAddParameterElement(name, op, reader);
                    break;
                }
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(op);
    }
 
Example 20
Source File: DeploymentScannerParser_1_1.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
void parseScanner(XMLExtendedStreamReader reader, final ModelNode address, List<ModelNode> list) throws XMLStreamException {
    // Handle attributes

    String name = DeploymentScannerExtension.DEFAULT_SCANNER_NAME;
    String path = null;
    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    final int attrCount = reader.getAttributeCount();
    for (int i = 0; i < attrCount; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final String attribute = reader.getAttributeLocalName(i);
        switch (attribute) {
            case PATH: {
                path = value;
                DeploymentScannerDefinition.PATH.parseAndSetParameter(value,operation,reader);
                break;
            }
            case NAME: {
                name = DeploymentScannerDefinition.NAME.parse(value,reader).asString();
                break;
            }
            case RELATIVE_TO: {
                DeploymentScannerDefinition.RELATIVE_TO.parseAndSetParameter(value,operation,reader);
                break;
            }
            case SCAN_INTERVAL: {
                DeploymentScannerDefinition.SCAN_INTERVAL.parseAndSetParameter(value,operation,reader);
                break;
            }
            case SCAN_ENABLED: {
                DeploymentScannerDefinition.SCAN_ENABLED.parseAndSetParameter(value,operation,reader);
                break;
            }
            case AUTO_DEPLOY_ZIPPED: {
                DeploymentScannerDefinition.AUTO_DEPLOY_ZIPPED.parseAndSetParameter(value,operation,reader);
                break;
            }
            case AUTO_DEPLOY_EXPLODED: {
                DeploymentScannerDefinition.AUTO_DEPLOY_EXPLODED.parseAndSetParameter(value,operation,reader);
                break;
            }
            case AUTO_DEPLOY_XML: {
                DeploymentScannerDefinition.AUTO_DEPLOY_XML.parseAndSetParameter(value,operation,reader);
                break;
            }
            case DEPLOYMENT_TIMEOUT: {
                DeploymentScannerDefinition.DEPLOYMENT_TIMEOUT.parseAndSetParameter(value,operation,reader);
                break;
            }
            default:
                throw ParseUtils.unexpectedAttribute(reader, i);
        }
    }
    if (name == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(CommonAttributes.NAME));
    }
    if (path == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(PATH));
    }
    requireNoContent(reader);
    operation.get(OP_ADDR).set(address).add(CommonAttributes.SCANNER, name);
    list.add(operation);
}