Java Code Examples for org.jboss.staxmapper.XMLExtendedStreamReader#hasNext()

The following examples show how to use org.jboss.staxmapper.XMLExtendedStreamReader#hasNext() . 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: DomainXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseDomainSocketBindingGroups(final XMLExtendedStreamReader reader, final ModelNode address,
                                            final List<ModelNode> list, final Set<String> interfaces) throws XMLStreamException {
    HashSet<String> uniqueGroupNames = new HashSet<>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case SOCKET_BINDING_GROUP: {
                parseSocketBindingGroup(reader, interfaces, address, list, uniqueGroupNames);
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }
}
 
Example 2
Source File: HostXml_11.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseNativeManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list)  throws XMLStreamException {

        final ModelNode operationAddress = address.clone();
        operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_INTERFACE);
        final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress);

        // Handle attributes
        parseNativeManagementInterfaceAttributes(reader, addOp);

        // Handle elements
        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case SOCKET:
                    parseNativeManagementSocket(reader, addOp);
                    break;
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(addOp);
    }
 
Example 3
Source File: ProvisionedConfigXmlParser30.java    From galleon with Apache License 2.0 6 votes vote down vote up
private static void readLayers(XMLExtendedStreamReader reader, ProvisionedConfigBuilder config) throws XMLStreamException {
    ParsingUtils.parseNoAttributes(reader);
    while (reader.hasNext()) {
        switch (reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT: {
                return;
            }
            case XMLStreamConstants.START_ELEMENT: {
                final Element element = Element.of(reader.getName());
                switch (element) {
                    case LAYER:
                        readLayer(reader, config);
                        break;
                    default:
                        throw ParsingUtils.unexpectedContent(reader);
                }
                break;
            }
            default: {
                throw ParsingUtils.unexpectedContent(reader);
            }
        }
    }
    throw ParsingUtils.endOfDocument(reader.getLocation());
}
 
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 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 5
Source File: StandaloneXml_8.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseNativeManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException {
    final ModelNode operationAddress = address.clone();
    operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_INTERFACE);
    final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress);

    // Handle attributes
    parseNativeManagementInterfaceAttributes(reader, addOp);

    // Handle elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case SOCKET:
                throw ControllerLogger.ROOT_LOGGER.unsupportedElement(reader.getName(),reader.getLocation(), SOCKET_BINDING);
            case SOCKET_BINDING:
                parseNativeManagementSocketBinding(reader, addOp);
                break;
            default:
                throw unexpectedElement(reader);
        }
    }

    list.add(addOp);
}
 
Example 6
Source File: HostXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void parseDiscoveryOptions(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames,
                                     final Set<String> discoveryOptionNames) throws XMLStreamException {
    requireNoAttributes(reader);

    // Handle elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case DISCOVERY_OPTION:
                parseDiscoveryOption(reader, address, list, discoveryOptionNames);
                break;
            case STATIC_DISCOVERY:
                parseStaticDiscoveryOption(reader, address, list, staticDiscoveryOptionNames);
                break;
            default:
                throw unexpectedElement(reader);
        }
    }
}
 
Example 7
Source File: DeploymentScannerParser_1_0.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 {
    // no attributes
    requireNoAttributes(reader);

    final ModelNode address = new ModelNode();
    address.add(ModelDescriptionConstants.SUBSYSTEM, DeploymentScannerExtension.SUBSYSTEM_NAME);
    address.protect();

    final ModelNode subsystem = new ModelNode();
    subsystem.get(OP).set(ADD);
    subsystem.get(OP_ADDR).set(address);
    list.add(subsystem);

    // elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch (Namespace.forUri(reader.getNamespaceURI())) {
            case DEPLOYMENT_SCANNER_1_0: {
                final String element = reader.getLocalName();
                switch (element) {
                    case CommonAttributes.DEPLOYMENT_SCANNER: {
                        //noinspection unchecked
                        parseScanner(reader, address, list);
                        break;
                    }
                    default: throw unexpectedElement(reader);
                }
                break;
            }
            default: throw unexpectedElement(reader);
        }
    }
}
 
