private void parseArtifactVersions( final XMLStreamReader reader, final FeaturePackDescription result) throws XMLStreamException { final Set<Artifact> artifactVersions = result.getArtifactVersions(); 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 ARTIFACT: artifactVersions.add(parseArtifact(reader)); break; default: throw ParsingUtils.unexpectedContent(reader); } break; } default: { throw ParsingUtils.unexpectedContent(reader); } } } throw ParsingUtils.endOfDocument(reader.getLocation()); }
@Override public void readElement(final XMLExtendedStreamReader reader, final FeaturePackDescription result) throws XMLStreamException { final Set<Attribute> required = EnumSet.noneOf(Attribute.class); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { throw ParsingUtils.unexpectedContent(reader); } if (!required.isEmpty()) { throw ParsingUtils.missingAttributes(reader.getLocation(), required); } 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 DEPENDENCIES: parseDependencies(reader, result); break; case ARTIFACT_VERSIONS: parseArtifactVersions(reader, result); break; case CONFIG: configModelParser.parseConfig(reader, result.getConfig()); break; case COPY_ARTIFACTS: copyArtifactsModelParser.parseCopyArtifacts(reader, result.getCopyArtifacts()); break; case FILE_PERMISSIONS: filePermissionsModelParser.parseFilePermissions( reader, result.getFilePermissions()); break; default: throw ParsingUtils.unexpectedContent(reader); } break; } default: { throw ParsingUtils.unexpectedContent(reader); } } } throw ParsingUtils.endOfDocument(reader.getLocation()); }
/* we only override this method, for now only change new EXTRACT_SCHEMAS_GROUPS attribute */ @Override public void readElement( final XMLExtendedStreamReader reader, final ServerProvisioningDescription result) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { final Attribute attribute = Attribute.of(reader.getAttributeName(i)); switch (attribute) { case COPY_MODULE_ARTIFACTS: result.setCopyModuleArtifacts(Boolean.parseBoolean(reader.getAttributeValue(i))); break; case EXTRACT_SCHEMAS: result.setExtractSchemas(Boolean.parseBoolean(reader.getAttributeValue(i))); break; case EXTRACT_SCHEMAS_GROUPS: result.setExtractSchemasGroups(reader.getAttributeValue(i)); break; case EXCLUDE_DEPENDENCIES: result.setExcludeDependencies(Boolean.parseBoolean(reader.getAttributeValue(i))); break; default: throw ParsingUtils.unexpectedAttribute(reader, i); } } while (reader.hasNext()) { switch (reader.nextTag()) { case XMLStreamConstants.END_ELEMENT: { return; } case XMLStreamConstants.START_ELEMENT: { final Element element = Element.of(reader.getLocalName()); switch (element) { case FEATURE_PACKS: parseFeaturePacks(reader, result); break; case VERSION_OVERRIDES: parseVersionOverrides(reader, result); break; case COPY_ARTIFACTS: copyArtifactsModelParser.parseCopyArtifacts(reader, result.getCopyArtifacts()); break; default: throw new XMLStreamException( String.format( "Unknown element: '%s', elementName: %s, localName: %s", element, reader.getName(), reader.getLocalName()), reader.getLocation()); // throw ParsingUtils.unexpectedContent(reader); } break; } default: { throw ParsingUtils.unexpectedContent(reader); } } } throw ParsingUtils.endOfDocument(reader.getLocation()); }