org.apache.jackrabbit.server.io
Class ZipHandler

java.lang.Object
  extended by org.apache.jackrabbit.server.io.DefaultHandler
      extended by org.apache.jackrabbit.server.io.ZipHandler
All Implemented Interfaces:
IOHandler, PropertyHandler

public class ZipHandler
extends DefaultHandler

ZipHandler imports and extracts Zip files and exported nodes (an their subnodes) to a Zip file. Please not that for the export the selected export root must have the property ZIP_MIMETYPE defined with its content. Furthermore the content must not represent a zip-file that has been imported to a binary property, which is properly handled by the DefaultHandler.


Field Summary
static String ZIP_MIMETYPE
          the zip mimetype
 
Constructor Summary
ZipHandler()
          Creates a new ZipHandler with default nodetype definitions and without setting the IOManager.
ZipHandler(IOManager ioManager)
          Creates a new ZipHandler with default nodetype definitions:
Nodetype for Collection: nt:unstructured Nodetype for Non-Collection: nt:file Nodetype for Non-Collection content: nt:unstructured
ZipHandler(IOManager ioManager, String collectionNodetype, String defaultNodetype, String contentNodetype)
          Creates a new ZipHandler
 
Method Summary
 boolean canExport(ExportContext context, boolean isCollection)
          Returns true if the export root is a node and if it contains a child node with name jcr:content in case this export is not intended for a collection.
 boolean canImport(ImportContext context, boolean isCollection)
          Returns true, if this handler can run a successful import based on the specified context.
protected  void exportData(ExportContext context, boolean isCollection, Node contentNode)
          Checks if the given content node contains a jcr:data property and spools its value to the output stream of the export context.
protected  boolean importData(ImportContext context, boolean isCollection, Node contentNode)
          Imports the data present on the import context to the specified content node.
 void setIntermediateSave(boolean intermediateSave)
          If set to true the import root will be saved after every imported zip entry.
 
Methods inherited from class org.apache.jackrabbit.server.io.DefaultHandler
canExport, canExport, canImport, canImport, detect, exportContent, exportContent, exportProperties, exportProperties, forceCompatibleContentNodes, getCollectionNodeType, getContentNode, getContentNode, getContentNodeType, getIOManager, getName, getNodeType, importContent, importContent, importProperties, importProperties, setIOManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZIP_MIMETYPE

public static final String ZIP_MIMETYPE
the zip mimetype

See Also:
Constant Field Values
Constructor Detail

ZipHandler

public ZipHandler()
Creates a new ZipHandler with default nodetype definitions and without setting the IOManager.

See Also:
IOHandler.setIOManager(IOManager)

ZipHandler

public ZipHandler(IOManager ioManager)
Creates a new ZipHandler with default nodetype definitions:

Parameters:
ioManager -
Throws:
IllegalArgumentException - if the specified IOManager is null

ZipHandler

public ZipHandler(IOManager ioManager,
                  String collectionNodetype,
                  String defaultNodetype,
                  String contentNodetype)
Creates a new ZipHandler

Parameters:
ioManager -
collectionNodetype -
defaultNodetype -
contentNodetype -
Throws:
IllegalArgumentException - if the specified IOManager is null
Method Detail

setIntermediateSave

public void setIntermediateSave(boolean intermediateSave)
If set to true the import root will be saved after every imported zip entry. Note however, that this removes the possibility to revert all modifications if the import cannot be completed successfully. By default the intermediate save is disabled.

Parameters:
intermediateSave -

canImport

public boolean canImport(ImportContext context,
                         boolean isCollection)
Description copied from interface: IOHandler
Returns true, if this handler can run a successful import based on the specified context.

Specified by:
canImport in interface IOHandler
Overrides:
canImport in class DefaultHandler
Returns:
See Also:
IOHandler.canImport(ImportContext, boolean)

importData

protected boolean importData(ImportContext context,
                             boolean isCollection,
                             Node contentNode)
                      throws IOException,
                             RepositoryException
Description copied from class: DefaultHandler
Imports the data present on the import context to the specified content node.

Overrides:
importData in class DefaultHandler
Returns:
Throws:
IOException
RepositoryException
See Also:
DefaultHandler.importData(ImportContext, boolean, Node)

canExport

public boolean canExport(ExportContext context,
                         boolean isCollection)
Description copied from class: DefaultHandler
Returns true if the export root is a node and if it contains a child node with name jcr:content in case this export is not intended for a collection.

Specified by:
canExport in interface IOHandler
Overrides:
canExport in class DefaultHandler
Returns:
true if the export root is a node. If the specified boolean parameter is false (not a collection export) the given export root must contain a child node with name jcr:content.
See Also:
IOHandler.canExport(ExportContext, boolean)

exportData

protected void exportData(ExportContext context,
                          boolean isCollection,
                          Node contentNode)
                   throws IOException,
                          RepositoryException
Description copied from class: DefaultHandler
Checks if the given content node contains a jcr:data property and spools its value to the output stream of the export context.
Please note, that subclasses that define a different structure of the content node should create their own exportData method.

Overrides:
exportData in class DefaultHandler
Parameters:
context - export context
isCollection - true if collection
contentNode - the content node
Throws:
IOException - if an I/O error occurs
RepositoryException
See Also:
DefaultHandler.exportData(ExportContext,boolean,Node)


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.