Java Code Examples for org.jboss.staxmapper.XMLExtendedStreamReader#getAttributeLocalName()
The following examples show how to use
org.jboss.staxmapper.XMLExtendedStreamReader#getAttributeLocalName() .
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 |
void readCertificate(XMLExtendedStreamReader reader, ModelNode addKeyStore) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = KeyStoreCertificateDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, addKeyStore, reader); } if (!addKeyStore.hasDefined(Constants.Model.CERTIFICATE_ALIAS)) { throw ParseUtils.missingRequired(reader, asSet(Constants.XML.CERTIFICATE_ALIAS)); } ParseUtils.requireNoContent(reader); }
Example 2
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 6 votes |
void readPrincipalNameMapping(ModelNode addServiceProvider, XMLExtendedStreamReader reader) throws XMLStreamException { boolean policySet = false; for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); if (Constants.XML.PRINCIPAL_NAME_MAPPING_POLICY.equals(name)) { policySet = true; ServiceProviderDefinition.PRINCIPAL_NAME_MAPPING_POLICY.parseAndSetParameter(value, addServiceProvider, reader); } else if (Constants.XML.PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME.equals(name)) { ServiceProviderDefinition.PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME.parseAndSetParameter(value, addServiceProvider, reader); } else { throw ParseUtils.unexpectedAttribute(reader, i); } } if (!policySet) { throw ParseUtils.missingRequired(reader, Constants.XML.PRINCIPAL_NAME_MAPPING_POLICY); } ParseUtils.requireNoContent(reader); }
Example 3
Source File: JMXExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected ModelNode parseRemoteConnector(final XMLExtendedStreamReader reader) throws XMLStreamException { final ModelNode connector = new ModelNode(); connector.get(OP).set(ADD); connector.get(OP_ADDR).add(SUBSYSTEM, JMX).add(REMOTING_CONNECTOR, CommonAttributes.JMX); int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); final String attribute = reader.getAttributeLocalName(i); switch (attribute) { case CommonAttributes.USE_MANAGEMENT_ENDPOINT: { RemotingConnectorResource.USE_MANAGEMENT_ENDPOINT.parseAndSetParameter(value, connector, reader); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); return connector; }
Example 4
Source File: JMXExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void parseSensitivity(ModelNode add, XMLExtendedStreamReader reader) throws XMLStreamException { final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); final String attribute = reader.getAttributeLocalName(i); switch (attribute) { case CommonAttributes.NON_CORE_MBEANS: JMXSubsystemRootResource.CORE_MBEAN_SENSITIVITY.parseAndSetParameter(value, add, reader); break; default: throw ParseUtils.unexpectedAttribute(reader, i); } } ParseUtils.requireNoContent(reader); }
Example 5
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 6 votes |
void readPrivateKey(XMLExtendedStreamReader reader, ModelNode addKeyStore) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = KeyStorePrivateKeyDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, addKeyStore, reader); } if (!addKeyStore.hasDefined(Constants.Model.PRIVATE_KEY_ALIAS)) { throw ParseUtils.missingRequired(reader, asSet(Constants.XML.PRIVATE_KEY_ALIAS)); } if (!addKeyStore.hasDefined(Constants.Model.PRIVATE_KEY_PASSWORD)) { throw ParseUtils.missingRequired(reader, asSet(Constants.XML.PRIVATE_KEY_PASSWORD)); } ParseUtils.requireNoContent(reader); }
Example 6
Source File: VaultConfig.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * In the 3.0 xsd the vault configuration and its options are part of the vault xsd. * * @param reader the reader at the vault element * @param expectedNs the namespace * @return the vault configuration */ static VaultConfig readVaultElement_3_0(XMLExtendedStreamReader reader, Namespace expectedNs) throws XMLStreamException { final VaultConfig config = new VaultConfig(); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); String name = reader.getAttributeLocalName(i); if (name.equals(CODE)){ config.code = value; } else if (name.equals(MODULE)){ config.module = value; } else { unexpectedVaultAttribute(reader.getAttributeLocalName(i), reader); } } if (config.code == null && config.module != null){ throw new XMLStreamException("Attribute 'module' was specified without an attribute" + " 'code' for element '" + VAULT + "' at " + reader.getLocation()); } readVaultOptions(reader, config); return config; }
Example 7
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 6 votes |
void readPrincipalNameMapping(ModelNode addServiceProvider, XMLExtendedStreamReader reader) throws XMLStreamException { boolean policySet = false; for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); if (Constants.XML.PRINCIPAL_NAME_MAPPING_POLICY.equals(name)) { policySet = true; ServiceProviderDefinition.PRINCIPAL_NAME_MAPPING_POLICY.parseAndSetParameter(value, addServiceProvider, reader); } else if (Constants.XML.PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME.equals(name)) { ServiceProviderDefinition.PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME.parseAndSetParameter(value, addServiceProvider, reader); } else { throw ParseUtils.unexpectedAttribute(reader, i); } } if (!policySet) { throw ParseUtils.missingRequired(reader, asSet(Constants.XML.PRINCIPAL_NAME_MAPPING_POLICY)); } ParseUtils.requireNoContent(reader); }
Example 8
Source File: JMXExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected ModelNode parseShowModelElement(XMLExtendedStreamReader reader, String showModelChild) throws XMLStreamException { ModelNode op = createOperation(ADD, CommonAttributes.EXPOSE_MODEL, showModelChild); String domainName = null; Boolean properPropertyFormat = null; for (int i = 0; i < reader.getAttributeCount(); i++) { final String value = reader.getAttributeValue(i); final String attribute = reader.getAttributeLocalName(i); switch (attribute) { case CommonAttributes.DOMAIN_NAME: ExposeModelResource.getDomainNameAttribute(showModelChild).parseAndSetParameter(value, op, reader); break; case CommonAttributes.PROPER_PROPERTY_FORMAT: if (showModelChild.equals(CommonAttributes.RESOLVED)) { ExposeModelResourceResolved.PROPER_PROPERTY_FORMAT.parseAndSetParameter(value, op, reader); } else { throw ParseUtils.unexpectedAttribute(reader, i); } break; default: throw ParseUtils.unexpectedAttribute(reader, i); } } if (domainName == null && properPropertyFormat == null) { ParseUtils.requireNoContent(reader); } return op; }
Example 9
Source File: JMXExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseAuditLogHandler(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException { String name = null; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); final String attribute = reader.getAttributeLocalName(i); switch (attribute) { case NAME: name = value; break; default: throw ParseUtils.unexpectedAttribute(reader, i); } } if (name == null) { throw ParseUtils.missingRequired(reader, Collections.singleton(NAME)); } ModelNode op = createOperation(ADD, JmxAuditLoggerResourceDefinition.PATH_ELEMENT.getKey(), JmxAuditLoggerResourceDefinition.PATH_ELEMENT.getValue(), JmxAuditLogHandlerReferenceResourceDefinition.PATH_ELEMENT.getKey(), name); list.add(op); ParseUtils.requireNoContent(reader); }
Example 10
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 5 votes |
void readSingleSignOn(ModelNode addIdentityProvider, XMLExtendedStreamReader reader) throws XMLStreamException { ModelNode sso = addIdentityProvider.get(Constants.Model.SINGLE_SIGN_ON); for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = SingleSignOnDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, sso, reader); } ParseUtils.requireNoContent(reader); }
Example 11
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 5 votes |
/** * Read an attribute, and throw exception if attribute is not present */ String readRequiredAttribute(XMLExtendedStreamReader reader, String attrName) throws XMLStreamException { String value = null; for (int i = 0; i < reader.getAttributeCount(); i++) { String attr = reader.getAttributeLocalName(i); if (attr.equals(attrName)) { value = reader.getAttributeValue(i); break; } } if (value == null) { throw ParseUtils.missingRequired(reader, Collections.singleton(attrName)); } return value; }
Example 12
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 5 votes |
void readHttpClient(final ModelNode addIdentityProvider, final XMLExtendedStreamReader reader) throws XMLStreamException { ModelNode httpClientNode = addIdentityProvider.get(Constants.Model.HTTP_CLIENT); for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = HttpClientDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, httpClientNode, reader); } ParseUtils.requireNoContent(reader); }
Example 13
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 5 votes |
void readHttpClient(final ModelNode addIdentityProvider, final XMLExtendedStreamReader reader) throws XMLStreamException { ModelNode httpClientNode = addIdentityProvider.get(Constants.Model.HTTP_CLIENT); for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = HttpClientDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, httpClientNode, reader); } ParseUtils.requireNoContent(reader); }
Example 14
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 4 votes |
void readIdentityProvider(List<ModelNode> list, XMLExtendedStreamReader reader, PathAddress parentAddr) throws XMLStreamException { String entityId = readRequiredAttribute(reader, Constants.XML.ENTITY_ID); PathAddress addr = PathAddress.pathAddress(parentAddr, PathElement.pathElement(Constants.Model.IDENTITY_PROVIDER, entityId)); ModelNode addIdentityProvider = Util.createAddOperation(addr); list.add(addIdentityProvider); for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); if (Constants.XML.ENTITY_ID.equals(name) // don't break if encountering this noop attr from client-adapter/core keycloak_saml_adapter_1_6.xsd || "encryption".equals(name)) { continue; } SimpleAttributeDefinition attr = IdentityProviderDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, addIdentityProvider, reader); } Set<String> parsedElements = new HashSet<>(); while (reader.hasNext() && nextTag(reader) != END_ELEMENT) { String tagName = reader.getLocalName(); if (parsedElements.contains(tagName)) { // all sub-elements of the identity provider type should occur only once. throw ParseUtils.unexpectedElement(reader); } if (Constants.XML.SINGLE_SIGN_ON.equals(tagName)) { readSingleSignOn(addIdentityProvider, reader); } else if (Constants.XML.SINGLE_LOGOUT.equals(tagName)) { readSingleLogout(addIdentityProvider, reader); } else if (Constants.XML.KEYS.equals(tagName)) { readKeys(list, reader, addr); } else if (Constants.XML.HTTP_CLIENT.equals(tagName)) { readHttpClient(addIdentityProvider, reader); } else if (Constants.XML.ALLOWED_CLOCK_SKEW.equals(tagName)) { readAllowedClockSkew(addIdentityProvider, reader); } else { throw ParseUtils.unexpectedElement(reader); } parsedElements.add(tagName); } }
Example 15
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 4 votes |
void readIdentityProvider(List<ModelNode> list, XMLExtendedStreamReader reader, PathAddress parentAddr) throws XMLStreamException { String entityId = readRequiredAttribute(reader, Constants.XML.ENTITY_ID); PathAddress addr = PathAddress.pathAddress(parentAddr, PathElement.pathElement(Constants.Model.IDENTITY_PROVIDER, entityId)); ModelNode addIdentityProvider = Util.createAddOperation(addr); list.add(addIdentityProvider); for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); if (Constants.XML.ENTITY_ID.equals(name) // don't break if encountering this noop attr from client-adapter/core keycloak_saml_adapter_1_6.xsd || "encryption".equals(name)) { continue; } SimpleAttributeDefinition attr = IdentityProviderDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, addIdentityProvider, reader); } Set<String> parsedElements = new HashSet<>(); while (reader.hasNext() && nextTag(reader) != END_ELEMENT) { String tagName = reader.getLocalName(); if (parsedElements.contains(tagName)) { // all sub-elements of the identity provider type should occur only once. throw ParseUtils.unexpectedElement(reader); } if (Constants.XML.SINGLE_SIGN_ON.equals(tagName)) { readSingleSignOn(addIdentityProvider, reader); } else if (Constants.XML.SINGLE_LOGOUT.equals(tagName)) { readSingleLogout(addIdentityProvider, reader); } else if (Constants.XML.KEYS.equals(tagName)) { readKeys(list, reader, addr); } else if (Constants.XML.HTTP_CLIENT.equals(tagName)) { readHttpClient(addIdentityProvider, reader); } else if (Constants.XML.ALLOWED_CLOCK_SKEW.equals(tagName)) { readAllowedClockSkew(addIdentityProvider, reader); } else { throw ParseUtils.unexpectedElement(reader); } parsedElements.add(tagName); } }
Example 16
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 4 votes |
void readServiceProvider(XMLExtendedStreamReader reader, List<ModelNode> list, PathAddress parentAddr) throws XMLStreamException { String entityId = readRequiredAttribute(reader, Constants.XML.ENTITY_ID); PathAddress addr = PathAddress.pathAddress(parentAddr, PathElement.pathElement(Constants.Model.SERVICE_PROVIDER, entityId)); ModelNode addServiceProvider = Util.createAddOperation(addr); list.add(addServiceProvider); for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); if (Constants.XML.ENTITY_ID.equals(name)) { continue; } String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = ServiceProviderDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, addServiceProvider, reader); } Set parsedElements = new HashSet<>(); while (reader.hasNext() && nextTag(reader) != END_ELEMENT) { String tagName = reader.getLocalName(); if (parsedElements.contains(tagName)) { // all sub-elements of the service provider type should occur only once. throw ParseUtils.unexpectedElement(reader); } if (Constants.XML.KEYS.equals(tagName)) { readKeys(list, reader, addr); } else if (Constants.XML.PRINCIPAL_NAME_MAPPING.equals(tagName)) { readPrincipalNameMapping(addServiceProvider, reader); } else if (Constants.XML.ROLE_IDENTIFIERS.equals(tagName)) { readRoleIdentifiers(addServiceProvider, reader); } else if (Constants.XML.ROLE_MAPPINGS_PROVIDER.equals(tagName)) { readRoleMappingsProvider(addServiceProvider, reader); } else if (Constants.XML.IDENTITY_PROVIDER.equals(tagName)) { readIdentityProvider(list, reader, addr); } else { throw ParseUtils.unexpectedElement(reader); } parsedElements.add(tagName); } }
Example 17
Source File: BpmPlatformParser.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
private void parseJobAcquisition(XMLExtendedStreamReader reader, List<ModelNode> list, ModelNode parentAddress) throws XMLStreamException { if (!Element.JOB_AQUISITION.getLocalName().equals(reader.getLocalName())) { throw unexpectedElement(reader); } String acquisitionName = null; for (int i = 0; i < reader.getAttributeCount(); i++) { String attr = reader.getAttributeLocalName(i); if (Attribute.forName(attr).equals(Attribute.NAME)) { acquisitionName = String.valueOf(reader.getAttributeValue(i)); } else { throw unexpectedAttribute(reader, i); } } if ("null".equals(acquisitionName)) { throw missingRequiredElement(reader, Collections.singleton(Attribute.NAME.getLocalName())); } // Add the 'add' operation for each 'job-acquisition' child ModelNode addJobAcquisition = new ModelNode(); addJobAcquisition.get(OP).set(ADD); PathAddress addr = PathAddress.pathAddress( PathElement.pathElement(SUBSYSTEM, ModelConstants.SUBSYSTEM_NAME), PathElement.pathElement(Element.JOB_EXECUTOR.getLocalName(), ModelConstants.DEFAULT), PathElement.pathElement(Element.JOB_AQUISITIONS.getLocalName(), acquisitionName)); addJobAcquisition.get(OP_ADDR).set(addr.toModelNode()); addJobAcquisition.get(Attribute.NAME.getLocalName()).set(acquisitionName); list.add(addJobAcquisition); // 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, list, addJobAcquisition); break; } case ACQUISITION_STRATEGY: { parseElement(SubsystemAttributeDefinitons.ACQUISITION_STRATEGY, reader, addJobAcquisition); break; } default: { throw unexpectedElement(reader); } } break; } } } }
Example 18
Source File: DeploymentScannerParser_1_0.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
void parseScanner(XMLExtendedStreamReader reader, final ModelNode address, List<ModelNode> list) throws XMLStreamException { // Handle attributes Boolean enabled = null; Integer interval = null; String path = null; String name = DeploymentScannerExtension.DEFAULT_SCANNER_NAME; String relativeTo = null; Boolean autoDeployZipped = null; Boolean autoDeployExploded = null; Long deploymentTimeout = null; final int attrCount = reader.getAttributeCount(); for (int i = 0; i < attrCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final String attribute = reader.getAttributeLocalName(i); switch (attribute) { case PATH: { path = value; break; } case NAME: { name = value; break; } case RELATIVE_TO: { relativeTo = value; break; } case SCAN_INTERVAL: { interval = Integer.parseInt(value); break; } case SCAN_ENABLED: { enabled = Boolean.parseBoolean(value); break; } case AUTO_DEPLOY_ZIPPED: { autoDeployZipped = Boolean.parseBoolean(value); break; } case AUTO_DEPLOY_EXPLODED: { autoDeployExploded = Boolean.parseBoolean(value); break; } case DEPLOYMENT_TIMEOUT: { deploymentTimeout = Long.parseLong(value); break; } default: throw ParseUtils.unexpectedAttribute(reader, i); } } if (name == null) { throw ParseUtils.missingRequired(reader, Collections.singleton(CommonAttributes.NAME)); } if (path == null) { throw ParseUtils.missingRequired(reader, Collections.singleton(PATH)); } requireNoContent(reader); final ModelNode operation = new ModelNode(); operation.get(OP).set(ADD); operation.get(OP_ADDR).set(address).add(CommonAttributes.SCANNER, name); operation.get(PATH).set(path); if (interval != null) operation.get(CommonAttributes.SCAN_INTERVAL).set(interval.intValue()); if (autoDeployZipped != null) operation.get(CommonAttributes.AUTO_DEPLOY_ZIPPED).set(autoDeployZipped.booleanValue()); if (autoDeployExploded != null) operation.get(CommonAttributes.AUTO_DEPLOY_EXPLODED).set(autoDeployExploded.booleanValue()); if (enabled != null) operation.get(CommonAttributes.SCAN_ENABLED).set(enabled.booleanValue()); if(relativeTo != null) operation.get(CommonAttributes.RELATIVE_TO).set(relativeTo); if(deploymentTimeout != null) operation.get(CommonAttributes.DEPLOYMENT_TIMEOUT).set(deploymentTimeout); list.add(operation); }
Example 19
Source File: LoggingSubsystemParser_5_0.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
void parseStructuredFormatter(final XMLExtendedStreamReader reader, final ModelNode operation, final SimpleAttributeDefinition... additionalAttributes) throws XMLStreamException { final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String attributeName = reader.getAttributeLocalName(i); final String value = reader.getAttributeValue(i); if (attributeName.equals(StructuredFormatterResourceDefinition.DATE_FORMAT.getXmlName())) { StructuredFormatterResourceDefinition.DATE_FORMAT.parseAndSetParameter(value, operation, reader); } else if (attributeName.equals(StructuredFormatterResourceDefinition.PRETTY_PRINT.getXmlName())) { StructuredFormatterResourceDefinition.PRETTY_PRINT.parseAndSetParameter(value, operation, reader); } else if (attributeName.equals(StructuredFormatterResourceDefinition.PRINT_DETAILS.getXmlName())) { StructuredFormatterResourceDefinition.PRINT_DETAILS.parseAndSetParameter(value, operation, reader); } else if (attributeName.equals(StructuredFormatterResourceDefinition.ZONE_ID.getXmlName())) { StructuredFormatterResourceDefinition.ZONE_ID.parseAndSetParameter(value, operation, reader); } else { boolean invalid = true; for (SimpleAttributeDefinition ad : additionalAttributes) { if (attributeName.equals(ad.getXmlName())) { invalid = false; ad.parseAndSetParameter(value, operation, reader); break; } } if (invalid) { throw unexpectedAttribute(reader, i); } } } final Set<String> encountered = new HashSet<>(); while (reader.nextTag() != END_ELEMENT) { final String elementName = reader.getLocalName(); if (!encountered.add(elementName)) { throw unexpectedElement(reader); } if (elementName.equals(StructuredFormatterResourceDefinition.EXCEPTION_OUTPUT_TYPE.getXmlName())) { StructuredFormatterResourceDefinition.EXCEPTION_OUTPUT_TYPE.parseAndSetParameter(readValueAttribute(reader), operation, reader); } else if (elementName.equals(StructuredFormatterResourceDefinition.RECORD_DELIMITER.getXmlName())) { StructuredFormatterResourceDefinition.RECORD_DELIMITER.parseAndSetParameter(readValueAttribute(reader), operation, reader); } else if (elementName.equals(StructuredFormatterResourceDefinition.KEY_OVERRIDES.getXmlName())) { StructuredFormatterResourceDefinition.KEY_OVERRIDES.getParser().parseElement(StructuredFormatterResourceDefinition.KEY_OVERRIDES, reader, operation); } else if (elementName.equals(StructuredFormatterResourceDefinition.META_DATA.getXmlName())) { parsePropertyElement(operation, reader, StructuredFormatterResourceDefinition.META_DATA.getName()); } else { throw unexpectedElement(reader); } } }
Example 20
Source File: BpmPlatformParser.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
private void parseProcessEngine(XMLExtendedStreamReader reader, List<ModelNode> list, ModelNode parentAddress, List<String> discoveredEngineNames) throws XMLStreamException { if (!Element.PROCESS_ENGINE.getLocalName().equals(reader.getLocalName())) { throw unexpectedElement(reader); } ModelNode addProcessEngine = new ModelNode(); String engineName = null; for (int i = 0; i < reader.getAttributeCount(); i++) { String attr = reader.getAttributeLocalName(i); if (Attribute.forName(attr).equals(Attribute.NAME)) { engineName = String.valueOf(reader.getAttributeValue(i)); } else if (Attribute.forName(attr).equals(Attribute.DEFAULT)) { SubsystemAttributeDefinitons.DEFAULT.parseAndSetParameter(reader.getAttributeValue(i), addProcessEngine, reader);; } else { throw unexpectedAttribute(reader, i); } } if ("null".equals(engineName)) { throw missingRequiredElement(reader, Collections.singleton(Attribute.NAME.getLocalName())); } //Add the 'add' operation for each 'process-engine' child addProcessEngine.get(OP).set(ModelDescriptionConstants.ADD); PathAddress addr = PathAddress.pathAddress( PathElement.pathElement(SUBSYSTEM, ModelConstants.SUBSYSTEM_NAME), PathElement.pathElement(Element.PROCESS_ENGINES.getLocalName(), engineName)); addProcessEngine.get(OP_ADDR).set(addr.toModelNode()); addProcessEngine.get(Attribute.NAME.getLocalName()).set(engineName); if (discoveredEngineNames.contains(engineName)) { throw new ProcessEngineException("A process engine with name '" + engineName + "' already exists. The process engine name must be unique."); } else { discoveredEngineNames.add(engineName); } list.add(addProcessEngine); // iterate deeper while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { final Element element = Element.forName(reader.getLocalName()); switch (element) { case PLUGINS: { parsePlugins(reader, list, addProcessEngine); break; } case PROPERTIES: { parseProperties(reader, list, addProcessEngine); break; } case DATASOURCE: { parseElement(SubsystemAttributeDefinitons.DATASOURCE, reader, addProcessEngine); break; } case HISTORY_LEVEL: { parseElement(SubsystemAttributeDefinitons.HISTORY_LEVEL, reader, addProcessEngine); break; } case CONFIGURATION: { parseElement(SubsystemAttributeDefinitons.CONFIGURATION, reader, addProcessEngine); break; } default: { throw unexpectedElement(reader); } } } }