/** * Returns the prefixed JCR name for the namespace URI and local name * using the current namespace mappings. * * @param uri namespace URI * @param name namespace-local name * @return prefixed JCR name * @throws RepositoryException if an error occurs */ private String getName(String name) throws RepositoryException { return new NamespaceHelper(getSession()).getJcrName(name); }
/** * Safely registers all namespaces in the given map from * prefixes to namespace URIs. * * @param namespaces namespace mappings * @throws RepositoryException if the namespaces could not be registered */ public void registerNamespaces(Map<String,String> namespaces) throws RepositoryException { for (Map.Entry<String, String> stringStringEntry : namespaces.entrySet()) { Map.Entry<String, String> entry = stringStringEntry; registerNamespace(entry.getKey(), entry.getValue()); } }
public ImportHandler(Importer importer, Session session) throws RepositoryException { this.importer = importer; this.helper = new NamespaceHelper(session); this.localNamespaceMappings = helper.getNamespaces(); this.valueFactory = session.getValueFactory(); }
/** * Records the given namespace mapping to be included in the local * namespace context. The local namespace context is instantiated * in {@link #startElement(String, String, String, Attributes)} using * all the the namespace mappings recorded for the current XML element. * <p> * The namespace is also recorded in the persistent namespace registry * unless it is already known. * * @param prefix namespace prefix * @param uri namespace URI */ @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { try { new NamespaceHelper(sessionContext.getSession()).registerNamespace( prefix, uri); if (targetHandler != null) { targetHandler.startPrefixMapping(prefix, uri); } else { tempPrefixMap.put(prefix, uri); } } catch (RepositoryException re) { throw new SAXException(re); } }
/** * Creates an exporter instance. * * @param session current session * @param handler SAX event handler * @param recurse whether the export should be recursive * @param binary whether the export should include binary values */ protected Exporter( Session session, ContentHandler handler, boolean recurse, boolean binary) { this.session = session; this.helper = new NamespaceHelper(session); this.handler = handler; this.recurse = recurse; this.binary = binary; stack.add(new HashMap()); }
new NamespaceHelper(context.getSessionImpl()).registerNamespaces(namespaceMap);
/** * Exports the given node either as XML characters (if it's an * <code>xml:text</code> node) or as an XML element with properties * mapped to XML attributes. */ protected void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException { if (NamespaceHelper.JCR.equals(uri) && "xmltext".equals(local)) { try { // assume jcr:xmlcharacters is single-valued Property property = node.getProperty(helper.getJcrName("jcr:xmlcharacters")); char[] ch = property.getString().toCharArray(); characters(ch, 0, ch.length); } catch (PathNotFoundException e) { // jcr:xmlcharacters not found, ignore this node } } else { // attributes (properties) exportProperties(node); // encode node name to make sure it's a valid xml name String encoded = ISO9075.encode(local); startElement(uri, encoded); exportNodes(node); endElement(uri, encoded); } }
/** * Records the given namespace mapping to be included in the local * namespace context. The local namespace context is instantiated * in {@link #startElement(String, String, String, Attributes)} using * all the the namespace mappings recorded for the current XML element. * <p> * The namespace is also recorded in the persistent namespace registry * unless it is already known. * * @param prefix namespace prefix * @param uri namespace URI */ @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { try { new NamespaceHelper(sessionContext.getSession()).registerNamespace( prefix, uri); if (targetHandler != null) { targetHandler.startPrefixMapping(prefix, uri); } else { tempPrefixMap.put(prefix, uri); } } catch (RepositoryException re) { throw new SAXException(re); } }
/** * Creates an exporter instance. * * @param session current session * @param handler SAX event handler * @param recurse whether the export should be recursive * @param binary whether the export should include binary values */ protected Exporter( Session session, ContentHandler handler, boolean recurse, boolean binary) { this.session = session; this.helper = new NamespaceHelper(session); this.handler = handler; this.recurse = recurse; this.binary = binary; stack.add(new HashMap()); }
new NamespaceHelper(context.getSessionImpl()).registerNamespaces(namespaceMap);
/** * Exports the given node either as XML characters (if it's an * <code>xml:text</code> node) or as an XML element with properties * mapped to XML attributes. */ protected void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException { if (NamespaceHelper.JCR.equals(uri) && "xmltext".equals(local)) { try { // assume jcr:xmlcharacters is single-valued Property property = node.getProperty(helper.getJcrName("jcr:xmlcharacters")); char[] ch = property.getString().toCharArray(); characters(ch, 0, ch.length); } catch (PathNotFoundException e) { // jcr:xmlcharacters not found, ignore this node } } else { // attributes (properties) exportProperties(node); // encode node name to make sure it's a valid xml name String encoded = ISO9075.encode(local); startElement(uri, encoded); exportNodes(node); endElement(uri, encoded); } }
/** * Records the given namespace mapping to be included in the local * namespace context. The local namespace context is instantiated * in {@link #startElement(String, String, String, Attributes)} using * all the the namespace mappings recorded for the current XML element. * <p> * The namespace is also recorded in the persistent namespace registry * unless it is already known. * * @param prefix namespace prefix * @param uri namespace URI */ @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { try { new NamespaceHelper(sessionContext.getSession()).registerNamespace( prefix, uri); if (targetHandler != null) { targetHandler.startPrefixMapping(prefix, uri); } else { tempPrefixMap.put(prefix, uri); } } catch (RepositoryException re) { throw new SAXException(re); } }
/** * Returns the prefixed JCR name for the namespace URI and local name * using the current namespace mappings. * * @param uri namespace URI * @param name namespace-local name * @return prefixed JCR name * @throws RepositoryException if an error occurs */ private String getName(String name) throws RepositoryException { return new NamespaceHelper(getSession()).getJcrName(name); }
/** * Safely registers all namespaces in the given map from * prefixes to namespace URIs. * * @param namespaces namespace mappings * @throws RepositoryException if the namespaces could not be registered */ public void registerNamespaces(Map<String,String> namespaces) throws RepositoryException { for (Map.Entry<String, String> stringStringEntry : namespaces.entrySet()) { Map.Entry<String, String> entry = stringStringEntry; registerNamespace(entry.getKey(), entry.getValue()); } }
/** * Creates an exporter instance. * * @param session current session * @param handler SAX event handler * @param recurse whether the export should be recursive * @param binary whether the export should include binary values */ protected Exporter( Session session, ContentHandler handler, boolean recurse, boolean binary) { this.session = session; this.helper = new NamespaceHelper(session); this.handler = handler; this.recurse = recurse; this.binary = binary; stack.add(new HashMap()); }
public ImportHandler(Importer importer, Session session) throws RepositoryException { this.importer = importer; this.helper = new NamespaceHelper(session); this.localNamespaceMappings = helper.getNamespaces(); this.valueFactory = session.getValueFactory(); }
/** * Exports the given node either as XML characters (if it's an * <code>xml:text</code> node) or as an XML element with properties * mapped to XML attributes. */ protected void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException { if (NamespaceHelper.JCR.equals(uri) && "xmltext".equals(local)) { try { // assume jcr:xmlcharacters is single-valued Property property = node.getProperty(helper.getJcrName("jcr:xmlcharacters")); char[] ch = property.getString().toCharArray(); characters(ch, 0, ch.length); } catch (PathNotFoundException e) { // jcr:xmlcharacters not found, ignore this node } } else { // attributes (properties) exportProperties(node); // encode node name to make sure it's a valid xml name String encoded = ISO9075.encode(local); startElement(uri, encoded); exportNodes(node); endElement(uri, encoded); } }
/** * Build jcr property name from dav property name. If the property name * defines a namespace uri, that has not been registered yet, an attempt * is made to register the uri with the prefix defined. * * @param propName name of the dav property * @param session repository session * @return jcr name * @throws RepositoryException if an error during repository access occurs. */ private String getJcrName(DavPropertyName propName, Session session) throws RepositoryException { // remove any encoding necessary for xml compliance String pName = ISO9075.decode(propName.getName()); Namespace propNamespace = propName.getNamespace(); if (!Namespace.EMPTY_NAMESPACE.equals(propNamespace)) { NamespaceHelper helper = new NamespaceHelper(session); String prefix = helper.registerNamespace( propNamespace.getPrefix(), propNamespace.getURI()); pName = prefix + ":" + pName; } return pName; }
/** * Returns the prefixed JCR name for the namespace URI and local name * using the current namespace mappings. * * @param uri namespace URI * @param name namespace-local name * @return prefixed JCR name * @throws RepositoryException if an error occurs */ private String getName(String name) throws RepositoryException { return new NamespaceHelper(getSession()).getJcrName(name); }
/** * Safely registers all namespaces in the given map from * prefixes to namespace URIs. * * @param namespaces namespace mappings * @throws RepositoryException if the namespaces could not be registered */ public void registerNamespaces(Map<String,String> namespaces) throws RepositoryException { for (Map.Entry<String, String> stringStringEntry : namespaces.entrySet()) { Map.Entry<String, String> entry = stringStringEntry; registerNamespace(entry.getKey(), entry.getValue()); } }