jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r160914 [2/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
Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLExportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLExportCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLExportCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLExportCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,124 @@
+/*
+ * 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.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+
+/**
+ * This Class implements an export command that generates a docview or
+ * sysview of the node to be exported.
+ */
+public class XMLExportCommand extends AbstractExportCommand {
+
+    /**
+     * the xml content type
+     */
+    public static final String XML_CONTENT_TYPE = "text/xml";
+
+    /**
+     * the 'sysview' mode constant.
+     */
+    public static final String MODE_SYSVIEW = "sysview";
+
+    /**
+     * the 'docview' mode contant
+     */
+    public static final String MODE_DOCVIEW = "docview";
+
+    /**
+     * the export mode. either 'sysview' or 'docview'
+     */
+    private String mode = MODE_DOCVIEW;
+
+    /**
+     * Creats a XMLExportCommand
+     */
+    public XMLExportCommand() {
+    }
+
+    /**
+     * Creates a XMLExportCommand with the given mode.
+     * @param mode
+     */
+    public XMLExportCommand(String mode) {
+        setMode(mode);
+    }
+
+    /**
+     * Returns the export mode.
+     * @return the export mode.
+     */
+    public String getMode() {
+        return mode;
+    }
+
+    /**
+     * Sets the export mode. This mus be either {@link #MODE_DOCVIEW} or
+     * {@link #MODE_SYSVIEW}, otherwise a IllegalArgumentException is thrown.
+     * @param mode the export mode
+     * @throws IllegalArgumentException if the mode is not correct.
+     */
+    public void setMode(String mode) {
+        if (MODE_DOCVIEW.equals(mode) || MODE_SYSVIEW.equals(mode)) {
+            this.mode = mode;
+        } else {
+            throw new IllegalArgumentException("mode must be either " + MODE_DOCVIEW + " or " + MODE_SYSVIEW);
+        }
+    }
+
+    /**
+     * Creates a docview response for the given node.
+     * @param context the export context
+     * @param content the node to be exported
+     * @return <code>true</code>
+     * @throws Exception if an error occurrs.
+     */
+    public boolean exportNode(ExportContext context, Node content) throws Exception {
+        File tmpfile = File.createTempFile("__webdav", ".xml");
+        FileOutputStream out = new FileOutputStream(tmpfile);
+        if (mode.equals(MODE_DOCVIEW)) {
+            content.getSession().exportDocView(content.getPath(), out, true, false);
+        } else {
+            content.getSession().exportSysView(content.getPath(), out, true, false);
+        }
+        out.close();
+        context.setInputStream(new FileInputStream(tmpfile));
+        context.setContentLength(tmpfile.length());
+        tmpfile.deleteOnExit();
+        return true;
+    }
+
+    /**
+     * Returns {@link #XML_CONTENT_TYPE}.
+     * @return {@link #XML_CONTENT_TYPE}.
+     */
+    public String getDefaultContentType() {
+        return XML_CONTENT_TYPE;
+    }
+
+    /**
+     * Returns <code>true</code>
+     * @param node
+     * @return <code>true</code>
+     */
+    public boolean canHandle(Node node) {
+        return true;
+    }
+}

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,72 @@
+/*
+ * 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 deserializes the xml contained
+ * in the import stream, using {@link javax.jcr.Session#importXML(String, java.io.InputStream)}.
+ * It further sets the following properties:
+ * <ul>
+ * <li>jcr:mimeType (from {@link ImportContext#getContentType()})
+ * <li>jcr:lastModified (from current time)
+ * </ul>
+ */
+public class XMLImportCommand extends AbstractImportCommand {
+
+    /**
+     * the xml content type
+     */
+    public static final String XML_CONTENT_TYPE = "text/xml";
+
+    /**
+     * Imports the resource by deseriaizing the xml.
+     * @param ctx
+     * @param parentNode
+     * @param in
+     * @return
+     * @throws Exception
+     */
+    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_UNSTRUCTURED);
+        content.setProperty(JCR_MIMETYPE, ctx.getContentType());
+        Calendar lastMod = Calendar.getInstance();
+        if (ctx.getModificationTime() != 0) {
+            lastMod.setTimeInMillis(ctx.getModificationTime());
+        }
+        content.setProperty(JCR_LASTMODIFIED, lastMod);
+        parentNode.getSession().importXML(content.getPath(), in);
+        return true;
+    }
+
+    /**
+     * Returns <code>true</code> if the given content type is equal to
+     * {@link #XML_CONTENT_TYPE}.
+     * @param contentType the content type to check.
+     * @return <code>true</code> if equal to {@link #XML_CONTENT_TYPE}.
+     */
+    public boolean canHandle(String contentType) {
+        return XML_CONTENT_TYPE.equals(contentType);
+    }
+}

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZIPImportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZIPImportCommand.java?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZIPImportCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZIPImportCommand.java Mon Apr 11 09:04:58 2005
@@ -0,0 +1,161 @@
+/*
+ * 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.log4j.Logger;
+import org.apache.jackrabbit.webdav.util.Text;
+import org.apache.jackrabbit.JCRConstants;
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.Command;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import java.io.InputStream;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipEntry;
+
+/**
+ * This Class implements an import command that reads entries from a zip input
+ * stream and delegates the extracted file back to the import chain.
+ */
+public class ZIPImportCommand implements Command, JCRConstants {
+
+    /** the default logger */
+    private static final Logger log = Logger.getLogger(ZIPImportCommand.class);
+
+    /**
+     * the zip content type
+     */
+    public static final String ZIP_CONTENT_TYPE = "application/zip";
+
+    /**
+     * 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;
+        }
+        importResource(parentNode, in);
+        context.setInputStream(null);
+        return true;
+    }
+
+    /**
+     * Imports a resource by extracting the input stream and delegating to
+     * import chain.
+     *
+     * @param parentNode the parent node
+     * @param in the input stream
+     * @throws Exception in an error occurrs
+     */
+    private void importResource(Node parentNode, InputStream in)
+            throws Exception {
+
+        // assuming zip content
+        ZipInputStream zin = new ZipInputStream(in);
+        ZipEntry entry;
+        while ((entry=zin.getNextEntry())!=null) {
+            log.info("entry: " + entry.getName() + " size: " + entry.getSize());
+            if (entry.isDirectory()) {
+                mkDirs(parentNode, Text.makeValidJCRPath(entry.getName()));
+                zin.closeEntry();
+            } else {
+                String path = Text.makeValidJCRPath(entry.getName());
+                if (path.charAt(0)!='/') {
+                    path  = "/" + path;
+                }
+                Node parent = mkDirs(parentNode, Text.getRelativeParent(path, 1));
+
+                BoundedInputStream bin = new BoundedInputStream(zin);
+                bin.setPropagateClose(false);
+
+                ImportContext subctx = new ImportContext(parent);
+                subctx.setInputStream(bin);
+                subctx.setSystemId(Text.getLabel(path));
+                subctx.setModificationTime(entry.getTime());
+                ImportNCResourceChain.getChain().execute(subctx);
+                zin.closeEntry();
+            }
+        }
+        zin.close();
+    }
+
+    /**
+     * Creates collection recursively.
+     *
+     * @param root
+     * @param relPath
+     * @return
+     * @throws RepositoryException
+     */
+    private Node mkDirs(Node root, String relPath) throws RepositoryException {
+        String[] seg = Text.explode(relPath, '/');
+        for (int i=0; i< seg.length; i++) {
+            if (!root.hasNode(seg[i])) {
+                // not quite correct
+                ImportContext subctx = new ImportContext(root);
+                subctx.setSystemId(seg[i]);
+                try {
+                    ImportCollectionChain.getChain().execute(subctx);
+                } catch (Exception e) {
+                    throw new RepositoryException(e);
+                }
+            }
+            root = root.getNode(seg[i]);
+        }
+        return root;
+    }
+
+    /**
+     * Returns <code>true</code> if the given content type is equal to
+     * {@link #ZIP_CONTENT_TYPE}.
+     * @param contentType the content type to check.
+     * @return <code>true</code> if equal to {@link #ZIP_CONTENT_TYPE}.
+     */
+    public boolean canHandle(String contentType) {
+        return ZIP_CONTENT_TYPE.equals(contentType);
+    }
+}

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/package.html?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/package.html Mon Apr 11 09:04:58 2005
@@ -0,0 +1,39 @@
+The jackrabbit webdav server, makes use of the <a href="http://jakarta.apache.org/commons/chain/">commons-chain</a>
+framekwork in order to perform inport and export operations.
+</p>
+the i/o catalog consists of 4 commands chains:
+<ul>
+<li><b>import-collection</b><br>
+    commands that import a collection, eg. create a folder node in the
+    repository.
+<li><b>import-nc-resource</b><br>
+    commands that import a non-collection resource, eg. importing a file, deserializing
+    an xml document. etc.
+<li><b>export-collection</b><br>
+    commands that export a collection, eg. create a dir-listing
+<li><b>export-nc-resource</b><br>
+    commands that export a non-collection resource, eg. spool a file, generate a docview response
+</ul>
+
+an example catalog.xml:<br>
+<xmp>
+<?xml version="1.0" ?>
+<catalog>
+    <chain name="import-collection">
+        <command id="add-node" className="org.apache.jackrabbit.server.io.AddNodeCommand" nodeType="nt:folder" />
+    </chain>
+
+    <chain name="import-nc-resource">
+        <command id="add-node"  className="org.apache.jackrabbit.server.io.AddNodeCommand" nodeType="nt:file" />
+        <command id="add-mixin" className="org.apache.jackrabbit.server.io.AddMixinCommand" nodeType="mix:versionable"/>
+        <command id="import-file" className="org.apache.jackrabbit.server.io.FileImportCommand" />
+    </chain>
+
+    <chain name="export-collection">
+        <command id="export-dirlisting" className="org.apache.jackrabbit.server.io.DirListingExportCommand"  collectionNodeType="nt:folder"/>
+    </chain>
+    <chain name="export-nc-resource">
+        <command id="export-file" className="org.apache.jackrabbit.server.io.FileExportCommand" />
+    </chain>
+</catalog>
+</xmp>
\ No newline at end of file

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

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java Mon Apr 11 09:04:58 2005
@@ -23,10 +23,15 @@
 import javax.servlet.http.*;
 import javax.servlet.*;
 import java.io.*;
