jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicolas " <nto...@gmail.com>
Subject Re: exportDocumentView and importXML ?
Date Tue, 28 Nov 2006 10:27:11 GMT
Hi Michael,

You are exporting /jcr:system/ which is read only and then reimporting them.
Besides there are issues also with UUID and importation of the root node
with this uuidBehaviour. If you need, I can explain in more depth.

Here is how it is done on the backup tool to avoid exporting the jcr:system
subtree. (in the backup tool case, the versioning history is backuped by
another class.)

 /* (non-Javadoc)
     * @see org.apache.jackrabbijcr:root/t.backup.Backup#backup(org.apache.jackrabbit.backup.BackupIOHandler)
     */
    public void backup(BackupIOHandler h) throws RepositoryException,

    IOException {
        SessionImpl s = (SessionImpl)
this.getRepo().login(this.getCredentials(), this.wspName);

        SAXTransformerFactory stf = (SAXTransformerFactory)
SAXTransformerFactory.newInstance
();
        File temp = new File(this.getConf().getWorkFolder() + "wsp.xml");
        try {
            TransformerHandler th = stf.newTransformerHandler();
            th.setResult(new StreamResult(new FileOutputStream(temp)));

            th.getTransformer().setParameter(OutputKeys.METHOD, "xml");
            th.getTransformer().setParameter(OutputKeys.ENCODING, "UTF-8");
            th.getTransformer().setParameter(
OutputKeys.INDENT, "no");

            new SysViewSAXEventGenerator(
                    s.getRootNode(), false, false, th) {
                protected void process(Node node, int level)

                throws RepositoryException, SAXException {
                    if (!"/jcr:system".equals(node.getPath())) {
                        super.process(node, level);
                    }
                }

            }.serialize();
            h.write("export_"+ this.wspName +".xml", temp);
        } catch (TransformerException te) {
            throw new RepositoryException(te);
        } catch (SAXException se) {

            throw new RepositoryException(se);
        } finally {
            temp.delete();
        }

    }


On a sidenote, for your use case I would use system view instead of the
document view.

BR,
Nicolas

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message