jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r160914 [1/2] - in incubator/jackrabbit/trunk/contrib/jcr-server: server/ server/src/java/org/apache/jackrabbit/ server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/io/ server/src/java/org/apache/jackrabbit/server/simple/ server/src/java/org/apache/jackrabbit/server/simple/dav/ server/src/java/org/apache/jackrabbit/server/simple/dav/lock/ server/src/java/org/apache/jackrabbit/webdav/spi/ server/src/java/org/apache/jackrabbit/webdav/spi/version/ webapp/src/webapp/WEB-INF/ webdav/src/java/org/apache/jackrabbit/webdav/lock/ webdav/src/java/org/apache/jackrabbit/webdav/util/
Date Mon, 11 Apr 2005 16:05:06 GMT
Author: tripod
Date: Mon Apr 11 09:04:58 2005
New Revision: 160914

URL: http://svn.apache.org/viewcvs?view=rev&rev=160914
Log:
[JCR-103] Add plugable mechanism for import/export of dav resources

Added:
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/JCRConstants.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractImportCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddMixinCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddNodeCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/BoundedInputStream.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportCollectionChain.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportNCResourceChain.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportCollectionChain.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportNCResourceChain.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLExportCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZIPImportCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/package.html   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/simple_catalog.xml   (with props)
Removed:
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionControlledItemCollection.java
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavResourceImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/NodeResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/ItemResourceConstants.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/Text.java

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml Mon Apr 11 09:04:58 2005
@@ -68,6 +68,18 @@
             <id>jcr-rmi</id>
             <version>0.16.2</version>
         </dependency>
