/** * {@inheritDoc} */ public String getPrefix(String uri) throws NamespaceException { if (URIToPrefix.containsKey(uri)) { return URIToPrefix.getProperty(uri); } else if (base == null) { throw new NamespaceException("No prefix for URI '" + uri + "' declared."); } else { return base.getPrefix(uri); } }
public String getNamespaceURI(String prefix) { try { return namespaceResolver.getURI(prefix); } catch (NamespaceException e) { throw new RuntimeException(e); } } };
/** * {@inheritDoc} */ public String getPrefix(String uri) throws NamespaceException { if (URIToPrefix.containsKey(uri)) { return URIToPrefix.get(uri); } else if (base == null) { throw new NamespaceException("No prefix for URI '" + uri + "' declared."); } else { return base.getPrefix(uri); } }
public String getNamespaceURI(String prefix) { try { return namespaceResolver.getURI(prefix); } catch (NamespaceException e) { throw new RuntimeException(e); } } };
/** * {@inheritDoc} */ public String getPrefix(String uri) throws NamespaceException { if (URIToPrefix.containsKey(uri)) { return URIToPrefix.get(uri); } else if (base == null) { throw new NamespaceException("No prefix for URI '" + uri + "' declared."); } else { return base.getPrefix(uri); } }
/** * {@inheritDoc} */ public String getURI(String prefix) throws NamespaceException { if (prefixToURI.containsKey(prefix)) { return prefixToURI.getProperty(prefix); } else if (base == null) { throw new NamespaceException("No URI for pefix '" + prefix + "' declared."); } else { return base.getURI(prefix); } }
/** * Returns the qualified JCR name for the given <code>Name</code>. * Note, that the JCR prefix is always retrieved from the NamespaceResolver * even if the name is in the default namespace. This is a special treatment * for query specific implementation, which defines a prefix for all namespace * URIs including the default namespace. * * @param name A <code>Name</code> object. * @return The corresponding qualified JCR name string. * @throws NamespaceException if the namespace URI can not be resolved */ public String getJCRName(Name name) throws NamespaceException { String uri = name.getNamespaceURI(); if (resolver.getPrefix(uri).length() == 0) { return name.getLocalName(); } else { return resolver.getPrefix(uri) + ":" + name.getLocalName(); } } }
/** * {@inheritDoc} */ public String getURI(String prefix) throws NamespaceException { if (prefixToURI.containsKey(prefix)) { return prefixToURI.get(prefix); } else if (base == null) { throw new NamespaceException("No URI for prefix '" + prefix + "' declared."); } else { return base.getURI(prefix); } }
/** * Returns the qualified JCR name for the given <code>Name</code>. * Note, that the JCR prefix is always retrieved from the NamespaceResolver * even if the name is in the default namespace. This is a special treatment * for query specific implementation, which defines a prefix for all namespace * URIs including the default namespace. * * @param name A <code>Name</code> object. * @return The corresponding qualified JCR name string. * @throws NamespaceException if the namespace URI can not be resolved */ public String getJCRName(Name name) throws NamespaceException { String uri = name.getNamespaceURI(); if (resolver.getPrefix(uri).length() == 0) { return name.getLocalName(); } else { return resolver.getPrefix(uri) + ":" + name.getLocalName(); } } }
/** * {@inheritDoc} */ public String getURI(String prefix) throws NamespaceException { if (prefixToURI.containsKey(prefix)) { return prefixToURI.get(prefix); } else if (base == null) { throw new NamespaceException("No URI for prefix '" + prefix + "' declared."); } else { return base.getURI(prefix); } }
/** * Returns the prefixed JCR name for the given qualified name. * If the name is in the default namespace, then the local name * is returned without a prefix. Otherwise the prefix for the * namespace is resolved and used to construct returned the JCR name. * * @param name qualified name * @return prefixed JCR name * @throws NamespaceException if the namespace URI can not be resolved */ public String getJCRName(Name name) throws NamespaceException { String uri = name.getNamespaceURI(); if (uri.length() == 0) { return name.getLocalName(); } else { return resolver.getPrefix(uri) + ":" + name.getLocalName(); } } }
private static String convertPattern(String pattern, NamespaceResolver resolver, NamespaceMappings nsMappings) { String prefix = ""; int idx = pattern.indexOf(':'); if (idx != -1) { prefix = pattern.substring(0, idx); } StringBuffer sb = new StringBuffer(); // translate prefix try { sb.append(nsMappings.getPrefix(resolver.getURI(prefix))); } catch (NamespaceException e) { // prefix in pattern is probably unknown log.debug("unknown namespace prefix in pattern: " + pattern); // -> ignore and use empty string for index internal prefix // this will not match anything } sb.append(":"); // remaining pattern, may also be whole pattern sb.append(pattern.substring(idx + 1)); return sb.toString(); } }
/** * Returns the qualified JCR name for the given <code>Name</code> object. * If the name is in the default namespace, then the local name * is returned without a prefix. Otherwise the prefix for the * namespace is resolved and used to construct the JCR name. * * @param name A <code>Name</code> object. * @return A qualified JCR name string. * @throws NamespaceException if the namespace URI can not be resolved. * @see NameResolver#getJCRName(org.apache.jackrabbit.spi.Name) */ public String getJCRName(Name name) throws NamespaceException { String uri = name.getNamespaceURI(); if (uri.length() == 0) { return name.getLocalName(); } else { return resolver.getPrefix(uri) + ":" + name.getLocalName(); } } }
private static String convertPattern(String pattern, NamespaceResolver resolver, NamespaceMappings nsMappings) { String prefix = ""; int idx = pattern.indexOf(':'); if (idx != -1) { prefix = pattern.substring(0, idx); } StringBuffer sb = new StringBuffer(); // translate prefix try { sb.append(nsMappings.getPrefix(resolver.getURI(prefix))); } catch (NamespaceException e) { // prefix in pattern is probably unknown log.debug("unknown namespace prefix in pattern: " + pattern); // -> ignore and use empty string for index internal prefix // this will not match anything } sb.append(":"); // remaining pattern, may also be whole pattern sb.append(pattern.substring(idx + 1)); return sb.toString(); } }
/** * Returns the qualified JCR name for the given <code>Name</code> object. * If the name is in the default namespace, then the local name * is returned without a prefix. Otherwise the prefix for the * namespace is resolved and used to construct the JCR name. * * @param name A <code>Name</code> object. * @return A qualified JCR name string. * @throws NamespaceException if the namespace URI can not be resolved. * @see NameResolver#getJCRName(org.apache.jackrabbit.spi.Name) */ public String getJCRName(Name name) throws NamespaceException { String uri = name.getNamespaceURI(); if (uri.length() == 0) { return name.getLocalName(); } else { return resolver.getPrefix(uri) + ":" + name.getLocalName(); } } }
uri = resolver.getURI(prefix);
/** * {@inheritDoc} */ public void writePrivilegeDef(PrivilegeDefinition privilegeDefinition) throws JournalException { try { Map<String, String> nsMapping = new HashMap<String, String>(); String uri = privilegeDefinition.getName().getNamespaceURI(); nsMapping.put(nsResolver.getPrefix(uri), uri); for (Name n : privilegeDefinition.getDeclaredAggregateNames()) { nsMapping.put(nsResolver.getPrefix(n.getNamespaceURI()), n.getNamespaceURI()); } StringWriter sw = new StringWriter(); PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter("text/xml"); writer.writeDefinitions(sw, new PrivilegeDefinition[] {privilegeDefinition}, nsMapping); sw.close(); writeString(sw.toString()); } catch (IOException e) { String msg = "I/O error while writing privilege definition."; throw new JournalException(msg, e); } catch (NamespaceException e) { String msg = "NamespaceException error while writing privilege definition."; throw new JournalException(msg, e); } }
String uri = resolver.getURI(prefix); return factory.create(uri, nameStart == 0 ? jcrName : jcrName.substring(nameStart, len));
/** * {@inheritDoc} */ public void writePrivilegeDef(PrivilegeDefinition privilegeDefinition) throws JournalException { try { Map<String, String> nsMapping = new HashMap<String, String>(); String uri = privilegeDefinition.getName().getNamespaceURI(); nsMapping.put(nsResolver.getPrefix(uri), uri); for (Name n : privilegeDefinition.getDeclaredAggregateNames()) { nsMapping.put(nsResolver.getPrefix(n.getNamespaceURI()), n.getNamespaceURI()); } StringWriter sw = new StringWriter(); PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter("text/xml"); writer.writeDefinitions(sw, new PrivilegeDefinition[] {privilegeDefinition}, nsMapping); sw.close(); writeString(sw.toString()); } catch (IOException e) { String msg = "I/O error while writing privilege definition."; throw new JournalException(msg, e); } catch (NamespaceException e) { String msg = "NamespaceException error while writing privilege definition."; throw new JournalException(msg, e); } }
uri = resolver.getURI(prefix);