Example 8
Source File: AuditLogXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseAuditLogHandlersReference(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace expectedNs, final List<ModelNode> list) throws XMLStreamException {
    requireNamespace(reader, expectedNs);

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
        case HANDLER:{
            requireNamespace(reader, expectedNs);
            final ModelNode add = new ModelNode();
            add.get(OP).set(ADD);
            list.add(add);

            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);
                }
                final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
                switch (attribute) {
                    case NAME: {
                        add.get(OP_ADDR).set(address).add(ModelDescriptionConstants.HANDLER, value);
                        break;
                    }
                    default: {
                        throw unexpectedAttribute(reader, i);
                    }
                }
                requireNoContent(reader);
            }
            break;
        }
        default:
            throw unexpectedElement(reader);
        }
    }
}
 
Example 9
Source File: HostXml_12.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseHttpManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list)  throws XMLStreamException {

        final ModelNode operationAddress = address.clone();
        operationAddress.add(MANAGEMENT_INTERFACE, HTTP_INTERFACE);
        final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress);

        int socketCount = 0;
        int httpUpgradeCount = 0;

        // Handle attributes
        parseHttpManagementInterfaceAttributes(reader, addOp);

        // Handle elements
        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case SOCKET:
                    if (++socketCount > 1) {
                        throw unexpectedElement(reader);
                    }
                    parseHttpManagementSocket(reader, addOp);
                    break;
                case HTTP_UPGRADE:
                    if (++httpUpgradeCount > 1) {
                        throw unexpectedElement(reader);
                    }
                    parseHttpUpgrade(reader, addOp);
                    break;
                case CONSTANT_HEADERS:
                    parseConstantHeaders(reader, addOp);
                    break;
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(addOp);
    }
 
Example 10
Source File: ConfigXmlParser10.java    From galleon with Apache License 2.0 5 votes vote down vote up
@Override
public void readElement(XMLExtendedStreamReader reader, Configuration t) throws XMLStreamException {
    while (reader.hasNext()) {
        switch (reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT: {
                // DONE.
                return;
            }
            case XMLStreamConstants.START_ELEMENT: {
                switch (reader.getLocalName()) {
                    case MavenConfigXml.MAVEN: {
                        try {
                            MavenConfigXml.read(reader, t.getMavenConfig());
                        } catch (ProvisioningException | IOException ex) {
                            throw new XMLStreamException(ex);
                        }
                        break;
                    }
                    default: {
                        throw ParsingUtils.unexpectedContent(reader);
                    }
                }
                break;
            }
            default: {
                throw ParsingUtils.unexpectedContent(reader);
            }
        }
    }
}
 
Example 11
Source File: AuditLogXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseSyslogAuditLogHandler(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace expectedNs, final List<ModelNode> list) throws XMLStreamException {
    final ModelNode add = Util.createAddOperation();
    list.add(add);

    parseSyslogAuditLogHandlerAttributes(reader, address, add);

    if (!add.get(OP_ADDR).isDefined()) {
        throw missingRequired(reader, Collections.singleton(Attribute.NAME));
    }

    boolean protocolSet = false;
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        final Element element = Element.forName(reader.getLocalName());

        //Check there is only one protocol
        if (protocolSet) {
            throw DomainManagementLogger.ROOT_LOGGER.onlyOneSyslogHandlerProtocol(reader.getLocation());
        }
        protocolSet = true;

        switch (element) {
            case UDP:
            case TCP:
            case TLS: {
                parseSyslogAuditLogHandlerProtocol(reader, add.get(OP_ADDR), expectedNs, list, element);
                break;
            }
            default:
                throw unexpectedElement(reader);
        }
    }
}
 
