Package org.apache.jackrabbit.server.io
Class ZipHandler
- java.lang.Object
-
- org.apache.jackrabbit.server.io.DefaultHandler
-
- org.apache.jackrabbit.server.io.ZipHandler
-
- All Implemented Interfaces:
CopyMoveHandler,DeleteHandler,IOHandler,PropertyHandler
public class ZipHandler extends DefaultHandler
ZipHandlerimports 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 propertyZIP_MIMETYPEdefined with its content. Furthermore the content must not represent a zip-file that has been imported to a binaryproperty, which is properly handled by theDefaultHandler.
-
-
Field Summary
Fields Modifier and Type Field Description static StringZIP_MIMETYPEthe zip mimetype
-
Constructor Summary
Constructors Constructor Description ZipHandler()Creates a newZipHandlerwith default nodetype definitions and without setting the IOManager.ZipHandler(IOManager ioManager)Creates a newZipHandlerwith default nodetype definitions:
Nodetype for Collection:nt:unstructuredNodetype for Non-Collection:nt:fileNodetype for Non-Collection content:nt:unstructuredZipHandler(IOManager ioManager, String collectionNodetype, String defaultNodetype, String contentNodetype)Creates a newZipHandler
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanExport(ExportContext context, boolean isCollection)Returns true if the export root is a node and if it contains a child node with namejcr:contentin case this export is not intended for a collection.booleancanImport(ImportContext context, boolean isCollection)Returns true, if this handler can run a successful import based on the specified context.protected voidexportData(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.
Please note, that subclasses that define a different structure of the content node should create their ownexportDatamethod.protected booleanimportData(ImportContext context, boolean isCollection, Node contentNode)Imports the data present on the import context to the specified content node.voidsetIntermediateSave(boolean intermediateSave)If set totruethe import root will besavedafter every imported zip entry.-
Methods inherited from class org.apache.jackrabbit.server.io.DefaultHandler
canCopy, canDelete, canExport, canExport, canImport, canImport, canMove, copy, delete, detect, exportContent, exportContent, exportProperties, exportProperties, forceCompatibleContentNodes, getCollectionNodeType, getContentNode, getContentNode, getContentNodeType, getIOManager, getName, getNodeType, importContent, importContent, importProperties, importProperties, move, setCollectionNodetype, setContentNodetype, setDefaultNodetype, setIOManager
-
-
-
-
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 newZipHandlerwith default nodetype definitions and without setting the IOManager.- See Also:
IOHandler.setIOManager(IOManager)
-
ZipHandler
public ZipHandler(IOManager ioManager)
Creates a newZipHandlerwith default nodetype definitions:
- Nodetype for Collection:
nt:unstructured - Nodetype for Non-Collection:
nt:file - Nodetype for Non-Collection content:
nt:unstructured
- Parameters:
ioManager-- Throws:
IllegalArgumentException- if the specifiedIOManagerisnull
- Nodetype for Collection:
-
ZipHandler
public ZipHandler(IOManager ioManager, String collectionNodetype, String defaultNodetype, String contentNodetype)
Creates a newZipHandler- Parameters:
ioManager-collectionNodetype-defaultNodetype-contentNodetype-- Throws:
IllegalArgumentException- if the specifiedIOManagerisnull
-
-
Method Detail
-
setIntermediateSave
public void setIntermediateSave(boolean intermediateSave)
If set totruethe import root will besavedafter 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:IOHandlerReturns true, if this handler can run a successful import based on the specified context.- Specified by:
canImportin interfaceIOHandler- Overrides:
canImportin classDefaultHandler- See Also:
IOHandler.canImport(ImportContext, boolean)
-
importData
protected boolean importData(ImportContext context, boolean isCollection, Node contentNode) throws IOException, RepositoryException
Description copied from class:DefaultHandlerImports the data present on the import context to the specified content node.- Overrides:
importDatain classDefaultHandler- Throws:
IOExceptionRepositoryException- See Also:
DefaultHandler.importData(ImportContext, boolean, Node)
-
canExport
public boolean canExport(ExportContext context, boolean isCollection)
Description copied from class:DefaultHandlerReturns true if the export root is a node and if it contains a child node with namejcr:contentin case this export is not intended for a collection.- Specified by:
canExportin interfaceIOHandler- Overrides:
canExportin classDefaultHandler- 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:DefaultHandlerChecks 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 ownexportDatamethod.- Overrides:
exportDatain classDefaultHandler- Parameters:
context- export contextisCollection-trueif collectioncontentNode- the content node- Throws:
IOException- if an I/O error occursRepositoryException- See Also:
DefaultHandler.exportData(ExportContext,boolean,Node)
-
-