+        <dependency>
+            <id>commons-chain</id>
+            <version>1.0</version>
+        </dependency>
+        <dependency>
+            <id>commons-digester</id>
+            <version>1.6</version>
+        </dependency>
+        <dependency>
+            <id>commons-beanutils</id>
+            <version>1.7.0</version>
+        </dependency>
         <!-- dependencies of jackrabbit -->
         <!--
         <dependency>

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/JCRConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/JCRConstants.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/JCRConstants.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/JCRConstants.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,390 @@
+/*
+ * Copyright (c) 2005 Your Corporation. All Rights Reserved.
+ */
+package org.apache.jackrabbit;
+
+/**
+ * This Interface defines some jcr constants
+ */
+public interface JCRConstants {
+    /**
+     * jcr:autoCreate
+     */
+    public static final String JCR_AUTOCREATE = "jcr:autoCreate";
+    /**
+     * jcr:baseVersion
+     */
+    public static final String JCR_BASEVERSION = "jcr:baseVersion";
+    /**
+     * jcr:child
+     */
+    public static final String JCR_CHILD = "jcr:child";
+    /**
+     * jcr:childNodeDef
+     */
+    public static final String JCR_CHILDNODEDEF = "jcr:childNodeDef";
+    /**
+     * jcr:content
+     */
+    public static final String JCR_CONTENT = "jcr:content";
+    /**
+     * jcr:created
+     */
+    public static final String JCR_CREATED = "jcr:created";
+    /**
+     * jcr:data
+     */
+    public static final String JCR_DATA = "jcr:data";
+    /**
+     * jcr:defaultPrimaryType
+     */
+    public static final String JCR_DEFAULTPRIMARYTYPE = "jcr:defaultPrimaryType";
+    /**
+     * jcr:defaultValues
+     */
+    public static final String JCR_DEFAULTVALUES = "jcr:defaultValues";
+    /**
+     * jcr:encoding
+     */
+    public static final String JCR_ENCODING = "jcr:encoding";
+    /**
+     * jcr:frozenMixinTypes
+     */
+    public static final String JCR_FROZENMIXINTYPES = "jcr:frozenMixinTypes";
+    /**
+     * jcr:frozenNode
+     */
+    public static final String JCR_FROZENNODE = "jcr:frozenNode";
+    /**
+     * jcr:frozenPrimaryType
+     */
+    public static final String JCR_FROZENPRIMARYTYPE = "jcr:frozenPrimaryType";
+    /**
+     * jcr:frozenUuid
+     */
+    public static final String JCR_FROZENUUID = "jcr:frozenUuid";
+    /**
+     * jcr:hasOrderableChildNodes
+     */
+    public static final String JCR_HASORDERABLECHILDNODES = "jcr:hasOrderableChildNodes";
+    /**
+     * jcr:isCheckedOut
+     */
+    public static final String JCR_ISCHECKEDOUT = "jcr:isCheckedOut";
+    /**
+     * jcr:isMixin
+     */
+    public static final String JCR_ISMIXIN = "jcr:isMixin";
+    /**
+     * jcr:language
+     */
+    public static final String JCR_LANGUAGE = "jcr:language";
+    /**
+     * jcr:lastModified
+     */
+    public static final String JCR_LASTMODIFIED = "jcr:lastModified";
+    /**
+     * jcr:lockIsDeep
+     */
+    public static final String JCR_LOCKISDEEP = "jcr:lockIsDeep";
+    /**
+     * jcr:lockOwner
+     */
+    public static final String JCR_LOCKOWNER = "jcr:lockOwner";
+    /**
+     * jcr:mandatory
+     */
+    public static final String JCR_MANDATORY = "jcr:mandatory";
+    /**
+     * jcr:mergeFailed
+     */
+    public static final String JCR_MERGEFAILED = "jcr:mergeFailed";
+    /**
+     * jcr:mimeType
+     */
+    public static final String JCR_MIMETYPE = "jcr:mimeType";
+    /**
+     * jcr:mixinTypes
+     */
+    public static final String JCR_MIXINTYPES = "jcr:mixinTypes";
+    /**
+     * jcr:multiple
+     */
+    public static final String JCR_MULTIPLE = "jcr:multiple";
+    /**
+     * jcr:name
+     */
+    public static final String JCR_NAME = "jcr:name";
+    /**
+     * jcr:nodeTypeName
+     */
+    public static final String JCR_NODETYPENAME = "jcr:nodeTypeName";
+    /**
+     * jcr:onParentVersion
+     */
+    public static final String JCR_ONPARENTVERSION = "jcr:onParentVersion";
+    /**
+     * jcr:predecessors
+     */
+    public static final String JCR_PREDECESSORS = "jcr:predecessors";
+    /**
+     * jcr:primaryItemName
+     */
+    public static final String JCR_PRIMARYITEMNAME = "jcr:primaryItemName";
+    /**
+     * jcr:primaryType
+     */
+    public static final String JCR_PRIMARYTYPE = "jcr:primaryType";
+    /**
+     * jcr:propertyDef
+     */
+    public static final String JCR_PROPERTYDEF = "jcr:propertyDef";
+    /**
+     * jcr:protected
+     */
+    public static final String JCR_PROTECTED = "jcr:protected";
+    /**
+     * jcr:requiredPrimaryTypes
+     */
+    public static final String JCR_REQUIREDPRIMARYTYPES = "jcr:requiredPrimaryTypes";
+    /**
+     * jcr:requiredType
+     */
+    public static final String JCR_REQUIREDTYPE = "jcr:requiredType";
+    /**
+     * jcr:rootVersion
+     */
+    public static final String JCR_ROOTVERSION = "jcr:rootVersion";
+    /**
+     * jcr:sameNameSibs
+     */
+    public static final String JCR_SAMENAMESIBS = "jcr:sameNameSibs";
+    /**
+     * jcr:statement
+     */
+    public static final String JCR_STATEMENT = "jcr:statement";
+    /**
+     * jcr:successors
+     */
+    public static final String JCR_SUCCESSORS = "jcr:successors";
+    /**
+     * jcr:supertypes
+     */
+    public static final String JCR_SUPERTYPES = "jcr:supertypes";
+    /**
+     * jcr:system
+     */
+    public static final String JCR_SYSTEM = "jcr:system";
+    /**
+     * jcr:uuid
+     */
+    public static final String JCR_UUID = "jcr:uuid";
+    /**
+     * jcr:valueConstraints
+     */
+    public static final String JCR_VALUECONSTRAINTS = "jcr:valueConstraints";
+    /**
+     * jcr:versionHistory
+     */
+    public static final String JCR_VERSIONHISTORY = "jcr:versionHistory";
+    /**
+     * jcr:versionLabels
+     */
+    public static final String JCR_VERSIONLABELS = "jcr:versionLabels";
+    /**
+     * jcr:versionStorage
+     */
+    public static final String JCR_VERSIONSTORAGE = "jcr:versionStorage";
+    /**
+     * mix:accessControllable
+     */
+    public static final String MIX_ACCESSCONTROLLABLE = "mix:accessControllable";
+    /**
+     * mix:lockable
+     */
+    public static final String MIX_LOCKABLE = "mix:lockable";
+    /**
+     * mix:referenceable
+     */
+    public static final String MIX_REFERENCEABLE = "mix:referenceable";
+    /**
+     * mix:versionable
+     */
+    public static final String MIX_VERSIONABLE = "mix:versionable";
+    /**
+     * nt:base
+     */
+    public static final String NT_BASE = "nt:base";
+    /**
+     * nt:childNodeDef
+     */
+    public static final String NT_CHILDNODEDEF = "nt:childNodeDef";
+    /**
+     * nt:file
+     */
+    public static final String NT_FILE = "nt:file";
+    /**
+     * nt:folder
+     */
+    public static final String NT_FOLDER = "nt:folder";
+    /**
+     * nt:frozenNode
+     */
+    public static final String NT_FROZENNODE = "nt:frozenNode";
+    /**
+     * nt:hierarchyNode
+     */
+    public static final String NT_HIERARCHYNODE = "nt:hierarchyNode";
+    /**
+     * nt:linkedFile
+     */
+    public static final String NT_LINKEDFILE = "nt:linkedFile";
+    /**
+     * nt:nodeType
+     */
+    public static final String NT_NODETYPE = "nt:nodeType";
+    /**
+     * nt:propertyDef
+     */
+    public static final String NT_PROPERTYDEF = "nt:propertyDef";
+    /**
+     * nt:query
+     */
+    public static final String NT_QUERY = "nt:query";
+    /**
+     * nt:resource
+     */
+    public static final String NT_RESOURCE = "nt:resource";
+    /**
+     * nt:unstructured
+     */
+    public static final String NT_UNSTRUCTURED = "nt:unstructured";
+    /**
+     * nt:version
+     */
+    public static final String NT_VERSION = "nt:version";
+    /**
+     * nt:versionHistory
+     */
+    public static final String NT_VERSIONHISTORY = "nt:versionHistory";
+    /**
+     * nt:versionLabels
+     */
+    public static final String NT_VERSIONLABELS = "nt:versionLabels";
+    /**
+     * nt:versionedChild
+     */
+    public static final String NT_VERSIONEDCHILD = "nt:versionedChild";
+    /**
+     * nt:xmlElement
+     */
+    public static final String NT_XMLELEMENT = "nt:xmlElement";
+    /**
+     * rep:accessControl
+     */
+    public static final String REP_ACCESSCONTROL = "rep:accessControl";
+    /**
+     * rep:actions
+     */
+    public static final String REP_ACTIONS = "rep:actions";
+    /**
+     * rep:crxPrincipal
+     */
+    public static final String REP_CRXPRINCIPAL = "rep:crxPrincipal";
+    /**
+     * rep:denyPermission
+     */
+    public static final String REP_DENYPERMISSION = "rep:denyPermission";
+    /**
+     * rep:frozen
+     */
+    public static final String REP_FROZEN = "rep:frozen";
+    /**
+     * rep:frozenVersionHistory
+     */
+    public static final String REP_FROZENVERSIONHISTORY = "rep:frozenVersionHistory";
+    /**
+     * rep:grantPermission
+     */
+    public static final String REP_GRANTPERMISSION = "rep:grantPermission";
+    /**
+     * rep:group
+     */
+    public static final String REP_GROUP = "rep:group";
+    /**
+     * rep:linkedPrincipal
+     */
+    public static final String REP_LINKEDPRINCIPAL = "rep:linkedPrincipal";
+    /**
+     * rep:member
+     */
+    public static final String REP_MEMBER = "rep:member";
+    /**
+     * rep:nodeTypes
+     */
+    public static final String REP_NODETYPES = "rep:nodeTypes";
+    /**
+     * rep:password
+     */
+    public static final String REP_PASSWORD = "rep:password";
+    /**
+     * rep:permission
+     */
+    public static final String REP_PERMISSION = "rep:permission";
+    /**
+     * rep:principal
+     */
+    public static final String REP_PRINCIPAL = "rep:principal";
+    /**
+     * rep:principalFolder
+     */
+    public static final String REP_PRINCIPALFOLDER = "rep:principalFolder";
+    /**
+     * rep:principalName
+     */
+    public static final String REP_PRINCIPALNAME = "rep:principalName";
+    /**
+     * rep:root
+     */
+    public static final String REP_ROOT = "rep:root";
+    /**
+     * rep:sudoers
+     */
+    public static final String REP_SUDOERS = "rep:sudoers";
+    /**
+     * rep:system
+     */
+    public static final String REP_SYSTEM = "rep:system";
+    /**
+     * rep:user
+     */
+    public static final String REP_USER = "rep:user";
+    /**
+     * rep:userId
+     */
+    public static final String REP_USERID = "rep:userId";
+    /**
+     * rep:version
+     */
+    public static final String REP_VERSION = "rep:version";
+    /**
+     * rep:versionHistory
+     */
+    public static final String REP_VERSIONHISTORY = "rep:versionHistory";
+    /**
+     * rep:versionLabels
+     */
+    public static final String REP_VERSIONLABELS = "rep:versionLabels";
+    /**
+     * rep:versionStorage
+     */
+    public static final String REP_VERSIONSTORAGE = "rep:versionStorage";
+    /**
+     * rep:workspace
+     */
+    public static final String REP_WORKSPACE = "rep:workspace";
+    /**
+     * rep:workspaceAccess
+     */
+    public static final String REP_WORKSPACEACCESS = "rep:workspaceAccess";
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/JCRConstants.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/JCRConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java Mon Apr 11 09:04:58 2005
@@ -451,6 +451,10 @@
             ActiveLock[] activeLocks = resource.getLocks();
             List lList = new ArrayList();
             for (int i = 0; i < activeLocks.length; i++) {
+                // adjust lockinfo with type/scope retrieved from the lock.
+                lockInfo.setType(activeLocks[i].getType());
+                lockInfo.setScope(activeLocks[i].getScope());
+                
                 // todo: do not ignore etag
                 if (request.matchesIfHeader(resource.getHref(), activeLocks[i].getToken(), "")) {
                     lList.add(resource.refreshLock(lockInfo, activeLocks[i].getToken()));

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.JCRConstants;
+
+import javax.jcr.Node;
+
+/**
+ * This Class implements an abstract export command for a nc-resource. It acts
+ * as generic base class that retrieves the resource properties from the
+ * exporting node.
+ * </p>
+ * the following properties are retrieved from the node and set to the context
+ * prior of calling {@link #exportNode(ExportContext, javax.jcr.Node)}:
+ * <ul>
+ * <li>jcr:lastModified
+ * <li>jcr:created
+ * <li>jcr:mimeType
+ * <ul>
+ */
+public abstract class AbstractExportCommand implements Command, JCRConstants {
+
+    /**
+     * Executes this command by calling {@link #execute(ExportContext)} if
+     * the given context is of the correct class.
+     *
+     * @param context the (export) context.
+     * @return the return value of the delegated method or false;
+     * @throws Exception in an error occurrs
+     */
+    public boolean execute(Context context) throws Exception {
+        if (context instanceof ExportContext) {
+            return execute((ExportContext) context);
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Executs this command using the given export context. It copies the common
+     * resource properties to the export context and finally calls
+     * {@link #exportNode(ExportContext, javax.jcr.Node)}.
+     *
+     * @param context the export context
+     * @return the return value of {@link #exportNode(ExportContext, javax.jcr.Node)}
+     *         or false, if this command does not handle the given node at all.
+     * @throws Exception if an error occurrs
+     */
+    public boolean execute(ExportContext context) throws Exception {
+        Node node = context.getNode();
+        if (!canHandle(node)) {
+            return false;
+        }
+
+        Node content = node.getPrimaryNodeType().getName().equals(NT_FILE)
+                ? node.getNode(JCR_CONTENT)
+                : node;
+        if (content.hasProperty(JCR_LASTMODIFIED)) {
+            context.setModificationTime(content.getProperty(JCR_LASTMODIFIED).getLong());
+        } else {
+            context.setModificationTime(System.currentTimeMillis());
+        }
+        if (node.hasProperty(JCR_CREATED)) {
+            context.setCreationTime(node.getProperty(JCR_CREATED).getValue().getLong());
+        }
+        if (content.hasProperty(JCR_MIMETYPE)) {
+            context.setContentType(content.getProperty(JCR_MIMETYPE).getString());
+        } else {
+            context.setContentType(getDefaultContentType());
+        }
+        return exportNode(context, content);
+    }
+
+    /**
+     * Creates the response content. a successfull export must set the
+     * input stream and contentlength of the export context.
+     *
+     * @param context
+     * @param content
+     * @return
+     * @throws Exception
+     */
+    public abstract boolean exportNode(ExportContext context, Node content) throws Exception ;
+
+    /**
+     * Returns the default content type of this export
+     * @return
+     */
+    public abstract String getDefaultContentType();
+
+    /**
+     * Checks if this export command can handle the given node.
+     * @param node
+     * @return <code>true</code> if it can handle the export;
+     *         <code>false</code> otherwise.
+     */
+    public abstract boolean canHandle(Node node);
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractImportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractImportCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractImportCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractImportCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.JCRConstants;
+
+import javax.jcr.Node;
+import java.io.InputStream;
+
+/**
+ * This Class implements an abstract import command for a nc-resource.
+ */
+public abstract class AbstractImportCommand implements Command, JCRConstants {
+
+    /**
+     * Executes this command by calling {@link #importResource} if
+     * the given context is of the correct class.
+     *
+     * @param context the (import) context.
+     * @return the return value of the delegated method or false;
+     * @throws Exception in an error occurrs
+     */
+    public boolean execute(Context context) throws Exception {
+        if (context instanceof ImportContext) {
+            return execute((ImportContext) context);
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Executes this command. It checks if this command can handle the content
+     * type and delegates it to {@link #importResource}. If the import is
+     * successfull, the input stream of the importcontext is cleared.
+     *
+     * @param context the import context
+     * @return false
+     * @throws Exception if an error occurrs
+     */
+    public boolean execute(ImportContext context) throws Exception {
+        Node parentNode = context.getNode();
+        InputStream in = context.getInputStream();
+        if (in == null) {
+            // assume already consumed
+            return false;
+        }
+        if (!canHandle(context.getContentType())) {
+            // ignore imports
+            return false;
+        }
+        if (importResource(context, parentNode, in)) {
+            context.setInputStream(null);
+        }
+        return false;
+    }
+
+    /**
+     * Imports the resource contained in the import context.
+     * @param ctx
+     * @param parentNode
+     * @param in
+     * @return
+     * @throws Exception
+     */
+    public abstract boolean importResource(ImportContext ctx, Node parentNode, InputStream in)
+            throws Exception;
+
+    /**
+     * Returns true, if this command handles the given content type.
+     * @param contentType
+     * @return <code>true</code> if this command handles the given content type;
+     *         <code>false</code> otherwise.
+     */
+    public abstract boolean canHandle(String contentType);
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractImportCommand.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractImportCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddMixinCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddMixinCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddMixinCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddMixinCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.JCRConstants;
+
+import javax.jcr.Node;
+
+/**
+ * This Class implements a import command that adds a mixin node type to the
+ * current node.
+ */
+public class AddMixinCommand implements Command, JCRConstants {
+
+    /**
+     * the mixin node type to add
+     */
+    private String nodeType = null;
+
+    /**
+     * Creates a new AddMixinCommand
+     */
+    public AddMixinCommand() {
+    }
+
+    /**
+     * Creates a new AddMixinCommand with the given node type.
+     * @param nodeType the node type to add as mixin.
+     */
+    public AddMixinCommand(String nodeType) {
+        this.nodeType = nodeType;
+    }
+
+    /**
+     * Returns the node type parameter
+     * @return the node type.
+     */
+    public String getNodeType() {
+        return nodeType;
+    }
+
+    /**
+     * Sets the node type that is to be added to the current node.
+     * @param nodeType the mixin node type
+     */
+    public void setNodeType(String nodeType) {
+        this.nodeType = nodeType;
+    }
+
+    /**
+     * Executes this command by delegating to {@link #execute(ImportContext)} if
+     * the context has the correct class.
+     * @param context the (import) context.
+     * @return <code>false</code>.
+     * @throws Exception if an error occurrs.
+     */
+    public boolean execute(Context context) throws Exception {
+        if (context instanceof ImportContext) {
+            return execute((ImportContext) context);
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Adds the mixin nodetype to the current import node.
+     * @param context the import context.
+     * @return <code>false</code>
+     * @throws Exception if an error occurrs.
+     */
+    public boolean execute(ImportContext context) throws Exception {
+        Node parentNode = context.getNode();
+        if (nodeType == null) {
+            throw new IllegalArgumentException("AddMixinCommand needs 'nodeType' attribute.");
+        }
+        parentNode.addMixin(nodeType);
+        return false;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddMixinCommand.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddMixinCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddNodeCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddNodeCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddNodeCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddNodeCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.JCRConstants;
+
+import javax.jcr.Node;
+
+/**
+ * This Class implements a import command that adds a mixin node type to the
+ * current node.
+ */
+public class AddNodeCommand implements Command, JCRConstants {
+
+    /**
+     * the nodetype to be added.
+     */
+    private String nodeType = NT_UNSTRUCTURED;
+
+    /**
+     * Creates a new AddNodeCommand
+     */
+    public AddNodeCommand() {
+    }
+
+    /**
+     * Creates a new AddNodeCommand with the given node type.
+     * @param nodeType the node type of the node to be added.
+     */
+    public AddNodeCommand(String nodeType) {
+        this.nodeType = nodeType;
+    }
+
+    /**
+     * Returns the node type of the new node to be added.
+     * @return the node type
+     */
+    public String getNodeType() {
+        return nodeType;
+    }
+
+    /**
+     * Sets the node type of the new node to be added.
+     * @param nodeType the node type
+     */
+    public void setNodeType(String nodeType) {
+        this.nodeType = nodeType;
+    }
+
+    /**
+     * Executes this command by delegating to {@link #execute(ImportContext)} if
+     * the context has the correct class.
+     * @param context the (import) context.
+     * @return <code>false</code>.
+     * @throws Exception if an error occurrs.
+     */
+    public boolean execute(Context context) throws Exception {
+        if (context instanceof ImportContext) {
+            return execute((ImportContext) context);
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Executes this command. It adds a node, using the systemid of the import
+     * context and the given node type unless the respective chils node
+     * already exists. In either case, the current node of the import context
+     * is set to this new node.
+     *
+     * @param context the import context
+     * @return <code>false</code>
+     * @throws Exception in an error occurrs
+     *
+     * @see ImportContext#getSystemId()
+     * @see ImportContext#getNode()
+     */
+    public boolean execute(ImportContext context) throws Exception {
+        Node parentNode = context.getNode();
+        if (parentNode.hasNode(context.getSystemId())) {
+            context.setNode(parentNode.getNode(context.getSystemId()));
+        } else {
+            context.setNode(parentNode.addNode(context.getSystemId(), nodeType));
+        }
+        return false;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddNodeCommand.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AddNodeCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/BoundedInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/BoundedInputStream.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/BoundedInputStream.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/BoundedInputStream.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * This is a stream that will only supply bytes up to a certain length - if its
+ * position goes above that, it will stop.
+ * <p>
+ * This is useful to wrap ServletInputStreams. The ServletInputStream will block
+ * if you try to read content from it that isn't there, because it doesn't know
+ * whether the content hasn't arrived yet or whether the content has finished.
+ * So, one of these, initialized with the Content-length sent in the
+ * ServletInputStream's header, will stop it blocking, providing it's been sent
+ * with a correct content length.
+ *
+ * @version $Revision: 13729 $, $Date: 2004/06/04 15:48:16 $
+ * @author InigoSurguy
+ * @since antbear
+ */
+public class BoundedInputStream extends InputStream {
+
+    /** the wrapped input stream */
+    private final InputStream in;
+
+    /** the max length to provide */
+    private final int max;
+
+    /** the number of bytes already returned */
+    private int pos = 0;
+
+    /** the marked position */
+    private int mark = -1;
+
+    /** flag if close shoud be propagated */
+    private boolean propagateClose = true;
+
+    /**
+     * Creates a new <code>BoundedInputStream</code> that wraps the given input
+     * stream and limits it to a certain size.
+     *
+     * @param in The wrapped input stream
+     * @param size The maximum number of bytes to return
+     */
+    public BoundedInputStream(InputStream in, long size) {
+        // Some badly designed methods - eg the servlet API - overload length
+        // such that "-1" means stream finished
+        this.max = (int) size;
+        this.in = in;
+    }
+
+    public BoundedInputStream(InputStream in) {
+        this(in, -1);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int read() throws IOException {
+        if (max>=0 && pos==max) {
+            return -1;
+        }
+        int result = in.read();
+        pos++;
+        return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int read(byte[] b) throws IOException {
+        return this.read(b, 0, b.length);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int read(byte[] b, int off, int len) throws IOException {
+        if (max>=0 && pos>=max) {
+            return -1;
+        }
+        int maxRead = max>=0 ? Math.min(len, max-pos) : len;
+        int bytesRead = in.read(b, off, maxRead);
+
+        if (bytesRead==-1) {
+            return -1;
+        }
+
+        pos+=bytesRead;
+        return bytesRead;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public long skip(long n) throws IOException {
+        long toSkip = max>=0 ? Math.min(n, max-pos) : n;
+        long skippedBytes = in.skip(toSkip);
+        pos+=skippedBytes;
+        return skippedBytes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int available() throws IOException {
+        if (max>=0 && pos>=max) {
+            return 0;
+        }
+        return in.available();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+        return in.toString();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void close() throws IOException {
+        if (propagateClose) {
+            in.close();
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public synchronized void reset() throws IOException {
+        in.reset();
+        pos = mark;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public synchronized void mark(int readlimit) {
+        in.mark(readlimit);
+        mark = pos;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean markSupported() {
+        return in.markSupported();
+    }
+
+    public boolean isPropagateClose() {
+        return propagateClose;
+    }
+
+    public void setPropagateClose(boolean propagateClose) {
+        this.propagateClose = propagateClose;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/BoundedInputStream.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/BoundedInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.webdav.util.Text;
+import org.apache.jackrabbit.JCRConstants;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.NodeIterator;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.io.FileInputStream;
+
+/**
+ * This Class implements a collection export command that produces a HTML
+ * directory listing of all child nodes. All child nodes having the
+ * {@link #getCollectionNodeType()} result in a directory link.
+ */
+public class DirListingExportCommand implements Command, JCRConstants {
+
+    /**
+     * the node type of a collection
+     */
+    private String collectionNodeType = NT_FOLDER;
+
+    /**
+     * Creates a DirListingExportCommand
+     */
+    public DirListingExportCommand() {
+    }
+
+    /**
+     * Creates a DirListingExportCommand with the given collection node type.
+     * @param collectionNodeType
+     */
+    public DirListingExportCommand(String collectionNodeType) {
+        this.collectionNodeType = collectionNodeType;
+    }
+
+    /**
+     * Returns the node type of a collection node.
+     * @return the node type of a collection node.
+     */
+    public String getCollectionNodeType() {
+        return collectionNodeType;
+    }
+
+    /**
+     * Sets the node type of collection nodes. child nodes having this node
+     * type result in a directory link.
+     *
+     * @param collectionNodeType
+     */
+    public void setCollectionNodeType(String collectionNodeType) {
+        this.collectionNodeType = collectionNodeType;
+    }
+
+    /**
+     * Executes this command by delegating to {@link #execute(ExportContext)} if
+     * the context has the correct class.
+     * @param context the (import) context.
+     * @return <code>false</code>.
+     * @throws Exception if an error occurrs.
+     */
+    public boolean execute(Context context) throws Exception {
+        if (context instanceof ExportContext) {
+            return execute((ExportContext) context);
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Executes this command. It generates a HTML directory listing of all
+     * child nodes of the collection node.
+     *
+     * @param context the export context
+     * @return <code>true</code>
+     * @throws Exception in an error occurrs
+     */
+    public boolean execute(ExportContext context) throws Exception {
+        Node node = context.getNode();
+        File tmpfile = File.createTempFile("__webdav", ".xml");
+        FileOutputStream out = new FileOutputStream(tmpfile);
+
+        String repName = node.getSession().getRepository().getDescriptor(Repository.REP_NAME_DESC);
+        String repURL = node.getSession().getRepository().getDescriptor(Repository.REP_VENDOR_URL_DESC);
+        String repVersion = node.getSession().getRepository().getDescriptor(Repository.REP_VERSION_DESC);
+        PrintWriter writer = new PrintWriter(out);
+        writer.print("<html><head><title>");
+        writer.print(repName);
+        writer.print(" ");
+        writer.print(repVersion);
+        writer.print(" ");
+        writer.print(node.getPath());
+        writer.print("</title></head>");
+        writer.print("<body><h2>");
+        writer.print(node.getPath());
+        writer.print("</h2><ul>");
+        writer.print("<li><a href=\"..\">..</a></li>");
+        NodeIterator iter = node.getNodes();
+        while (iter.hasNext()) {
+            Node child = iter.nextNode();
+            String label = Text.getLabel(child.getPath());
+            writer.print("<li><a href=\"");
+            writer.print(Text.escape(label));
+            if (child.getPrimaryNodeType().getName().equals(collectionNodeType)) {
+                writer.print("/");
+            }
+            writer.print("\">");
+            writer.print(label);
+            writer.print("</a></li>");
+        }
+        writer.print("</ul><hr size=\"1\"><em>Powered by <a href=\"");
+        writer.print(repURL);
+        writer.print("\">");
+        writer.print(repName);
+        writer.print("</a> version ");
+        writer.print(repVersion);
+        writer.print("</em></body></html>");
+
+        writer.close();
+        out.close();
+
+        // set output
+        context.setInputStream(new FileInputStream(tmpfile));
+        context.setContentLength(tmpfile.length());
+        context.setModificationTime(tmpfile.lastModified());
+        context.setContentType("text/html");
+        tmpfile.deleteOnExit();
+
+        return true;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportCollectionChain.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportCollectionChain.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportCollectionChain.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportCollectionChain.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.impl.ChainBase;
+import org.apache.commons.chain.impl.CatalogFactoryBase;
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Catalog;
+import org.apache.jackrabbit.JCRConstants;
+
+/**
+ * This Class implements a default chain for exporting collection resources.
+ * It adds the following commands:
+ * <ul>
+ * <li>{@link DirListingExportCommand}("nt:folder").
+ * </ul>
+ */
+public class ExportCollectionChain extends ChainBase implements JCRConstants {
+
+    /**
+     * the name of this chain
+     */
+    public static final String NAME = "export-collection";
+
+    /**
+     * Creates a new command chain for exporting collection resources
+     */
+    public ExportCollectionChain() {
+        super();
+        addCommand(new DirListingExportCommand(NT_FOLDER));
+    }
+
+    /**
+     * Returns an export chain. It first tries to lookup the command
+     * in the default catalog. If this failes, a new instance of this class
+     * is returned.
+     * @return an export chain.
+     */
+    public static Command getChain() {
+        Catalog catalog = CatalogFactoryBase.getInstance().getCatalog();
+        Command exportChain = catalog.getCommand(NAME);
+        if (exportChain == null) {
+            // generate default import chain
+            exportChain = new ExportCollectionChain();
+        }
+        return exportChain;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportCollectionChain.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportCollectionChain.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.impl.ContextBase;
+
+import javax.jcr.Node;
+import java.io.InputStream;
+
+/**
+ * This Class implements a export context which is passed to the respective
+ * export commands.
+ * </p>
+ * Please note, that this export context lacks an explicit
+ * {@link org.apache.jackrabbit.webdav.DavResource} member. Currently, this
+ * information is not needed in any of the known export commands but leaves this
+ * I/O framework more generic.
+ */
+public class ExportContext extends ContextBase {
+
+    /**
+     * the node to be exported
+     */
+    private Node node;
+
+    /**
+     * the input stream that needs to be set by the export commands
+     */
+    private InputStream inputStream;
+
+    /**
+     * the content length of the data in the input stream
+     */
+    private long contentLength;
+
+    /**
+     * the last modifiaction time of the resource
+     */
+    private long modificationTime;
+
+    /**
+     * the creation time of the resource
+     */
+    private long creationTime;
+
+    /**
+     * the content type of the resource
+     */
+    private String contentType;
+
+    /**
+     * Creates a new ExportContext for the given node
+     * @param node
+     */
+    public ExportContext(Node node) {
+        this.node = node;
+    }
+
+    /**
+     * Returns the input stream
+     * @return the input stream
+     */
+    public InputStream getInputStream() {
+        return inputStream;
+    }
+
+    /**
+     * Sets a the inpurt stream to the data to be exported. A successfull
+     * export command must set this memeber.
+     * @param inputStream
+     */
+    public void setInputStream(InputStream inputStream) {
+        this.inputStream = inputStream;
+    }
+
+    /**
+     * Returns the node to be exported
+     * @return
+     */
+    public Node getNode() {
+        return node;
+    }
+
+    /**
+     * Returns the length of the data to be exported
+     * @return the content length
+     */
+    public long getContentLength() {
+        return contentLength;
+    }
+
+    /**
+     * Sets the length of the data to be exported. A successfull export command
+     * must set this memeber.
+     * @param contentLength the content length
+     */
+    public void setContentLength(long contentLength) {
+        this.contentLength = contentLength;
+    }
+
+    /**
+     * Returns the last modification time.
+     * @return the last modification time.
+     */
+    public long getModificationTime() {
+        return modificationTime;
+    }
+
+    /**
+     * Sets the last modification time. A successfull export command may set
+     * this member.
+     * @param modificationTime the last modification time
+     */
+    public void setModificationTime(long modificationTime) {
+        this.modificationTime = modificationTime;
+    }
+
+    /**
+     * Returns the creation time of the resource.
+     * @return the creation time
+     */
+    public long getCreationTime() {
+        return creationTime;
+    }
+
+    /**
+     * Sets the creation time of the resource. A successfull export command may
+     * set this member.
+     * @param creationTime the creation time
+     */
+    public void setCreationTime(long creationTime) {
+        this.creationTime = creationTime;
+    }
+
+    /**
+     * Returns the content type of the resource.
+     * @return the content type
+     */
+    public String getContentType() {
+        return contentType;
+    }
+
+    /**
+     * Sets the content type of the resource. A successfull export command
+     * may set this member.
+     * @param contentType the content type
+     */
+    public void setContentType(String contentType) {
+        this.contentType = contentType;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportNCResourceChain.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportNCResourceChain.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportNCResourceChain.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportNCResourceChain.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.impl.ChainBase;
+import org.apache.commons.chain.impl.CatalogFactoryBase;
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Catalog;
+
+/**
+ * This Class implements a default chain for exporting non collection resources.
+ * It adds the following commands:
+ * <ul>
+ * <li>{@link FileExportCommand}().
+ * <li>{@link XMLExportCommand}({@link XMLExportCommand#MODE_DOCVIEW).
+ * </ul>
+ */
+public class ExportNCResourceChain extends ChainBase {
+
+    /**
+     * default name of this chain
+     */
+    public static final String NAME = "export-nc-resource";
+
+    /**
+     * Creats a new command chain for exporting non collection resources.
+     */
+    public ExportNCResourceChain() {
+        super();
+        addCommand(new FileExportCommand());
+        addCommand(new XMLExportCommand(XMLExportCommand.MODE_DOCVIEW));
+    }
+
+    /**
+     * Returns an export chain. It first tries to lookup the command
+     * in the default catalog. If this failes, a new instance of this class
+     * is returned.
+     * @return an export chain.
+     */
+    public static Command getChain() {
+        Catalog catalog = CatalogFactoryBase.getInstance().getCatalog();
+        Command exportChain = catalog.getCommand(NAME);
+        if (exportChain == null) {
+            // generate default import chain
+            exportChain = new ExportNCResourceChain();
+        }
+        return exportChain;
+    }
+
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportNCResourceChain.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportNCResourceChain.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+/**
+ * This Class implements a export command that returns the data included in the
+ * jcr:data property of a nt:resource node.
+ */
+public class FileExportCommand extends AbstractExportCommand {
+
+    /**
+     * Exports the node by returning the content of the jcr:data property of
+     * the content node.
+     * @param context the export context
+     * @param content the content node
+     * @return <code>true</code>
+     * @throws Exception if an error occurrs
+     */
+    public boolean exportNode(ExportContext context, Node content) throws Exception {
+        if (content.hasProperty(JCR_ENCODING)) {
+            String encoding = content.getProperty(JCR_ENCODING).getString();
+            if (!encoding.equals("")) {
+                context.setContentType(context.getContentType() + "; charset=\"" + encoding + "\"");
+            }
+        }
+        if (content.hasProperty(JCR_DATA)) {
+            Property p = content.getProperty(JCR_DATA);
+            context.setContentLength(p.getLength());
+            context.setInputStream(p.getStream());
+        } else {
+            context.setContentLength(0);
+            context.setInputStream(null);
+        }
+        return true;
+    }
+
+    /**
+     * Returns the default content type
+     * @return "application/octet-stream".
+     */
+    public String getDefaultContentType() {
+        return "application/octet-stream";
+    }
+
+    /**
+     * Checks if the given node can be handled by this export command. This is
+     * the case, if the node contains a 'jcr:content' node which is of node type
+     * 'nt:resource'.
+     * @param node the node to be exported
+     * @return <code>true</code> if the correct node is passed;
+     *         <code>false</code> otherwise.
+     */
+    public boolean canHandle(Node node) {
+        try {
+            return node.hasNode(JCR_CONTENT) && node.getNode(JCR_CONTENT).isNodeType(NT_RESOURCE);
+        } catch (RepositoryException e) {
+            return false;
+        }
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import javax.jcr.Node;
+import java.io.InputStream;
+import java.util.Calendar;
+
+/**
+ * This Class implements an import command that creates a "nt:resource" below
+ * the current node and a add the resource data as binary property. It further
+ * sets the following properties:
+ * <ul>
+ * <li>jcr:encoding (to "")
+ * <li>jcr:mimeType (from {@link ImportContext#getContentType()})
+ * <li>jcr:lastModified (from current time)
+ * <li>jcr:data (from {@link ImportContext#getInputStream()})
+ * </ul>
+ */
+public class FileImportCommand extends AbstractImportCommand {
+
+    /**
+     * Imports a resource by creating a new nt:resource node.
+     *
+     * @param ctx the import context
+     * @param parentNode the parent node
+     * @param in the input stream
+     * @return <code>true</code>
+     * @throws Exception in an error occurrs
+     */
+    public boolean importResource(ImportContext ctx, Node parentNode,
+                                  InputStream in)
+            throws Exception {
+        Node content = parentNode.hasNode(JCR_CONTENT)
+                ? parentNode.getNode(JCR_CONTENT)
+                : parentNode.addNode(JCR_CONTENT, NT_RESOURCE);
+        // todo: to be removed with spec. 0.16.4 where jcr:encoding is not mandatory any more...
+        content.setProperty(JCR_ENCODING, "");
+        content.setProperty(JCR_MIMETYPE, ctx.getContentType());
+        content.setProperty(JCR_DATA, in);
+        Calendar lastMod = Calendar.getInstance();
+        if (ctx.getModificationTime() != 0) {
+            lastMod.setTimeInMillis(ctx.getModificationTime());
+        }
+        content.setProperty(JCR_LASTMODIFIED, lastMod);
+        return true;
+    }
+
+    /**
+     * Can handle all content type thus returning <code>true</code>.
+     * @param contentType
+     * @return <code>true</code>
+     */
+    public boolean canHandle(String contentType) {
+        return true;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportCollectionChain.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportCollectionChain.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportCollectionChain.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportCollectionChain.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.impl.ChainBase;
+import org.apache.commons.chain.impl.CatalogFactoryBase;
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Catalog;
+import org.apache.jackrabbit.JCRConstants;
+
+/**
+ * This Class implements a default chain for importing collection resources.
+ * It adds the following commands:
+ * <ul>
+ * <li>{@link AddNodeCommand}("nt:folder").
+ * </ul>
+ */
+public class ImportCollectionChain extends ChainBase implements JCRConstants {
+
+    /**
+     * The default name of this chain.
+     */
+    public static final String NAME = "import-collection";
+
+    /**
+     * Creates a new default import chain for importing collection resource.
+     */
+    public ImportCollectionChain() {
+        super();
+        addCommand(new AddNodeCommand(NT_FOLDER));
+    }
+
+    /**
+     * Returns an import chain. It first tries to lookup the command
+     * in the default catalog. If this failes, a new instance of this class
+     * is returned.
+     * @return an import chain.
+     */
+    public static Command getChain() {
+        Catalog catalog = CatalogFactoryBase.getInstance().getCatalog();
+        Command importChain = catalog.getCommand(NAME);
+        if (importChain == null) {
+            // generate default import chain
+            importChain = new ImportCollectionChain();
+        }
+        return importChain;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportCollectionChain.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportCollectionChain.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.impl.ContextBase;
+
+import javax.jcr.Node;
+import java.io.InputStream;
+
+/**
+ * This Class implements an import context which is passed to the respective
+ * import commands. An import command can alter the current node for creating
+ * a recursive structure, thus is can lead to errors, if the configuration
+ * is not done properly. A import command should clear the input stream,
+ * after having processed it.
+ * </p>
+ * Please note, that this import context lacks an explicit
+ * {@link org.apache.jackrabbit.webdav.DavResource} member. Currently, this
+ * information is not needed in any of the known import commands but leaves this
+ * I/O framework more generic.
+ */
+public class ImportContext extends ContextBase {
+
+    /**
+     * The import root node, i.e. the parent node of the new content.
+     */
+    private final Node importRoot;
+
+    /**
+     * The 'current' node.
+     */
+    private Node node = null;
+
+    /**
+     * The input stream of the resource data
+     */
+    private InputStream inputStream;
+
+    /**
+     * The systemid of the resource, eg. the display name of a dav resource,
+     * the filename of a file, etc.
+     */
+    private String systemId;
+
+    /**
+     * The content type of the resource to be imported.
+     */
+    private String contentType;
+
+    /**
+     * The modification time of the resource, if known
+     */
+    private long modificationTime;
+
+    /**
+     * Creates a new import context with the given root node
+     * @param importRoot the import root node
+     */
+    public ImportContext(Node importRoot) {
+        if (importRoot == null) {
+            throw new IllegalArgumentException("importRoot can not be null.");
+        }
+        this.importRoot = importRoot;
+    }
+
+    /**
+     * Retruns the input stream of the resource to import.
+     * @return the input stream.
+     */
+    public InputStream getInputStream() {
+        return inputStream;
+    }
+
+    /**
+     * Sets the inpurt stream of the resource to import. A import command that
+     * consumed the input stream should set this member to <code>null</code>.
+     * @param inputStream the input stream
+     */
+    public void setInputStream(InputStream inputStream) {
+        this.inputStream = inputStream;
+    }
+
+    /**
+     * Returns the import root of the resource to import.
+     * @return the import root of the resource to import.
+     */
+    public Node getImportRoot() {
+        return importRoot;
+    }
+
+    /**
+     * Returns the current parent node of the resource to import. If no current
+     * parent node is defined, the import root is returned.
+     * @return the parent node.
+     */
+    public Node getNode() {
+        return node == null ? importRoot : node;
+    }
+
+    /**
+     * Sets the current parent node of the resource to import. A command can
+     * set this member in order to generate recursive structured.
+     * @param node
+     */
+    public void setNode(Node node) {
+        this.node = node;
+    }
+
+    /**
+     * Returns the system id of the resource to be imported. This id depends on
+     * the system the resource is comming from. it can be a filename, a
+     * display name of a webdav resource, an URI, etc.
+     * @return the system id of the resource to import
+     */
+    public String getSystemId() {
+        return systemId;
+    }
+
+    /**
+     * sets the system id of this resource.
+     * @param systemId
+     */
+    public void setSystemId(String systemId) {
+        this.systemId = systemId;
+    }
+
+    /**
+     * Returns the content type of the resource to be imported or null, if
+     * no contenttype was defined.
+     * @return the content type of the resource
+     */
+    public String getContentType() {
+        return contentType;
+    }
+
+    /**
+     * Sets the content type of the resource.
+     * @param contentType the content type.
+     */
+    public void setContentType(String contentType) {
+        this.contentType = contentType;
+    }
+
+    /**
+     * Returns the modification time of the resource
+     * @return the modification time.
+     */
+    public long getModificationTime() {
+        return modificationTime;
+    }
+
+    /**
+     * Sets the modification time of the resource
+     * @param modificationTime the modification time
+     */
+    public void setModificationTime(long modificationTime) {
+        this.modificationTime = modificationTime;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportNCResourceChain.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportNCResourceChain.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportNCResourceChain.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportNCResourceChain.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.impl.ChainBase;
+import org.apache.commons.chain.impl.CatalogFactoryBase;
+import org.apache.commons.chain.Catalog;
+import org.apache.commons.chain.Command;
+import org.apache.jackrabbit.JCRConstants;
+
+/**
+ * This Class implements a default chain for importing non-collection resources.
+ * It adds the following commands:
+ * <ul>
+ * <li>{@link SetContentTypeCommand}().
+ * <li>{@link AddNodeCommand}("nt:file").
+ * <li>{@link AddMixinCommand}("mix:versionable").
+ * <li>{@link FileImportCommand}()
+ * </ul>
+ */
+public class ImportNCResourceChain extends ChainBase implements JCRConstants {
+
+    /**
+     * the name of this chain
+     */
+    public static final String NAME = "import-nc-resource";
+
+    /**
+     * Creates a new default import chain for importing non collection resource.
+     */
+    public ImportNCResourceChain() {
+        super();
+        addCommand(new SetContentTypeCommand());
+        addCommand(new AddNodeCommand(NT_FILE));
+        addCommand(new AddMixinCommand(MIX_VERSIONABLE));
+        addCommand(new FileImportCommand());
+    }
+
+    /**
+     * Returns an import chain. It first tries to lookup the command
+     * in the default catalog. If this failes, a new instance of this class
+     * is returned.
+     * @return an import chain.
+     */
+    public static Command getChain() {
+        Catalog catalog = CatalogFactoryBase.getInstance().getCatalog();
+        Command importChain = catalog.getCommand(NAME);
+        if (importChain == null) {
+            // generate default import chain
+            importChain = new ImportNCResourceChain();
+        }
+        return importChain;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportNCResourceChain.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportNCResourceChain.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+
+/**
+ * This Class implements...
+ *
+ * @author tripod
+ * @version $Revision:$, $Date:$
+ */
+public class SetContentTypeCommand implements Command {
+
+    /**
+     * Executes this command by calling {@link #execute(ImportContext)} if
+     * the given context is of the correct class.
+     *
+     * @param context the (import) context.
+     * @return the return value of the delegated method or false;
+     * @throws Exception in an error occurrs
+     */
+    public boolean execute(Context context) throws Exception {
+        if (context instanceof ImportContext) {
+            return execute((ImportContext) context);
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Executes this command. It resolves the content type in the import context
+     * if it is not alerady set.
+     *
+     * @param context the import context
+     * @return false
+     * @throws Exception if an error occurrs
+     */
+    public boolean execute(ImportContext context) throws Exception {
+        if (context.getContentType() == null) {
+            String name = context.getSystemId();
+            // todo: add extensible list
+            if (name.endsWith(".xml")) {
+                context.setContentType("text/xml");
+            } else if (name.endsWith(".zip")) {
+                context.setContentType("application/zip");
+            } else {
+                context.setContentType("application/octet-stream");
+            }
+        }
+        return false;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message