jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r240176 - in /incubator/jackrabbit/trunk/contrib/jcr-server: ./ server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/io/ server/src/java/org/apache/jackrabbit/webdav/jcr/ server/src/java/org/apache/jack...
Date Fri, 26 Aug 2005 07:26:31 GMT
Author: tripod
Date: Fri Aug 26 00:26:01 2005
New Revision: 240176

URL: http://svn.apache.org/viewcvs?rev=240176&view=rev
Log:
[JCR-181] jcr-server should honor a webdav request's Content-Type and Content-Language headers
[JCR-200] move log4j initialization out of RepositoryStartupServlet

Added:
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/LoggingServlet.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/log4j.dtd   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/log4j.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/io/
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/io/InputContext.java   (with props)
Removed:
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/ResourceType.java
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-server/project.properties
    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/ExportContext.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/mimetypes.properties
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/NodeResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryAccessServlet.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/webapp/src/webapp/WEB-INF/repository/repository.xml
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavMethods.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionHistoryResource.java

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/project.properties?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/project.properties (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/project.properties Fri Aug 26 00:26:01 2005
@@ -4,4 +4,4 @@
 #-------------------------------------------------------
 jackrabbit.build.version.jcr=1.0
 jackrabbit.build.version.jackrabbit=1.0-SNAPSHOT
-jackrabbit.build.version.jcr.rmi=1.0-dev
+jackrabbit.build.version.jcr.rmi=1.0-SNAPSHOT

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=240176&r1=240175&r2=240176&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 Fri Aug 26 00:26:01 2005
@@ -28,6 +28,7 @@
 import org.apache.jackrabbit.webdav.WebdavRequestImpl;
 import org.apache.jackrabbit.webdav.WebdavResponse;
 import org.apache.jackrabbit.webdav.WebdavResponseImpl;
+import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.lock.ActiveLock;
 import org.apache.jackrabbit.webdav.lock.LockInfo;
 import org.apache.jackrabbit.webdav.observation.EventDiscovery;
@@ -37,7 +38,6 @@
 import org.apache.jackrabbit.webdav.ordering.OrderPatch;
 import org.apache.jackrabbit.webdav.ordering.OrderingResource;
 import org.apache.jackrabbit.webdav.property.DavProperty;
-import org.apache.jackrabbit.webdav.property.DavPropertyIterator;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
 import org.apache.jackrabbit.webdav.property.DavPropertySet;
@@ -381,17 +381,17 @@
 
         DavProperty lastMod = resource.getProperty(DavPropertyName.GETLASTMODIFIED);
         if (lastMod != null) {
-            response.setHeader("Last-Modified", String.valueOf(lastMod.getValue()));
+            response.setHeader(HEADER_LAST_MODIFIED, String.valueOf(lastMod.getValue()));
         }
 
         DavProperty etag = resource.getProperty(DavPropertyName.GETETAG);
         if (etag != null) {
-            response.setHeader("ETag", String.valueOf(etag.getValue()));
+            response.setHeader(HEADER_ETAG, String.valueOf(etag.getValue()));
         }
 
         DavProperty contentType = resource.getProperty(DavPropertyName.GETCONTENTTYPE);
         if (contentType != null) {
-            response.setHeader("Content-Type", String.valueOf(contentType.getValue()));
+            response.setHeader(HEADER_CONTENT_TYPE, String.valueOf(contentType.getValue()));
         }
 
         DavProperty contentLength = resource.getProperty(DavPropertyName.GETCONTENTLENGTH);
@@ -399,13 +399,18 @@
             try {
                 int length = Integer.parseInt(contentLength.getValue() + "");
                 if (length > 0) {
-                    response.setIntHeader("Content-Length", length);
+                    response.setIntHeader(HEADER_CONTENT_LENGTH, length);
                 }
             } catch (NumberFormatException e) {
                 log.error("Could not build content length from property value '" + contentLength.getValue() + "'");
             }
         }
 
+        DavProperty contentLanguage = resource.getProperty(DavPropertyName.GETCONTENTLANGUAGE);
+        if (contentLanguage != null) {
+            response.setHeader(HEADER_CONTENT_LANGUAGE, contentLanguage.getValue().toString());
+        }
+
         // spool content in case of 'GET' request
         InputStream in = resource.getStream();
         try {
@@ -531,7 +536,7 @@
             status = DavServletResponse.SC_CREATED;
         }
 
-        parentResource.addMember(resource, request.getInputStream());
+        parentResource.addMember(resource, getInputContext(request));
         response.setStatus(status);
     }
 
@@ -555,11 +560,26 @@
         }
 
         if (request.getContentLength() > 0 || request.getHeader("Transfer-Encoding") != null) {
-            parentResource.addMember(resource, request.getInputStream());
+            parentResource.addMember(resource, getInputContext(request));
         } else {
             parentResource.addMember(resource);
         }
         response.setStatus(DavServletResponse.SC_CREATED);