Example 12
Source File: HostXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseRemoteDomainController_2_0(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException {
    boolean requireDiscoveryOptions;
    boolean hasDiscoveryOptions = false;
    if (namespace.getMajorVersion()< 3) {
        requireDiscoveryOptions = parseRemoteDomainControllerAttributes_2_0(reader, address, list);
    } else {
        requireDiscoveryOptions = parseRemoteDomainControllerAttributes_3_0(reader, address, list);
    }

    Set<String> types = new HashSet<String>();
    Set<String> staticDiscoveryOptionNames = new HashSet<String>();
    Set<String> discoveryOptionNames = new HashSet<String>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case IGNORED_RESOURCE: {
                parseIgnoredResource(reader, address, list, types);
                break;
            }
            case DISCOVERY_OPTIONS: { // Different from parseRemoteDomainController1_1
                if (hasDiscoveryOptions) {
                    throw ControllerLogger.ROOT_LOGGER.alreadyDefined(element.getLocalName(), reader.getLocation());
                }
                parseDiscoveryOptions(reader, address, list, staticDiscoveryOptionNames, discoveryOptionNames);
                hasDiscoveryOptions = true;
                break;
            }
            default:
                throw unexpectedElement(reader);
        }
    }

    if (requireDiscoveryOptions && !hasDiscoveryOptions) {
        throw ControllerLogger.ROOT_LOGGER.discoveryOptionsMustBeDeclared(CommandLineConstants.ADMIN_ONLY,
                Attribute.ADMIN_ONLY_POLICY.getLocalName(), AdminOnlyDomainConfigPolicy.FETCH_FROM_MASTER.toString(),
                Element.DISCOVERY_OPTIONS.getLocalName(), Attribute.HOST.getLocalName(), Attribute.PORT.getLocalName(),
                reader.getLocation());
    }
}
 
Example 13
Source File: VaultXml.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseVault_1_1(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace expectedNs, final List<ModelNode> list) throws XMLStreamException {
    final int vaultAttribCount = reader.getAttributeCount();

    ModelNode vault = new ModelNode();
    String code = null;

    for (int i = 0; i < vaultAttribCount; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        switch (attribute) {
            case CODE: {
                VaultResourceDefinition.CODE.parseAndSetParameter(value, vault, reader);
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }

    ModelNode vaultAddress = address.clone();
    vaultAddress.add(CORE_SERVICE, VAULT);
    if (code != null) {
        vault.get(Attribute.CODE.getLocalName()).set(code);
    }
    vault.get(OP_ADDR).set(vaultAddress);
    vault.get(OP).set(ADD);

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case VAULT_OPTION: {
                parseModuleOption(reader, vault.get(VAULT_OPTIONS));
                break;
            }
        }
    }
    list.add(vault);
}
 
Example 14
Source File: AuditLogXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseAuditLogHandlers(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace expectedNs, final List<ModelNode> list) throws XMLStreamException {

        requireNamespace(reader, expectedNs);   //FIXME is this needed? what it does?
        boolean configurationChangesConfigured = false;
        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, expectedNs);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
            case IN_MEMORY_HANDLER:
                if(configurationChangesConfigured) {
                    throw unexpectedElement(reader);
                }
                parseConfigurationChangesAuditLogHandler(reader, address, list);
                configurationChangesConfigured = true;
                break;
            case FILE_HANDLER:
                parseFileAuditLogHandler(reader, address, list);
                break;
            case PERIODIC_ROTATING_FILE_HANDLER:
                parsePeriodicRotatingFileAuditLogHandler(reader, address, list);
                break;
            case SIZE_ROTATING_FILE_HANDLER:
                parseSizeRotatingFileAuditLogHandler(reader, address, list);
                break;
            case SYSLOG_HANDLER:
                parseSyslogAuditLogHandler(reader, address, expectedNs, list);
                break;
            default:
                throw unexpectedElement(reader);
            }
        }
    }
 
Example 15
Source File: ManagementXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseSecurityRealms(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list)
        throws XMLStreamException {
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);

        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case SECURITY_REALM: {
                switch (namespace) {
                    case DOMAIN_1_0:
                        parseSecurityRealm_1_0(reader, address, list);
                        break;
                    case DOMAIN_1_1:
                    case DOMAIN_1_2:
                        parseSecurityRealm_1_1(reader, address, list);
                        break;
                    default:
                        parseSecurityRealm_1_3(reader, address, list);
                        break;
                }
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }
}
 