+import java.net.URL;
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.server.AbstractWebdavServlet;
 import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.lock.LockManager;
+import org.apache.commons.chain.config.ConfigParser;
+import org.apache.commons.chain.Catalog;
+import org.apache.commons.chain.impl.CatalogFactoryBase;
 
 /**
  * WebdavServlet provides webdav support (level 1 and 2 complient) for repository
@@ -40,13 +45,16 @@
     /** init param name of the repository prefix */
     public static final String INIT_PARAM_RESOURCE_PATH_PREFIX = "resource-path-prefix";
 
+    /** init param file of the commons chain catalog*/
+    public static final String INIT_PARAM_CHAIN_CATALOG = "chain-catalog";
+
     /**
      * Map used to remember any webdav lock created without being reflected
      * in the underlaying repository.
      * This is needed because some clients rely on a successful locking
      * mechanism in order to perform properly (e.g. mac OSX built-in dav client)
      */
-    private SimpleLockManager lockManager;
+    private LockManager lockManager;
 
     /** the resource factory */
     private DavResourceFactory resourceFactory;
@@ -60,6 +68,8 @@
     /** the repository prefix retrieved from config */
     private static String resourcePathPrefix;
 
+    private static Catalog chainCatalog;
+
     /**
      * Init this servlet
      *
@@ -78,9 +88,16 @@
 	}
 	log.info(INIT_PARAM_RESOURCE_PATH_PREFIX + " = '" + resourcePathPrefix + "'");
 
-	lockManager = new SimpleLockManager();
-        resourceFactory = new ResourceFactoryImpl(lockManager);
-        locatorFactory = new LocatorFactoryImpl(resourcePathPrefix);
+        try {
+            String chain = getInitParameter(INIT_PARAM_CHAIN_CATALOG);
+            URL chainUrl = getServletContext().getResource(chain);
+            ConfigParser parser = new ConfigParser();
+            parser.parse(chainUrl);
+            chainCatalog = CatalogFactoryBase.getInstance().getCatalog();
+        } catch (Exception e) {
+            throw new ServletException(e);
+        }
+        log.info(INIT_PARAM_CHAIN_CATALOG + " = '" + chainCatalog + "'");
     }
 
     /**
@@ -95,11 +112,11 @@
 	throws ServletException, IOException {
 
 	try {
-            WebdavRequest webdavRequest = new WebdavRequestImpl(request, locatorFactory);
+            WebdavRequest webdavRequest = new WebdavRequestImpl(request, getLocatorFactory());
             WebdavResponse webdavResponse = new WebdavResponseImpl(response);
 
             // make sure there is a authenticated user
-	    getDavSessionProvider().acquireSession(webdavRequest);
+	    getSessionProvider().acquireSession(webdavRequest);
 	    if (webdavRequest.getDavSession() == null) {
  		return;
  	    }
@@ -156,7 +173,7 @@
 		    // GET, HEAD, TRACE......
 		    super.service(request, response);
 	    }
-	    getDavSessionProvider().releaseSession(webdavRequest);
+	    getSessionProvider().releaseSession(webdavRequest);
 
 	} catch (DavException e) {
             // special handling for unauthorized, should be done nicer
@@ -192,7 +209,7 @@
      */
     protected DavResource createResource(DavResourceLocator locator, WebdavRequest request, WebdavResponse response)
             throws DavException {
-        return resourceFactory.createResource(locator, request, response);
+        return getResourceFactory().createResource(locator, request, response);
     }
 
     /**
@@ -206,13 +223,82 @@
     }
 
     /**
+     * Returns the <code>DavLocatorFactory</code>. If no locator factory has
+     * been set or created a new instance of {@link LocatorFactoryImpl} is
+     * returned.
+     *
+     * @return the locator factory
+     */
+    public DavLocatorFactory getLocatorFactory() {
+	if (locatorFactory == null) {
+	    locatorFactory = new LocatorFactoryImpl(resourcePathPrefix);
+	}
+	return locatorFactory;
+    }
+
+    /**
+     * Set the locator factory
+     *
+     * @param locatorFactory
+     */
+    public void setLocatorFactory(DavLocatorFactory locatorFactory) {
+	this.locatorFactory = locatorFactory;
+    }
+
+    /**
+     * Returns the <code>LockManager</code>. If no lock manager has
+     * been set or created a new instance of {@link SimpleLockManager} is
+     * returned.
+     *
+     * @return the lock manager
+     */
+    public LockManager getLockManager() {
+	if (lockManager == null) {
+	    lockManager = new SimpleLockManager();
+	}
+	return lockManager;
+    }
+
+    /**
+     * Set the lock manager
+     *
+     * @param lockManager
+     */
+    public void setLockManager(LockManager lockManager) {
+	this.lockManager = lockManager;
+    }
+
+    /**
+     * Returns the <code>DavResourceFactory</code>. If no request factory has
+     * been set or created a new instance of {@link ResourceFactoryImpl} is
+     * returned.
+     *
+     * @return the resource factory
+     */
+    public DavResourceFactory getResourceFactory() {
+	if (resourceFactory == null) {
+	    resourceFactory = new ResourceFactoryImpl(getLockManager());
+	}
+	return resourceFactory;
+    }
+
+    /**
+     * Set the resource factory
+     *
+     * @param resourceFactory
+     */
+    public void setResourceFactory(DavResourceFactory resourceFactory) {
+	this.resourceFactory = resourceFactory;
+    }
+
+    /**
      * Returns the <code>DavSessionProvider</code>. If no session provider has
      * been set or created a new instance of {@link DavSessionProviderImpl} is
-     * return.
+     * returned.
      *
      * @return the session provider
      */
