Java Code Examples for org.jboss.staxmapper.XMLExtendedStreamReader#getAttributeCount()
The following examples show how to use
org.jboss.staxmapper.XMLExtendedStreamReader#getAttributeCount() .
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_5.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: StandaloneXml_10.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 3
Source File: ConfigXml.java From galleon with Apache License 2.0 | 5 votes |
private static void readConfigDep(XMLExtendedStreamReader reader, ConfigModel.Builder builder) throws XMLStreamException { String id = null; String name = null; String model = null; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final Attribute attribute = Attribute.of(reader.getAttributeName(i)); switch (attribute) { case ID: id = reader.getAttributeValue(i); break; case NAME: name = reader.getAttributeValue(i); break; case MODEL: model = reader.getAttributeValue(i); break; default: throw ParsingUtils.unexpectedContent(reader); } } if(id == null || name == null && model == null) { if(id == null) { throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.ID)); } throw ParsingUtils.missingOneOfAttributes(reader.getLocation(), Attribute.NAME, Attribute.MODEL); } builder.setConfigDep(id, new ConfigId(model, name)); ParsingUtils.parseNoContent(reader); }
Example 4
Source File: ManagementXml_5.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseSecret(final XMLExtendedStreamReader reader, final ModelNode realmAddress, final List<ModelNode> list) throws XMLStreamException { ModelNode secret = new ModelNode(); secret.get(OP).set(ADD); secret.get(OP_ADDR).set(realmAddress).add(SERVER_IDENTITY, SECRET); final int count = reader.getAttributeCount(); boolean hasSecret = false; if (count > 0) { String secretValue = readStringAttributeElement(reader, Attribute.VALUE.getLocalName()); SecretServerIdentityResourceDefinition.VALUE.parseAndSetParameter(secretValue, secret, reader); hasSecret = true; } else { while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); final Element element = Element.forName(reader.getLocalName()); switch (element) { case CREDENTIAL_REFERENCE: { SecretServerIdentityResourceDefinition.CREDENTIAL_REFERENCE.getParser().parseElement(SecretServerIdentityResourceDefinition.CREDENTIAL_REFERENCE, reader, secret); hasSecret = true; break; } default: { throw unexpectedElement(reader); } } } } if(!hasSecret) { throw missingRequired(reader, Collections.singleton(Attribute.VALUE.getLocalName())); } list.add(secret); }
Example 5
Source File: StandaloneXml_8.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseNativeManagementInterfaceAttributes(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_AUTHENTICATION_FACTORY: { NativeManagementResourceDefinition.SASL_AUTHENTICATION_FACTORY.parseAndSetParameter(value, addOp, reader); break; } case SASL_PROTOCOL: { NativeManagementResourceDefinition.SASL_PROTOCOL.parseAndSetParameter(value, addOp, reader); break; } case SECURITY_REALM: { NativeManagementResourceDefinition.SECURITY_REALM.parseAndSetParameter(value, addOp, reader); break; } case SERVER_NAME: { NativeManagementResourceDefinition.SERVER_NAME.parseAndSetParameter(value, addOp, reader); break; } case SSL_CONTEXT: { NativeManagementResourceDefinition.SSL_CONTEXT.parseAndSetParameter(value, addOp, reader); break; } default: throw unexpectedAttribute(reader, i); } } } }
Example 6
Source File: CamelSubsystemParser.java From wildfly-camel with Apache License 2.0 | 5 votes |
private void parseCamelContext(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> operations) throws XMLStreamException { String contextName = null; for (int i = 0; i < reader.getAttributeCount(); i++) { requireNoNamespaceAttribute(reader, i); final String attrValue = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case ID: { contextName = attrValue; break; } default: throw unexpectedAttribute(reader, i); } } if (contextName == null) { throw missingRequired(reader, Collections.singleton(Attribute.ID)); } StringBuffer content = new StringBuffer(); while (reader.hasNext() && reader.next() != END_ELEMENT) { switch (reader.getEventType()) { case CHARACTERS: case CDATA: content.append(reader.getText()); break; } } String contextContent = content.toString(); ModelNode propNode = new ModelNode(); propNode.get(OP).set(ADD); propNode.get(OP_ADDR).set(address).add(ModelConstants.CONTEXT, contextName); propNode.get(ModelConstants.VALUE).set(contextContent); operations.add(propNode); }
Example 7
Source File: ProvisioningXmlParser30.java From galleon with Apache License 2.0 | 5 votes |
private static void readUniverse(XMLExtendedStreamReader reader, FeaturePackDepsConfigBuilder<?> fpBuilder) throws XMLStreamException { String name = null; String factory = null; String location = null; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final Attribute attribute = Attribute.of(reader.getAttributeName(i).getLocalPart()); switch (attribute) { case FACTORY: factory = reader.getAttributeValue(i); break; case NAME: name = reader.getAttributeValue(i); break; case LOCATION: location = reader.getAttributeValue(i); break; default: throw ParsingUtils.unexpectedContent(reader); } } ParsingUtils.parseNoContent(reader); try { fpBuilder.addUniverse(name, factory, location); } catch (ProvisioningDescriptionException e) { throw new XMLStreamException("Failed to parse universe declaration", e); } }
Example 8
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 9
Source File: StandaloneXml_5.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseNativeManagementInterfaceAttributes(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_AUTHENTICATION_FACTORY: { NativeManagementResourceDefinition.SASL_AUTHENTICATION_FACTORY.parseAndSetParameter(value, addOp, reader); break; } case SASL_PROTOCOL: { NativeManagementResourceDefinition.SASL_PROTOCOL.parseAndSetParameter(value, addOp, reader); break; } case SECURITY_REALM: { NativeManagementResourceDefinition.SECURITY_REALM.parseAndSetParameter(value, addOp, reader); break; } case SERVER_NAME: { NativeManagementResourceDefinition.SERVER_NAME.parseAndSetParameter(value, addOp, reader); break; } case SSL_CONTEXT: { NativeManagementResourceDefinition.SSL_CONTEXT.parseAndSetParameter(value, addOp, reader); break; } default: throw unexpectedAttribute(reader, i); } } } }
Example 10
Source File: AuditLogXml_4.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parsePeriodicRotatingFileAuditLogHandler(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.PERIODIC_ROTATING_FILE_HANDLER, value); break; case MAX_FAILURE_COUNT: PeriodicRotatingFileAuditLogHandlerResourceDefinition.MAX_FAILURE_COUNT.parseAndSetParameter(value, add, reader); break; case FORMATTER: PeriodicRotatingFileAuditLogHandlerResourceDefinition.FORMATTER.parseAndSetParameter(value, add, reader); break; case PATH: PeriodicRotatingFileAuditLogHandlerResourceDefinition.PATH.parseAndSetParameter(value, add, reader); break; case RELATIVE_TO: PeriodicRotatingFileAuditLogHandlerResourceDefinition.RELATIVE_TO.parseAndSetParameter(value, add, reader); break; case SUFFIX: PeriodicRotatingFileAuditLogHandlerResourceDefinition.SUFFIX.parseAndSetParameter(value, add, reader); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); }
Example 11
Source File: HostXml_6.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseServerSocketBindings(final XMLExtendedStreamReader reader, final ModelNode serverAddOperation) throws XMLStreamException { // Handle attributes final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); if (!isNoNamespaceAttribute(reader, i)) { throw ParseUtils.unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case SOCKET_BINDING_GROUP: { ServerConfigResourceDefinition.SOCKET_BINDING_GROUP.parseAndSetParameter(value, serverAddOperation, reader); break; } case DEFAULT_INTERFACE: { ServerConfigResourceDefinition.SOCKET_BINDING_DEFAULT_INTERFACE.parseAndSetParameter(value, serverAddOperation, reader); break; } case PORT_OFFSET: { ServerConfigResourceDefinition.SOCKET_BINDING_PORT_OFFSET.parseAndSetParameter(value, serverAddOperation, reader); break; } default: throw unexpectedAttribute(reader, i); } } } // Handle elements requireNoContent(reader); }
Example 12
Source File: ManagementXml_5.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseGroupToPrincipalAttributes(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 13
Source File: PatchXmlUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static ContentModification parseMiscModification(final XMLExtendedStreamReader reader, ModificationType type) throws XMLStreamException { String path = null; byte[] hash = NO_CONTENT; boolean directory = false; boolean affectsRuntime = false; byte[] targetHash = NO_CONTENT; ModificationCondition condition = null; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case DIRECTORY: directory = Boolean.parseBoolean(reader.getAttributeValue(i)); break; case PATH: path = reader.getAttributeValue(i); break; case HASH: if (type == ModificationType.REMOVE) { targetHash = hexStringToByteArray(reader.getAttributeValue(i)); } else { hash = hexStringToByteArray(reader.getAttributeValue(i)); } break; case NEW_HASH: if (type == ModificationType.REMOVE) { hash = hexStringToByteArray(reader.getAttributeValue(i)); } else { targetHash = hexStringToByteArray(reader.getAttributeValue(i)); } break; case IN_RUNTIME_USE: affectsRuntime = Boolean.parseBoolean(reader.getAttributeValue(i)); break; case CONDITION: try { condition = ModificationCondition.Factory.fromString(reader.getAttributeValue(i)); } catch (PatchingException e) { throw ControllerLogger.ROOT_LOGGER.invalidAttributeValue(reader.getAttributeValue(i), new QName( attribute.name), reader.getLocation()); } break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); final MiscContentItem item = createMiscItem(path, hash, directory, affectsRuntime); return new ContentModification(item, targetHash, type, condition); }
Example 14
Source File: HostXml_4.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
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 15
Source File: HostXml_8.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private boolean parseRemoteDomainControllerAttributes(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException { final ModelNode remoteDc = new ModelNode(); final ModelNode updateDc = remoteDc.get(REMOTE).setEmptyObject() ; // 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, updateDc, reader); break; } case PORT: { DomainControllerWriteAttributeHandler.PORT.parseAndSetParameter(value, updateDc, reader); break; } case PROTOCOL: { DomainControllerWriteAttributeHandler.PROTOCOL.parseAndSetParameter(value, updateDc, reader); break; } case AUTHENTICATION_CONTEXT: { DomainControllerWriteAttributeHandler.AUTHENTICATION_CONTEXT.parseAndSetParameter(value, updateDc, reader); break; } case SECURITY_REALM: { DomainControllerWriteAttributeHandler.SECURITY_REALM.parseAndSetParameter(value, updateDc, reader); break; } case USERNAME: { DomainControllerWriteAttributeHandler.USERNAME.parseAndSetParameter(value, updateDc, reader); break; } case IGNORE_UNUSED_CONFIG: { DomainControllerWriteAttributeHandler.IGNORE_UNUSED_CONFIG.parseAndSetParameter(value, updateDc, reader); break; } case ADMIN_ONLY_POLICY: { DomainControllerWriteAttributeHandler.ADMIN_ONLY_POLICY.parseAndSetParameter(value, updateDc, reader); ModelNode nodeValue = updateDc.get(DomainControllerWriteAttributeHandler.ADMIN_ONLY_POLICY.getName()); if (nodeValue.getType() != ModelType.EXPRESSION) { adminOnlyPolicy = AdminOnlyDomainConfigPolicy.getPolicy(nodeValue.asString()); } break; } default: throw unexpectedAttribute(reader, i); } } } if (!updateDc.hasDefined(DomainControllerWriteAttributeHandler.HOST.getName())) { requireDiscoveryOptions = isRequireDiscoveryOptions(adminOnlyPolicy); } if (!updateDc.hasDefined(DomainControllerWriteAttributeHandler.PORT.getName())) { requireDiscoveryOptions = requireDiscoveryOptions || isRequireDiscoveryOptions(adminOnlyPolicy); } final ModelNode update = Util.getWriteAttributeOperation(address, DOMAIN_CONTROLLER, remoteDc); list.add(update); return requireDiscoveryOptions; }
Example 16
Source File: HostXml_9.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 17
Source File: ManagementXml_4.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseLdapConnectionProperties(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 PROPERTY: { Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE); final ModelNode add = new ModelNode(); add.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)); required.remove(attribute); switch (attribute) { case NAME: { add.get(OP_ADDR).set(address.clone()).add(PROPERTY, value); break; } case VALUE: { LdapConnectionPropertyResourceDefinition.VALUE.parseAndSetParameter(value, add, reader); break; } default: { throw unexpectedAttribute(reader, i); } } } } if (required.size() > 0) { throw missingRequired(reader, required); } requireNoContent(reader); list.add(add); break; } default: { throw unexpectedElement(reader); } } } }
Example 18
Source File: HostXml_Legacy.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * 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 19
Source File: RemotingSubsystem10Parser.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
ModelNode parsePolicyElement(XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException { final ModelNode policy = new ModelNode(); policy.get(OP).set(ADD); policy.get(OP_ADDR).set(address).add(SaslPolicyResource.SASL_POLICY_CONFIG_PATH.getKey(), SaslPolicyResource.SASL_POLICY_CONFIG_PATH.getValue()); list.add(policy); if (reader.getAttributeCount() > 0) { throw ParseUtils.unexpectedAttribute(reader, 0); } // Handle 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 FORWARD_SECRECY: { SaslPolicyResource.FORWARD_SECRECY.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader); break; } case NO_ACTIVE: { SaslPolicyResource.NO_ACTIVE.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader); break; } case NO_ANONYMOUS: { SaslPolicyResource.NO_ANONYMOUS.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader); break; } case NO_DICTIONARY: { SaslPolicyResource.NO_DICTIONARY.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader); break; } case NO_PLAIN_TEXT: { SaslPolicyResource.NO_PLAIN_TEXT.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader); break; } case PASS_CREDENTIALS: { SaslPolicyResource.PASS_CREDENTIALS.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader); break; } default: { throw unexpectedElement(reader); } } } return policy; }
Example 20
Source File: HostXml_12.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseConstantHeaders(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException { // Attributes requireNoAttributes(reader); ModelNode constantHeaders= new ModelNode(); // Content while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); if (Element.forName(reader.getLocalName()) != Element.HEADER_MAPPING) { throw unexpectedElement(reader); } ModelNode headerMapping = new ModelNode(); requireSingleAttribute(reader, Attribute.PATH.getLocalName()); // After double checking the name of the only attribute we can retrieve it. HttpManagementResourceDefinition.PATH.parseAndSetParameter(reader.getAttributeValue(0), headerMapping, reader); ModelNode headers = new ModelNode(); boolean headerFound = false; while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); if (Element.forName(reader.getLocalName()) != Element.HEADER) { throw unexpectedElement(reader); } headerFound = true; ModelNode header= new ModelNode(); 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 NAME: { HttpManagementResourceDefinition.HEADER_NAME.parseAndSetParameter(value, header, reader); break; } case VALUE: { HttpManagementResourceDefinition.HEADER_VALUE.parseAndSetParameter(value, header, reader); break; } default: throw unexpectedAttribute(reader, i); } } } headers.add(header); requireNoContent(reader); } if (headerFound == false) { throw missingRequiredElement(reader, Collections.singleton(Element.HEADER.getLocalName())); } headerMapping.get(ModelDescriptionConstants.HEADERS).set(headers); constantHeaders.add(headerMapping); } addOp.get(ModelDescriptionConstants.CONSTANT_HEADERS).set(constantHeaders); }