Example 16
Source File: ConfigXml.java    From galleon with Apache License 2.0 4 votes vote down vote up
private static void readLayers(XMLExtendedStreamReader reader, ConfigModel.Builder builder) throws XMLStreamException {
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch (attribute) {
            case INHERIT:
                builder.setInheritLayers(Boolean.parseBoolean(reader.getAttributeValue(i)));
                break;
            default:
                throw ParsingUtils.unexpectedContent(reader);
        }
    }
    try {
        while (reader.hasNext()) {
            switch (reader.nextTag()) {
                case XMLStreamConstants.END_ELEMENT: {
                    return;
                }
                case XMLStreamConstants.START_ELEMENT: {
                    final Element element = Element.of(reader.getName().getLocalPart());
                    switch (element) {
                        case INCLUDE:
                            builder.includeLayer(readLayer(reader, builder));
                            break;
                        case EXCLUDE:
                            builder.excludeLayer(readLayer(reader, builder));
                            break;
                        default:
                            throw ParsingUtils.unexpectedContent(reader);
                    }
                    break;
                }
                default: {
                    throw ParsingUtils.unexpectedContent(reader);
                }
            }
        }
    } catch (ProvisioningDescriptionException e) {
        throw new XMLStreamException("Failed to parse layers configuration: " + e.getMessage(), reader.getLocation());
    }
    throw ParsingUtils.endOfDocument(reader.getLocation());
}
 
Example 17
Source File: BpmPlatformParser.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
private void parseJobExecutor(XMLExtendedStreamReader reader, List<ModelNode> list, ModelNode parentAddress) throws XMLStreamException {
  if (!Element.JOB_EXECUTOR.getLocalName().equals(reader.getLocalName())) {
    throw unexpectedElement(reader);
  }
  
  // Add the 'add' operation for 'job-executor' parent
  ModelNode addJobExecutor = new ModelNode();
  addJobExecutor.get(OP).set(ModelDescriptionConstants.ADD);
  PathAddress addr = PathAddress.pathAddress(
            PathElement.pathElement(SUBSYSTEM, ModelConstants.SUBSYSTEM_NAME),
            PathElement.pathElement(Element.JOB_EXECUTOR.getLocalName(), ModelConstants.DEFAULT));
  addJobExecutor.get(OP_ADDR).set(addr.toModelNode());
  
  list.add(addJobExecutor);

  // iterate deeper
  while (reader.hasNext()) {
    switch (reader.nextTag()) {
    case END_ELEMENT: {
      if (Element.forName(reader.getLocalName()) == Element.JOB_EXECUTOR) {
        // should mean we're done, so ignore it.
        return;
      }
    }
    case START_ELEMENT: {
      switch (Element.forName(reader.getLocalName())) {
        case JOB_AQUISITIONS: {
          parseJobAcquisitions(reader, list, addJobExecutor);
          break;
        }
        case THREAD_POOL_NAME: {
          parseElement(SubsystemAttributeDefinitons.THREAD_POOL_NAME, reader, addJobExecutor);
          break;
        }
        default: {
          throw unexpectedElement(reader);
        }
      }
      break;
    }
   }
  }
}
 
