/** * Parse recovery tag * * @param reader reader * @return the parsed recovery object * @throws XMLStreamException in case of error * @throws ParserException in case of error * @throws ValidateException in case of error */ protected Recovery parseRecovery(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException { Boolean noRecovery = null; Credential security = null; Extension plugin = null; for (Recovery.Attribute attribute : Recovery.Attribute.values()) { switch (attribute) { case NO_RECOVERY: { noRecovery = attributeAsBoolean(reader, attribute.getLocalName(), Boolean.FALSE); break; } default: break; } } while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (XaDataSource.Tag.forName(reader.getLocalName()) == XaDataSource.Tag.RECOVERY) { return new Recovery(security, plugin, noRecovery); } else { if (Recovery.Tag.forName(reader.getLocalName()) == Recovery.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); } } break; } case START_ELEMENT: { Recovery.Tag tag = Recovery.Tag.forName(reader.getLocalName()); switch (tag) { case RECOVER_CREDENTIAL: { security = parseCredential(reader); break; } case RECOVER_PLUGIN: { plugin = parseExtension(reader, tag.getLocalName()); break; } default: throw new ParserException(bundle.unexpectedElement(reader.getLocalName())); } break; } } } throw new ParserException(bundle.unexpectedEndOfDocument()); }
/** * parse credential tag * * @param reader reader * @return the parse Object * @throws XMLStreamException in case of error * @throws ParserException in case of error * @throws ValidateException in case of error */ protected Credential parseCredential(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException { String userName = null; String password = null; String securityDomain = null; while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.SECURITY || Recovery.Tag.forName(reader.getLocalName()) == Recovery.Tag.RECOVER_CREDENTIAL) { return new CredentialImpl(userName, password, securityDomain); } else { if (Credential.Tag.forName(reader.getLocalName()) == Credential.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); } } break; } case START_ELEMENT: { switch (Credential.Tag.forName(reader.getLocalName())) { case PASSWORD: { password = elementAsString(reader); break; } case USER_NAME: { userName = elementAsString(reader); break; } case SECURITY_DOMAIN: { securityDomain = elementAsString(reader); break; } default: throw new ParserException(bundle.unexpectedElement(reader.getLocalName())); } break; } } } throw new ParserException(bundle.unexpectedEndOfDocument()); }