@Override public void exportDocumentView(String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse) throws SAXException, RepositoryException { export(checkNotNull(absPath), new DocumentViewExporter(this, checkNotNull(contentHandler), !noRecurse, !skipBinary)); }
/** * 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); } }
@Override protected void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException { if ("jcr:system".equals(node.getName())) { // skip version history return; } super.exportNode(uri, local, node); } });
@Override protected void exportProperty(String uri, String local, int type, Value[] values) { try { final StringBuilder attribute = new StringBuilder(""); for (Value value : values) { attribute.append(getPropertyTypePrefix(value)); attribute.append(serializeValue(value, type)); attribute.append(","); } final String name = StringUtils.isEmpty(uri) ? ISO9075.encode(serializeKey(uri, local)) : local; final String attributeString = "[" + (values.length == 0 ? "" : attribute.substring(0, attribute.length() - 1)) + "]"; super.addAttribute(uri, name, attributeString); } catch (RepositoryException e) { throw new RuntimeException(e); } }
@Override protected void exportNodes(Node node) throws RepositoryException, SAXException { if (!JcrUtils.isVirtual(node)) { super.exportNodes(node); } }
/** * Maps the given single-valued property to an XML attribute. */ protected void exportProperty(String uri, String local, Value value) throws RepositoryException { // TODO: Serialized names and paths should use XML namespace mappings String attribute = ValueHelper.serialize(value, false); addAttribute(uri, ISO9075.encode(local), attribute); }
/** * 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); } }
@Override public void exportDocumentView(String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse) throws SAXException, RepositoryException { export(checkNotNull(absPath), new DocumentViewExporter(this, checkNotNull(contentHandler), !noRecurse, !skipBinary)); }
/** * Maps the given single-valued property to an XML attribute. */ protected void exportProperty(String uri, String local, Value value) throws RepositoryException { // TODO: Serialized names and paths should use XML namespace mappings String attribute = ValueHelper.serialize(value, false); addAttribute(uri, ISO9075.encode(local), attribute); }
@Override protected void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException { if (node.getDepth() == 0) { //don't include root node final NodeIterator iterator = node.getNodes(); while (iterator.hasNext()) { final Node child = iterator.nextNode(); super.exportNode(StringUtils.EMPTY, serializeKey(uri, child.getName()), child); //omit jcr: prefix for all child nodes } } else { super.exportNode(uri, serializeKey(uri, local), node); } }
/** * 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); } }
@Override public void exportDocumentView(String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse) throws SAXException, RepositoryException { export(checkNotNull(absPath), new DocumentViewExporter(this, checkNotNull(contentHandler), !noRecurse, !skipBinary)); }
/** * Maps the given single-valued property to an XML attribute. */ protected void exportProperty(String uri, String local, Value value) throws RepositoryException { // TODO: Serialized names and paths should use XML namespace mappings String attribute = ValueHelper.serialize(value, false); addAttribute(uri, ISO9075.encode(local), attribute); }
/** * Generates a document view export using a {@link DocumentViewExporter} * instance. * * @param path of the node to be exported * @param handler handler for the SAX events of the export * @param skipBinary whether binary values should be skipped * @param noRecurse whether to export just the identified node * @throws PathNotFoundException if a node at the given path does not exist * @throws SAXException if the SAX event handler failed * @throws RepositoryException if another error occurs */ public void exportDocumentView( String path, ContentHandler handler, boolean skipBinary, boolean noRecurse) throws PathNotFoundException, SAXException, RepositoryException { export(path, new DocumentViewExporter( this, handler, !noRecurse, !skipBinary)); }
@Override protected void exportProperty(String uri, String local, Value value) throws RepositoryException { //mgnl:contentNode is the default nodeType, no need to export it, this saves a lot of lines e.g. in the configuration workspace export if (JcrConstants.JCR_PRIMARYTYPE.equals(getXMLName(uri, local)) && NodeTypes.ContentNode.NAME.equals(value.getString())) { return; } final String name = ISO9075.encode(serializeKey(uri, local)); final String attribute = serializeValue(value, value.getType()); final String propertyType = getPropertyTypePrefix(value); super.addAttribute(uri, name, propertyType + attribute); }
/** * Generates a document view export using a {@link DocumentViewExporter} * instance. * * @param path of the node to be exported * @param handler handler for the SAX events of the export * @param skipBinary whether binary values should be skipped * @param noRecurse whether to export just the identified node * @throws PathNotFoundException if a node at the given path does not exist * @throws SAXException if the SAX event handler failed * @throws RepositoryException if another error occurs */ public void exportDocumentView( String path, ContentHandler handler, boolean skipBinary, boolean noRecurse) throws PathNotFoundException, SAXException, RepositoryException { export(path, new DocumentViewExporter( this, handler, !noRecurse, !skipBinary)); }
/** * Generates a document view export using a {@link DocumentViewExporter} * instance. * * @param path of the node to be exported * @param handler handler for the SAX events of the export * @param skipBinary whether binary values should be skipped * @param noRecurse whether to export just the identified node * @throws PathNotFoundException if a node at the given path does not exist * @throws SAXException if the SAX event handler failed * @throws RepositoryException if another error occurs */ public void exportDocumentView( String path, ContentHandler handler, boolean skipBinary, boolean noRecurse) throws PathNotFoundException, SAXException, RepositoryException { export(path, new DocumentViewExporter( this, handler, !noRecurse, !skipBinary)); }
@Override public void exportDocumentView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse) throws IOException, RepositoryException { try { ContentHandler handler = new ToXmlContentHandler(checkNotNull(out)); export(checkNotNull(absPath), new DocumentViewExporter(this, handler, !noRecurse, !skipBinary)); } catch (SAXException e) { Exception exception = e.getException(); if (exception instanceof RepositoryException) { throw (RepositoryException) exception; } else if (exception instanceof IOException) { throw (IOException) exception; } else { throw new RepositoryException( "Error serializing document view XML", e); } } }
@Override public void exportDocumentView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse) throws IOException, RepositoryException { try { ContentHandler handler = new ToXmlContentHandler(checkNotNull(out)); export(checkNotNull(absPath), new DocumentViewExporter(this, handler, !noRecurse, !skipBinary)); } catch (SAXException e) { Exception exception = e.getException(); if (exception instanceof RepositoryException) { throw (RepositoryException) exception; } else if (exception instanceof IOException) { throw (IOException) exception; } else { throw new RepositoryException( "Error serializing document view XML", e); } } }
@Override public void exportDocumentView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse) throws IOException, RepositoryException { try { ContentHandler handler = new ToXmlContentHandler(checkNotNull(out)); export(checkNotNull(absPath), new DocumentViewExporter(this, handler, !noRecurse, !skipBinary)); } catch (SAXException e) { Exception exception = e.getException(); if (exception instanceof RepositoryException) { throw (RepositoryException) exception; } else if (exception instanceof IOException) { throw (IOException) exception; } else { throw new RepositoryException( "Error serializing document view XML", e); } } }