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

The following examples show how to use org.jboss.as.controller.parsing.ParseUtils#requireNoAttributes() . 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
/**
 * {@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 2
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 3
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(KeycloakSamlExtension.PATH_SUBSYSTEM));
    list.add(addKeycloakSub);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        if (reader.getLocalName().equals(Constants.XML.SECURE_DEPLOYMENT)) {
            readSecureDeployment(reader, list);
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
    }
}
 
Example 4
Source File: AccessControlXml.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void parseHostScopedRoles(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException {

        ParseUtils.requireNoAttributes(reader);

        String scopedRoleType = HostScopedRolesResourceDefinition.PATH_ELEMENT.getKey();

        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case ROLE: {
                    parseScopedRole(reader, address, list, scopedRoleType, Element.HOST,
                            HostScopedRolesResourceDefinition.BASE_ROLE, HostScopedRolesResourceDefinition.HOSTS, false);
                    break;
                }
                default: {
                    throw unexpectedElement(reader);
                }
            }
        }

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

        ParseUtils.requireNoAttributes(reader);

        String scopedRoleType = ServerGroupScopedRoleResourceDefinition.PATH_ELEMENT.getKey();

        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case ROLE: {
                    parseScopedRole(reader, address, list, scopedRoleType, Element.SERVER_GROUP,
                            ServerGroupScopedRoleResourceDefinition.BASE_ROLE, ServerGroupScopedRoleResourceDefinition.SERVER_GROUPS, true);
                    break;
                }
                default: {
                    throw unexpectedElement(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(PATH_SUBSYSTEM));
    list.add(addKeycloakSub);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        if (reader.getLocalName().equals(WEB_CONTEXT.getXmlName())) {
            WEB_CONTEXT.parseAndSetParameter(reader.getElementText(), addKeycloakSub, reader);
        } else if (reader.getLocalName().equals(PROVIDERS.getXmlName())) {
            readProviders(reader, addKeycloakSub);
        } else if (reader.getLocalName().equals(MASTER_REALM_NAME.getXmlName())) {
            MASTER_REALM_NAME.parseAndSetParameter(reader.getElementText(), addKeycloakSub, reader);
        } else if (reader.getLocalName().equals(SCHEDULED_TASK_INTERVAL.getXmlName())) {
            SCHEDULED_TASK_INTERVAL.parseAndSetParameter(reader.getElementText(), addKeycloakSub, reader);
        } else if (reader.getLocalName().equals(ThemeResourceDefinition.TAG_NAME)) {
            readTheme(list, reader);
        } else if (reader.getLocalName().equals(SpiResourceDefinition.TAG_NAME)) {
            readSpi(list, reader);
        } else {
            throw new XMLStreamException("Unknown keycloak-server subsystem tag: " + reader.getLocalName());
        }
    }
}
 
Example 7
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 8
Source File: CliExtCommandsParser.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> ops) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    ParseUtils.requireNoContent(reader);
    ops.add(Util.createAddOperation(PathAddress.pathAddress(CliExtCommandsSubsystemResourceDescription.PATH)));
}
 
Example 9
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 10
Source File: JMXExtension.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 {
    boolean showResolvedModel = false;
    boolean showExpressionModel = false;
    boolean connectorAdd = false;

    ParseUtils.requireNoAttributes(reader);

    list.add(createAddOperation());

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String element = reader.getLocalName();
        switch (element) {
            case CommonAttributes.EXPOSE_RESOLVED_MODEL:
                if (showResolvedModel) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.EXPOSE_RESOLVED_MODEL);
                }
                showResolvedModel = true;
                list.add(parseShowModelElement(reader, CommonAttributes.RESOLVED));
                break;
            case CommonAttributes.EXPOSE_EXPRESSION_MODEL:
                if (showExpressionModel) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.EXPOSE_EXPRESSION_MODEL);
                }
                showExpressionModel = true;
                list.add(parseShowModelElement(reader, CommonAttributes.EXPRESSION));
                break;
            case REMOTING_CONNECTOR:
                if (connectorAdd) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.REMOTING_CONNECTOR);
                }
                connectorAdd = true;
                list.add(parseRemoteConnector(reader));
                break;
            default: {
                throw ParseUtils.unexpectedElement(reader);
            }
        }
    }
}
 
Example 11
Source File: JMXExtension.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 {
    boolean showModel = false;

    ParseUtils.requireNoAttributes(reader);

    ModelNode connectorAdd = null;
    list.add(createAddOperation());
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String element = reader.getLocalName();
        switch (element) {
            case CommonAttributes.SHOW_MODEL:
                if (showModel) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.SHOW_MODEL);
                }
                if (parseShowModelElement(reader)) {
                    //Add the show-model=>resolved part with the default domain name
                    ModelNode op = createOperation(ADD, CommonAttributes.EXPOSE_MODEL, CommonAttributes.RESOLVED);
                    //Use false here to keep total backwards compatibility
                    op.get(CommonAttributes.PROPER_PROPERTY_FORMAT).set(false);
                    list.add(op);
                }
                showModel = true;
                break;
            case CommonAttributes.REMOTING_CONNECTOR: {
                if (connectorAdd != null) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.REMOTING_CONNECTOR);
                }
                list.add(parseRemoteConnector(reader));
                break;
            }
            default: {
                throw ParseUtils.unexpectedElement(reader);
            }
        }
    }
}
 
Example 12
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 13
Source File: JvmXml.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static void parseModuleOptions(final XMLExtendedStreamReader reader, final ModelNode addOp) throws XMLStreamException {

        final ModelNode options = new ModelNode();
        // Handle attributes
        ParseUtils.requireNoAttributes(reader);
        // Handle elements
        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            final Element moduleOptionElement = Element.forName(reader.getLocalName());
            if (moduleOptionElement == 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));
                        if (attribute == Attribute.VALUE) {
                            option = ParseUtils.parsePossibleExpression(attrValue);
                        } else {
                            throw ParseUtils.unexpectedAttribute(reader, i);
                        }
                    }
                }
                if (option == null) {
                    throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.VALUE));
                }

                options.add(option);
                // Handle elements
                requireNoContent(reader);
            } else {
                throw unexpectedElement(reader);
            }
        }
        if (!options.isDefined()) {
            throw missingRequiredElement(reader, Collections.singleton(Element.OPTION));
        }
        addOp.get(JvmAttributes.MODULE_OPTIONS.getName()).set(options);
    }
 
Example 14
Source File: SubsystemInitialization.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> value) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    ParseUtils.requireNoContent(reader);
}
 
Example 15
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 4 votes vote down vote up
void readNoAttrElementContent(SimpleAttributeDefinition attr, ModelNode model, XMLExtendedStreamReader reader) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    String value = reader.getElementText();
    attr.parseAndSetParameter(value, model, reader);
}
 
Example 16
Source File: EmptySubsystemParser.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> value) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    ParseUtils.requireNoContent(reader);
}
 
Example 17
Source File: LoggingSubsystemParser_1_0.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException {
    // No attributes
    ParseUtils.requireNoAttributes(reader);

    // Subsystem add operation
    operations.add(Util.createAddOperation(SUBSYSTEM_ADDRESS));

    final List<ModelNode> loggerOperations = new ArrayList<>();
    final List<ModelNode> asyncHandlerOperations = new ArrayList<>();
    final List<ModelNode> handlerOperations = new ArrayList<>();

    // Elements
    final Set<String> loggerNames = new HashSet<>();
    final Set<String> handlerNames = new HashSet<>();
    boolean rootDefined = false;
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case LOGGER: {
                parseLoggerElement(reader, SUBSYSTEM_ADDRESS, loggerOperations, loggerNames);
                break;
            }
            case ROOT_LOGGER: {
                if (rootDefined) {
                    throw unexpectedElement(reader);
                }
                rootDefined = true;
                parseRootLoggerElement(reader, SUBSYSTEM_ADDRESS, loggerOperations);
                break;
            }
            case CONSOLE_HANDLER: {
                parseConsoleHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case FILE_HANDLER: {
                parseFileHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case PERIODIC_ROTATING_FILE_HANDLER: {
                parsePeriodicRotatingFileHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case SIZE_ROTATING_FILE_HANDLER: {
                parseSizeRotatingHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case ASYNC_HANDLER: {
                parseAsyncHandlerElement(reader, SUBSYSTEM_ADDRESS, asyncHandlerOperations, handlerNames);
                break;
            }
            default: {
                reader.handleAny(operations);
                break;
            }
        }
    }

    operations.addAll(handlerOperations);
    operations.addAll(asyncHandlerOperations);
    operations.addAll(loggerOperations);
}
 
Example 18
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 4 votes vote down vote up
void readNoAttrElementContent(SimpleAttributeDefinition attr, ModelNode model, XMLExtendedStreamReader reader) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    String value = reader.getElementText();
    attr.parseAndSetParameter(value, model, reader);
}
 
Example 19
Source File: LoggingSubsystemParser_1_1.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException {
    // No attributes
    ParseUtils.requireNoAttributes(reader);

    // Subsystem add operation
    operations.add(Util.createAddOperation(SUBSYSTEM_ADDRESS));

    final List<ModelNode> loggerOperations = new ArrayList<>();
    final List<ModelNode> asyncHandlerOperations = new ArrayList<>();
    final List<ModelNode> handlerOperations = new ArrayList<>();

    // Elements
    final Set<String> loggerNames = new HashSet<>();
    final Set<String> handlerNames = new HashSet<>();
    boolean rootDefined = false;
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case LOGGER: {
                parseLoggerElement(reader, SUBSYSTEM_ADDRESS, loggerOperations, loggerNames);
                break;
            }
            case ROOT_LOGGER: {
                if (rootDefined) {
                    throw unexpectedElement(reader);
                }
                rootDefined = true;
                parseRootLoggerElement(reader, SUBSYSTEM_ADDRESS, loggerOperations);
                break;
            }
            case CONSOLE_HANDLER: {
                parseConsoleHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case FILE_HANDLER: {
                parseFileHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case CUSTOM_HANDLER: {
                parseCustomHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case PERIODIC_ROTATING_FILE_HANDLER: {
                parsePeriodicRotatingFileHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case SIZE_ROTATING_FILE_HANDLER: {
                parseSizeRotatingHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case ASYNC_HANDLER: {
                parseAsyncHandlerElement(reader, SUBSYSTEM_ADDRESS, asyncHandlerOperations, handlerNames);
                break;
            }
            default: {
                reader.handleAny(operations);
                break;
            }
        }
    }
    operations.addAll(handlerOperations);
    operations.addAll(asyncHandlerOperations);
    operations.addAll(loggerOperations);
}
 
Example 20
Source File: LoggingSubsystemParser_1_2.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException {
    // No attributes
    ParseUtils.requireNoAttributes(reader);

    // Subsystem add operation
    operations.add(Util.createAddOperation(SUBSYSTEM_ADDRESS));

    final List<ModelNode> loggerOperations = new ArrayList<>();
    final List<ModelNode> asyncHandlerOperations = new ArrayList<>();
    final List<ModelNode> handlerOperations = new ArrayList<>();

    // Elements
    final Set<String> loggerNames = new HashSet<>();
    final Set<String> handlerNames = new HashSet<>();
    boolean rootDefined = false;
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case LOGGER: {
                parseLoggerElement(reader, SUBSYSTEM_ADDRESS, loggerOperations, loggerNames);
                break;
            }
            case ROOT_LOGGER: {
                if (rootDefined) {
                    throw unexpectedElement(reader);
                }
                rootDefined = true;
                parseRootLoggerElement(reader, SUBSYSTEM_ADDRESS, loggerOperations);
                break;
            }
            case CONSOLE_HANDLER: {
                parseConsoleHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case FILE_HANDLER: {
                parseFileHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case CUSTOM_HANDLER: {
                parseCustomHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case PERIODIC_ROTATING_FILE_HANDLER: {
                parsePeriodicRotatingFileHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case SIZE_ROTATING_FILE_HANDLER: {
                parseSizeRotatingHandlerElement(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case ASYNC_HANDLER: {
                parseAsyncHandlerElement(reader, SUBSYSTEM_ADDRESS, asyncHandlerOperations, handlerNames);
                break;
            }
            case SYSLOG_HANDLER: {
                parseSyslogHandler(reader, SUBSYSTEM_ADDRESS, handlerOperations, handlerNames);
                break;
            }
            case LOGGING_PROFILES:
                parseLoggingProfilesElement(reader, operations);
                break;
            default: {
                reader.handleAny(operations);
                break;
            }
        }
    }
    operations.addAll(handlerOperations);
    operations.addAll(asyncHandlerOperations);
    operations.addAll(loggerOperations);
}