public class XmlHandler extends DefaultHandler
XmlHandler
imports xml files and exports nodes that have
the proper XML_MIMETYPE
defined with their content. The export is
performed by running a document view export
for the content of the export root defined with the
specified ExportContext
.
Please note that this handler is not suited for a generic system or document
view import/export of Node
s because an extra root node is always
created during import and expected during export, respectively.
Modifier and Type | Field and Description |
---|---|
static String |
XML_MIMETYPE
the xml mimetype
|
static String |
XML_MIMETYPE_ALT
the alternative xml mimetype.
|
Constructor and Description |
---|
XmlHandler()
Creates a new
XmlHandler with default nodetype definitions
and without setting the IOManager. |
XmlHandler(IOManager ioManager)
Creates a new
XmlHandler with default nodetype definitions:Nodetype for Collection: nt:unstructured
Nodetype for Non-Collection: nt:file
Nodetype for Non-Collection content: nt:unstructured
|
XmlHandler(IOManager ioManager,
String collectionNodetype,
String defaultNodetype,
String contentNodetype)
Creates a new
XmlHandler |
Modifier and Type | Method and Description |
---|---|
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.
Please note, that subclasses that define a different structure of the content node should create their own exportData method. |
protected void |
exportProperties(ExportContext context,
boolean isCollection,
Node contentNode)
Retrieves mimetype, encoding and modification time from the content node.
|
protected boolean |
forceCompatibleContentNodes()
Defines if content nodes should be replace if they don't have the
node type given by
DefaultHandler.getCollectionNodeType() . |
protected boolean |
importData(ImportContext context,
boolean isCollection,
Node contentNode)
Imports the data present on the import context to the specified content
node.
|
protected boolean |
importProperties(ImportContext context,
boolean isCollection,
Node contentNode)
Imports the properties present on the specified context to the content
node.
|
canCopy, canDelete, canExport, canExport, canImport, canImport, canMove, copy, delete, detect, exportContent, exportContent, exportProperties, getCollectionNodeType, getContentNode, getContentNode, getContentNodeType, getIOManager, getName, getNodeType, importContent, importContent, importProperties, move, setCollectionNodetype, setContentNodetype, setDefaultNodetype, setIOManager
public static final String XML_MIMETYPE
public static final String XML_MIMETYPE_ALT
public XmlHandler()
XmlHandler
with default nodetype definitions
and without setting the IOManager.IOHandler.setIOManager(IOManager)
public XmlHandler(IOManager ioManager)
XmlHandler
with default nodetype definitions:nt:unstructured
nt:file
nt:unstructured
ioManager
- public boolean canImport(ImportContext context, boolean isCollection)
IOHandler
canImport
in interface IOHandler
canImport
in class DefaultHandler
IOHandler.canImport(ImportContext, boolean)
protected boolean importData(ImportContext context, boolean isCollection, Node contentNode) throws IOException, RepositoryException
DefaultHandler
importData
in class DefaultHandler
IOException
RepositoryException
DefaultHandler.importData(ImportContext, boolean, Node)
protected boolean importProperties(ImportContext context, boolean isCollection, Node contentNode)
DefaultHandler
importProperties
in class DefaultHandler
DefaultHandler.importProperties(ImportContext, boolean, Node)
protected boolean forceCompatibleContentNodes()
DefaultHandler.getCollectionNodeType()
.forceCompatibleContentNodes
in class DefaultHandler
true
, always.public boolean canExport(ExportContext context, boolean isCollection)
DefaultHandler
jcr:content
in case this
export is not intended for a collection.canExport
in interface IOHandler
canExport
in class DefaultHandler
jcr:content
.IOHandler.canExport(ExportContext, boolean)
protected void exportData(ExportContext context, boolean isCollection, Node contentNode) throws IOException, RepositoryException
DefaultHandler
exportData
method.exportData
in class DefaultHandler
context
- export contextisCollection
- true
if collectioncontentNode
- the content nodeIOException
- if an I/O error occursRepositoryException
DefaultHandler.exportData(ExportContext, boolean, Node)
protected void exportProperties(ExportContext context, boolean isCollection, Node contentNode) throws IOException
DefaultHandler
exportProperties
in class DefaultHandler
context
- the export contextisCollection
- true
if collectioncontentNode
- the content nodeIOException
- If an error occurs.DefaultHandler.exportProperties(ExportContext, boolean, Node)
Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.