jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r190721 - in /incubator/jackrabbit/trunk/contrib/jcr-server: commons/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/webdav/simple/ webapp/ webapp/src/java/org/apache/jackrabbit/j2ee/ webdav/src/java/org/apache/jackrabbit/ webdav/src/java/org/apache/jackrabbit/webdav/lock/
Date Wed, 15 Jun 2005 08:47:58 GMT
Author: tripod
Date: Wed Jun 15 01:47:56 2005
New Revision: 190721

URL: http://svn.apache.org/viewcvs?rev=190721&view=rev
Log:
- [JCR-134] extensibility patch for DavResourceImpl
- moving JcrConstants.java to commons
- fixing minor import issues
- readding lost stuff
- adding proper shutdown to RepositoryStartupServlet.java

Added:
    incubator/jackrabbit/trunk/contrib/jcr-server/commons/src/java/org/apache/jackrabbit/JcrConstants.java
  (with props)
Removed:
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/JcrConstants.java
Modified:
    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/io/AbstractImportCommand.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/JCRWebdavServerServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SimpleLockManager.java

Added: incubator/jackrabbit/trunk/contrib/jcr-server/commons/src/java/org/apache/jackrabbit/JcrConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/commons/src/java/org/apache/jackrabbit/JcrConstants.java?rev=190721&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/commons/src/java/org/apache/jackrabbit/JcrConstants.java
(added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/commons/src/java/org/apache/jackrabbit/JcrConstants.java
Wed Jun 15 01:47:56 2005
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 2005 Your Corporation. All Rights Reserved.
+ */
+package org.apache.jackrabbit;
+
+/**
+ * This Interface defines some jcr constants
+ */
+public interface JcrConstants {
+    /**
+     * jcr:autoCreated
+     */
+    public static final String JCR_AUTOCREATED = "jcr:autoCreated";
+    /**
+     * jcr:baseVersion
+     */
+    public static final String JCR_BASEVERSION = "jcr:baseVersion";
+    /**
+     * jcr:child
+     */
+    public static final String JCR_CHILD = "jcr:child";
+    /**
+     * jcr:childNodeDefinition
+     */
+    public static final String JCR_CHILDNODEDEFINITION = "jcr:childNodeDefinition";
+    /**
+     * 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:propertyDefinition
+     */
+    public static final String JCR_PROPERTYDEFINITION = "jcr:propertyDefinition";
+    /**
+     * 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:sameNameSiblings
+     */
+    public static final String JCR_SAMENAMESIBLINGS = "jcr:sameNameSiblings";
+    /**
+     * 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";
+    /**
+     * jcr:versionableUuid
+     */
+    public static final String JCR_VERSIONABLEUUID = "jcr:versionableUuid";
+
+    /**
+     * Pseudo property jcr:path used with query results
+     */
+    public static final String JCR_PATH = "jcr:path";
+    /**
+     * Pseudo property jcr:score used with query results
+     */
+    public static final String JCR_SCORE = "jcr:score";
+
+    /**
+     * 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:childNodeDefinition
+     */
+    public static final String NT_CHILDNODEDEFINITION = "nt:childNodeDefinition";
+    /**
+     * 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:propertyDefinition
+     */
+    public static final String NT_PROPERTYDEFINITION = "nt:propertyDefinition";
+    /**
+     * 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";
+    /**
+     * rep:frozen
+     */
+    public static final String REP_FROZEN = "rep:frozen";
+    /**
+     * rep:frozenVersionHistory
+     */
+    public static final String REP_FROZENVERSIONHISTORY = "rep:frozenVersionHistory";
+    /**
+     * rep:nodeTypes
+     */
+    public static final String REP_NODETYPES = "rep:nodeTypes";
+    /**
+     * rep:root
+     */
+    public static final String REP_ROOT = "rep:root";
+    /**
+     * rep:system
+     */
+    public static final String REP_SYSTEM = "rep:system";
+    /**
+     * 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";
+}

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

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/commons/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?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- 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
Wed Jun 15 01:47:56 2005
@@ -107,7 +107,14 @@
      *
      * @return the session provider
      */
-    abstract public DavSessionProvider getSessionProvider();
+    abstract public DavSessionProvider getDavSessionProvider();
+
+    /**
+     * Returns the <code>DavSessionProvider</code>.
+     *
+     * @param davSessionProvider
+     */
+    abstract public void setDavSessionProvider(DavSessionProvider davSessionProvider);
 
     /**
      * Returns the <code>DavLocatorFactory</code>.
@@ -117,6 +124,13 @@
     abstract public DavLocatorFactory getLocatorFactory();
 
     /**
+     * Sets the <code>DavLocatorFactory</code>.
+     *
+     * @param locatorFactory
+     */
+    abstract public void setLocatorFactory(DavLocatorFactory locatorFactory);
+
+    /**
      * Returns the <code>DavResourceFactory</code>.
      *
      * @return the resource factory
@@ -124,6 +138,13 @@
     abstract public DavResourceFactory getResourceFactory();
 
     /**
+     * Sets the <code>DavResourceFactory</code>.
+     *
+     * @param resourceFactory
+     */
+    abstract public void setResourceFactory(DavResourceFactory resourceFactory);
+
+    /**
      * Returns the value of the 'WWW-Authenticate' header, that is returned in
      * case of 401 error.
      *
@@ -146,7 +167,7 @@
         WebdavResponse webdavResponse = new WebdavResponseImpl(response);
         try {
             // make sure there is a authenticated user
-            if (!getSessionProvider().attachSession(webdavRequest)) {
+            if (!getDavSessionProvider().attachSession(webdavRequest)) {
                 return;
             }
 
@@ -170,7 +191,7 @@
                 webdavResponse.sendErrorResponse(e);
             }
         } finally {
-            getSessionProvider().releaseSession(webdavRequest);
+            getDavSessionProvider().releaseSession(webdavRequest);
         }
     }
 

Modified: 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?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractImportCommand.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractImportCommand.java
Wed Jun 15 01:47:56 2005
@@ -75,9 +75,9 @@
 
         if (importResource(context, fileNode, in)) {
             context.setInputStream(null);
+            // set current node
+            context.setNode(fileNode);
         }
-        // set current node
-        context.setNode(fileNode);
         return false;
     }
 

Modified: 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?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java
Wed Jun 15 01:47:56 2005
@@ -16,10 +16,15 @@
  */
 package org.apache.jackrabbit.server.io;
 
+import org.apache.log4j.Logger;
+
 import javax.jcr.Node;
 import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.RepositoryException;
 import java.io.InputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
 import java.util.Calendar;
 
 /**
@@ -31,7 +36,12 @@
  * <li>jcr:lastModified (from current time)
  * </ul>
  */
-public class XMLImportCommand extends AbstractImportCommand {
+public class XMLImportCommand extends AbstractCommand {
+
+    /**
+     * the default logger
+     */
+    private static Logger log = Logger.getLogger(XMLImportCommand.class);
 
     /**
      * the xml content type
@@ -44,6 +54,100 @@
     private String contentNodeType = NT_UNSTRUCTURED;
 
     /**
+     * the nodetype for the node
+     */
+    private String nodeType = "nt:file";
+
+    /**
+     * 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(AbstractContext 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;
+        }
+
+        // we need a tmp file, since the import could fail
+        File tmpFile = File.createTempFile("__xmlimport", "xml");
+        FileOutputStream out = new FileOutputStream(tmpFile);
+        byte[] buffer = new byte[8192];
+        boolean first = true;
+        boolean isSysView = false;
+        int read;
+        while ((read=in.read(buffer))>0) {
+            out.write(buffer, 0, read);
+            if (first) {
+                first = false;
+                // could be too less information. is a bit a lazy test
+                isSysView = new String(buffer, 0, read).indexOf("<sv:node") >= 0;
+            }
+        }
+        out.close();
+        in.close();
+        in = new FileInputStream(tmpFile);
+        context.setInputStream(in);
+
+        if (isSysView) {
+            // just import sys view
+            try {
+                parentNode.getSession().importXML(parentNode.getPath(), in,
+                        ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
+                context.setInputStream(null);
+                // no further processing
+                return true;
+            } catch (RepositoryException e) {
+                // if error occurrs, reset input stream
+                context.setInputStream(new FileInputStream(tmpFile));
+                log.error("Unable to import sysview. will store as normal file: " + e.toString());
+                parentNode.refresh(false);
+            } finally {
+                in.close();
+            }
+        } else {
+            // check 'file' node
+            Node fileNode = parentNode.hasNode(context.getSystemId())
+                    ? parentNode.getNode(context.getSystemId())
+                    : parentNode.addNode(context.getSystemId(), nodeType);
+            if (importResource(context, fileNode, in)) {
+                context.setInputStream(null);
+                // set current node
+                context.setNode(fileNode);
+            } else {
+                context.setInputStream(new FileInputStream(tmpFile));
+            }
+        }
+        return false;
+    }
+
+    /**
      * Imports the resource by deseriaizing the xml.
      * @param ctx
      * @param parentNode
@@ -54,6 +158,7 @@
     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, contentNodeType);
@@ -71,7 +176,17 @@
         } catch (RepositoryException e) {
             // ignore
         }
-        parentNode.getSession().importXML(content.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+        try {
+            parentNode.getSession().importXML(content.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+        } catch (RepositoryException e) {
+            // if this fails, we ignore import and pass to next command
+            if (content.isNew()) {
+                content.remove();
+            }
+            return false;
+        } finally {
+            in.close();
+        }
         return true;
     }
 
@@ -101,4 +216,13 @@
     public void setContentNodeType(String contentNodeType) {
         this.contentNodeType = contentNodeType;
     }
+
+    /**
+     * Sets the node type
+     * @param nodeType
+     */
+    public void setNodeType(String nodeType) {
+        this.nodeType = nodeType;
+    }
+
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
Wed Jun 15 01:47:56 2005
@@ -587,6 +587,14 @@
     }
 
     /**
+     * Returns the node that is wrapped by this resource.
+     * @return
+     */
+    protected Node getNode() {
+        return node;
+    }
+    
+    /**
      * Returns true, if this webdav resource allows for locking without checking
      * its current lock status.
      *

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml Wed Jun 15 01:47:56 2005
@@ -68,14 +68,23 @@
             <groupId>jsr170</groupId>
             <artifactId>jcr</artifactId>
             <version>${jackrabbit.build.version.jcr}</version>
+            <properties>
+                <war.bundle>true</war.bundle>
+            </properties>
         </dependency>
         <dependency>
             <id>jackrabbit</id>
             <version>${jackrabbit.build.version.jackrabbit}</version>
+            <properties>
+                <war.bundle>true</war.bundle>
+            </properties>
         </dependency>
         <dependency>
             <id>jcr-rmi</id>
             <version>${jackrabbit.build.version.jcr.rmi}</version>
+            <properties>
+                <war.bundle>true</war.bundle>
+            </properties>
         </dependency>
         
         <!-- non-jackrabbit dependencies -->
@@ -100,14 +109,23 @@
         <dependency>
             <id>commons-chain</id>
             <version>1.0</version>
+            <properties>
+                <war.bundle>true</war.bundle>
+            </properties>
         </dependency>
         <dependency>
             <id>commons-digester</id>
             <version>1.6</version>
+            <properties>
+                <war.bundle>true</war.bundle>
+            </properties>
         </dependency>
         <dependency>
             <id>commons-beanutils</id>
             <version>1.7.0</version>
+            <properties>
+                <war.bundle>true</war.bundle>
+            </properties>
         </dependency>
 
         <!-- dependencies of jackrabbit -->

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/JCRWebdavServerServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/JCRWebdavServerServlet.java?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/JCRWebdavServerServlet.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/JCRWebdavServerServlet.java
Wed Jun 15 01:47:56 2005
@@ -47,6 +47,7 @@
      */
     public static final String INIT_PARAM_PREFIX = "resource-path-prefix";
 
+    private String pathPrefix;
     private JCRWebdavServer server;
     private DavResourceFactory resourceFactory;
     private DavLocatorFactory locatorFactory;
@@ -66,7 +67,7 @@
         super.init();
 
 	// set resource path prefix
-	String pathPrefix = getInitParameter(INIT_PARAM_PREFIX);
+	pathPrefix = getInitParameter(INIT_PARAM_PREFIX);
 	log.debug(INIT_PARAM_PREFIX + " = " + pathPrefix);
 
 	Repository repository = RepositoryAccessServlet.getRepository();
@@ -89,10 +90,14 @@
     }
 
     /**
+     * Returns true if the preconditions are met. This includes validation of
+     * {@link WebdavRequest#matchesIfHeader(DavResource) If header} and validation
+     * of {@link org.apache.jackrabbit.webdav.transaction.TransactionConstants#HEADER_TRANSACTIONID
+     * TransactionId header}. This method will also return false if the requested
+     * resource lays within a differenct workspace as is assigned to the repository
+     * session attached to the given request.
      *
-     * @param request
-     * @param resource
-     * @return
+     * @see AbstractWebdavServlet#isPreconditionValid(WebdavRequest, DavResource)
      */
     protected boolean isPreconditionValid(WebdavRequest request, DavResource resource) {
         // first check matching If header
@@ -117,24 +122,64 @@
     }
 
     /**
-     * {@inheritDoc}
+     * Returns the <code>DavSessionProvider</code>
+     *
+     * @return server
+     * @see AbstractWebdavServlet#getDavSessionProvider()
      */
-    public DavSessionProvider getSessionProvider() {
+    public DavSessionProvider getDavSessionProvider() {
         return server;
     }
 
     /**
-     * {@inheritDoc}
+     * Throws <code>UnsupportedOperationException</code>.
+     *
+     * @see AbstractWebdavServlet#setDavSessionProvider(DavSessionProvider)
+     */
+    public void setDavSessionProvider(DavSessionProvider davSessionProvider) {
+        throw new UnsupportedOperationException("Not implemented. DavSession(s) are provided
by the 'JCRWebdavServer'");
+    }
+
+    /**
+     * Returns the <code>DavLocatorFactory</code>
+     *
+     * @see AbstractWebdavServlet#getLocatorFactory()
      */
     public DavLocatorFactory getLocatorFactory() {
+        if (locatorFactory == null) {
+            locatorFactory = new DavLocatorFactoryImpl(pathPrefix);
+        }
         return locatorFactory;
     }
 
     /**
-     * {@inheritDoc}
+     * Sets the <code>DavLocatorFactory</code>
+     *
+     * @see AbstractWebdavServlet#setLocatorFactory(DavLocatorFactory)
+     */
+    public void setLocatorFactory(DavLocatorFactory locatorFactory) {
+        this.locatorFactory = locatorFactory;
+    }
+
+    /**
+     * Returns the <code>DavResourceFactory</code>. 
+     *
+     * @see AbstractWebdavServlet#getResourceFactory()
      */
     public DavResourceFactory getResourceFactory() {
+        if (resourceFactory == null) {
+            resourceFactory = new DavResourceFactoryImpl(txMgr, subscriptionMgr);
+        }
         return resourceFactory;
+    }
+
+    /**
+     * Sets the <code>DavResourceFactory</code>.
+     *
+     * @see AbstractWebdavServlet#setResourceFactory(org.apache.jackrabbit.webdav.DavResourceFactory)
+     */
+    public void setResourceFactory(DavResourceFactory resourceFactory) {
+        this.resourceFactory = resourceFactory;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
Wed Jun 15 01:47:56 2005
@@ -98,9 +98,14 @@
 	} else {
 	    log.info("RepositoryStartupServlet shutting down...");
 	}
+        shutdownRepository();
 	unregisterRMI();
 	unregisterJNDI();
-	log("RepositoryStartupServlet shut down.");
+        if (log == null) {
+            log("RepositoryStartupServlet shut down.");
+        } else {
+            log.info("RepositoryStartupServlet shut down.");
+        }
     }
 
     /**
@@ -179,6 +184,12 @@
 	}
     }
 
+    private void shutdownRepository() {
+        if (repository instanceof RepositoryImpl) {
+            ((RepositoryImpl) repository).shutdown();
+            repository = null;
+        }
+    }
     /**
      * Creates the repository for the given config and homedir.
      *

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java
Wed Jun 15 01:47:56 2005
@@ -118,12 +118,12 @@
     private Repository repository;
 
     /**
-     * the session provider
+     * the webdav session provider
      */
     private DavSessionProvider davSessionProvider;
 
     /**
-     * the session provider
+     * the repository session provider
      */
     private SessionProvider sessionProvider;
 
@@ -145,11 +145,6 @@
         }
         log.info(INIT_PARAM_RESOURCE_PATH_PREFIX + " = '" + resourcePathPrefix + "'");
 
-        // init repository
-        repository = RepositoryAccessServlet.getRepository();
-        if (repository == null) {
-            throw new ServletException("Repository could not be retrieved. Check config of
'RepositoryAccessServlet'.");
-        }
         try {
             String chain = getInitParameter(INIT_PARAM_CHAIN_CATALOG);
             URL chainUrl = getServletContext().getResource(chain);
@@ -276,6 +271,7 @@
      * returned.
      *
      * @return the locator factory
+     * @see AbstractWebdavServlet#getLocatorFactory()
      */
     public DavLocatorFactory getLocatorFactory() {
         if (locatorFactory == null) {
@@ -285,6 +281,16 @@
     }
 
     /**
+     * Sets the <code>DavLocatorFactory</code>.
+     *
+     * @param locatorFactory
+     * @see AbstractWebdavServlet#setLocatorFactory(DavLocatorFactory)
+     */
+    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.
@@ -299,11 +305,21 @@
     }
 
     /**
+     * Sets the <code>LockManager</code>.
+     *
+     * @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
+     * @see org.apache.jackrabbit.server.AbstractWebdavServlet#getResourceFactory()
      */
     public DavResourceFactory getResourceFactory() {
         if (resourceFactory == null) {
@@ -313,23 +329,25 @@
     }
 
     /**
-     * Returns the header value retrieved from the {@link #INIT_PARAM_AUTHENTICATE_HEADER}
-     * init parameter. If the parameter is missing, the value defaults to
-     * {@link #DEFAULT_AUTHENTICATE_HEADER}.
+     * Sets the <code>DavResourceFactory</code>.
      *
-     * @return the header value retrieved from the corresponding init parameter
-     * or {@link #DEFAULT_AUTHENTICATE_HEADER}.
+     * @param resourceFactory
+     * @see AbstractWebdavServlet#setResourceFactory(org.apache.jackrabbit.webdav.DavResourceFactory)
      */
-    public String getAuthenticateHeaderValue() {
-        return authenticate_header;
+    public void setResourceFactory(DavResourceFactory resourceFactory) {
+        this.resourceFactory = resourceFactory;
     }
 
     /**
-     * Returns the <code>DavSessionProvider</code>.
+     * Returns the <code>SessionProvider</code>. If no session provider has been
+     * set or created a new instance of {@link SessionProviderImpl} that extracts
+     * credentials from the request's <code>Authorization</code> header is
+     * returned.
      *
      * @return the session provider
+     * @see RepositoryAccessServlet#getCredentialsFromHeader(String)
      */
-    public synchronized SessionProvider getRepositorySessionProvider() {
+    public synchronized SessionProvider getSessionProvider() {
         if (sessionProvider == null) {
             CredentialsProvider cp = new CredentialsProvider() {
                 public Credentials getCredentials(HttpServletRequest request) throws LoginException,
ServletException {
@@ -342,16 +360,77 @@
     }
 
     /**
-     * Returns the <code>DavSessionProvider</code>.
+     * Sets the <code>SessionProvider</code>.
+     *
+     * @param sessionProvider
+     */
+    public synchronized void setSessionProvider(SessionProvider sessionProvider) {
+        this.sessionProvider = sessionProvider;
+    }
+
+    /**
+     * Returns the <code>DavSessionProvider</code>. If no session provider has
+     * been set or created a new instance of {@link DavSessionProviderImpl}
+     * is returned.
      *
      * @return the session provider
+     * @see org.apache.jackrabbit.server.AbstractWebdavServlet#getDavSessionProvider()
      */
-    public synchronized DavSessionProvider getSessionProvider() {
+    public synchronized DavSessionProvider getDavSessionProvider() {
         if (davSessionProvider == null) {
             davSessionProvider =
-                    new DavSessionProviderImpl(repository, getRepositorySessionProvider());
+                new DavSessionProviderImpl(getRepository(), getSessionProvider());
         }
         return davSessionProvider;
     }
 
+    /**
+     * Sets the <code>DavSessionProvider</code>.
+     *
+     * @param sessionProvider
+     * @see AbstractWebdavServlet#setDavSessionProvider(org.apache.jackrabbit.webdav.DavSessionProvider)
+     */
+    public synchronized void setDavSessionProvider(DavSessionProvider sessionProvider) {
+        this.davSessionProvider = sessionProvider;
+    }
+
+    /**
+     * Returns the header value retrieved from the {@link #INIT_PARAM_AUTHENTICATE_HEADER}
+     * init parameter. If the parameter is missing, the value defaults to
+     * {@link #DEFAULT_AUTHENTICATE_HEADER}.
+     *
+     * @return the header value retrieved from the corresponding init parameter
+     * or {@link #DEFAULT_AUTHENTICATE_HEADER}.
+     * @see org.apache.jackrabbit.server.AbstractWebdavServlet#getAuthenticateHeaderValue()
+     */
+    public String getAuthenticateHeaderValue() {
+        return authenticate_header;
+    }
+
+    /**
+     * Returns the <code>Repository</code>. If no repository has been set or
+     * created the repository initialized by <code>RepositoryAccessServlet</code>
+     * is returned.
+     *
+     * @return repository
+     * @see RepositoryAccessServlet#getRepository()
+     */
+    public Repository getRepository() {
+        if (repository == null) {
+            repository = RepositoryAccessServlet.getRepository();
+            if (repository == null) {
+                throw new IllegalStateException("Repository could not be retrieved. Check
config of 'RepositoryAccessServlet'.");
+            }
+        }
+        return repository;
+    }
+
+    /**
+     * Sets the <code>Repository</code>.
+     *
+     * @param repository
+     */
+    public void setRepository(Repository repository) {
+        this.repository = repository;
+    }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SimpleLockManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SimpleLockManager.java?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SimpleLockManager.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SimpleLockManager.java
Wed Jun 15 01:47:56 2005
@@ -23,8 +23,6 @@
 
 /**
  * Simple manager for webdav locks.<br>
- * NOTE: the timeout requested is always replace by a infinite timeout and
- * expiration of locks is not checked.
  */
 public class SimpleLockManager implements LockManager {
 
@@ -55,33 +53,37 @@
      * @param resource
      * @return lock that applies to the given resource or <code>null</code>.
      */
-    public ActiveLock getLock(Type type, Scope scope, DavResource resource) {
+    public synchronized ActiveLock getLock(Type type, Scope scope, DavResource resource)
{
 	if (!(Type.WRITE.equals(type) && Scope.EXCLUSIVE.equals(scope))) {
 	    return null;
 	}
-	String key = resource.getResourcePath();
-	ActiveLock lock = (locks.containsKey(key)) ? (ActiveLock)locks.get(key) : null;
+        return getLock(resource.getResourcePath());
+    }
 
-	// look for an inherited lock
-	if (lock == null) {
-	    // cut path instead of retrieving the parent resource
-	    String parentPath = Text.getRelativeParent(key, 1);
-	    boolean found = false;
-	    /* stop as soon as parent lock is found:
-	    if the lock is deep or the parent is a collection the lock
-	    applies to the given resource. */
-	    while (!"/".equals(parentPath) && !(found = locks.containsKey(parentPath)))
{
-		parentPath = Text.getRelativeParent(parentPath, 1);
-	    }
-	    if (found) {
-		ActiveLock parentLock = (ActiveLock)locks.get(parentPath);
-		if (parentLock.isDeep()) {
-		    lock = parentLock;
-		}
-	    }
-	}
-	// since locks have infinite timeout, check for expired lock is omitted.
-	return lock;
+    /**
+     * Recursivly tries to find the lock
+     *
+     * @param path
+     * @return
+     */
+    private ActiveLock getLock(String path) {
+	ActiveLock lock = (ActiveLock) locks.get(path);
+        if (lock != null) {
+            // check if not expired
+            if (lock.isExpired()) {
+                lock = null;
+            }
+        }
+        if (lock == null) {
+            // check, if child of deep locked parent
+            if (!path.equals("/")) {
+                ActiveLock parentLock = getLock(Text.getRelativeParent(path, 1));
+                if (parentLock != null && parentLock.isDeep()) {
+                    lock = parentLock;
+                }
+            }
+        }
+        return lock;
     }
 
     /**
@@ -90,7 +92,8 @@
      * @param lockInfo
      * @param resource being the lock holder
      */
-    public synchronized ActiveLock createLock(LockInfo lockInfo, DavResource resource)
+    public synchronized ActiveLock createLock(LockInfo lockInfo,
+                                              DavResource resource)
 	    throws DavException {
 	if (lockInfo == null || resource == null) {
 	    throw new IllegalArgumentException("Neither lockInfo nor resource must be null.");
@@ -98,7 +101,12 @@
 
 	String resourcePath = resource.getResourcePath();
 	// test if there is already a lock present on this resource
-	if (locks.containsKey(resourcePath)) {
+        ActiveLock lock = (ActiveLock) locks.get(resourcePath);
+        if (lock != null && lock.isExpired()) {
+            locks.remove(resourcePath);
+            lock = null;
+        }
+        if (lock != null) {
 	    throw new DavException(DavServletResponse.SC_LOCKED, "Resource '" + resource.getResourcePath()
+ "' already holds a lock.");
 	}
 	// test if the new lock would conflict with any lock inherited from the
@@ -119,10 +127,7 @@
 
 	    }
 	}
-	ActiveLock lock = new DefaultActiveLock(lockInfo);
-	// Lazy: reset the timeout to 'Infinite', in order to omit the tests for
-	// lock expiration.
-	lock.setTimeout(DavConstants.INFINITE_TIMEOUT);
+	lock = new DefaultActiveLock(lockInfo);
 	locks.put(resource.getResourcePath(), lock);
 	return lock;
     }
@@ -138,13 +143,13 @@
      */
     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(lockInfo.getType(), lockInfo.getScope(), resource);
 	if (lock == null) {
 	    throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED);
 	} else if (!lock.getToken().equals(lockToken)) {
 	    throw new DavException(DavServletResponse.SC_LOCKED);
 	}
+        lock.setTimeout(lockInfo.getTimeout());
 	return lock;
     }
 
@@ -159,8 +164,6 @@
 	if (!locks.containsKey(resource.getResourcePath())) {
 	    throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED);
 	}
-	// since locks have infinite timeout, check for expiration is omitted.
-
 	ActiveLock lock = (ActiveLock) locks.get(resource.getResourcePath());
 	if (lock.getToken().equals(lockToken)) {
 	    locks.remove(resource.getResourcePath());



Mime
View raw message