Java Code Examples for org.jboss.staxmapper.XMLExtendedStreamReader#getAttributeValue()
The following examples show how to use
org.jboss.staxmapper.XMLExtendedStreamReader#getAttributeValue() .
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: HostXml_8.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void parseServersAttributes(final XMLExtendedStreamReader reader, final ModelNode parentAddress, final List<ModelNode> list) throws XMLStreamException { // Handle attributes final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); if (!isNoNamespaceAttribute(reader, i)) { throw unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case DIRECTORY_GROUPING: { final ModelNode address = parentAddress.clone(); list.add(Util.getWriteAttributeOperation(address, DIRECTORY_GROUPING, HostResourceDefinition.DIRECTORY_GROUPING.parse(value,reader))); break; } default: throw unexpectedAttribute(reader, i); } } } }
Example 2
Source File: InterfacesXml.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void parseInterfaces(final XMLExtendedStreamReader reader, final Set<String> names, final ModelNode address, final Namespace expectedNs, final List<ModelNode> list, final boolean checkSpecified) throws XMLStreamException { requireNoAttributes(reader); while (reader.nextTag() != END_ELEMENT) { requireNamespace(reader, expectedNs); Element element = Element.forName(reader.getLocalName()); if (Element.INTERFACE != element) { throw unexpectedElement(reader); } // Attributes requireSingleAttribute(reader, Attribute.NAME.getLocalName()); final String name = reader.getAttributeValue(0); if (!names.add(name)) { throw ControllerLogger.ROOT_LOGGER.duplicateInterfaceDeclaration(reader.getLocation()); } final ModelNode interfaceAdd = new ModelNode(); interfaceAdd.get(OP_ADDR).set(address).add(ModelDescriptionConstants.INTERFACE, name); interfaceAdd.get(OP).set(ADD); final ModelNode criteriaNode = interfaceAdd; parseInterfaceCriteria(reader, expectedNs, interfaceAdd); if (checkSpecified && criteriaNode.getType() != ModelType.STRING && criteriaNode.getType() != ModelType.EXPRESSION && criteriaNode.asInt() == 0) { throw unexpectedEndElement(reader); } list.add(interfaceAdd); } }
Example 3
Source File: HostXml_10.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected void parseDiscoveryOptionProperty(XMLExtendedStreamReader reader, ModelNode discoveryOptionProperties) throws XMLStreamException { String propertyName = null; String propertyValue = null; EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE); final int count = reader.getAttributeCount(); 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: { propertyName = value; break; } case VALUE: { propertyValue = value; break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } discoveryOptionProperties.add(propertyName, propertyValue); requireNoContent(reader); }
Example 4
Source File: AuditLogXml_5.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseSizeRotatingFileAuditLogHandler(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException { final ModelNode add = Util.createAddOperation(); 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.SIZE_ROTATING_FILE_HANDLER, value); break; case MAX_FAILURE_COUNT: SizeRotatingFileAuditLogHandlerResourceDefinition.MAX_FAILURE_COUNT.parseAndSetParameter(value, add, reader); break; case FORMATTER: SizeRotatingFileAuditLogHandlerResourceDefinition.FORMATTER.parseAndSetParameter(value, add, reader); break; case PATH: SizeRotatingFileAuditLogHandlerResourceDefinition.PATH.parseAndSetParameter(value, add, reader); break; case RELATIVE_TO: SizeRotatingFileAuditLogHandlerResourceDefinition.RELATIVE_TO.parseAndSetParameter(value, add, reader); break; case ROTATE_SIZE: SizeRotatingFileAuditLogHandlerResourceDefinition.ROTATE_SIZE.parseAndSetParameter(value, add, reader); break; case MAX_BACKUP_INDEX: SizeRotatingFileAuditLogHandlerResourceDefinition.MAX_BACKUP_INDEX.parseAndSetParameter(value, add, reader); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); }
Example 5
Source File: ManagementXml_Legacy.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseGroupToPrincipalAttributes_1_6_and_3_0(final XMLExtendedStreamReader reader, final ModelNode addOp) throws XMLStreamException { boolean baseDnFound = 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 BASE_DN: { baseDnFound = true; GroupToPrincipalResourceDefinition.BASE_DN.parseAndSetParameter(value, addOp, reader); break; } case RECURSIVE: { GroupToPrincipalResourceDefinition.RECURSIVE.parseAndSetParameter(value, addOp, reader); break; } case SEARCH_BY: GroupToPrincipalResourceDefinition.SEARCH_BY.parseAndSetParameter(value, addOp, reader); break; case PREFER_ORIGINAL_CONNECTION: GroupToPrincipalResourceDefinition.PREFER_ORIGINAL_CONNECTION.parseAndSetParameter(value, addOp, reader); break; default: { throw unexpectedAttribute(reader, i); } } } } if (baseDnFound == false) { throw missingRequired(reader, Collections.singleton(Attribute.BASE_DN)); } }
Example 6
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 5 votes |
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 7
Source File: HostXml_4.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseHttpManagementInterfaceAttributes(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException { 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 SASL_PROTOCOL: { HttpManagementResourceDefinition.SASL_PROTOCOL.parseAndSetParameter(value, addOp, reader); break; } case SECURITY_REALM: { HttpManagementResourceDefinition.SECURITY_REALM.parseAndSetParameter(value, addOp, reader); break; } case SERVER_NAME: { NativeManagementResourceDefinition.SERVER_NAME.parseAndSetParameter(value, addOp, reader); break; } case CONSOLE_ENABLED: { HttpManagementResourceDefinition.CONSOLE_ENABLED.parseAndSetParameter(value, addOp, reader); break; } case HTTP_UPGRADE_ENABLED: { ModelNode httpUpgrade = addOp.get(HTTP_UPGRADE); HttpManagementResourceDefinition.ENABLED.parseAndSetParameter(value, httpUpgrade, reader); break; } case ALLOWED_ORIGINS: { HttpManagementResourceDefinition.ALLOWED_ORIGINS.getParser().parseAndSetParameter(HttpManagementResourceDefinition.ALLOWED_ORIGINS, value, addOp, reader); break; } default: throw unexpectedAttribute(reader, i); } } } }
Example 8
Source File: ManagementXml_Legacy.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseLocalAuthentication_1_6_and_2_1(final XMLExtendedStreamReader reader, final ModelNode realmAddress, final List<ModelNode> list) throws XMLStreamException { ModelNode addr = realmAddress.clone().add(AUTHENTICATION, LOCAL); ModelNode local = Util.getEmptyOperation(ADD, addr); list.add(local); final int count = reader.getAttributeCount(); Set<Attribute> attributesFound = new HashSet<Attribute>(count); 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)); if (attributesFound.contains(attribute)) { throw unexpectedAttribute(reader, i); } attributesFound.add(attribute); switch (attribute) { case DEFAULT_USER: LocalAuthenticationResourceDefinition.DEFAULT_USER.parseAndSetParameter(value, local, reader); break; case ALLOWED_USERS: LocalAuthenticationResourceDefinition.ALLOWED_USERS.parseAndSetParameter(value, local, reader); break; case SKIP_GROUP_LOADING: LocalAuthenticationResourceDefinition.SKIP_GROUP_LOADING.parseAndSetParameter(value, local, reader); break; default: { throw unexpectedAttribute(reader, i); } } } } // All attributes are optional. requireNoContent(reader); }
Example 9
Source File: StandaloneXml_Legacy.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseNativeManagementSocketBinding(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException { // Handle attributes boolean hasRef = 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 NATIVE: { NativeManagementResourceDefinition.SOCKET_BINDING.parseAndSetParameter(value, addOp, reader); hasRef = true; break; } default: throw unexpectedAttribute(reader, i); } } } if (!hasRef) { throw missingRequired(reader, Collections.singleton(Attribute.REF.getLocalName())); } requireNoContent(reader); }
Example 10
Source File: HostXml_8.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private ModelNode parseServerAttributes(final XMLExtendedStreamReader reader, final ModelNode parentAddress, final Set<String> serverNames) throws XMLStreamException { final ModelNode addUpdate = new ModelNode(); addUpdate.get(OP).set(ADD); final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.GROUP); 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)); required.remove(attribute); switch (attribute) { case NAME: { if (!serverNames.add(value)) { throw ControllerLogger.ROOT_LOGGER.duplicateDeclaration("server", value, reader.getLocation()); } final ModelNode address = parentAddress.clone().add(SERVER_CONFIG, value); addUpdate.get(OP_ADDR).set(address); break; } case GROUP: { ServerConfigResourceDefinition.GROUP.parseAndSetParameter(value, addUpdate, reader); break; } case AUTO_START: { ServerConfigResourceDefinition.AUTO_START.parseAndSetParameter(value, addUpdate, reader); break; } case UPDATE_AUTO_START_WITH_SERVER_STATUS: { ServerConfigResourceDefinition.UPDATE_AUTO_START_WITH_SERVER_STATUS.parseAndSetParameter(value, addUpdate, reader); break; } default: throw unexpectedAttribute(reader, i); } } } if (required.size() > 0) { throw missingRequired(reader, required); } return addUpdate; }
Example 11
Source File: HostXml_5.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseStaticDiscoveryOption(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames) throws XMLStreamException { // OP_ADDR will be set after parsing the NAME attribute final ModelNode staticDiscoveryOptionAddress = address.clone(); staticDiscoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS); final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode()); list.add(addOp); // Handle attributes final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.HOST, Attribute.PORT); final int count = reader.getAttributeCount(); 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: { if (!staticDiscoveryOptionNames.add(value)) { throw ParseUtils.duplicateNamedElement(reader, value); } addOp.get(OP_ADDR).set(staticDiscoveryOptionAddress).add(STATIC_DISCOVERY, value); break; } case HOST: { StaticDiscoveryResourceDefinition.HOST.parseAndSetParameter(value, addOp, reader); break; } case PROTOCOL: { StaticDiscoveryResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOp, reader); break; } case PORT: { StaticDiscoveryResourceDefinition.PORT.parseAndSetParameter(value, addOp, reader); break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } requireNoContent(reader); }
Example 12
Source File: ManagementXml_Legacy.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseUsernameToDn_2_0(final XMLExtendedStreamReader reader, final ModelNode ldapAddress, final List<ModelNode> list) throws XMLStreamException { // Add operation to be defined by parsing a child element, however the attribute FORCE is common here. final ModelNode childAdd = new ModelNode(); childAdd.get(OP).set(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); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case FORCE: BaseLdapUserSearchResource.FORCE.parseAndSetParameter(value, childAdd, reader); break; default: { throw unexpectedAttribute(reader, i); } } } } boolean filterFound = false; ModelNode cacheAdd = null; ModelNode address = ldapAddress.clone().add(USERNAME_TO_DN); while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); final Element element = Element.forName(reader.getLocalName()); if (filterFound) { throw unexpectedElement(reader); } switch (element) { case CACHE: if (cacheAdd != null) { throw unexpectedElement(reader); } cacheAdd = parseLdapCache(reader); break; case USERNAME_IS_DN: filterFound = true; parseUsernameIsDn(reader, address, childAdd); break; case USERNAME_FILTER: filterFound = true; parseUsernameFilter(reader, address, childAdd); break; case ADVANCED_FILTER: filterFound = true; parseAdvancedFilter(reader, address, childAdd); break; default: { throw unexpectedElement(reader); } } } if (filterFound == false) { throw missingOneOf(reader, EnumSet.of(Element.USERNAME_IS_DN, Element.USERNAME_FILTER, Element.ADVANCED_FILTER)); } list.add(childAdd); if (cacheAdd != null) { correctCacheAddress(childAdd, cacheAdd); list.add(cacheAdd); } }
Example 13
Source File: HostXml_7.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseServerSsl(final ModelNode parentAddress, final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { ModelNode addOp = new ModelNode(); addOp.get(OP).set(ADD); final ModelNode address = parentAddress.clone(); address.add(SSL, LOOPBACK); addOp.get(OP_ADDR).set(address); operations.add(addOp); 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 SSL_PROTOCOL: { SslLoopbackResourceDefinition.SSL_PROTOCOCOL.parseAndSetParameter(value, addOp, reader); break; } case TRUST_MANAGER_ALGORITHM: { SslLoopbackResourceDefinition.TRUST_MANAGER_ALGORITHM.parseAndSetParameter(value, addOp, reader); break; } case TRUSTSTORE_TYPE: { SslLoopbackResourceDefinition.TRUSTSTORE_TYPE.parseAndSetParameter(value, addOp, reader); break; } case TRUSTSTORE_PATH: { SslLoopbackResourceDefinition.TRUSTSTORE_PATH.parseAndSetParameter(value, addOp, reader); break; } case TRUSTSTORE_PASSWORD: { SslLoopbackResourceDefinition.TRUSTSTORE_PASSWORD.parseAndSetParameter(value, addOp, reader); break; } default: throw unexpectedAttribute(reader, i); } } } requireNoContent(reader); }
Example 14
Source File: StandaloneXml_9.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseHttpManagementInterfaceAttributes(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException { 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 HTTP_AUTHENTICATION_FACTORY: { HttpManagementResourceDefinition.HTTP_AUTHENTICATION_FACTORY.parseAndSetParameter(value, addOp, reader); break; } case SASL_PROTOCOL: { HttpManagementResourceDefinition.SASL_PROTOCOL.parseAndSetParameter(value, addOp, reader); break; } case SECURITY_REALM: { HttpManagementResourceDefinition.SECURITY_REALM.parseAndSetParameter(value, addOp, reader); break; } case SERVER_NAME: { HttpManagementResourceDefinition.SERVER_NAME.parseAndSetParameter(value, addOp, reader); break; } case SSL_CONTEXT: { HttpManagementResourceDefinition.SSL_CONTEXT.parseAndSetParameter(value, addOp, reader); break; } case CONSOLE_ENABLED: { HttpManagementResourceDefinition.CONSOLE_ENABLED.parseAndSetParameter(value, addOp, reader); break; } case ALLOWED_ORIGINS: { HttpManagementResourceDefinition.ALLOWED_ORIGINS.getParser().parseAndSetParameter(HttpManagementResourceDefinition.ALLOWED_ORIGINS, value, addOp, reader); break; } default: throw unexpectedAttribute(reader, i); } } } }
Example 15
Source File: RemotingSubsystem20Parser.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
void parseRemoteOutboundConnection(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; final ModelNode addOperation = Util.createAddOperation(); 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: { RemoteOutboundConnectionResourceDefinition.OUTBOUND_SOCKET_BINDING_REF.parseAndSetParameter(value, addOperation, reader); break; } case USERNAME: { RemoteOutboundConnectionResourceDefinition.USERNAME.parseAndSetParameter(value, addOperation, reader); break; } case SECURITY_REALM: { RemoteOutboundConnectionResourceDefinition.SECURITY_REALM.parseAndSetParameter(value, addOperation, reader); break; } case PROTOCOL: { RemoteOutboundConnectionResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOperation, reader); break; } default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } final PathAddress address = PathAddress.pathAddress(PathAddress.pathAddress(parentAddress), PathElement.pathElement(CommonAttributes.REMOTE_OUTBOUND_CONNECTION, name)); addOperation.get(OP_ADDR).set(address.toModelNode()); // create add operation add it to the list of operations operations.add(addOperation); // 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 16
Source File: FeatureSpecXmlParser10.java From galleon with Apache License 2.0 | 4 votes |
@Override public void readElement(XMLExtendedStreamReader reader, FeatureSpec.Builder featureBuilder) throws XMLStreamException { final int count = reader.getAttributeCount(); String specName = null; for (int i = 0; i < count; i++) { final Attribute attribute = Attribute.of(reader.getAttributeName(i)); switch (attribute) { case NAME: specName = reader.getAttributeValue(i); break; default: throw ParsingUtils.unexpectedAttribute(reader, i); } } if (specName == null) { throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.NAME)); } featureBuilder.setName(specName); 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 ANNOTATION: parseAnnotation(reader, featureBuilder); break; case DEPENDENCIES: parseDependencies(reader, featureBuilder); break; case REFERENCES: parseReferences(reader, featureBuilder); break; case PARAMETERS: parseParameters(reader, featureBuilder); break; case PACKAGES: PackageDepsSpecXmlParser.parsePackageDeps(Element.PACKAGES, reader, featureBuilder); break; case PROVIDES: parseCapabilities(reader, featureBuilder, true); break; case REQUIRES: parseCapabilities(reader, featureBuilder, false); break; default: throw ParsingUtils.unexpectedContent(reader); } break; } default: { throw ParsingUtils.unexpectedContent(reader); } } } throw ParsingUtils.endOfDocument(reader.getLocation()); }
Example 17
Source File: ProvisioningXmlParser30.java From galleon with Apache License 2.0 | 4 votes |
private static void parseConfigModelRef(XMLExtendedStreamReader reader, ConfigCustomizationsBuilder<?> fpBuilder, boolean include) throws XMLStreamException { String name = null; String model = null; Boolean namedConfigsOnly = null; for (int i = 0; i < reader.getAttributeCount(); i++) { final Attribute attribute = Attribute.of(reader.getAttributeName(i).getLocalPart()); switch (attribute) { case NAME: name = reader.getAttributeValue(i); break; case MODEL: model = reader.getAttributeValue(i); break; case NAMED_MODELS_ONLY: namedConfigsOnly = Boolean.parseBoolean(reader.getAttributeValue(i)); break; default: throw ParsingUtils.unexpectedContent(reader); } } try { if (include) { if (name == null) { fpBuilder.includeConfigModel(model); } else { fpBuilder.includeDefaultConfig(new ConfigId(model, name)); } } else if (name == null) { if(namedConfigsOnly != null) { fpBuilder.excludeConfigModel(model, namedConfigsOnly); } else { fpBuilder.excludeConfigModel(model); } } else { fpBuilder.excludeDefaultConfig(model, name); } } catch(ProvisioningDescriptionException e) { throw new XMLStreamException(e); } ParsingUtils.parseNoContent(reader); }
Example 18
Source File: AuditLogXml_Legacy.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseSyslogAuditLogHandlerAttributes(final XMLExtendedStreamReader reader, final ModelNode address, final ModelNode addOp) throws XMLStreamException { 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: { addOp.get(OP_ADDR).set(address).add(ModelDescriptionConstants.SYSLOG_HANDLER, value); break; } case MAX_FAILURE_COUNT: { SyslogAuditLogHandlerResourceDefinition.MAX_FAILURE_COUNT.parseAndSetParameter(value, addOp, reader); break; } case FORMATTER:{ SyslogAuditLogHandlerResourceDefinition.FORMATTER.parseAndSetParameter(value, addOp, reader); break; } case MAX_LENGTH: { SyslogAuditLogHandlerResourceDefinition.MAX_LENGTH.parseAndSetParameter(value, addOp, reader); break; } case TRUNCATE: { SyslogAuditLogHandlerResourceDefinition.TRUNCATE.parseAndSetParameter(value, addOp, reader); break; } case FACILITY: { SyslogAuditLogHandlerResourceDefinition.FACILITY.parseAndSetParameter(value, addOp, reader); break; } case APP_NAME: { SyslogAuditLogHandlerResourceDefinition.APP_NAME.parseAndSetParameter(value, addOp, reader); break; } case SYSLOG_FORMAT: { SyslogAuditLogHandlerResourceDefinition.SYSLOG_FORMAT.parseAndSetParameter(value, addOp, reader); break; } default: { throw unexpectedAttribute(reader, i); } } } }
Example 19
Source File: JvmXml.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
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 20
Source File: ManagementXml_Legacy.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseSSL_1_7_and_2_2(final XMLExtendedStreamReader reader, final ModelNode realmAddress, final List<ModelNode> list) throws XMLStreamException { ModelNode ssl = new ModelNode(); ssl.get(OP).set(ADD); ssl.get(OP_ADDR).set(realmAddress).add(SERVER_IDENTITY, SSL); list.add(ssl); 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 PROTOCOL: { SSLServerIdentityResourceDefinition.PROTOCOL.parseAndSetParameter(value, ssl, reader); break; } default: { throw unexpectedAttribute(reader, i); } } } } while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); final Element element = Element.forName(reader.getLocalName()); switch (element) { case ENGINE: { parseEngine(reader, ssl); break; } case KEYSTORE: { // Most recent versions for 1.x, 2.x and 3.x streams converge at this point. parseKeystore_1_6_and_2_1(reader, ssl, true); break; } default: { throw unexpectedElement(reader); } } } }