-    public DavSessionProvider getDavSessionProvider() {
+    public DavSessionProvider getSessionProvider() {
 	if (sessionProvider == null) {
 	    sessionProvider = new DavSessionProviderImpl();
 	}
@@ -224,7 +310,7 @@
      *
      * @param sessionProvider
      */
-    public void setDavSessionProvider(DavSessionProvider sessionProvider) {
+    public void setSessionProvider(DavSessionProvider sessionProvider) {
 	this.sessionProvider = sessionProvider;
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavResourceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavResourceImpl.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavResourceImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavResourceImpl.java Mon Apr 11 09:04:58 2005
@@ -26,11 +26,19 @@
 import org.apache.jackrabbit.webdav.spi.JcrDavException;
 import org.apache.jackrabbit.webdav.lock.*;
 import org.apache.jackrabbit.webdav.property.*;
+import org.apache.jackrabbit.JCRConstants;
+import org.apache.jackrabbit.server.io.ImportContext;
+import org.apache.jackrabbit.server.io.ImportNCResourceChain;
+import org.apache.jackrabbit.server.io.ImportCollectionChain;
+import org.apache.log4j.Logger;
 
 /**
  * DavResourceImpl imeplements a DavResource.
  */
-public class DavResourceImpl implements DavResource {
+public class DavResourceImpl implements DavResource, JCRConstants {
+
+    /** the default logger */
+    private static final Logger log = Logger.getLogger(DavResourceImpl.class);
 
     private DavResourceFactory factory;
     private LockManager lockManager;
@@ -79,7 +87,7 @@
         node = (Node)repositoryItem;
 
         // define what is a resource in webdav
-        if (node.isNodeType("nt:resource") || node.isNodeType("nt:file")) {
+        if (node.isNodeType(NT_RESOURCE) || node.isNodeType(NT_FILE)) {
             isCollection = false;
         }
     }
@@ -315,70 +323,24 @@
 
         try {
             String fileName = member.getDisplayName();
-	    Node file;
-	    boolean makeVersionable = true; // todo: to be configurable somewhere
-	    if (node.hasNode(fileName)) {
-		file = node.getNode(fileName);
-		if (file.hasNode("jcr:content")) {
-		    // remove an existing repository entry for 'overwriting' is not possible
-		    file.getNode("jcr:content").remove();
-		}
-	    } else {
-		file = node.addNode(fileName, "nt:file");
-		if (makeVersionable) {
-		    file.addMixin("mix:versionable");
-		}
-	    }
-
-	    if (fileName.endsWith(".xml")) {
-		importXml(file, in, "text/xml");
-	    } else {
-		// todo: retrieve proper mimetype from filename
-		importFile(file, in, "application/octet-stream");
-	    }
+            ImportContext ctx = new ImportContext(node);
+            ctx.setInputStream(in);
+            ctx.setSystemId(fileName);
+            ImportNCResourceChain.getChain().execute(ctx);
             session.getRepositorySession().save();
         } catch (RepositoryException e) {
+            log.error("Error while executing import chain: " + e.toString());
             throw new JcrDavException(e);
         } catch (IOException e) {
+            log.error("Error while executing import chain: " + e.toString());
+            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+        } catch (Exception e) {
+            log.error("Error while executing import chain: " + e.toString());
             throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
         }
     }
 
     /**
-     * Imports a xml into the repository
-     *
-     * @param parentNode
-     * @param in
-     * @param contentType
-     * @throws RepositoryException
-     * @throws IOException
-     */
-    private void importXml(Node parentNode, InputStream in, String contentType)
-	    throws RepositoryException, IOException {
-	Node content = parentNode.addNode("jcr:content", "nt:unstructured");
-	content.setProperty("jcr:mimeType", contentType);
-	content.setProperty("jcr:lastModified", Calendar.getInstance());
-	session.getRepositorySession().importXML(content.getPath(), in);
-    }
-
-    /**
-     * Imports a plain file to the repository
-     *
-     * @param parentNode
-     * @param in
-     * @param contentType
-     * @throws RepositoryException
-     */
-    private void importFile(Node parentNode, InputStream in, String contentType)
-	    throws RepositoryException {
-	Node content = parentNode.addNode("jcr:content", "nt:resource");
-	content.setProperty("jcr:mimeType", contentType);
-	content.setProperty("jcr:encoding", "");
-	content.setProperty("jcr:data", in);
-	content.setProperty("jcr:lastModified", Calendar.getInstance());
-    }
-
-    /**
      * Creates a new collection as member of this resource.
      *
      * @see DavResource#addMember(DavResource)
@@ -391,12 +353,19 @@
             throw new DavException(DavServletResponse.SC_LOCKED);
         }
         try {
-            node.addNode(member.getDisplayName(), "nt:folder");
+            ImportContext ctx = new ImportContext(node);
+            ctx.setSystemId(member.getDisplayName());
+            ImportCollectionChain.getChain().execute(ctx);
             node.save();
         } catch (ItemExistsException e) {
+            log.error("Error while executing import chain: " + e.toString());
             throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
         } catch (RepositoryException e) {
+            log.error("Error while executing import chain: " + e.toString());
             throw new JcrDavException(e);
+        } catch (Exception e) {
+            log.error("Error while executing import chain: " + e.toString());
+            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
         }
     }
 
@@ -508,8 +477,12 @@
                     // LockException: no lock applies to this node >> ignore
                     // RepositoryException, AccessDeniedException or another error >> ignore
                 }
-            } else {
-                // not-jcr lockable >> check for webdav lock
+            }
+
+            // could not retrieve jcr-lock (either not jcr-lockable or the lock has
+            // been created before the node was made jcr-lockable. test if a simple
+            // webdav lock is present.
+            if (lock == null) {
                 lock = lockManager.getLock(type, scope, this);
             }
         }
@@ -528,8 +501,9 @@
      */
     public ActiveLock lock(LockInfo lockInfo) throws DavException {
 	ActiveLock lock = null;
-	if (isLockable(lockInfo.getType(), lockInfo.getScope())) {
-	    if (isJsrLockable()) {
+        if (isLockable(lockInfo.getType(), lockInfo.getScope())) {
+            // todo: deal with existing locks, that may have been created, before the node was jcr-lockable...            
+            if (isJsrLockable()) {
 		try {
 		    // try to execute the lock operation
 		    Lock jcrLock = node.lock(lockInfo.isDeep(), false);
@@ -540,7 +514,7 @@
 		    throw new JcrDavException(e);
 		}
 	    } else {
-		// create a new lock which creates a random lock token
+		// create a new webdav lock
 		lock = lockManager.createLock(lockInfo, this);
 	    }
 	} else {
@@ -556,11 +530,9 @@
         if (!exists()) {
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
-        /* since lock is always has infinite timeout >> no extra refresh needed
-           return a lockdiscovery with the lock-info and the default scope and type */
-        ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE);
+        ActiveLock lock = getLock(lockInfo.getType(), lockInfo.getScope());
         if (lock == null) {
-           throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock present on resource " + getResourcePath());
+           throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock with the given type/scope present on resource " + getResourcePath());
         }
         
         if (lock instanceof JcrActiveLock) {
@@ -573,6 +545,8 @@
         } else {
             lock = lockManager.refreshLock(lockInfo, lockToken, this);
         }
+        /* since lock has infinite lock (simple) or undefined timeout (jcr)
+           return the lock as retrieved from getLock. */
         return lock;
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/NodeResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/NodeResource.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/NodeResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/NodeResource.java Mon Apr 11 09:04:58 2005
@@ -16,7 +16,10 @@
 package org.apache.jackrabbit.server.simple.dav;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.util.Text;
+import org.apache.jackrabbit.server.io.ExportContext;
+import org.apache.jackrabbit.server.io.ExportCollectionChain;
+import org.apache.jackrabbit.server.io.ExportNCResourceChain;
+import org.apache.commons.chain.Command;
 
 import javax.jcr.*;
 import java.util.Date;
@@ -50,11 +53,6 @@
     public static SimpleDateFormat creationDateFormat =
 	new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
 
-    private static final String PROP_MIMETYPE = "jcr:mimeType";
-    private static final String PROP_ENCODING = "jcr:encoding";
-    private static final String PROP_LASTMODIFIED = "jcr:lastModified";
-    private static final String PROP_CREATED = "jcr:created";
-
     private long creationTime = 0;
     private long modificationTime = new Date().getTime();
     private long contentLength = 0;
@@ -69,120 +67,21 @@
      * @throws IllegalArgumentException if the given item is <code>null</code>
      */
     public NodeResource(DavResourceImpl davResource, Node node) throws ItemNotFoundException, RepositoryException {
-	try {
-	    if (davResource.isCollection()) {
-		createDirListingContent(node);
-	    } else {
-		if (node.hasProperty(PROP_CREATED)) {
-		    creationTime = node.getProperty(PROP_CREATED).getValue().getLong();
-		}
-		Node content = node.getPrimaryNodeType().getName().equals("nt:file")
-			? node.getNode("jcr:content")
-			: node;
-		if (content.getPrimaryNodeType().getName().equals("nt:resource")) {
-		    createPlainFileContent(content);
-		} else {
-		    createDocViewContent(content);
-		}
-	    }
-	} catch (IOException e) {
-	    // ignore
-	}
-    }
-
-    private void createPlainFileContent(Node content) throws IOException, RepositoryException {
-	if (content.hasProperty(PROP_LASTMODIFIED)) {
-	    modificationTime = content.getProperty(PROP_LASTMODIFIED).getLong();
-	}
-	if (content.hasProperty(PROP_MIMETYPE)) {
-	    contentType = content.getProperty(PROP_MIMETYPE).getString();
-	}
-	if (content.hasProperty(PROP_ENCODING)) {
-	    String encoding = content.getProperty(PROP_ENCODING).getString();
-	    if (!encoding.equals("")) {
-		contentType+="; charset=\"" + encoding + "\"";
-	    }
-	}
-	if (content.hasProperty("jcr:data")) {
-	    Property p = content.getProperty("jcr:data");
-	    contentLength = p.getLength();
-	    in = p.getStream();
-	} else {
-	    contentLength = 0;
-	}
-    }
-
-    private void createDocViewContent(Node node) throws IOException, RepositoryException {
-	File tmpfile = File.createTempFile("__webdav", ".xml");
-	FileOutputStream out = new FileOutputStream(tmpfile);
-	node.getSession().exportDocView(node.getPath(), out, true, false);
-	out.close();
-	in = new FileInputStream(tmpfile);
-	contentLength = tmpfile.length();
-	modificationTime = tmpfile.lastModified();
-	contentType = "text/xml";
-	tmpfile.deleteOnExit();
-    }
-
-    private void createSysViewContent(Node node) throws IOException, RepositoryException {
-	File tmpfile = File.createTempFile("__webdav", ".xml");
-	FileOutputStream out = new FileOutputStream(tmpfile);
-	node.getSession().exportSysView(node.getPath(), out, true, false);
-	out.close();
-	in = new FileInputStream(tmpfile);
-	contentLength = tmpfile.length();
-	modificationTime = tmpfile.lastModified();
-	contentType = "text/xml";
-	tmpfile.deleteOnExit();
-    }
-
-    private void createDirListingContent(Node node) throws IOException, RepositoryException {
-	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("nt:file")) {
-		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();
-	in = new FileInputStream(tmpfile);
-	contentLength = tmpfile.length();
-	modificationTime = tmpfile.lastModified();
-	contentType = "text/html";
-	tmpfile.deleteOnExit();
+        ExportContext ctx = new ExportContext(node);
+        Command exportChain =davResource.isCollection()
+                ? ExportCollectionChain.getChain()
+                : ExportNCResourceChain.getChain();
+        try {
+            exportChain.execute(ctx);
+        } catch (Exception e) {
+            log.error("Error while executing export chain: " + e.toString());
+            throw new RepositoryException(e);
+        }
+        this.contentLength = ctx.getContentLength();
+        this.contentType = ctx.getContentType();
+        this.in = ctx.getInputStream();
+        this.creationTime = ctx.getCreationTime();
+        this.modificationTime = ctx.getModificationTime();
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java Mon Apr 11 09:04:58 2005
@@ -140,7 +140,7 @@
     public ActiveLock refreshLock(LockInfo lockInfo, String lockToken, DavResource resource)
 	    throws DavException {
 	// timeout is always infinite > no test for expiration or adjusting timeout needed.
-	ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE, resource);
+	ActiveLock lock = getLock(lockInfo.getType(), lockInfo.getScope(), resource);
 	if (lock == null) {
 	    throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED);
 	} else if (!lock.getToken().equals(lockToken)) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractResource.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractResource.java Mon Apr 11 09:04:58 2005
@@ -106,7 +106,7 @@
      * @see DavResourceLocator#getHref(boolean)
      */
     public String getHref() {
-        return locator.getHref(true);
+        return locator.getHref(isCollection());
     }
 
     /**
@@ -294,7 +294,7 @@
      * @see DavResource#refreshLock(org.apache.jackrabbit.webdav.lock.LockInfo, String)
      */
     public ActiveLock refreshLock(LockInfo info, String lockToken) throws DavException {
-        return txMgr.refreshLock(info, lockToken, this);
+        return txMgr.refreshLock(info, lockToken, this);        
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java Mon Apr 11 09:04:58 2005
@@ -24,6 +24,7 @@
 import org.apache.jackrabbit.webdav.ordering.*;
 import org.apache.jackrabbit.webdav.util.Text;
 import org.apache.jackrabbit.webdav.lock.*;
+import org.apache.jackrabbit.JCRConstants;
 
 import javax.jcr.*;
 import javax.jcr.lock.Lock;
@@ -430,8 +431,12 @@
             throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED);
         }
 
-        ActiveLock lock = getWriteLock();
-        if (lock != null && lockToken.equals(lock.getToken())) {
+        ActiveLock lock = getLock(reqLockInfo.getType(), reqLockInfo.getScope());
+        if (lock == null) {
+            throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock with the given scope/type present on this resource.");
+        }
+
+        if (Type.WRITE.equals(lock.getType())) {
             try {
                 Lock jcrLock = ((Node) item).getLock();
                 jcrLock.refresh();
@@ -599,13 +604,13 @@
      * resource: write locks (exclusive or exclusive session-scoped) in case the underlaying
      * node has the node type mix:lockable.
      *
-     * @see #MIX_LOCKABLE
+     * @see org.apache.jackrabbit.JCRConstants#MIX_LOCKABLE
      */
     protected void initLockSupport() {
         super.initLockSupport();
         // add exclusive write lock if allowed for the given node
         try {
-            if (exists() && ((Node)item).isNodeType(MIX_LOCKABLE)) {
+            if (exists() && ((Node)item).isNodeType(JCRConstants.MIX_LOCKABLE)) {
                 supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE);
                 // TODO: do session-scoped lock properly (including session caching and proper scope discovery)
                 //supportedLock.addEntry(new SessionScopedLockEntry());
@@ -643,16 +648,16 @@
             Node n = (Node)item;
             // overwrite the default modificationtime if possible
             try {
-		if (n.hasProperty(PROP_LASTMODIFIED)) {
-                    setModificationTime(n.getProperty(PROP_LASTMODIFIED).getLong());
+		if (n.hasProperty(JCRConstants.JCR_LASTMODIFIED)) {
+                    setModificationTime(n.getProperty(JCRConstants.JCR_LASTMODIFIED).getLong());
 		}
 	    } catch (RepositoryException e) {
 		log.warn("Error while accessing jcr:lastModified property");
 	    }
             // overwrite the default creation date if possible
             try {
-                if (n.hasProperty(PROP_CREATED)) {
-                    long creationTime = n.getProperty(PROP_CREATED).getValue().getLong();
+                if (n.hasProperty(JCRConstants.JCR_CREATED)) {
+                    long creationTime = n.getProperty(JCRConstants.JCR_CREATED).getValue().getLong();
                     properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE,
                             DavConstants.creationDateFormat.format(new Date(creationTime))));
                 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java Mon Apr 11 09:04:58 2005
@@ -99,7 +99,8 @@
      * @param property
      * @throws DavException
      * @see DavResource#setProperty(org.apache.jackrabbit.webdav.property.DavProperty)
-     * @todo undo incomplete modifications...
+     *
+     * todo: undo incomplete modifications...
      */
     public void setProperty(DavProperty property) throws DavException {
         if (!exists()) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/ItemResourceConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/ItemResourceConstants.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/ItemResourceConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/ItemResourceConstants.java Mon Apr 11 09:04:58 2005
@@ -50,16 +50,6 @@
     public static final String VERSIONSTORAGE_PATH = "/jcr:system/jcr:versionStorage";
 
     /**
-     * Constant for the mix:versionable node type name.
-     */
-    public static final String MIX_VERSIONABLE = "mix:versionable";
-
-    /**
-     * Constant for the mix:lockable node type name.
-     */
-    public static final String MIX_LOCKABLE = "mix:lockable";
-
-    /**
      * The namespace for all jcr specific extensions.
      */
     public static final Namespace NAMESPACE = Namespace.getNamespace("jcr", "http://www.day.com/jcr/webdav/1.0");
@@ -129,16 +119,4 @@
 
     // property names used for resource representing a workspace
     public static final DavPropertyName JCR_NAMESPACES = DavPropertyName.create("namespaces", NAMESPACE);
-
-    /**
-     * Property name for the jcr:created property present on Version items.
-     */
-    public static final DavPropertyName CREATED = DavPropertyName.create("created", ItemResourceConstants.NAMESPACE);
-
-    // JCR property names
-    public static final String PROP_LASTMODIFIED = "jcr:lastModified";
-    public static final String PROP_CREATED = "jcr:created";
-    public static final String PROP_BASEVERSION = "jcr:baseVersion";
-    public static final String PROP_PREDECESSORS = "jcr:predecessors";
-    public static final String PROP_MERGEFAILED = "jcr:mergeFailed";
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java Mon Apr 11 09:04:58 2005
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.webdav.*;
 import org.apache.jackrabbit.webdav.version.*;
 import org.apache.jackrabbit.webdav.version.report.*;
+import org.apache.jackrabbit.JCRConstants;
 
 import javax.jcr.*;
 import javax.jcr.observation.*;
@@ -95,7 +96,7 @@
         }
         if (!isVersionControlled()) {
             try {
-                ((Node)item).addMixin(MIX_VERSIONABLE);
+                ((Node)item).addMixin(JCRConstants.MIX_VERSIONABLE);
                 item.save();
             } catch (RepositoryException e) {
                 throw new JcrDavException(e);
@@ -308,10 +309,10 @@
             Node n = (Node)item;
             if (removePropertyNames.contains(AUTO_MERGE_SET)) {
                 // retrieve the current jcr:mergeFailed property values
-                if (!((Node)item).hasProperty(PROP_MERGEFAILED)) {
+                if (!((Node)item).hasProperty(JCRConstants.JCR_MERGEFAILED)) {
                     throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
                 }
-                Value[] mergeFailed = ((Node)item).getProperty(PROP_MERGEFAILED).getValues();
+                Value[] mergeFailed = ((Node)item).getProperty(JCRConstants.JCR_MERGEFAILED).getValues();
 
                 // resolve all remaining merge conflicts with 'cancel'
                 for (int i = 0; i < mergeFailed.length; i++) {
@@ -322,10 +323,10 @@
 
             } else if (setProperties.contains(AUTO_MERGE_SET) && setProperties.contains(PREDECESSOR_SET)){
                 // retrieve the current jcr:mergeFailed property values
-                if (!((Node)item).hasProperty(PROP_MERGEFAILED)) {
+                if (!((Node)item).hasProperty(JCRConstants.JCR_MERGEFAILED)) {
                     throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
                 }
-                Value[] mergeFailed = ((Node)item).getProperty(PROP_MERGEFAILED).getValues();
+                Value[] mergeFailed = ((Node)item).getProperty(JCRConstants.JCR_MERGEFAILED).getValues();
 
 
                 // check which mergeFailed entries have been removed from the
@@ -460,15 +461,15 @@
                         properties.add(new HrefProperty(CHECKED_OUT, baseVHref, true));
 
                         // DAV:predecessors property
-                        if (n.hasProperty(PROP_PREDECESSORS)) {
-                            Value[] predec = n.getProperty(PROP_PREDECESSORS).getValues();
+                        if (n.hasProperty(JCRConstants.JCR_PREDECESSORS)) {
+                            Value[] predec = n.getProperty(JCRConstants.JCR_PREDECESSORS).getValues();
                             addHrefProperty(PREDECESSOR_SET, predec, false);
                         }
                         // DAV:auto-merge-set property. NOTE: the DAV:merge-set
                         // never occurs, because merging without bestEffort flag
                         // being set results in an exception on failure.
-                        if (n.hasProperty(PROP_MERGEFAILED)) {
-                            ReferenceValue[] mergeFailed = (ReferenceValue[]) n.getProperty(PROP_MERGEFAILED).getValues();
+                        if (n.hasProperty(JCRConstants.JCR_MERGEFAILED)) {
+                            ReferenceValue[] mergeFailed = (ReferenceValue[]) n.getProperty(JCRConstants.JCR_MERGEFAILED).getValues();
                             addHrefProperty(AUTO_MERGE_SET, mergeFailed, false);
                         }
                         // todo: checkout-fork, checkin-fork

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionItemCollection.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionItemCollection.java Mon Apr 11 09:04:58 2005
@@ -23,6 +23,7 @@
 import org.apache.jackrabbit.webdav.property.*;
 import org.apache.jackrabbit.webdav.version.*;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.JCRConstants;
 import org.jdom.Element;
 
 import javax.jcr.*;
@@ -156,8 +157,6 @@
             // created and creationDate properties
             try {
                 String creationDate = DavConstants.creationDateFormat.format(v.getCreated().getTime());
-                // jcr specific 'created' property
-                properties.add(new DefaultDavProperty(CREATED, creationDate));
                 // replace dummy creation date from default collection
                 properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, creationDate));
 
@@ -185,7 +184,7 @@
                 List nodeList = new ArrayList();
                 while (it.hasNext()) {
                     Property p = it.nextProperty();
-                    if (PROP_BASEVERSION.equals(p.getName())) {
+                    if (JCRConstants.JCR_BASEVERSION.equals(p.getName())) {
                         Node n = p.getParent();
                         if (n.isCheckedOut()) {
                            nodeList.add(n);

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.xml?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.xml (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.xml Mon Apr 11 09:04:58 2005
@@ -0,0 +1,133 @@
+<?xml version="1.0" ?>
+<!--
+    command catalog for import/export of resources
+-->
+<catalog>
+    <!--
+        command-chain for importing a webdav collection into the jcr repository
+    -->
+    <chain name="import-collection">
+        <!--
+            create a new node with the given node type using the systemid of
+            the resource to be imported. the current node of the import context
+            is set to the newly created node.
+            @param nodeType the node type of the node to be created
+            @return false
+        -->
+        <command
+            id="add-folder"
+            className="org.apache.jackrabbit.server.io.AddNodeCommand"
+            nodeType="nt:folder"
+        />
+    </chain>
+
+    <!--
+        command-chain for importing a webdav non-collection-resource into the jcr repository
+    -->
+    <chain name="import-nc-resource">
+        <!--
+            registers the content type of the resource in the import context
+            @return false
+        -->
+        <command
+            id="set-contenttype"
+            className="org.apache.jackrabbit.server.io.SetContentTypeCommand"
+        />
+
+        <!--
+            if content type is application/zip, this command recursivly imports
+            the contents of the zip.
+            @return true, if the command completed; false otherwise.
+        -->
+        <command
+            id="import-zip"
+            className="org.apache.jackrabbit.server.io.ZIPImportCommand"
+        />
+
+        <!--
+            create a new node with the given node type using the systemid of
+            the resource to be imported. the current node of the import context
+            is set to the newly created node.
+            @param nodeType the node type of the node to be created
+            @return false
+        -->
+        <command
+            id="add-file"
+            className="org.apache.jackrabbit.server.io.AddNodeCommand"
+            nodeType="nt:file"
+        />
+
+        <!--
+            adds a mixin nodetype to the current node
+            @param nodeType the mixin node type to add
+            @return false
+        -->
+        <command
+            id="make-versionable"
+            className="org.apache.jackrabbit.server.io.AddMixinCommand"
+            nodeType="mix:versionable"
+        />
+
+        <!--
+            if the content type matches 'text/xml' the content of the resource
+            i considered as xml and deserialized into the jcr repository.
+            @return false
+        -->
+        <command
+            id="import-xml"
+            className="org.apache.jackrabbit.server.io.XMLImportCommand"
+        />
+
+        <!--
+            the content of the resource is added a nt:resource to the repository
+            @return false
+        -->
+        <command
+            id="import-file"
+            className="org.apache.jackrabbit.server.io.FileImportCommand"
+        />
+    </chain>
+
+    <!--
+        command-chain for exporting collections
+    -->
+    <chain name="export-collection">
+        <!--
+            exports a HTML listing of the child nodes of the exported collection.
+            nodes having the 'collectionNodeType' node type are displayed as
+            directory links.
+            @param collectionNodeType node type for collections
+            @return true
+        -->
+        <command
+            id="export-dirlisting"
+            className="org.apache.jackrabbit.server.io.DirListingExportCommand"
+            collectionNodeType="nt:folder"
+        />
+    </chain>
+
+    <!--
+        command-chain for exporting non-collection-resources
+    -->
+    <chain name="export-nc-resource">
+        <!--
+            exports the jcr:data property if the node contains a jcr:content
+            node of type nt:resource.
+            @return true if the node was exported; false otherwise.
+        -->
+        <command
+            id="export-file"
+            className="org.apache.jackrabbit.server.io.FileExportCommand"
+        />
+        <!--
+            exports the node as docview or sysview content
+            @param mode the export mode. either 'docview' or 'sysview'
+            @return true
+        -->
+        <command
+            id="export-docxml"
+            className="org.apache.jackrabbit.server.io.XMLExportCommand"
+            mode="docview"
+        />
+    </chain>
+</catalog>
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/simple_catalog.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/simple_catalog.xml?view=auto&rev=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/simple_catalog.xml (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/simple_catalog.xml Mon Apr 11 09:04:58 2005
@@ -0,0 +1,51 @@
+<?xml version="1.0" ?>
+<!--
+    defines the minimal command catalog for import/export of resources
+-->
+<catalog>
+    <!--
+        command-chain for importing a webdav collection into the jcr repository
+    -->
+    <chain name="import-collection">
+        <command
+            id="add-folder"
+            className="org.apache.jackrabbit.server.io.AddNodeCommand"
+            nodeType="nt:folder"
+        />
+    </chain>
+
+    <!--
+        command-chain for importing a webdav non-collection-resource into the jcr repository
+    -->
+    <chain name="import-nc-resource">
+        <command
+            id="set-contenttype"
+            className="org.apache.jackrabbit.server.io.SetContentTypeCommand"
+        />
+        <command
+            id="add-file"
+            className="org.apache.jackrabbit.server.io.AddNodeCommand"
+            nodeType="nt:file"
+        />
+        <command
+            id="import-file"
+            className="org.apache.jackrabbit.server.io.FileImportCommand"
+        />
+    </chain>
+
+    <!--
+        command-chain for exporting collections
+    -->
+    <chain name="export-collection">
+    </chain>
+
+    <!--
+        command-chain for exporting non-collection-resources
+    -->
+    <chain name="export-nc-resource">
+        <command
+            id="export-file"
+            className="org.apache.jackrabbit.server.io.FileExportCommand"
+        />
+    </chain>
+</catalog>
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/simple_catalog.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml Mon Apr 11 09:04:58 2005
@@ -151,6 +151,13 @@
                 defines the prefix for spooling resources out of the repository.
             </description>
         </init-param>
+        <init-param>
+            <param-name>chain-catalog</param-name>
+            <param-value>/WEB-INF/catalog.xml</param-value>
+            <description>
+                the defines the commons-chain catalog for server tasks.
+            </description>
+        </init-param>
         <load-on-startup>3</load-on-startup>
     </servlet>
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java Mon Apr 11 09:04:58 2005
@@ -110,7 +110,8 @@
 
     /**
      * Returns the lock type or <code>null</null> if no 'lockinfo' element was
-     * passed to the constructor or did not contain an 'type' element.
+     * passed to the constructor or did not contain an 'type' element and the
+     * type has not been set otherwise.
      *
      * @return type or <code>null</code>
      */
@@ -119,13 +120,32 @@
     }
 
     /**
+     * Set the lock type.
+     *
+     * @param type
+     */
+    public void setType(Type type) {
+        this.type = type;
+    }
+
+    /**
      * Return the lock scope or <code>null</null> if no 'lockinfo' element was
-     * passed to the constructor or did not contain an 'scope' element.
+     * passed to the constructor or did not contain an 'scope' element and the
+     * scope has not been set otherwise.
      *
      * @return scope or <code>null</code>
      */
     public Scope getScope() {
         return scope;
+    }
+
+    /**
+     * Set the lock scope.
+     *
+     * @param scope
+     */
+    public void setScope(Scope scope) {
+        this.scope = scope;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/Text.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/Text.java?view=diff&r1=160913&r2=160914
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/Text.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/Text.java Mon Apr 11 09:04:58 2005
@@ -169,6 +169,28 @@
     }
 
     /**
+     * Creates a valid jcr label from the given one
+     *
+     * @param label
+     * @return
+     */
+    public static String makeValidJCRPath(String label) {
+        StringBuffer ret = new StringBuffer(label.length());
+        for (int i=0; i<label.length(); i++) {
+            char c = label.charAt(i);
+            if (c=='*' || c=='\'' || c=='\"') {
+                c='_';
+            } else if (c=='[') {
+                c='(';
+            } else if (c==']') {
+                c=')';
+            }
+            ret.append(c);
+        }
+        return ret.toString();
+    }
+
+    /**
      * compares to handles lexigographically with one exception: the '/'
      * character is always considered smaller than all other chars. this results
      * in a ordering, in which the parent pages come first (it's about 6 times



Mime
View raw message