@Override public final XMLStreamException unexpectedElement(final QName name, final Location location) { final XMLStreamException result = new XMLStreamException(String.format(getLoggingLocale(), unexpectedElement$str(), name), location); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToProcessEJBClientDescriptor = "WFLYEE0089: Failed to process jboss-ejb-client.xml";
private static XMLStreamException unexpectedContent(final XMLStreamReader reader) { final String kind; switch (reader.getEventType()) { case XMLStreamConstants.ATTRIBUTE: kind = "attribute"; break; case XMLStreamConstants.CDATA: kind = "cdata"; break; case XMLStreamConstants.CHARACTERS: kind = "characters"; break; case XMLStreamConstants.COMMENT: kind = "comment"; break; case XMLStreamConstants.DTD: kind = "dtd"; break; case XMLStreamConstants.END_DOCUMENT: kind = "document end"; break; case XMLStreamConstants.END_ELEMENT: kind = "element end"; break; case XMLStreamConstants.ENTITY_DECLARATION: kind = "entity decl"; break; case XMLStreamConstants.ENTITY_REFERENCE: kind = "entity ref"; break; case XMLStreamConstants.NAMESPACE: kind = "namespace"; break; case XMLStreamConstants.NOTATION_DECLARATION: kind = "notation decl"; break; case XMLStreamConstants.PROCESSING_INSTRUCTION: kind = "processing instruction"; break; case XMLStreamConstants.SPACE: kind = "whitespace"; break; case XMLStreamConstants.START_DOCUMENT: kind = "document start"; break; case XMLStreamConstants.START_ELEMENT: kind = "element start"; break; default: kind = "unknown"; break; } return new XMLStreamException(SarLogger.ROOT_LOGGER.unexpectedContent(kind, reader.getName(), reader.getText()), reader.getLocation()); }
@Override public final XMLStreamException errorParsingEJBClientDescriptor(final String message, final Location location) { final XMLStreamException result = new XMLStreamException(String.format(getLoggingLocale(), errorParsingEJBClientDescriptor$str(), message), location); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String noMessageDestination = "WFLYEE0092: No message destination with name %s for binding %s";
private static MenuItem parseMenuItem(XMLStreamReader reader) throws XMLStreamException { String key = reader.getAttributeValue(null, "key"); String label = reader.getAttributeValue(null, "label"); if (key == null) throw new XMLStreamException("Menu item key cannot be null.", reader.getLocation()); return new MenuItem(key, label != null ? label : key); }
@Override public final XMLStreamException invalidInitializerConfig(final String value, final Location location) { final XMLStreamException result = new XMLStreamException(String.format(getLoggingLocale(), invalidInitializerConfig$str(), value), location); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String invalidSSLConfig = "WFLYORB0039: Illegal SSL config option: %s. Should be one of [0.20,40,60]";
private static NodeLibrary load(String libraryName, File file, Reader r, NodeRepository nodeRepository) throws XMLStreamException { XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(r); NodeLibrary nodeLibrary = null; while (reader.hasNext()) { int eventType = reader.next(); if (eventType == XMLStreamConstants.START_ELEMENT) { String tagName = reader.getLocalName(); if (tagName.equals("ndbx")) { String formatVersion = reader.getAttributeValue(null, "formatVersion"); if (formatVersion != null && !CURRENT_FORMAT_VERSION.equals(formatVersion)) { throw new OutdatedLibraryException(file, "File uses version " + formatVersion + ", current version is " + CURRENT_FORMAT_VERSION + "."); } String uuidString = reader.getAttributeValue(null, "uuid"); UUID uuid = (uuidString == null) ? UUID.randomUUID() : UUID.fromString(uuidString); nodeLibrary = parseNDBX(libraryName, file, reader, nodeRepository, uuid); } else { throw new XMLStreamException("Only tag ndbx allowed, not " + tagName, reader.getLocation()); } } } return nodeLibrary; }
@Override public final XMLStreamException xmlStreamExceptionAuth(final Location loc) { final XMLStreamException result = new XMLStreamException(String.format(getLoggingLocale(), xmlStreamExceptionAuth$str()), loc); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String xmlStreamExceptionMissingAttribute = "WFLYSEC0023: Missing required attribute: either %s or %s must be present";
public static Map<String, String> parseHeader(File f) { try { XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(createFileReader(f)); while (reader.hasNext()) { int eventType = reader.next(); if (eventType == XMLStreamConstants.START_ELEMENT) { String tagName = reader.getLocalName(); if (tagName.equals("ndbx")) { return parseHeader(reader); } else { throw new XMLStreamException("Only tag ndbx allowed, not " + tagName, reader.getLocation()); } } } } catch (XMLStreamException e) { throw new RuntimeException(e); } catch (FileNotFoundException e) { throw new RuntimeException(e); } return Collections.emptyMap(); }
@Override public final XMLStreamException mutuallyExclusiveAttributes(final Location location, final String attribute1, final String attribute2) { final XMLStreamException result = new XMLStreamException(String.format(getLoggingLocale(), mutuallyExclusiveAttributes$str(), attribute1, attribute2), location); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
rootNode = parseNode(reader, rootNode, nodeRepository); } else { throw new XMLStreamException("Unknown tag " + tagName, reader.getLocation());
@Override public final XMLStreamException invalidValue(final String value, final String element, final Location location) { final XMLStreamException result = new XMLStreamException(String.format(getLoggingLocale(), invalidValue$str(), value, element), location); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String methodNotFound1 = "WFLYEE0067: Method does not exist %s";
b.add(parseMenuItem(reader)); } else { throw new XMLStreamException("Unknown tag " + tagName, reader.getLocation());
@Override public final XMLStreamException invalidSSLConfig(final String value, final Location location) { final XMLStreamException result = new XMLStreamException(String.format(getLoggingLocale(), invalidSSLConfig$str(), value), location); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String cannotEmulateProperties = "WFLYORB0132: Properties %s cannot be emulated using OpenJDK ORB and are not supported";
String prototypeId = attributeMap.get("prototype"); if (node == null) { throw new XMLStreamException("Prototype " + prototypeId + " could not be found.", reader.getLocation()); Node coreNode = Node.coreNodes.get(s); if (coreNode == null) { throw new XMLStreamException("Core node '" + s + "' does not exist.", reader.getLocation()); node = node.withConnectionAdded(parseConnection(reader)); } else { throw new XMLStreamException("Unknown tag " + tagName, reader.getLocation());
@Override public final XMLStreamException unsupportedAttribute(final String attribute, final Location location) { final XMLStreamException result = new XMLStreamException(String.format(getLoggingLocale(), unsupportedAttribute$str(), attribute), location); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String mustBeDefinedIfTrue = "WFLYTX0032: %s must be defined if %s is 'true'.";
private static void unexpectedVaultAttribute(String attribute, XMLStreamReader reader) throws XMLStreamException { throw new XMLStreamException("Attribute '" + attribute + "' is unknown for element '" + VAULT_OPTION + "' at " + reader.getLocation()); }
@Override public final XMLStreamException xmlStreamExceptionMissingAttribute(final String a, final String b, final Location loc) { final XMLStreamException result = new XMLStreamException(String.format(getLoggingLocale(), xmlStreamExceptionMissingAttribute$str(), a, b), loc); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String loginModuleStackIllegalArgument = "WFLYSEC0024: auth-module references a login module stack that doesn't exist::%s";
protected static void throwUnexpectedEntity(XMLStreamReader xmlReader, String name, int type, String currentTag) throws XMLStreamException { throw new XMLStreamException("unexpected entity " + name + '[' + type + ']' + " inside '" + currentTag + "' at: " + xmlReader.getLocation()); }
@Override public final XMLStreamException unexpectedElement(final String elementName, final Location location) { final XMLStreamException result = new XMLStreamException(String.format(unexpectedElement$str(), elementName), location); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String unexpectedAttribute = "PBOX00087: Unexpected attribute %s encountered";
protected static void throwUnexpectedEntity(XMLStreamReader xmlReader, String name, int type, String currentTag) throws XMLStreamException { throw new XMLStreamException("unexpected entity " + name + '[' + type + ']' + " inside '" + currentTag + "' at: " + xmlReader.getLocation()); }