org.apache.jackrabbit.server.io
Class XMLImportCommand

java.lang.Object
  extended byorg.apache.jackrabbit.server.io.AbstractCommand
      extended byorg.apache.jackrabbit.server.io.XMLImportCommand
All Implemented Interfaces:
org.apache.commons.chain.Command, org.apache.jackrabbit.JcrConstants

public class XMLImportCommand
extends AbstractCommand

This Class implements an import command that deserializes the xml contained in the import stream, using Session.importXML(String, java.io.InputStream, int). It further sets the following properties:


Field Summary
static String XML_CONTENT_TYPE
          the xml content type
 
Fields inherited from interface org.apache.jackrabbit.JcrConstants
JCR_AUTOCREATED, JCR_BASEVERSION, JCR_CHILD, JCR_CHILDNODEDEFINITION, JCR_CONTENT, JCR_CREATED, JCR_DATA, JCR_DEFAULTPRIMARYTYPE, JCR_DEFAULTVALUES, JCR_ENCODING, JCR_FROZENMIXINTYPES, JCR_FROZENNODE, JCR_FROZENPRIMARYTYPE, JCR_FROZENUUID, JCR_HASORDERABLECHILDNODES, JCR_ISCHECKEDOUT, JCR_ISMIXIN, JCR_LANGUAGE, JCR_LASTMODIFIED, JCR_LOCKISDEEP, JCR_LOCKOWNER, JCR_MANDATORY, JCR_MERGEFAILED, JCR_MIMETYPE, JCR_MIXINTYPES, JCR_MULTIPLE, JCR_NAME, JCR_NODETYPENAME, JCR_ONPARENTVERSION, JCR_PATH, JCR_PREDECESSORS, JCR_PRIMARYITEMNAME, JCR_PRIMARYTYPE, JCR_PROPERTYDEFINITION, JCR_PROTECTED, JCR_REQUIREDPRIMARYTYPES, JCR_REQUIREDTYPE, JCR_ROOTVERSION, JCR_SAMENAMESIBLINGS, JCR_SCORE, JCR_STATEMENT, JCR_SUCCESSORS, JCR_SUPERTYPES, JCR_SYSTEM, JCR_UUID, JCR_VALUECONSTRAINTS, JCR_VERSIONABLEUUID, JCR_VERSIONHISTORY, JCR_VERSIONLABELS, JCR_VERSIONSTORAGE, MIX_LOCKABLE, MIX_REFERENCEABLE, MIX_VERSIONABLE, NT_BASE, NT_CHILDNODEDEFINITION, NT_FILE, NT_FOLDER, NT_FROZENNODE, NT_HIERARCHYNODE, NT_LINKEDFILE, NT_NODETYPE, NT_PROPERTYDEFINITION, NT_QUERY, NT_RESOURCE, NT_UNSTRUCTURED, NT_VERSION, NT_VERSIONEDCHILD, NT_VERSIONHISTORY, NT_VERSIONLABELS
 
Constructor Summary
XMLImportCommand()
           
 
Method Summary
 boolean canHandle(String contentType)
          Returns true if the given content type is equal to XML_CONTENT_TYPE.
 boolean execute(AbstractContext context)
          Executes this command by calling importResource(org.apache.jackrabbit.server.io.ImportContext, javax.jcr.Node, java.io.InputStream) if the given context is of the correct class.
 boolean execute(ImportContext context)
          Executes this command.
 String getContentNodeType()
          Returns the nodetype for the jcr:content node
 boolean importResource(ImportContext ctx, Node parentNode, InputStream in)
          Imports the resource by deseriaizing the xml.
 void setContentNodeType(String contentNodeType)
          Sets the nodetype for the jcr:content node.
 void setNodeType(String nodeType)
          Sets the node type
 
Methods inherited from class org.apache.jackrabbit.server.io.AbstractCommand
execute, getId, setEnabled, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_CONTENT_TYPE

public static final String XML_CONTENT_TYPE
the xml content type

See Also:
Constant Field Values
Constructor Detail

XMLImportCommand

public XMLImportCommand()
Method Detail

execute

public boolean execute(AbstractContext context)
                throws Exception
Executes this command by calling importResource(org.apache.jackrabbit.server.io.ImportContext, javax.jcr.Node, java.io.InputStream) if the given context is of the correct class.

Specified by:
execute in class AbstractCommand
Parameters:
context - the (import) context.
Returns:
the return value of the delegated method or false;
Throws:
Exception - in an error occurrs

execute

public boolean execute(ImportContext context)
                throws Exception
Executes this command. It checks if this command can handle the content type and delegates it to importResource(org.apache.jackrabbit.server.io.ImportContext, javax.jcr.Node, java.io.InputStream). If the import is successfull, the input stream of the importcontext is cleared.

Parameters:
context - the import context
Returns:
false
Throws:
Exception - if an error occurrs

importResource

public boolean importResource(ImportContext ctx,
                              Node parentNode,
                              InputStream in)
                       throws Exception
Imports the resource by deseriaizing the xml.

Parameters:
ctx -
parentNode -
in -
Returns:
Throws:
Exception

canHandle

public boolean canHandle(String contentType)
Returns true if the given content type is equal to XML_CONTENT_TYPE.

Parameters:
contentType - the content type to check.
Returns:
true if equal to XML_CONTENT_TYPE.

getContentNodeType

public String getContentNodeType()
Returns the nodetype for the jcr:content node

Returns:

setContentNodeType

public void setContentNodeType(String contentNodeType)
Sets the nodetype for the jcr:content node.

Parameters:
contentNodeType -

setNodeType

public void setNodeType(String nodeType)
Sets the node type

Parameters:
nodeType -


Copyright © 2005 . All Rights Reserved.