+    }
+
+    /**
+     * Build an InputContext for the given request
+     * 
+     * @param request
+     * @return
+     * @throws IOException
+     */
+    protected InputContext getInputContext(WebdavRequest request) throws IOException {
+        InputContext cxt = new InputContext();
+        cxt.setContentType(request.getHeader(DavConstants.HEADER_CONTENT_TYPE));
+        cxt.setContentLanguage(request.getHeader(DavConstants.HEADER_CONTENT_LANGUAGE));
+        cxt.setInputStream(request.getInputStream());
+        return cxt;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContext.java Fri Aug 26 00:26:01 2005
@@ -62,6 +62,11 @@
     private String contentType;
 
     /**
+     * The content language of the resource
+     */
+    private String contentLanguage;
+
+    /**
      * the ETag of the resource
      */
     private String etag;
@@ -200,6 +205,24 @@
      */
     public void setContentType(String contentType) {
         this.contentType = contentType;
+    }
+
+    /**
+     * Returns the content language or <code>null</code>
+     *
+     * @return contentLanguage
+     */
+    public String getContentLanguage() {
+        return contentLanguage;
+    }
+
+    /**
+     * Sets the content language.
+     *
+     * @param contentLanguage
+     */
+    public void setContentLanguage(String contentLanguage) {
+        this.contentLanguage = contentLanguage;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java Fri Aug 26 00:26:01 2005
@@ -60,12 +60,18 @@
     private String contentType;
 
     /**
+     * The content language of the resource to be imported.
+     */
+    private String contentLanguage;
+
+    /**
      * The modification time of the resource, if known
      */
     private long modificationTime;
 
     /**
      * Creates a new import context with the given root node
+     *
      * @param importRoot the import root node
      */
     public ImportContext(Node importRoot) {
@@ -74,6 +80,7 @@
 
     /**
      * Creats a new import context with the given root node and property defaults.
+     *
      * @param base
      * @param importRoot
      */
@@ -87,6 +94,7 @@
 
     /**
      * Creates a new sub context which bases on this contexts properties
+     *
      * @param importRoot
      * @return
      */
@@ -96,6 +104,7 @@
 
     /**
      * Retruns the input stream of the resource to import.
+     *
      * @return the input stream.
      */
     public InputStream getInputStream() {
@@ -105,6 +114,7 @@
     /**
      * Sets the inpurt stream of the resource to import. A import command that
      * consumed the input stream should set this member to <code>null</code>.
+     *
      * @param inputStream the input stream
      */
     public void setInputStream(InputStream inputStream) {
@@ -113,6 +123,7 @@
 
     /**
      * Returns the import root of the resource to import.
+     *
      * @return the import root of the resource to import.
      */
     public Node getImportRoot() {
@@ -122,6 +133,7 @@
     /**
      * Returns the current parent node of the resource to import. If no current
      * parent node is defined, the import root is returned.
+     *
      * @return the parent node.
      */
     public Node getNode() {
@@ -131,6 +143,7 @@
     /**
      * Sets the current parent node of the resource to import. A command can
      * set this member in order to generate recursive structured.
+     *
      * @param node
      */
     public void setNode(Node node) {
@@ -141,6 +154,7 @@
      * Returns the system id of the resource to be imported. This id depends on
      * the system the resource is comming from. it can be a filename, a
      * display name of a webdav resource, an URI, etc.
+     *
      * @return the system id of the resource to import
      */
     public String getSystemId() {
@@ -149,6 +163,7 @@
 
     /**
      * sets the system id of this resource.
+     *
      * @param systemId
      */
     public void setSystemId(String systemId) {
@@ -158,6 +173,7 @@
     /**
      * Returns the content type of the resource to be imported or null, if
      * no contenttype was defined.
+     *
      * @return the content type of the resource
      */
     public String getContentType() {
@@ -166,6 +182,7 @@
 
     /**
      * Sets the content type of the resource.
+     *
      * @param contentType the content type.
      */
     public void setContentType(String contentType) {
@@ -173,7 +190,26 @@
     }
 
     /**
+     * Returns the content language or <code>null</code>
+     *
+     * @return contentLanguage
+     */
+    public String getContentLanguage() {
+        return contentLanguage;
+    }
+
+    /**
+     * Sets the content language.
+     *
+     * @param contentLanguage
+     */
+    public void setContentLanguage(String contentLanguage) {
+        this.contentLanguage = contentLanguage;
+    }
+
+    /**
      * Returns the modification time of the resource
+     *
      * @return the modification time.
      */
     public long getModificationTime() {
@@ -182,10 +218,10 @@
 
     /**
      * Sets the modification time of the resource
+     *
      * @param modificationTime the modification time
      */
     public void setModificationTime(long modificationTime) {
         this.modificationTime = modificationTime;
     }
-
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/SetContentTypeCommand.java Fri Aug 26 00:26:01 2005
@@ -47,7 +47,7 @@
 
     /**
      * Executes this command. It resolves the content type in the import context
-     * if it is not alerady set.
+     * if it is not already set.
      *
      * @param context the import context
      * @return false

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/mimetypes.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/mimetypes.properties?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/mimetypes.properties (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/mimetypes.properties Fri Aug 26 00:26:01 2005
@@ -37,7 +37,9 @@
 htm=text/html
 html=text/html
 ice=x-conference/x-cooltalk
+ics=text/calendar
 ief=image/ief
+ifb=text/calendar
 iges=model/iges
 igs=model/iges
 jpe=image/jpeg

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java Fri Aug 26 00:26:01 2005
@@ -18,6 +18,7 @@
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.property.*;
 import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.jcr.nodetype.NodeTypeProperty;
 import org.apache.jackrabbit.webdav.jcr.lock.JcrActiveLock;
 import org.apache.jackrabbit.webdav.jcr.version.report.ExportViewReport;
@@ -250,13 +251,13 @@
      * changed/set to type {@link PropertyType#BINARY binary}.
      *
      * @param resource
-     * @param in
+     * @param inputCxt
      * @throws org.apache.jackrabbit.webdav.DavException
-     * @see org.apache.jackrabbit.webdav.DavResource#addMember(org.apache.jackrabbit.webdav.DavResource, java.io.InputStream)
+     * @see org.apache.jackrabbit.webdav.DavResource#addMember(org.apache.jackrabbit.webdav.DavResource, InputContext)
      * @see Node#addNode(String)
      * @see Node#setProperty(String, java.io.InputStream)
      */
-    public void addMember(DavResource resource, InputStream in)
+    public void addMember(DavResource resource, InputContext inputCxt)
             throws DavException {
 
         /* RFC 2815 states that all 'parents' must exist in order all addition of members */
@@ -266,6 +267,7 @@
 
         try {
             Node n = (Node) item;
+            InputStream in = (inputCxt != null) ? inputCxt.getInputStream() : null;
             if (resource.isCollection()) {
                 if (in == null) {
                     // MKCOL without a request body, try if a default-primary-type is defined.
@@ -308,7 +310,9 @@
      * @see org.apache.jackrabbit.webdav.DavResource#addMember(org.apache.jackrabbit.webdav.DavResource)
      */
     public void addMember(DavResource resource) throws DavException {
-        addMember(resource, resource.getStream());
+        InputContext ctx = new InputContext();
+        ctx.setInputStream(resource.getStream());
+        addMember(resource, ctx);
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java Fri Aug 26 00:26:01 2005
@@ -18,6 +18,7 @@
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.property.*;
 import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.jcr.property.ValuesProperty;
 import org.apache.jackrabbit.webdav.jcr.property.LengthsProperty;
 import org.apache.jackrabbit.webdav.lock.*;
@@ -184,7 +185,7 @@
      *
      * @see org.apache.jackrabbit.webdav.DavResource#addMember(org.apache.jackrabbit.webdav.DavResource, InputStream)
      */
-    public void addMember(DavResource resource, InputStream in) throws DavException {
+    public void addMember(DavResource resource, InputContext inputCxt) throws DavException {
         throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED, "Cannot add members to a non-collection resource");
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java Fri Aug 26 00:26:01 2005
@@ -17,6 +17,7 @@
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.jcr.version.report.RegisteredNamespacesReport;
 import org.apache.jackrabbit.webdav.jcr.version.report.NodeTypesReport;
 import org.apache.jackrabbit.webdav.jcr.version.report.RepositoryDescriptorsReport;
@@ -121,7 +122,7 @@
      * Throws exception: 403 Forbidden.
      * @see DavResource#addMember(DavResource, InputStream)
      */
-    public void addMember(DavResource resource, InputStream in) throws DavException {
+    public void addMember(DavResource resource, InputContext inputCxt) throws DavException {
         throw new DavException(DavServletResponse.SC_FORBIDDEN);
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java Fri Aug 26 00:26:01 2005
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.webdav.version.*;
 import org.apache.jackrabbit.webdav.property.HrefProperty;
 import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.ResourceType;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.jcr.DefaultItemCollection;

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=240176&r1=240175&r2=240176&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 Fri Aug 26 00:26:01 2005
@@ -16,11 +16,13 @@
 package org.apache.jackrabbit.webdav.simple;
 
 import javax.jcr.*;
+import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.lock.Lock;
 import java.util.*;
 import java.io.*;
 
 import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.transaction.TransactionConstants;
 import org.apache.jackrabbit.webdav.observation.ObservationConstants;
 import org.apache.jackrabbit.webdav.jcr.lock.JcrActiveLock;
@@ -56,7 +58,7 @@
     private Node node;
     private DavResourceLocator locator;
 
-    private DavPropertySet properties;
+    private DavPropertySet properties = new DavPropertySet();
     private boolean isCollection = true;
 
     /** is created on initProperties */
@@ -139,6 +141,16 @@
     }
 
     /**
+     * Package protected method that allows to define whether this resource
+     * represents a collection or not.
+     *
+     * @param isCollection
+     */
+    void setIsCollection(boolean isCollection) {
+        this.isCollection = isCollection;
+    }
+
+    /**
      * @see org.apache.jackrabbit.webdav.DavResource#getLocator()
      */
     public DavResourceLocator getLocator() {
@@ -220,17 +232,14 @@
      * Fill the set of properties
      */
     private void initProperties() {
-        if (properties == null && exists()) {
-            properties = new DavPropertySet();
+        if (exists()) {
             try {
                 nodeResource = new NodeResource(this, node);
                 properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, nodeResource.getContentLength()+""));
                 properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, nodeResource.getCreationDate()));
                 properties.add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED, nodeResource.getLastModified()));
-                String contentType = nodeResource.getContentType();
-                if (contentType != null) {
-                    properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, contentType));
-                }
+                setContentType(nodeResource.getContentType());
+                setContentLanguage(nodeResource.getContentLanguage());
                 properties.add(new DefaultDavProperty(DavPropertyName.GETETAG, nodeResource.getETag()));
             } catch (RepositoryException e) {
                 // should not occure....
@@ -258,20 +267,21 @@
             supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE);
             properties.add(supportedLock);
 
-            // JCR properties defined on the underlaying jcr node
+            // non-protected JCR properties defined on the underlaying jcr node
             try {
                 // todo: should filter be respected for properties as well?
                 PropertyIterator it = node.getProperties();
                 while (it.hasNext()) {
                     Property p = it.nextProperty();
                     String pName = p.getName();
-                    DavPropertyName name = getDavName(pName, node.getSession());
-                    if (p.getDefinition().isMultiple()) {
-                        log.debug("Multivalued property '" + pName + "' not added to webdav property set.");
-                    } else {
-                        String value = p.getValue().getString();
-                        properties.add(new DefaultDavProperty(name, value));
+                    PropertyDefinition def = p.getDefinition();
+                    if (def.isMultiple()) {
+                        log.debug("Multivalue property '" +  pName + "' not added to webdav property set.");
+                        continue;
                     }
+                    DavPropertyName name = getDavName(pName, node.getSession());
+                    String value = p.getValue().getString();
+                    properties.add(new DefaultDavProperty(name, value, def.isProtected()));
                 }
             } catch (RepositoryException e) {
                 log.error("Unexpected error while retrieving properties: " + e.getMessage());
@@ -358,6 +368,27 @@
         }
     }
 
+    /**
+     * Set the content type.
+     *
+     * @param contentType
+     */
+    private void setContentType(String contentType) {
+        if (contentType != null) {
+            properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, contentType));
+        }
+    }
+
+    /**
+     * Set the content language.
+     *
+     * @param contentLanguage
+     */
+    private void setContentLanguage(String contentLanguage) {
+        if (contentLanguage != null) {
+            properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLANGUAGE, contentLanguage));
+        }
+    }
 
     /**
      * @see DavResource#getCollection()
@@ -405,68 +436,47 @@
     }
 
     /**
-     * Adds a new non-collection member to this resource.
-     *
-     * @see DavResource#addMember(DavResource, InputStream)
-     */
-    public void addMember(DavResource member, InputStream in) throws DavException {
-        if (!exists() || in == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
-        }
-	if (isLocked(this)) {
-            throw new DavException(DavServletResponse.SC_LOCKED);
-        }
-
-        try {
-            String fileName = member.getDisplayName();
-            // don't allow creation of nodes, that would be filtered out
-            if (isFilteredResource(member)) {
-                log.debug("Avoid creation of filtered resource: " + fileName);
-                throw new DavException(DavServletResponse.SC_FORBIDDEN);
-            }
-
-            ImportContext ctx = new ImportContext(node);
-            ctx.setInputStream(in);
-            ctx.setSystemId(fileName);
-            ImportResourceChain.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());
-        }
-    }
-
-    /**
-     * Creates a new collection as member of this resource.
+     * Adds a new member to this resource.
      *
-     * @see DavResource#addMember(DavResource)
+     * @see DavResource#addMember(DavResource, InputContext)
      */
-    public void addMember(DavResource member) throws DavException {
+    public void addMember(DavResource member, InputContext inputCxt) throws DavException {
         if (!exists()) {
             throw new DavException(DavServletResponse.SC_CONFLICT);
         }
-	if (isLocked(this)) {
+        if (isLocked(this)) {
             throw new DavException(DavServletResponse.SC_LOCKED);
         }
-
         // don't allow creation of nodes, that would be filtered out
         if (isFilteredResource(member)) {
             log.debug("Avoid creation of filtered resource: " + member.getDisplayName());
             throw new DavException(DavServletResponse.SC_FORBIDDEN);
         }
-
         try {
             ImportContext ctx = new ImportContext(node);
             ctx.setSystemId(member.getDisplayName());
-            ImportCollectionChain.getChain().execute(ctx);
+            boolean hasContent = inputCxt != null && inputCxt.getInputStream() != null;
+            if (hasContent) {
+                ctx.setInputStream(inputCxt.getInputStream());
+                ctx.setContentType(inputCxt.getContentType());
+                ctx.setContentLanguage(inputCxt.getContentLanguage());
+            }
+            if (member.isCollection()) {
+                ImportCollectionChain.getChain().execute(ctx);
+            } else {
+                ImportResourceChain.getChain().execute(ctx);
+            }
+            // if an input stream was present and was not consumed during the
+            // import the request must fail.
+            if (hasContent && ctx.getInputStream() != null) {
+                // undo all changes
+                node.refresh(false);
+                throw new DavException(DavServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
+            }
+            // persist changes after successful import
             node.save();
         } catch (ItemExistsException e) {
+            // should only be thrown by the ImportCollectionChain
             log.error("Error while executing import chain: " + e.toString());
             throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
         } catch (RepositoryException e) {
@@ -479,6 +489,15 @@
     }
 
     /**
+     * Creates a new member of this resource.
+     *
+     * @see DavResource#addMember(DavResource)
+     */
+    public void addMember(DavResource member) throws DavException {
+        addMember(member, null);
+    }
+
+    /**
      * @see DavResource#removeMember(DavResource)
      */
     public void removeMember(DavResource member) throws DavException {
@@ -787,7 +806,10 @@
     }
 
     /**
-     * Build jcr property name from dav property name
+     * Build jcr property name from dav property name. If the property name
+     * defines a namespace uri, that has not been registered yet, an attempt
+     * is made to register the uri with the prefix defined. Note, that no
+     * extra effort is made to generated a unique prefix. 
      *
      * @param propName
      * @return jcr name
@@ -796,9 +818,23 @@
     private String getJcrName(DavPropertyName propName) throws RepositoryException {
         String pName = propName.getName();
         String uri = propName.getNamespace().getURI();
-        String prefix = node.getSession().getNamespacePrefix(uri);
-        if (prefix != null && !"".equals(prefix)) {
-            pName = prefix + ":" + pName;
+
+        if (uri != null && !"".equals(uri)) {
+            Session s = session.getRepositorySession();
+            String prefix;
+            try {
+                // lookup 'prefix' in the session-ns-mappings / namespace-registry
+                prefix = s.getNamespacePrefix(uri);
+            } catch (NamespaceException e) {
+                // namespace uri has not been registered yet
+                NamespaceRegistry nsReg = s.getWorkspace().getNamespaceRegistry();
+                prefix = propName.getNamespace().getPrefix();
+                // NOTE: will fail if prefix is already in use in the namespace registry
+                nsReg.registerNamespace(prefix, uri);
+            }
+            if (prefix != null && !"".equals(prefix)) {
+                pName = prefix + ":" + pName;
+            }
         }
         return pName;
     }
@@ -817,7 +853,6 @@
     }
 
     /**
-     *
      * @param propertyName
      * @throws RepositoryException
      */

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/NodeResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/NodeResource.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/NodeResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/NodeResource.java Fri Aug 26 00:26:01 2005
@@ -59,6 +59,7 @@
     private long modificationTime = new Date().getTime();
     private long contentLength = 0;
     private String contentType = null;
+    private String contentLanguage = null;
     private String etag = null;
     private InputStream in = null;
 
@@ -82,6 +83,7 @@
         }
         this.contentLength = ctx.getContentLength();
         this.contentType = ctx.getContentType();
+        this.contentLanguage = ctx.getContentLanguage();
         this.in = ctx.getInputStream();
         this.creationTime = ctx.getCreationTime();
         this.modificationTime = ctx.getModificationTime();
@@ -161,6 +163,15 @@
      */
     public String getContentType() {
 	return contentType;
+    }
+
+    /**
+     * Return the content language or <code>null</code> if it could not be determined.
+     *
+     * @return content language
+     */
+    public String getContentLanguage() {
+        return contentLanguage;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java Fri Aug 26 00:26:01 2005
@@ -30,20 +30,61 @@
     private final LockManager lockMgr;
     private final ResourceFilter resourceFilter;
 
+    /**
+     * Create a new <code>ResourceFactory</code> that uses the given lock manager
+     * and the default {@link DefaultResourceFilter resource filter}.
+     *
+     * @param lockMgr
+     */
     public ResourceFactoryImpl(LockManager lockMgr) {
         this(lockMgr, new DefaultResourceFilter());
     }
 
+    /**
+     * Create a new <code>ResourceFactory</code> that uses the given lock manager
+     * and resource filter.
+     *
+     * @param lockMgr
+     * @param resourceFilter
+     */
     public ResourceFactoryImpl(LockManager lockMgr, ResourceFilter resourceFilter) {
         this.lockMgr = lockMgr;
         this.resourceFilter = resourceFilter;
     }
 
+    /**
+     * Create a new <code>DavResource</code> from the given locator and request.
+     *
+     * @param locator
+     * @param request
+     * @param response
+     * @return
+     * @throws DavException
+     * @see DavResourceFactory#createResource(DavResourceLocator, DavServletRequest, DavServletResponse)
+     */
     public DavResource createResource(DavResourceLocator locator, DavServletRequest request,
                                       DavServletResponse response) throws DavException {
-        return createResource(locator, request.getDavSession());
+        DavResourceImpl resource = (DavResourceImpl)createResource(locator, request.getDavSession());
+        int methodCode = DavMethods.getMethodCode(request.getMethod());
+        if (methodCode == DavMethods.DAV_MKCOL || methodCode == DavMethods.DAV_PUT || methodCode == DavMethods.DAV_POST) {
+            if (!resource.exists()) {
+                boolean isCollection = DavMethods.getMethodCode(request.getMethod()) == DavMethods.DAV_MKCOL;
+                resource.setIsCollection(isCollection);
+            }
+        }
+        return resource;
     }
 
+    /**
+     * Create a new <code>DavResource</code> from the given locator and webdav
+     * session.
+     *
+     * @param locator
+     * @param session
+     * @return
+     * @throws DavException
+     * @see DavResourceFactory#createResource(DavResourceLocator, DavSession)
+     */
     public DavResource createResource(DavResourceLocator locator, DavSession session) throws DavException {
         try {
             DavResource res = new DavResourceImpl(locator, this, session, resourceFilter);

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/LoggingServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/LoggingServlet.java?rev=240176&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/LoggingServlet.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/LoggingServlet.java Fri Aug 26 00:26:01 2005
@@ -0,0 +1,196 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 1997-2005 Day Management AG
+ * Barfuesserplatz 6, 4001 Basel, Switzerland
+ * All Rights Reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * Day Management AG, ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with Day.
+ */
+package org.apache.jackrabbit.j2ee;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.ServletException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+import java.util.Properties;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * This Class implements a servlet that is used for initializing the log4j
+ * facitilies for the containing webapp. since all classes in a webapp share
+ * the same Log4J repository, this servlet offers a centralized mechanism to
+ * configure the different loggers.
+ * <p/>
+ * please note, that Log4J holds its logging repository in static class variables,
+ * so the configuration spans all classes using the same classloader hierarchy.
+ * in a typical j2ee 4 classloaders are provided by the appserver: a shared,
+ * a server, a container and an application classloader:
+ * <xmp>
+ *       Bootstrap
+ *          |
+ *        System
+ *          |
+ *        Shared
+ *       /      \
+ *  Server     Container
+ *                /   \
+ *           Webapp1  Webapp2 ...
+ *
+ * </xmp>
+ * Classes are searched in the classloader hierarchy by aksing the parent
+ * classloader first. so if you put the log4j.jar in the 'shared' classloader,
+ * all webapps will shared the same log4j logger repository. if every webapp
+ * should use it's own hierarchy, the log4j.jar must be put in the classpath
+ * of the webapp classloader, usually WEB-INF/lib.
+ * <p/>
+ * Please note further that the exact way how the classloader hierarchy is
+ * set-up depends on the appserver you are using.
+ */
+public class LoggingServlet extends HttpServlet {
+
+    /**
+     * The init param for the log4j configuration. this can either point to
+     * a resource inside the application or a filepath. if the filename ends with
+     * ".xml", the {@link DOMConfigurator} is used to configure Log4J, otherwise
+     * the {@link PropertyConfigurator} is used.
+     */
+    public final static String INIT_PARAM_LOG4J_CONFIG = "log4j-config";
+
+    /**
+     * {@inheritDoc}
+     */
+    public void init() throws ServletException {
+        configure();
+        Logger.getRootLogger().info("Logging initialized.");
+    }
+
+    /**
+     * Configures Log4J using the config specified by the
+     * {@link #INIT_PARAM_LOG4J_CONFIG} init parameter.
+     *
+     * @throws ServletException
+     */
+    private void configure() throws ServletException {
+        // setup log4j
+        String log4jConfig = getServletConfig().getInitParameter(INIT_PARAM_LOG4J_CONFIG);
+        InputStream in =getServletContext().getResourceAsStream(log4jConfig);
+        if (in==null) {
+            // try file access
+            try {
+                in = new FileInputStream(log4jConfig);
+            } catch (FileNotFoundException e) {
+                throw new ServletException("Unable to initialize log4j: " + e.toString());
+            }
+        } else {
+            // hack for entity resolver
+            log4jConfig = "ctx:" + log4jConfig;
+        }
+        try {
+            if (log4jConfig.endsWith(".xml")) {
+                InputSource ins = new InputSource(in);
+                ins.setSystemId(log4jConfig);
+                configureXML(ins);
+            } else {
+                configureProperties(in);
+            }
+        } catch (IOException e) {
+            throw new ServletException("Unable to initialize log4j: " + e.toString());
+        } finally {
+            try {
+                in.close();
+            } catch (IOException e) {
+                // ignore
+            }
+        }
+    }
+
+    /**
+     * Configures Log4J using the {@link DOMConfigurator}
+     *
+     * @param in
+     * @throws ServletException
+     * @throws IOException
+     */
+    private void configureXML(InputSource in)
+            throws ServletException, IOException {
+        try {
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder = factory.newDocumentBuilder();
+            // only set resolver, if context resource
+            if (in.getSystemId().startsWith("ctx:")) {
+                builder.setEntityResolver(new ContextResolver());
+            }
+            Document document = builder.parse(in);
+            Element root =  document.getDocumentElement();
+            DOMConfigurator.configure(root);
+        } catch (ParserConfigurationException e) {
+            throw new ServletException(
+                    "Unable to create configuration XML parser", e);
+        } catch (SAXException e) {
+            throw new ServletException(
+                    "Configuration file syntax error.", e);
+        }
+    }
+
+    /**
+     * Configures Log4J using the {@link PropertyConfigurator}
+     *
+     * @param in
+     * @throws ServletException
+     * @throws IOException
+     */
+    private void configureProperties(InputStream in)
+            throws ServletException, IOException {
+        Properties log4jProperties = new Properties();
+        log4jProperties.load(in);
+        PropertyConfigurator.configure(log4jProperties);
+    }
+
+    /**
+     * own EntityResolver to resolve entities inside servlet context
+     */
+    private class ContextResolver implements EntityResolver {
+
+        public InputSource resolveEntity(String publicId, String systemId)
+                throws SAXException, IOException {
+
+            try {
+                URI uri = new URI(systemId);
+                if (uri.getScheme().equals("ctx")) {
+                    InputStream in = getServletContext().getResourceAsStream(uri.getPath());
+                    if (in != null) {
+                        InputSource ins = new InputSource(in);
+                        ins.setSystemId(systemId);
+                        return ins;
+                    }
+                }
+                log("Error while resolving entity. Unkwon systemid: " + systemId);
+            } catch (URISyntaxException e) {
+                log("Error while resolving entity: " + e.toString());
+            }
+            return null;
+        }
+    }
+
+}
\ No newline at end of file

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

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/LoggingServlet.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryAccessServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryAccessServlet.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryAccessServlet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryAccessServlet.java Fri Aug 26 00:26:01 2005
@@ -16,27 +16,29 @@
  */
 package org.apache.jackrabbit.j2ee;
 
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
 import org.apache.jackrabbit.rmi.client.ClientRepositoryFactory;
 import org.apache.jackrabbit.util.Base64;
+import org.apache.log4j.Logger;
 
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.ServletException;
-import javax.servlet.ServletContext;
-import javax.jcr.*;
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-
-import java.util.Properties;
-import java.util.Enumeration;
-import java.io.IOException;
-import java.io.InputStream;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
 import java.io.ByteArrayOutputStream;
-import java.rmi.RemoteException;
-import java.rmi.NotBoundException;
+import java.io.IOException;
 import java.net.MalformedURLException;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.util.Enumeration;
+import java.util.Properties;
 
 /**
  * This Class implements a servlet that is used as unified mechanism to retrieve
@@ -45,7 +47,7 @@
 public class RepositoryAccessServlet extends HttpServlet {
 
     /** default logger */
-    private static Logger log;
+    private static final Logger log = Logger.getLogger(RepositoryAccessServlet.class);
 
     // todo: implement correctly
     public final static String INIT_PARAM_LOG4J_CONFIG = "log4j-config";
@@ -72,7 +74,6 @@
      * @throws javax.servlet.ServletException
      */
     public void init() throws ServletException {
-	initLog4J();
 	log.info("RepositoryAccessServlet initializing...");
         repositoryName = getServletConfig().getInitParameter(INIT_PARAM_REPOSITORY_NAME);
         if (repositoryName==null) {
@@ -105,26 +106,6 @@
 	log.info("RepositoryAccessServlet initialized.");
     }
 
-    private void initLog4J() throws ServletException {
-	// setup log4j
-	String log4jConfig = getServletConfig().getInitParameter(INIT_PARAM_LOG4J_CONFIG);
-	InputStream in =getServletContext().getResourceAsStream(log4jConfig);
-	if (in==null) {
-	    // try normal init
-	    PropertyConfigurator.configure(log4jConfig);
-	} else {
-	    try {
-		Properties log4jProperties = new Properties();
-		log4jProperties.load(in);
-		in.close();
-		PropertyConfigurator.configure(log4jProperties);
-	    } catch (IOException e) {
-		throw new ServletException("Unable to load log4jProperties: " + e.toString());
-	    }
-	}
-	log = Logger.getLogger(RepositoryAccessServlet.class);
-    }
-
     private InitialContext getInitialContext() throws ServletException {
 	// retrieve JNDI Context environment
 	try {
@@ -170,7 +151,7 @@
     private Repository getRepositoryByRMI(String rmiURI) {
         // acquire via RMI
         log.info("  trying to retrieve repository using rmi. uri=" + rmiURI);
-        ClientFactoryDelegater cfd = null;
+        ClientFactoryDelegater cfd;
         try {
             Class clazz = Class.forName("org.apache.jackrabbit.j2ee.RMIClientFactoryDelegater");
             cfd = (ClientFactoryDelegater) clazz.newInstance();

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=240176&r1=240175&r2=240176&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 Fri Aug 26 00:26:01 2005
@@ -15,28 +15,32 @@
  */
 package org.apache.jackrabbit.j2ee;
 
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.rmi.server.ServerAdapterFactory;
+import org.apache.log4j.Logger;
 import org.xml.sax.InputSource;
 
-import javax.servlet.http.HttpServlet;
-import javax.servlet.ServletException;
-import javax.jcr.*;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import java.io.*;
-import java.util.Properties;
-import java.util.Enumeration;
-import java.rmi.registry.Registry;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.rmi.AlreadyBoundException;
+import java.rmi.Naming;
 import java.rmi.Remote;
-import java.net.MalformedURLException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.Enumeration;
+import java.util.Properties;
 
 /**
  * The RepositoryStartupServlet starts a jackrabbit repository and registers it
@@ -45,7 +49,7 @@
 public class RepositoryStartupServlet extends HttpServlet {
 
     /** the default logger */
-    private static Logger log;
+    private static final Logger log = Logger.getLogger(RepositoryStartupServlet.class);
 
     /** initial param name for the repository config location */
     public final static String INIT_PARAM_REPOSITORY_CONFIG = "repository-config";
@@ -80,7 +84,6 @@
      */
     public void init() throws ServletException {
 	super.init();
-	initLog4J();
 	log.info("RepositoryStartupServlet initializing...");
 	initRepository();
 	registerJNDI();
@@ -106,30 +109,6 @@
         } else {
             log.info("RepositoryStartupServlet shut down.");
         }
-    }
-
-    /**
-     * Initializes Log4J
-     * @throws ServletException
-     */
-    private void initLog4J() throws ServletException {
-	// setup log4j
-	String log4jConfig = getServletConfig().getInitParameter(INIT_PARAM_LOG4J_CONFIG);
-	InputStream in = getServletContext().getResourceAsStream(log4jConfig);
-	if (in==null) {
-	    // try normal init
-	    PropertyConfigurator.configure(log4jConfig);
-	} else {
-	    try {
-		Properties log4jProperties = new Properties();
-		log4jProperties.load(in);
-		in.close();
-		PropertyConfigurator.configure(log4jProperties);
-	    } catch (IOException e) {
-		throw new ServletException("Unable to load log4jProperties: " + e.toString());
-	    }
-	}
-	log = Logger.getLogger(RepositoryStartupServlet.class);
     }
 
     /**

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=240176&r1=240175&r2=240176&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 Fri Aug 26 00:26:01 2005
@@ -28,7 +28,6 @@
 import org.apache.jackrabbit.webdav.DavMethods;
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavResourceFactory;
-import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.DavSessionProvider;
 import org.apache.jackrabbit.webdav.WebdavRequest;
 import org.apache.jackrabbit.webdav.WebdavResponse;
@@ -272,21 +271,6 @@
     protected boolean isPreconditionValid(WebdavRequest request,
                                           DavResource resource) {
         return !resource.exists() || request.matchesIfHeader(resource);
-    }
-
-    /**
-     * The MKCOL method
-     *
-     * @throws IOException
-     */
-    protected void doMkCol(WebdavRequest request, WebdavResponse response,
-                           DavResource resource) throws IOException, DavException {
-        // mkcol request with request.body is not supported.
-        if (request.getContentLength() > 0 || request.getHeader("Transfer-Encoding") != null) {
-            response.sendError(DavServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
-            return;
-        }
-        super.doMkCol(request, response, resource);
     }
 
     /**

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/log4j.dtd
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/log4j.dtd?rev=240176&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/log4j.dtd (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/log4j.dtd Fri Aug 26 00:26:01 2005
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!-- Authors: Chris Taylor, Ceki Gulcu. -->
+
+<!-- Version: 1.2 -->
+
+<!-- A configuration element consists of optional renderer
+elements,appender elements, categories and an optional root
+element. -->
+
+<!ELEMENT log4j:configuration (renderer*, appender*, logger*, root?)>
+
+<!-- The "threshold" attribute takes a level value such that all -->
+<!-- logging statements with a level equal or below this value are -->
+<!-- disabled. -->
+
+<!-- Setting the "debug" enable the printing of internal log4j logging   -->
+<!-- statements.                                                         -->
+
+<!-- By default, debug attribute is "null", meaning that we not do touch -->
+<!-- internal log4j logging settings. The "null" value for the threshold -->
+<!-- attribute can be misleading. The threshold field of a repository	 -->
+<!-- cannot be set to null. The "null" value for the threshold attribute -->
+<!-- simply means don't touch the threshold field, the threshold field   --> 
+<!-- keeps its old value.                                                -->
+     
+<!ATTLIST log4j:configuration
+  xmlns:log4j              CDATA #FIXED "http://jakarta.apache.org/log4j/" 
+  threshold                (all|debug|info|warn|error|fatal|off|null) "null"
+  debug                    (true|false|null)  "null"
+>
+
+<!-- renderer elements allow the user to customize the conversion of  -->
+<!-- message objects to String.                                       -->
+
+<!ELEMENT renderer EMPTY>
+<!ATTLIST renderer
+  renderedClass  CDATA #REQUIRED
+  renderingClass CDATA #REQUIRED
+>
+
+<!-- Appenders must have a name and a class. -->
+<!-- Appenders may contain an error handler, a layout, optional parameters -->
+<!-- and filters. They may also reference (or include) other appenders. -->
+<!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)>
+<!ATTLIST appender
+  name 		ID 	#REQUIRED
+  class 	CDATA	#REQUIRED
+>
+
+<!ELEMENT layout (param*)>
+<!ATTLIST layout
+  class		CDATA	#REQUIRED
+>
+
+<!ELEMENT filter (param*)>
+<!ATTLIST filter
+  class		CDATA	#REQUIRED
+>
+
+<!-- ErrorHandlers can be of any class. They can admit any number of -->
+<!-- parameters. -->
+
+<!ELEMENT errorHandler (param*, root-ref?, logger-ref*,  appender-ref?)> 
+<!ATTLIST errorHandler
+   class        CDATA   #REQUIRED 
+>
+
+<!ELEMENT root-ref EMPTY>
+
+<!ELEMENT logger-ref EMPTY>
+<!ATTLIST logger-ref
+  ref IDREF #REQUIRED
+>
+
+<!ELEMENT param EMPTY>
+<!ATTLIST param
+  name		CDATA   #REQUIRED
+  value		CDATA	#REQUIRED
+>
+
+
+<!-- The priority class is org.apache.log4j.Level by default -->
+<!--
+    DEPRECATED
+
+<!ELEMENT priority (param*)>
+<!ATTLIST priority
+  class   CDATA	#IMPLIED
+  value	  CDATA #REQUIRED
+>
+-->
+
+<!-- The level class is org.apache.log4j.Level by default -->
+<!ELEMENT level (param*)>
+<!ATTLIST level
+  class   CDATA	#IMPLIED
+  value	  CDATA #REQUIRED
+>
+
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named category. -->
+<!--
+    DEPRECATED
+
+<!ELEMENT category (param*,(priority|level)?,appender-ref*)>
+<!ATTLIST category
+  class         CDATA   #IMPLIED
+  name		CDATA	#REQUIRED
+  additivity	(true|false) "true"  
+>
+-->
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named logger. -->
+<!ELEMENT logger (level?, appender-ref*)>
+<!ATTLIST logger
+  class         CDATA   #IMPLIED
+  name		ID	#REQUIRED
+  additivity	(true|false) "true"  
+>
+
+<!--
+    DEPRECATED
+
+<!ELEMENT categoryFactory (param*)>
+<!ATTLIST categoryFactory 
+   class        CDATA #REQUIRED>
+-->
+
+<!ELEMENT appender-ref EMPTY>
+<!ATTLIST appender-ref
+  ref IDREF #REQUIRED
+>
+
+<!-- If no priority element is specified, then the configurator MUST not -->
+<!-- touch the priority of root. -->
+<!-- The root category always exists and cannot be subclassed. -->
+<!ELEMENT root (param*, level?, appender-ref*)>
+
+
+<!-- ==================================================================== -->
+<!--                       A logging event                                -->
+<!-- ==================================================================== -->
+<!ELEMENT log4j:eventSet (log4j:event*)>
+<!ATTLIST log4j:eventSet
+  xmlns:log4j             CDATA #FIXED "http://jakarta.apache.org/log4j/" 
+  version                (1.1|1.2) "1.2" 
+  includesLocationInfo   (true|false) "true"
+>
+
+
+
+<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?, 
+                       log4j:locationInfo?) >
+
+<!-- The timestamp format is application dependent. -->
+<!ATTLIST log4j:event
+    logger     CDATA #REQUIRED
+    level      CDATA #REQUIRED
+    thread     CDATA #REQUIRED
+    timestamp  CDATA #REQUIRED
+>
+
+<!ELEMENT log4j:message (#PCDATA)>
+<!ELEMENT log4j:NDC (#PCDATA)>
+
+<!ELEMENT log4j:throwable (#PCDATA)>
+
+<!ELEMENT log4j:locationInfo EMPTY>
+<!ATTLIST log4j:locationInfo
+  class  CDATA	#REQUIRED
+  method CDATA	#REQUIRED
+  file   CDATA	#REQUIRED
+  line   CDATA	#REQUIRED
+>

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/log4j.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/log4j.xml?rev=240176&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/log4j.xml (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/log4j.xml Fri Aug 26 00:26:01 2005
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+    <!-- ====================================================================== -->
+    <!-- A P P E N D E R S                                                      -->
+    <!-- ====================================================================== -->
+
+    <!-- console -->
+    <appender name="console" class="org.apache.log4j.ConsoleAppender">
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}: %m (%F, line %L)%n"/>
+        </layout>
+    </appender>
+
+    <!-- error.log -->
+    <appender name="error" class="org.apache.log4j.FileAppender">
+        <param name="File" value="logs/jackrabbit.log"/>
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}: %m (%F, line %L)%n"/>
+        </layout>
+    </appender>
+
+    <!-- ====================================================================== -->
+    <!-- L O G G E R S                                                          -->
+    <!-- ====================================================================== -->
+
+    <root>
+        <level value="info" />
+        <appender-ref ref="console"/>
+        <!-- <appender-ref ref="error"/> -->
+    </root>
+
+</log4j:configuration>

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

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/repository/repository.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/repository/repository.xml?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/repository/repository.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/repository/repository.xml Fri Aug 26 00:26:01 2005
@@ -155,14 +155,7 @@
 	Search index and the file system it uses.
         -->
 	<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
-	    <param name="useCompoundFile" value="true"/>
-	    <param name="minMergeDocs" value="1000"/>
-	    <param name="maxMergeDocs" value="10000"/>
-	    <param name="mergeFactor" value="10"/>
-
-	    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
-		<param name="path" value="${wsp.home}/index"/>
-	    </FileSystem>
+  		<param name="path" value="${wsp.home}/index"/>
 	</SearchIndex>
     </Workspace>
 

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?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- 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 Fri Aug 26 00:26:01 2005
@@ -5,6 +5,23 @@
     <display-name>Jackrabbit JCR Server</display-name>
 
     <!-- ====================================================================== -->
+    <!-- L O G G I N G   S E R V L E T                                          -->
+    <!-- ====================================================================== -->
+    <servlet>
+        <servlet-name>Logging</servlet-name>
+        <description>The logging servlet configures the Log4J logging facility.</description>
+        <servlet-class>org.apache.jackrabbit.j2ee.LoggingServlet</servlet-class>
+
+        <init-param>
+            <param-name>log4j-config</param-name>
+            <param-value>/WEB-INF/log4j.xml</param-value>
+            <description>initial log4j configuration</description>
+        </init-param>
+
+        <load-on-startup>0</load-on-startup>
+    </servlet>
+
+    <!-- ====================================================================== -->
     <!-- R E P O S I T O R Y   S T A R T U P  S E R V L E T                     -->
     <!-- ====================================================================== -->
     <servlet>
@@ -17,12 +34,6 @@
         <servlet-class>org.apache.jackrabbit.j2ee.RepositoryStartupServlet</servlet-class>
 
         <init-param>
-            <param-name>log4j-config</param-name>
-            <param-value>/WEB-INF/repository/log4j.properties</param-value>
-            <description>initial log4j configuration</description>
-        </init-param>
-
-        <init-param>
             <param-name>repository-config</param-name>
             <param-value>/WEB-INF/repository/repository.xml</param-value>
             <description>the repository config location</description>
@@ -80,12 +91,6 @@
         <servlet-class>org.apache.jackrabbit.j2ee.RepositoryAccessServlet</servlet-class>
 
         <init-param>
-            <param-name>log4j-config</param-name>
-            <param-value>/WEB-INF/repository/log4j.properties</param-value>
-            <description>initial log4j configuration</description>
-        </init-param>
-
-        <init-param>
             <param-name>repository-name</param-name>
             <param-value>jackrabbit.repository</param-value>
             <description>Repository Name that is used to retrieve it via JNDI</description>
@@ -173,7 +178,7 @@
                 the defines the commons-chain catalog for server tasks.
             </description>
         </init-param>
-        !--
+        <!--
             Optional parameter defining namespaces (or uri or prefixes) and/or
             nodetype names that mark hidden resources.
             If omitted not resources will be filtered out.

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java Fri Aug 26 00:26:01 2005
@@ -35,6 +35,11 @@
     public static final String HEADER_DESTINATION = "Destination";
     public static final String HEADER_IF = "If";
     public static final String HEADER_AUTHORIZATION = "Authorization";
+    public static final String HEADER_CONTENT_TYPE = "Content-Type";
+    public static final String HEADER_CONTENT_LENGTH = "Content-Length";
+    public static final String HEADER_CONTENT_LANGUAGE = "Content-Language";
+    public static final String HEADER_ETAG = "ETag";
+    public static final String HEADER_LAST_MODIFIED = "Last-Modified";
 
     //---------------------------------------------------- Lock-Token header ---
     public static final String HEADER_LOCK_TOKEN = "Lock-Token";

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavMethods.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavMethods.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavMethods.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavMethods.java Fri Aug 26 00:26:01 2005
@@ -60,7 +60,7 @@
      * The webdav POST method and public constant
      */
     public static final int DAV_POST = DAV_HEAD + 1;
-    private static final String METHOD_POST = "POST";
+    public static final String METHOD_POST = "POST";
 
 
     /** The webdav DELETE method and public constant */

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java Fri Aug 26 00:26:01 2005
@@ -17,6 +17,7 @@
 
 import org.apache.jackrabbit.webdav.property.*;
 import org.apache.jackrabbit.webdav.lock.*;
+import org.apache.jackrabbit.webdav.io.InputContext;
 
 import java.io.InputStream;
 
@@ -184,12 +185,10 @@
      * Add the given resource as an internal member to this resource.
      *
      * @param resource {@link DavResource} to be added as internal member.
-     * @param in {@link java.io.InputStream} providing the content for the
-     * internal member.
+     * @param inputCxt Context providing the content for the internal member.
      * @throws DavException
      */
-    public void addMember(DavResource resource, InputStream in)
-            throws DavException;
+    public void addMember(DavResource resource, InputContext inputCxt) throws DavException;
 
     /**
      * Add the given resource as an internal member to this resource.

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/io/InputContext.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/io/InputContext.java?rev=240176&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/io/InputContext.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/io/InputContext.java Fri Aug 26 00:26:01 2005
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * 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.webdav.io;
+
+import java.io.InputStream;
+
+/**
+ * <code>InputContext</code> class encapsulates the <code>InputStream</code>
+ * and some header values as present in the POST, PUT or MKCOL request.
+ */
+public class InputContext {
+
+    private InputStream inputStream;
+    private String contentType;
+    private String contentLanguage;
+
+    /**
+     * Returns the input stream to be imported or <code>null</code> if no stream
+     * has been set or if the stream has been consumed.
+     *
+     * @return the input stream.
+     */
+    public InputStream getInputStream() {
+        return inputStream;
+    }
+
+    /**
+     * Sets the input stream to be imported. The input stream should be set to
+     * <code>null</code> if it has been consumed.
+     *
+     * @param inputStream the input stream
+     */
+    public void setInputStream(InputStream inputStream) {
+        this.inputStream = inputStream;
+    }
+
+    /**
+     * Returns the content type of the resource to be imported or null, if
+     * no has previously been set.
+     *
+     * @return the content type of the resource
+     */
+    public String getContentType() {
+        return contentType;
+    }
+
+    /**
+     * Sets the content type of the resource.
+     *
+     * @param contentType the content type.
+     */
+    public void setContentType(String contentType) {
+        this.contentType = contentType;
+    }
+
+    /**
+     * Returns the content language or <code>null</code>.
+     *
+     * @return contentLanguage
+     */
+    public String getContentLanguage() {
+        return contentLanguage;
+    }
+
+    /**
+     * Sets the content language.
+     *
+     * @param contentLanguage
+     */
+    public void setContentLanguage(String contentLanguage) {
+        this.contentLanguage = contentLanguage;
+    }
+}

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

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/io/InputContext.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java Fri Aug 26 00:26:01 2005
@@ -15,12 +15,26 @@
  */
 package org.apache.jackrabbit.webdav.property;
 
+import java.util.HashSet;
+import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.jdom.Element;
+import org.jdom.Namespace;
+import org.apache.jackrabbit.webdav.version.DeltaVConstants;
 
 /**
  * The <code>ResourceType</code> class represents the webdav resource
- * type property. Valid resource types are '{@link #COLLECTION collection}',
- * {@link #DEFAULT_RESOURCE}.
+ * type property. The property may contain multiple resource type
+ * values. Predefined resource types are those defined by RFC2518 and RFC3253:
+ * <ul>
+ * <li>{@link #DEFAULT_RESOURCE the empty default resource type},</li>
+ * <li>'{@link #COLLECTION DAV:collection}',</li>
+ * <li>'{@link #VERSION_HISTORY DAV:version-history}',</li>
+ * <li>'{@link #ACTIVITY DAV:activity}',</li>
+ * <li>'{@link #BASELINE DAV:baseline}',</li>
+ * </ul>
  */
 public class ResourceType extends AbstractDavProperty {
 
@@ -34,61 +48,176 @@
      */
     public static final int COLLECTION = DEFAULT_RESOURCE + 1;
 
-    private int resourceType = DEFAULT_RESOURCE;
+    /**
+     * The version-history resource type
+     */
+    public static final int VERSION_HISTORY = COLLECTION + 1;
+
+    /**
+     * The activity resource type
+     */
+    public static final int ACTIVITY = VERSION_HISTORY + 1;
+
+    /**
+     * The baseline resource type
+     */
+    public static final int BASELINE = ACTIVITY + 1;
+
+    /**
+     * Array containing all possible resourcetype elements
+     */
+    private static final List NAMES = new ArrayList();
+    static {
+        NAMES.add(null);
+        NAMES.add(new TypeName(XML_COLLECTION, NAMESPACE));
+        NAMES.add(new TypeName(DeltaVConstants.XML_VERSION_HISTORY, DeltaVConstants.NAMESPACE));
+        NAMES.add(new TypeName(DeltaVConstants.XML_ACTIVITY, DeltaVConstants.NAMESPACE));
+        NAMES.add(new TypeName(DeltaVConstants.XML_BASELINE, DeltaVConstants.NAMESPACE));
+    };
+
+    private final int[] resourceTypes;
 
     /**
-     * Create a resource type property
+     * Create a single-valued resource type property
      */
     public ResourceType(int resourceType) {
+        this(new int[] { resourceType });
+    }
+
+    /**
+     * Create a multi-valued resource type property
+     */
+    public ResourceType(int[] resourceTypes) {
         super(DavPropertyName.RESOURCETYPE, false);
-	if (!isValidResourceType(resourceType)) {
-           throw new IllegalArgumentException("Invalid resource type '"+ resourceType +"'.");
+        for (int i=0; i<resourceTypes.length; i++) {
+            if (!isValidResourceType(resourceTypes[i])) {
+                throw new IllegalArgumentException("Invalid resource type '"+ resourceTypes[i] +"'.");
+            }
         }
-	this.resourceType = resourceType;
+	this.resourceTypes = resourceTypes;
     }
 
     /**
-     * Return the JDOM element representation of this resource type
+     * Return the JDOM element representation of this property
      *
      * @return a JDOM element
      */
     public Element toXml() {
         Element elem = getName().toXml();
-        if (getValue() != null) {
-            elem.addContent((Element)getValue());
-        }
+        elem.addContent((Set)getValue());
         return elem;
     }
 
     /**
-     * Returns the Xml representation of this resource type.
+     * Returns the Xml representation of this property as a
+     * <code>Set</code> of <code>Element</code>s.
      *
-     * @return Xml representation of this resource type.
+     * @return a <code>Set</code> of <code>Element</code>s
+     * representing this property.
      * @see DavProperty#getValue()
      */
     public Object getValue() {
-        return (resourceType == COLLECTION) ? new Element(XML_COLLECTION, NAMESPACE) : null;
+        Set elements = new HashSet();
+        for (int i=0; i<resourceTypes.length; i++) {
+            Element elem = resourceTypeToXml(resourceTypes[i]);
+            if (elem != null) {
+                elements.add(elem);
+            }
+        }
+        return elements;
     }
 
     /**
-     * Returns the resource type specified with the constructor.
+     * Returns the resource types specified with the constructor.
      *
-     * @return resourceType
+     * @return resourceTypes
      */
-    public int getResourceType() {
-        return resourceType;
+    public int[] getResourceTypes() {
+        return resourceTypes;
     }
 
     /**
-     * Validates the specified resourceType.
+     * Returns the Xml representation of an individual resource type,
+     * or <code>null</code> if the resource type has no Xml
+     * representation (e.g. {@link #DEFAULT_RESOURCE}).<p/>{@link #getValue()} uses
+     * this method to build the full set of Xml elements for the property's resource
+     * types. Subclasses should override this method to add support for resource
+     * types they define.
      *
-     * @param resourceType
-     * @return true if the specified resourceType is valid.
+     * @return Xml element representing the internal type or <code>null</code>
+     * if the resource has no element name assigned (default resource type).
      */
-    public boolean isValidResourceType(int resourceType) {
-        if (resourceType < DEFAULT_RESOURCE || resourceType > COLLECTION) {
-	    return false;
-	}
+    private static Element resourceTypeToXml(int resourceType) {
+        TypeName name = (TypeName) NAMES.get(resourceType);
+        return (name != null) ? new Element(name.localName, name.namespace) : null;
+    }
+
+    /**
+     * Returns true if the given integer defines a valid resource type.
+     *
+     * @param resourceType to be validated.
+     * @return true if this is one of the predefined resource types
+     */
+    private static boolean isValidResourceType(int resourceType) {
+        if (resourceType < DEFAULT_RESOURCE || resourceType > NAMES.size()-1) {
+            return false;
+        }
         return true;
+    }
+
+    /**
+     * Register an additional resource type
+     *
+     * @param name
+     * @param namespace
+     * @return int to be used for creation of a new <code>ResourceType</code> property
+     * that contains this type.
+     * @throws IllegalArgumentException if the given element is <code>null</code> or
+     * if the registration fails for another reason.
+     */
+    public static int registerResourceType(String name, Namespace namespace) {
+        if (name == null || namespace == null) {
+            throw new IllegalArgumentException("Cannot register a <null> resourcetype");
+        }
+        TypeName tn = new TypeName(name, namespace);
+        // avoid duplicate registrations
+        if (NAMES.contains(tn)) {
+            return NAMES.indexOf(tn);
+        }
+        // register new type
+        if (NAMES.add(tn)) {
+            return NAMES.size() - 1;
+        } else {
+            throw new IllegalArgumentException("Could not register resourcetype " +  namespace.getPrefix() + name);
+        }
+    }
+
+    //--------------------------------------------------------< inner class >---
+    /**
+     * Private inner class used to register predefined and user defined resource
+     * types.
+     */
+    private static class TypeName {
+
+        private final String localName;
+        private final Namespace namespace;
+        private final int hashCode;
+
+        private TypeName(String localName, Namespace namespace) {
+            this.localName = localName;
+            this.namespace = namespace;
+            hashCode = ("{" + namespace.getURI() + "}" + localName).hashCode();
+        }
+
+        public int hashCode() {
+            return hashCode;
+        }
+
+        public boolean equals(Object o) {
+            if (o instanceof TypeName) {
+                return hashCode == ((TypeName)o).hashCode;
+            }
+            return false;
+        }
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionHistoryResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionHistoryResource.java?rev=240176&r1=240175&r2=240176&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionHistoryResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionHistoryResource.java Fri Aug 26 00:26:01 2005
@@ -16,6 +16,7 @@
 package org.apache.jackrabbit.webdav.version;
 
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.ResourceType;
 import org.apache.jackrabbit.webdav.DavException;
 
 /**



Mime
View raw message