mbaedke commented on code in PR #2223: URL: https://github.com/apache/jackrabbit-oak/pull/2223#discussion_r2037627670
########## oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SysViewImportHandler.java: ########## @@ -93,6 +95,42 @@ private void processNode(ImportState state, boolean start, boolean end) } } + //TODO avoid code duplication (this is stolen from GlobalNameMapper) + private static boolean isExpandedName(String name) { + if (name.startsWith("{")) { + int brace = name.indexOf('}', 1); + if (brace != -1) { + String namespace = name.substring(1, brace); + // the empty namespace and "internal" are valid as well, otherwise it always contains a colon (as it is a URI) + // compare with RFC 3986, Section 3 (https://datatracker.ietf.org/doc/html/rfc3986#section-3) + if (namespace.isEmpty() || namespace.equals(NamespaceConstants.NAMESPACE_REP)|| namespace.indexOf(':') != -1) { + return true; + } + } + } + return false; + } + + private NameInfo getNameInfo(String svName) throws RepositoryException { + if (isExpandedName(svName)) { + String namespaceUri = svName.substring(svName.indexOf("{") + 1, svName.indexOf("}")); + String localName = svName.substring(svName.indexOf("}") + 1); + NamespaceRegistry namespaceRegistry = sessionContext.getWorkspace().getNamespaceRegistry(); + String prefix; + try { + prefix = namespaceRegistry.getPrefix(namespaceUri); + } catch (NamespaceException expected) { + // this is an expanded svName using an unregistered namespace + // we need to make up a prefix for the namespace + prefix = "ns_" + UUID.randomUUID().toString().substring(0, 8); Review Comment: That's temporary. We already have other places where we create ns prefixes, I'm going to clone from there. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: oak-dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org