Example 18
Source File: RemotingSubsystem11Parser.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
void parseLocalOutboundConnection(final XMLExtendedStreamReader reader, final ModelNode parentAddress, final List<ModelNode> operations) throws XMLStreamException {
    final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.OUTBOUND_SOCKET_BINDING_REF);
    final int count = reader.getAttributeCount();
    String name = null;
    String outboundSocketBindingRef = null;
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch (attribute) {
            case NAME: {
                name = value;
                break;
            }
            case OUTBOUND_SOCKET_BINDING_REF: {
                outboundSocketBindingRef = value;
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    if (!required.isEmpty()) {
        throw missingRequired(reader, required);
    }

    final PathAddress address = PathAddress.pathAddress(PathAddress.pathAddress(parentAddress), PathElement.pathElement(CommonAttributes.LOCAL_OUTBOUND_CONNECTION, name));
    // add it to the list of operations
    operations.add(getConnectionAddOperation(name, outboundSocketBindingRef, address));
    // create add operation parse the nested elements

    final EnumSet<Element> visited = EnumSet.noneOf(Element.class);
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        if (visited.contains(element)) {
            throw ParseUtils.unexpectedElement(reader);
        }
        visited.add(element);
        switch (element) {
            case PROPERTIES: {
                parseProperties(reader, address.toModelNode(), operations);
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }
}
 
Example 19
Source File: BpmPlatformParser1_1.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void parseJobAcquisition(XMLExtendedStreamReader reader, List<ModelNode> operations, ModelNode parentAddress) throws XMLStreamException {
  String acquisitionName = null;

  // Add the 'add' operation for each 'job-acquisition' child
  ModelNode addJobAcquisitionOp = new ModelNode();
  addJobAcquisitionOp.get(OP).set(ADD);

  for (int i = 0; i < reader.getAttributeCount(); i++) {
    Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
    switch(attribute) {
      case NAME: {
        acquisitionName = rawAttributeText(reader, NAME.getLocalName());
        if (acquisitionName != null && !acquisitionName.equals("null")) {
          SubsystemAttributeDefinitons.NAME.parseAndSetParameter(acquisitionName, addJobAcquisitionOp, reader);
        } else {
          throw missingRequiredElement(reader, Collections.singleton(NAME.getLocalName()));
        }
        break;
      }
      default:
        throw unexpectedAttribute(reader, i);
    }
  }

  ModelNode jobAcquisitionAddress = parentAddress.get(OP_ADDR).clone();
  jobAcquisitionAddress.add(ModelConstants.JOB_ACQUISITIONS, acquisitionName);
  addJobAcquisitionOp.get(OP_ADDR).set(jobAcquisitionAddress);

  operations.add(addJobAcquisitionOp);

  // iterate deeper
  while (reader.hasNext()) {
    switch (reader.nextTag()) {
      case END_ELEMENT: {
        if (Element.forName(reader.getLocalName()) == Element.JOB_AQUISITION) {
          // should mean we're done, so ignore it.
          return;
        }
      }
      case START_ELEMENT: {
        switch (Element.forName(reader.getLocalName())) {
          case PROPERTIES: {
            parseProperties(reader, operations, addJobAcquisitionOp);
            break;
          }
          case ACQUISITION_STRATEGY: {
            parseElement(SubsystemAttributeDefinitons.ACQUISITION_STRATEGY, addJobAcquisitionOp, reader);
            break;
          }
          default: {
            throw unexpectedElement(reader);
          }
        }
        break;
      }
    }
  }
}
 
Example 20
Source File: PatchXmlUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static void parseIdentity(final XMLExtendedStreamReader reader, final PatchBuilder builder, final Patch.PatchType patchType) throws XMLStreamException {

        String name = null;
        String version = null;
        String resultingVersion = null;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (Attribute.VERSION == attribute) {
                version = reader.getAttributeValue(i);
            } else if (Attribute.TO_VERSION == attribute) {
                resultingVersion = reader.getAttributeValue(i);
            } else if (Attribute.NAME == attribute) {
                name = reader.getAttributeValue(i);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        final PatchIdentityBuilder identityBuilder;
        switch (patchType) {
            case CUMULATIVE:
                identityBuilder = builder.upgradeIdentity(name, version, resultingVersion);
                break;
            case ONE_OFF:
                identityBuilder = builder.oneOffPatchIdentity(name, version);
                break;
            default:
                throw new IllegalStateException();
        }

        int level = 0;
        while (reader.hasNext()) {
            if(reader.nextTag() == END_ELEMENT) {
                if(level == 0) {
                    break;
                } else {
                    --level;
                }
            }

            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case REQUIRES:
                    break;
                case PATCH:
                    level = 1;
                    parseIncluded(reader, identityBuilder);
                    break;
                default:
                    throw unexpectedElement(reader);
            }
        }
    }