/** * {@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); } }
/** * {@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 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); } }
/** * 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(); } } }
/** * 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(); } } }
/** * 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(); } } }
/** * 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(); } } }
/** * 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(); } } }
/** * {@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); } }
/** * {@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); } }
/** * {@inheritDoc} */ @Override public void startDocument() throws SAXException { systemViewXML = false; initialized = false; targetHandler = null; /** * start initial context containing existing mappings reflected * by nsResolver */ nsContext.reset(); nsContext.pushContext(); try { String[] uris = nsReg.getURIs(); for (int i = 0; i < uris.length; i++) { nsContext.declarePrefix(nsResolver.getPrefix(uris[i]), uris[i]); } } catch (RepositoryException re) { throw new SAXException(re); } // initialize flag nsContextStarted = false; }
/** * {@inheritDoc} */ @Override public void startDocument() throws SAXException { systemViewXML = false; initialized = false; targetHandler = null; /** * start initial context containing existing mappings reflected * by nsResolver */ nsContext.reset(); nsContext.pushContext(); try { String[] uris = nsReg.getURIs(); for (int i = 0; i < uris.length; i++) { nsContext.declarePrefix(nsResolver.getPrefix(uris[i]), uris[i]); } } catch (RepositoryException re) { throw new SAXException(re); } // initialize flag nsContextStarted = false; }