JCR Import Export
1 Introduction
There are a number of use cases that XML Import/Export can satisfy. Content Exchange Allows the exchange of JCR content with other content consumers. Archival Purposes Many business and governmental organizations have strict legal requirements regarding the availability of content and information. XML Import/Export facilitates this with the help of the ability to periodically export a JCR or a subset of workspaces to a secure storage. Application Import/Export Applications often need to exchange data between systems in an application specific fashion, the JCR XML Import/Export specification allows the architecture to define adapters for content import and export as well as shipping default adapters for content. This is to facilitate integrators and developers utilizing the framework when developing their own application specific import/export adapters.2 Export
Specification describes four methods for exporting. Two methods use “Document” and another two “System” view as interchange format (see JSR-170 for details).- Session.exportSystemView(String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse)
- Session.exportSystemView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse)
- Session.exportDocumentView(String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse)
- Session.exportDocumentView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse)
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file)); session.exportSystemView(node.getPath(), bufferedOutputStream, false, false); bufferedOutputStream.close();
3 Import
JSR-170 specifies four methods for content importing (two provided by Workspace interface and other two by Session):- Workspace.getImportContentHandler
- Workspace.importXML
- Session.getImportContentHandler
- Session.importXML
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file)); session.importXML(root.getPath(), bufferedInputStream, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
on 13/08/2009 at 14:56