jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r230679 [1/2] - in /incubator/jackrabbit/trunk/contrib/jcr-server: ./ client/src/java/org/apache/jackrabbit/client/ client/src/java/org/apache/jackrabbit/webdav/client/methods/ server/src/java/org/apache/jackrabbit/server/ server/src/java/o...
Date Sun, 07 Aug 2005 16:13:16 GMT
Author: tripod
Date: Sun Aug  7 09:12:33 2005
New Revision: 230679

URL: http://svn.apache.org/viewcvs?rev=230679&view=rev
Log:
[JCR-175] Contrib JCR-Server: enable PROPPATCH for simple-davresource
[JCR-174] Contrib JCR-Server: improve handing of strong etags

Added:
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DefaultResourceFilter.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFilter.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFilterConfig.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/filter.xml   (with props)
Removed:
    incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/client/
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/DavMethodBase.java   (contents, props changed)
    incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/OptionsMethod.java   (contents, props changed)
    incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/PropFindMethod.java   (contents, props changed)
    incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/ReportMethod.java   (contents, props changed)
    incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/SearchMethod.java   (contents, props changed)
    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/AbstractExportCommand.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.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/FileExportCommand.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/PrimaryItemExportCommand.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
    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/ItemResourceConstants.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/LengthsProperty.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.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/jcr/version/VersionItemCollection.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/SimpleWebdavServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.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/DavResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/CodedUrlHeader.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/DepthHeader.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/DavMethodBase.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/DavMethodBase.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/DavMethodBase.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/DavMethodBase.java Sun Aug  7 09:12:33 2005
@@ -104,4 +104,4 @@
             throw new DavException(getStatusCode(), getName() + " resulted with unexpected status code: " + getStatusCode());
         }
     }
-}
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/DavMethodBase.java
            ('svn' removed)

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/OptionsMethod.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/OptionsMethod.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/OptionsMethod.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/OptionsMethod.java Sun Aug  7 09:12:33 2005
@@ -33,4 +33,4 @@
     public String getName() {
 	return DavMethods.METHOD_OPTIONS;
     }
-}
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/OptionsMethod.java
            ('svn' removed)

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/PropFindMethod.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/PropFindMethod.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/PropFindMethod.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/PropFindMethod.java Sun Aug  7 09:12:33 2005
@@ -73,4 +73,4 @@
     public String getName() {
         return DavMethods.METHOD_PROPFIND;
     }
-}
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/PropFindMethod.java
            ('svn' removed)

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/ReportMethod.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/ReportMethod.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/ReportMethod.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/ReportMethod.java Sun Aug  7 09:12:33 2005
@@ -42,4 +42,4 @@
     public String getName() {
 	return DavMethods.METHOD_REPORT;
     }
-}
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/ReportMethod.java
            ('svn' removed)

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/SearchMethod.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/SearchMethod.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/SearchMethod.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/SearchMethod.java Sun Aug  7 09:12:33 2005
@@ -44,4 +44,4 @@
     public String getName() {
         return DavMethods.METHOD_SEARCH;
     }
-}
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/webdav/client/methods/SearchMethod.java
            ('svn' removed)

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/project.properties?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/project.properties (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/project.properties Sun Aug  7 09:12:33 2005
@@ -3,5 +3,5 @@
 
 #-------------------------------------------------------
 jackrabbit.build.version.jcr=1.0
-jackrabbit.build.version.jackrabbit=1.0-dev
-jackrabbit.build.version.jcr.rmi=1.0-dev
+jackrabbit.build.version.jackrabbit=1.0-SNAPSHOT
+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=230679&r1=230678&r2=230679&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 Sun Aug  7 09:12:33 2005
@@ -69,7 +69,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -485,16 +484,7 @@
         }
 
         // complete any other property setting or removing
-        DavPropertyIterator setIter = setProperties.iterator();
-        while (setIter.hasNext()) {
-            DavProperty prop = setIter.nextProperty();
-            resource.setProperty(prop);
-        }
-        Iterator remNameIter = removeProperties.iterator();
-        while (remNameIter.hasNext()) {
-            DavPropertyName propName = (DavPropertyName) remNameIter.next();
-            resource.removeProperty(propName);
-        }
+        resource.alterProperties(setProperties, removeProperties);
         response.setStatus(DavServletResponse.SC_OK);
 
         // todo return multistatus response in case of failure

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java Sun Aug  7 09:12:33 2005
@@ -81,6 +81,7 @@
         } else {
             context.setContentType(getDefaultContentType());
         }
+
         return exportNode(context, content);
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java Sun Aug  7 09:12:33 2005
@@ -171,6 +171,9 @@
         context.setContentType("text/html; charset=utf8");
         tmpfile.deleteOnExit();
 
+        // etag
+        context.setETag("");
+
         return true;
     }
 }

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=230679&r1=230678&r2=230679&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 Sun Aug  7 09:12:33 2005
@@ -62,6 +62,11 @@
     private String contentType;
 
     /**
+     * the ETag of the resource
+     */
+    private String etag;
+
+    /**
      * Creates a new ExportContext for the given node
      *
      * @param exportRoot
@@ -195,5 +200,24 @@
      */
     public void setContentType(String contentType) {
         this.contentType = contentType;
+    }
+
+    /**
+     * Returns the ETag of the resource.
+     *
+     * @return the ETag
+     */
+    public String getETag() {
+        return etag;
+    }
+
+    /**
+     * Sets the ETag of the resource. A successfull export command
+     * may set this member.
+     *
+     * @param etag the ETag
+     */
+    public void setETag(String etag) {
+        this.etag = etag;
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileExportCommand.java Sun Aug  7 09:12:33 2005
@@ -51,6 +51,13 @@
             context.setContentLength(0);
             context.setInputStream(null);
         }
+
+        String etag = "";
+        if (content.hasProperty(JCR_LASTMODIFIED)) {
+            etag = "\"" + context.getContentLength() + "-" + content.getProperty(JCR_LASTMODIFIED).getLong() + "\"";
+        }
+        context.setETag(etag);
+
         return true;
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/PrimaryItemExportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/PrimaryItemExportCommand.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/PrimaryItemExportCommand.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/PrimaryItemExportCommand.java Sun Aug  7 09:12:33 2005
@@ -81,13 +81,15 @@
 
             context.setCreationTime(creationTime);
             // check for last modified sibling
+            long lastModified = 0;
             try {
                 if (parent.hasProperty(JCR_LASTMODIFIED)) {
-                    context.setModificationTime(parent.getProperty(JCR_LASTMODIFIED).getLong());
+                    lastModified = parent.getProperty(JCR_LASTMODIFIED).getLong();
                 }
             } catch (RepositoryException e) {
                 // ignore
             }
+            context.setModificationTime(lastModified);
 
             // check for contenttype and encoding sibling of the primary item.
             String contentType="application/octet-stream";
@@ -120,6 +122,14 @@
                 context.setInputStream(prop.getValue().getStream());
                 context.setContentLength(prop.getLength());
             }
+
+            // build the etag
+            String etag = "";
+            if (lastModified > 0) {
+                etag = "\"" + context.getContentLength() + "-" + lastModified + "\"";
+            }
+            context.setETag(etag);
+
             return true;
         } else {
             /* no primaryItem property could be retrieved, abort command */

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java Sun Aug  7 09:12:33 2005
@@ -145,8 +145,8 @@
         if (!exists()) {
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
-        DavResourceLocator destPath = destination.getLocator();
-        if (!getLocator().isSameWorkspace(destPath)) {
+        DavResourceLocator destLocator = destination.getLocator();
+        if (!getLocator().isSameWorkspace(destLocator)) {
             throw new DavException(DavServletResponse.SC_FORBIDDEN);
         }
 
@@ -191,19 +191,13 @@
             throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow copy.");
         }
 
-        if (!(destination instanceof AbstractItemResource)) {
-            throw new DavException(DavServletResponse.SC_FORBIDDEN, "Cannot copy a resource that does not represent a repository item.");
-        }
-
         try {
-            AbstractItemResource destResource = (AbstractItemResource) destination;
-            String destResourcePath = destResource.getResourcePath();
             Workspace workspace = getRepositorySession().getWorkspace();
             if (getLocator().isSameWorkspace(destination.getLocator())) {
-                workspace.copy(getResourcePath(), destResourcePath);
+                workspace.copy(getResourcePath(), destination.getResourcePath());
             } else {
-                Workspace destWorkspace = destResource.getRepositorySession().getWorkspace();
-                destWorkspace.copy(workspace.getName(), getResourcePath(), destResourcePath);
+                log.error("Copy between workspaces is not yet implemented (src: '" + getHref() + "', dest: '" + destination.getHref() + "')");
+                throw new DavException(DavServletResponse.SC_NOT_IMPLEMENTED);
             }
         } catch (PathNotFoundException e) {
             // according to RFC 2518, should not occur
@@ -241,7 +235,6 @@
             supportedReports = new SupportedReportSetProperty(new ReportType[] {
                 ReportType.EXPAND_PROPERTY,
                 NodeTypesReport.NODETYPES_REPORT,
-                ExportViewReport.EXPORTVIEW_REPORT,
                 LocateByUuidReport.LOCATE_BY_UUID_REPORT,
                 RegisteredNamespacesReport.REGISTERED_NAMESPACES_REPORT,
                 RepositoryDescriptorsReport.REPOSITORY_DESCRIPTORS_REPORT
@@ -259,10 +252,16 @@
                 properties.add(new DefaultDavProperty(JCR_NAME, item.getName()));
                 properties.add(new DefaultDavProperty(JCR_PATH, item.getPath()));
                 properties.add(new DefaultDavProperty(JCR_DEPTH, String.valueOf(item.getDepth())));
+                // add href-property for the items parent unless its the root item
+                if (item.getDepth() > 0) {
+                    String parentHref = getLocatorFromResourcePath(item.getParent().getPath()).getHref(true);
+                    properties.add(new HrefProperty(JCR_PARENT, parentHref, false));
+                }
             } catch (RepositoryException e) {
+                // should not get here
                 log.error("Error while accessing jcr properties: " + e.getMessage());
             }
-
+            
             // transaction resource additional protected properties
             if (item.isNew()) {
                 properties.add(new DefaultDavProperty(JCR_ISNEW, null, true));

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java Sun Aug  7 09:12:33 2005
@@ -189,6 +189,20 @@
     /**
      * Throws {@link DavServletResponse#SC_METHOD_NOT_ALLOWED}
      *
+     * @param setProperties
+     * @param removePropertyNames
+     * @throws DavException
+     * @see DavResource#alterProperties(org.apache.jackrabbit.webdav.property.DavPropertySet, org.apache.jackrabbit.webdav.property.DavPropertyNameSet) 
+     */
+    public void alterProperties(DavPropertySet setProperties,
+                                DavPropertyNameSet removePropertyNames)
+        throws DavException {
+        throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
+    }
+
+    /**
+     * Throws {@link DavServletResponse#SC_METHOD_NOT_ALLOWED}
+     *
      * @param destination
      * @throws DavException Always throws {@link DavServletResponse#SC_METHOD_NOT_ALLOWED}
      * @see DavResource#move(org.apache.jackrabbit.webdav.DavResource)

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=230679&r1=230678&r2=230679&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 Sun Aug  7 09:12:33 2005
@@ -20,6 +20,8 @@
 import org.apache.jackrabbit.webdav.*;
 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;
+import org.apache.jackrabbit.webdav.jcr.version.report.LocateCorrespondingNodeReport;
 import org.apache.jackrabbit.webdav.ordering.*;
 import org.apache.jackrabbit.webdav.lock.*;
 import org.apache.jackrabbit.JcrConstants;
@@ -115,6 +117,19 @@
      * @todo undo incomplete modifications...
      */
     public void setProperty(DavProperty property) throws DavException {
+        internalSetProperty(property);
+        complete();
+    }
+
+    /**
+     * Internal method used to set or add the given property
+     *
+     * @param property
+     * @throws DavException
+     * @see #setProperty(DavProperty)
+     * @see #alterProperties(DavPropertySet, DavPropertyNameSet)
+     */
+    private void internalSetProperty(DavProperty property) throws DavException {
         if (!exists()) {
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
@@ -141,8 +156,6 @@
                 while (it.hasNext()) {
                     n.addMixin((String)it.next());
                 }
-                complete();
-
             } catch (RepositoryException e) {
                 throw new JcrDavException(e);
             }
@@ -163,6 +176,19 @@
      * @todo undo incomplete modifications...
      */
     public void removeProperty(DavPropertyName propertyName) throws DavException {
+        internalRemoveProperty(propertyName);
+        complete();
+    }
+
+    /**
+     * Internal method used to remove the property with the given name.
+     *
+     * @param propertyName
+     * @throws DavException
+     * @see #removeProperty(DavPropertyName)
+     * @see #alterProperties(DavPropertySet, DavPropertyNameSet)
+     */
+    private void internalRemoveProperty(DavPropertyName propertyName) throws DavException {
         if (!exists()) {
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
@@ -174,8 +200,6 @@
                 for (int i = 0; i < mixins.length; i++) {
                     n.removeMixin(mixins[i].getName());
                 }
-                complete();
-
             } catch (RepositoryException e) {
                 // NoSuchNodeTypeException, ConstraintViolationException should never occur...
                 throw new JcrDavException(e);
@@ -187,6 +211,30 @@
     }
 
     /**
+     *
+     * @param setProperties
+     * @param removePropertyNames
+     * @throws DavException
+     * @todo undo incomplete modifications...
+     */
+    public void alterProperties(DavPropertySet setProperties,
+                                DavPropertyNameSet removePropertyNames)
+        throws DavException {
+        DavPropertyIterator setIter = setProperties.iterator();
+        while (setIter.hasNext()) {
+            DavProperty prop = setIter.nextProperty();
+            internalSetProperty(prop);
+        }
+        Iterator remNameIter = removePropertyNames.iterator();
+        while (remNameIter.hasNext()) {
+            DavPropertyName propName = (DavPropertyName) remNameIter.next();
+            internalRemoveProperty(propName);
+        }
+        // save all changes together
+        complete();
+    }
+
+    /**
      * If the specified resource represents a collection, a new node is {@link Node#addNode(String)
      * added} to the item represented by this resource. If an input stream is specified
      * together with a collection resource {@link Session#importXML(String, java.io.InputStream, int)}
@@ -629,6 +677,24 @@
     }
 
     /**
+     * Defines the additional reports supported by this resource (reports
+     * specific for resources representing a repository {@link Node node}):
+     * <ul>
+     * <li>{@link ExportViewReport export view report}</li>
+     * <li>{@link LocateCorrespondingNodeReport locate corresponding node report}</li>
+     * </ul>
+     * 
+     * @see org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty
+     */
+    protected void initSupportedReports() {
+        super.initSupportedReports();
+        if (exists()) {
+            supportedReports.addReportType(ExportViewReport.EXPORTVIEW_REPORT);
+            supportedReports.addReportType(LocateCorrespondingNodeReport.LOCATE_CORRESPONDING_NODE_REPORT);
+        }
+    }
+
+    /**
      * Fill the property set for this resource.
      */
     protected void initProperties() {
@@ -717,7 +783,7 @@
         try {
             String[] pHref = new String[values.length];
             for (int i = 0; i < values.length; i++) {
-                pHref[i] = this.getLocatorFromResourcePath(values[i].getPath()).getHref(true);
+                pHref[i] = getLocatorFromResourcePath(values[i].getPath()).getHref(true);
             }
             properties.add(new HrefProperty(name, pHref, isProtected));
         } catch (RepositoryException e) {

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=230679&r1=230678&r2=230679&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 Sun Aug  7 09:12:33 2005
@@ -100,6 +100,19 @@
      * todo: undo incomplete modifications...
      */
     public void setProperty(DavProperty property) throws DavException {
+        internalSetProperty(property);
+        complete();
+    }
+
+    /**
+     * Internal method that performs the setting or adding of properties
+     *
+     * @param property
+     * @throws DavException
+     * @see #setProperty(DavProperty)
+     * @see #alterProperties(DavPropertySet, DavPropertyNameSet)
+     */
+    private void internalSetProperty(DavProperty property) throws DavException {
         if (!exists()) {
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
@@ -115,8 +128,6 @@
             } else {
                 throw new DavException(DavServletResponse.SC_CONFLICT);
             }
-            complete();
-
         } catch (IllegalArgumentException e) {
             throw new DavException(DavServletResponse.SC_BAD_REQUEST, e.getMessage());
         } catch (RepositoryException e) {
@@ -138,6 +149,34 @@
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
         throw new DavException(DavServletResponse.SC_FORBIDDEN);
+    }
+
+    /**
+     * Loops over the given <code>Set</code>s and alters the properties accordingly.
+     * Changes are persisted at the end only according to the rules defined with
+     * the {@link #complete()} method.
+     *
+     * @param setProperties
+     * @param removePropertyNames
+     * @throws DavException
+     * @see DavResource#alterProperties(DavPropertySet, DavPropertyNameSet)
+     */
+    public void alterProperties(DavPropertySet setProperties,
+                                DavPropertyNameSet removePropertyNames)
+        throws DavException {
+
+        // altering any properties fails if an attempt is made to remove a property
+        if (removePropertyNames != null && !removePropertyNames.isEmpty()) {
+            throw new DavException(DavServletResponse.SC_FORBIDDEN);
+        }
+
+        // only set/add >> existance of resource is checked inside internal method
+        DavPropertyIterator setIter = setProperties.iterator();
+        while (setIter.hasNext()) {
+            DavProperty prop = setIter.nextProperty();
+            internalSetProperty(prop);
+        }
+        complete();
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java Sun Aug  7 09:12:33 2005
@@ -61,7 +61,7 @@
     public static final String XML_EXCLUSIVE_SESSION_SCOPED = "exclusive-session-scoped";
 
     // xml elements used to reflect the workspaces ns-registry
-    // TODO: to be review...
+    // TODO: to be reviewed...
     public static final String XML_NAMESPACE = "namespace";
     public static final String XML_PREFIX = "prefix";
     public static final String XML_URI = "uri";
@@ -105,6 +105,7 @@
     public static final DavPropertyName JCR_NAME = DavPropertyName.create("name", NAMESPACE);
     public static final DavPropertyName JCR_PATH = DavPropertyName.create("path", NAMESPACE);
     public static final DavPropertyName JCR_DEPTH = DavPropertyName.create("depth", NAMESPACE);
+    public static final DavPropertyName JCR_PARENT = DavPropertyName.create("parent", NAMESPACE);
     public static final DavPropertyName JCR_ISNEW = DavPropertyName.create("isnew", NAMESPACE);
     public static final DavPropertyName JCR_ISMODIFIED = DavPropertyName.create("ismodified", NAMESPACE);
 
@@ -125,4 +126,7 @@
 
     // property names used for resource representing a workspace
     public static final DavPropertyName JCR_NAMESPACES = DavPropertyName.create("namespaces", NAMESPACE);
+
+    // property names used for resource representing a version hisotry
+    public static final DavPropertyName JCR_VERSIONABLEUUID = DavPropertyName.create("versionableuuid", NAMESPACE);
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java Sun Aug  7 09:12:33 2005
@@ -17,13 +17,13 @@
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
-import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.*;
 import org.jdom.Element;
 
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
 import javax.jcr.Item;
+import java.util.*;
 
 /**
  * <code>RootItemCollection</code> represents the root node of the underlaying
@@ -77,14 +77,79 @@
         return collection;
     }
 
+    /**
+     * Allows to alter the registered namespaces ({@link #JCR_NAMESPACES}) and
+     * forwards any other property to the super class.
+     *
+     * @param property
+     * @throws DavException
+     * @see VersionControlledItemCollection#setProperty(org.apache.jackrabbit.webdav.property.DavProperty)
+     */
     public void setProperty(DavProperty property) throws DavException {
-        if (ItemResourceConstants.JCR_NAMESPACES.equals(property.getName())) {
-            // todo: register and unregister namespaces
+        if (JCR_NAMESPACES.equals(property.getName())) {
+            Object v = property.getValue();
+            if (v instanceof List) {
+                Map changeMap = new HashMap();
+                // retrieve list of prefix/uri pairs that build the new values of
+                // the ns-registry
+                Iterator it = ((List)v).iterator();
+                while (it.hasNext()) {
+                    Object listEntry = it.next();
+                    if (listEntry instanceof Element) {
+                        Element e = (Element)listEntry;
+                        if (XML_NAMESPACE.equals(e.getName())) {
+                            String prefix = e.getChildText(XML_PREFIX, NAMESPACE);
+                            String uri = e.getChildText(XML_URI, NAMESPACE);
+                            changeMap.put(prefix, uri);
+                        }
+                    }
+                }
+                try {
+                    NamespaceRegistry nsReg = getRepositorySession().getWorkspace().getNamespaceRegistry();
+                    String[] registeredPrefixes = nsReg.getPrefixes();
+                    for (int i = 0; i < registeredPrefixes.length; i++) {
+                        String prfx = registeredPrefixes[i];
+                        if (!changeMap.containsKey(prfx)) {
+                            // prefix not present amongst the new values any more > unregister
+                            nsReg.unregisterNamespace(prfx);
+                        } else if (changeMap.get(prfx).equals(nsReg.getURI(prfx))) {
+                            // present with same uri-value >> no action required
+                            changeMap.remove(prfx);
+                        }
+                    }
+
+                    // try to register any prefix/uri pair that has a changed uri or
+                    // it has not been present before.
+                    Iterator prefixIt = changeMap.keySet().iterator();
+                    while (prefixIt.hasNext()) {
+                        String prefix = (String)prefixIt.next();
+                        String uri = (String)changeMap.get(prefix);
+                        nsReg.registerNamespace(prefix, uri);
+                    }
+                } catch (RepositoryException e) {
+                    throw new JcrDavException(e);
+                }
+            } else {
+                log.warn("Unexpected structure of jcr:namespace property.");
+                throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
+            }
         } else {
             super.setProperty(property);
         }
     }
 
+    /**
+     * @see #setProperty(DavProperty)
+     * @see DavResource#alterProperties(org.apache.jackrabbit.webdav.property.DavPropertySet, org.apache.jackrabbit.webdav.property.DavPropertyNameSet)
+     */
+    public void alterProperties(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames) throws DavException {
+        if (setProperties.contains(JCR_NAMESPACES)) {
+            setProperty(setProperties.remove(JCR_NAMESPACES));
+        }
+        // let super-class handle the rest of the properties
+        super.alterProperties(setProperties, removePropertyNames);
+    }
+
     //--------------------------------------------------------------------------
     protected void initProperties() {
         super.initProperties();
@@ -95,11 +160,11 @@
             Element[] nsElems = new Element[prefixes.length];
             for (int i = 0; i < prefixes.length; i++) {
                 Element elem = new Element(XML_NAMESPACE, NAMESPACE);
-                elem.addContent(new Element(XML_PREFIX).setText(prefixes[i]));
-                elem.addContent(new Element(XML_URI)).setText(nsReg.getURI(prefixes[i]));
+                elem.addContent(new Element(XML_PREFIX, NAMESPACE).setText(prefixes[i]));
+                elem.addContent(new Element(XML_URI, NAMESPACE)).setText(nsReg.getURI(prefixes[i]));
                 nsElems[i] = elem;
             }
-            properties.add(new DefaultDavProperty(ItemResourceConstants.JCR_NAMESPACES, nsElems, false));
+            properties.add(new DefaultDavProperty(JCR_NAMESPACES, nsElems, false));
         } catch (RepositoryException e) {
             log.error("Failed to access NamespaceRegistry from the session/workspace: " + e.getMessage());
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java Sun Aug  7 09:12:33 2005
@@ -484,7 +484,8 @@
     }
 
     /**
-     * Add a {@link org.apache.jackrabbit.webdav.property.HrefProperty} with the specified property name and values.
+     * Add a {@link org.apache.jackrabbit.webdav.property.HrefProperty} with the
+     * specified property name and values.
      *
      * @param name
      * @param values Array of {@link Value}s.

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java Sun Aug  7 09:12:33 2005
@@ -114,4 +114,4 @@
      * @return the name of the root element
      */
     public abstract String getElementName();
-}
+}
\ No newline at end of file

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java Sun Aug  7 09:12:33 2005
@@ -106,4 +106,4 @@
     public String getElementName() {
 	return CHILDNODEDEFINITION_ELEMENT;
     }
-}
+}
\ No newline at end of file

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java Sun Aug  7 09:12:33 2005
@@ -128,4 +128,4 @@
     public String getElementName() {
 	return PROPERTYDEFINITION_ELEMENT;
     }
-}
+}
\ No newline at end of file

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/LengthsProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/LengthsProperty.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/LengthsProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/LengthsProperty.java Sun Aug  7 09:12:33 2005
@@ -54,4 +54,4 @@
     public Object getValue() {
 	return value;
     }
-}
+}
\ No newline at end of file

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java Sun Aug  7 09:12:33 2005
@@ -116,4 +116,4 @@
     public Object getValue() {
 	return value;
     }
-}
+}
\ No newline at end of file

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=230679&r1=230678&r2=230679&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 Sun Aug  7 09:12:33 2005
@@ -18,6 +18,7 @@
 import org.apache.log4j.Logger;
 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.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.jcr.DefaultItemCollection;
@@ -119,6 +120,13 @@
 
         // change resourcetype defined by default item collection
         properties.add(new ResourceType(ResourceType.VERSION_HISTORY));
+        
+        // jcr specific property pointing to the node this history belongs to
+        try {
+            properties.add(new DefaultDavProperty(JCR_VERSIONABLEUUID, ((VersionHistory)item).getVersionableUUID()));
+        } catch (RepositoryException e) {
+            log.error(e.getMessage());
+        }
 
         // required root-version property for version-history resource
         try {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java Sun Aug  7 09:12:33 2005
@@ -124,13 +124,14 @@
     }
 
     /**
-     * Return the nearest ancestor of the underlaying repository item.
+     * Return versionhistory that contains this version item
      *
-     * @return nearest ancestor of the underlaying repository item.
+     * @return versionhistory that contains this version item
      * @throws RepositoryException
+     * @see javax.jcr.version.Version#getContainingHistory() 
      */
     private VersionHistory getVersionHistoryItem() throws RepositoryException {
-        return (VersionHistory) item.getParent();
+        return ((Version)item).getContainingHistory();
     }
 
     //--------------------------------------------------------------------------

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java?rev=230679&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java Sun Aug  7 09:12:33 2005
@@ -0,0 +1,134 @@
+/*
+ * 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.jcr.version.report;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.version.report.Report;
+import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.version.report.ReportInfo;
+import org.apache.jackrabbit.webdav.version.DeltaVResource;
+import org.apache.jackrabbit.webdav.version.DeltaVConstants;
+import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.util.XmlUtil;
+import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
+import org.apache.jackrabbit.webdav.jcr.JcrDavException;
+import org.jdom.Document;
+import org.jdom.Element;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>LocateCorrespondingNodeReport</code> is used to identify the resource that
+ * represents the corresponding node in another workspace.
+ *
+ * <p/>
+ * The request body must be a 'jcr:locate-corresponding-node' XML element, that
+ * contains the href of the source workspace, where the corresponding node should
+ * be searched:
+ * <pre>
+ * &lt;!ELEMENT locate-corresponding-node ( workspace ) &gt;
+ * &lt;!ELEMENT workspace ( href ) &gt;  (as defined by <a href="http://www.webdav.org/specs/rfc3253.html#PROPERTY_workspace">RFC 3253</a>)
+ * </pre>
+ * The response to a successful report request must be a jcr:locate-corresponding-node-report
+ * element that contains the href of the corresponding node in the given source
+ * workspace:
+ *
+ * <pre>
+ * &lt;!ELEMENT locate-corresponding-node-report ( href ) &gt;
+ * </pre>
+ *
+ * @see javax.jcr.Node#getCorrespondingNodePath(String)
+ */
+public class LocateCorrespondingNodeReport implements Report {
+
+    private static Logger log = Logger.getLogger(LocateCorrespondingNodeReport.class);
+
+    private static final String REPORT_NAME = "locate-corresponding-node";
+
+    private DeltaVResource resource;
+    private String workspaceHref;
+
+    /**
+     * The corresponding-node report type
+     */
+    public static final ReportType LOCATE_CORRESPONDING_NODE_REPORT = ReportType.register(REPORT_NAME, ItemResourceConstants.NAMESPACE, LocateByUuidReport.class);
+
+    /**
+     * Returns {@link #LOCATE_CORRESPONDING_NODE_REPORT}
+     *
+     * @return always returns {@link #LOCATE_CORRESPONDING_NODE_REPORT}
+     * @see org.apache.jackrabbit.webdav.version.report.Report#getType() 
+     */
+    public ReportType getType() {
+        return LOCATE_CORRESPONDING_NODE_REPORT;
+    }
+
+    /**
+     * @see Report#setResource(org.apache.jackrabbit.webdav.version.DeltaVResource)
+     */
+    public void setResource(DeltaVResource resource) {
+        if (resource == null) {
+            throw new IllegalArgumentException("Resource must not be null.");
+        }
+        DavSession davSession = resource.getSession();
+        if (davSession == null || davSession.getRepositorySession() == null) {
+            throw new IllegalArgumentException("The resource must provide a non-null session object in order to create the jcr:locate-corresponding-node report.");
+        }
+        this.resource = resource;
+    }
+
+    /**
+     * @see Report#setInfo(org.apache.jackrabbit.webdav.version.report.ReportInfo)
+     */
+    public void setInfo(ReportInfo info) {
+        if (info == null || !REPORT_NAME.equals(info.getReportElement().getName())) {
+            throw new IllegalArgumentException("jcr:locate-corresponding-node expected.");
+        }
+        Element workspace = info.getReportElement().getChild(DeltaVConstants.WORKSPACE.getName(), DeltaVConstants.WORKSPACE.getNamespace());
+        if (workspace != null) {
+            workspaceHref = workspace.getChildText(DavConstants.XML_HREF, DavConstants.NAMESPACE);
+        }
+    }
+
+    /**
+     * @see org.apache.jackrabbit.webdav.version.report.Report#toXml()
+     */
+    public Document toXml() throws DavException {
+        if (resource == null || workspaceHref == null) {
+            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while running jcr:locate-corresponding-node report: resource must not be null and request body must define the href of a source workspace");
+        }
+        try {
+            Item item = resource.getSession().getRepositorySession().getItem(resource.getResourcePath());
+            if (item.isNode()) {
+                DavResourceLocator rLoc = resource.getLocator();
+                String workspaceName = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), workspaceHref).getWorkspaceName();
+
+                String corrPath = ((Node)item).getCorrespondingNodePath(workspaceName);
+                DavResourceLocator corrLoc = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), workspaceName + "/", corrPath);
+
+                Element e = new Element("locate-corresponding-node-report", ItemResourceConstants.NAMESPACE);
+                e.addContent(XmlUtil.hrefToXml(corrLoc.getHref(true)));
+                return new Document(e);
+            } else {
+                throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while running jcr:locate-corresponding-node report: resource must represent a JCR node.");
+            }
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java
------------------------------------------------------------------------------
    svn = 

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

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=230679&r1=230678&r2=230679&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 Sun Aug  7 09:12:33 2005
@@ -31,6 +31,7 @@
 import org.apache.jackrabbit.server.io.ImportCollectionChain;
 import org.apache.jackrabbit.util.Text;
 import org.apache.log4j.Logger;
+import org.jdom.Namespace;
 
 /**
  * DavResourceImpl imeplements a DavResource.
@@ -52,6 +53,8 @@
     /** is created on initProperties */
     private NodeResource nodeResource;
 
+    private ResourceFilter filter;
+
     /**
      * Create a new {@link DavResource}.
      *
@@ -60,11 +63,12 @@
      * @param session
      */
     public DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory,
-                           DavSession session)
-        throws RepositoryException {
+                           DavSession session, ResourceFilter filter)
+        throws RepositoryException, DavException {
         this.session = session;
         this.factory = factory;
         this.locator = locator;
+        this.filter = filter;
         if (locator != null && locator.getResourcePath() != null) {
             try {
                 init(session.getRepositorySession().getItem(locator.getResourcePath()));
@@ -80,12 +84,15 @@
      * @param repositoryItem
      * @throws RepositoryException
      */
-    private void init(Item repositoryItem) throws RepositoryException {
+    private void init(Item repositoryItem) throws RepositoryException, DavException {
         if (repositoryItem == null || !repositoryItem.isNode()) {
             return;
         }
         node = (Node)repositoryItem;
-
+        if (isFilteredNode(node)) {
+            log.debug("Cannot to access resource based on a filtered repository item: " + locator.getResourcePath());
+            throw new DavException(DavServletResponse.SC_FORBIDDEN);
+        }
         // define what is a resource in webdav
         if (node.isNodeType(NT_RESOURCE) || node.isNodeType(NT_FILE)) {
             isCollection = false;
@@ -241,6 +248,28 @@
             SupportedLock supportedLock = new SupportedLock();
             supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE);
             properties.add(supportedLock);
+
+            // 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();
+                    String prefix = Text.getNamespacePrefix(pName);
+                    String uri = node.getSession().getNamespaceURI(prefix);
+                    Namespace namespace = Namespace.getNamespace(prefix, uri);
+                    DavPropertyName name = DavPropertyName.create(Text.getLocalName(pName), namespace);
+                    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));
+                    }
+                }
+            } catch (RepositoryException e) {
+                log.error("Unexpected error while retrieving properties: " + e.getMessage());
+            }
         }
     }
 
@@ -253,7 +282,21 @@
         if (isLocked(this)) {
             throw new DavException(DavServletResponse.SC_LOCKED);
         }
-        throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        try {
+            setJcrProperty(property);
+            node.save();
+        } catch (RepositoryException e) {
+            // revert any changes made so far an throw exception
+            try {
+                node.refresh(false);
+            } catch (RepositoryException re) {
+                throw new JcrDavException(e);
+            }
+            throw new JcrDavException(e);
+        }
     }
 
     /**
@@ -265,9 +308,51 @@
         if (isLocked(this)) {
             throw new DavException(DavServletResponse.SC_LOCKED);
         }
-        throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        try {
+            removeJcrProperty(propertyName);
+            node.save();
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
+    public void alterProperties(DavPropertySet setProperties,
+                                DavPropertyNameSet removePropertyNames)
+        throws DavException {
+        if (isLocked(this)) {
+            throw new DavException(DavServletResponse.SC_LOCKED);
+        }
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        try {
+            DavPropertyIterator setIter = setProperties.iterator();
+            while (setIter.hasNext()) {
+                DavProperty prop = setIter.nextProperty();
+                setJcrProperty(prop);
+            }
+            Iterator remNameIter = removePropertyNames.iterator();
+            while (remNameIter.hasNext()) {
+                DavPropertyName propName = (DavPropertyName) remNameIter.next();
+                removeJcrProperty(propName);
+            }
+            // save all changes together (reverted in case this fails)
+            node.save();
+        } catch (RepositoryException e) {
+            // revert any changes made so far an throw exception
+            try {
+                node.refresh(false);
+            } catch (RepositoryException re) {
+                throw new JcrDavException(e);
+            }
+            throw new JcrDavException(e);
+        }
     }
 
+
     /**
      * @see DavResource#getCollection()
      */
@@ -297,7 +382,12 @@
             try {
                 NodeIterator it = node.getNodes();
                 while(it.hasNext()) {
-                    list.add(buildResourceFromItem(it.nextNode()));
+                    Node n = it.nextNode();
+                    if (!isFilteredNode(n)) {
+                        list.add(buildResourceFromItem(n));
+                    } else {
+                        log.debug("Filtered resource '" + n.getName() + "'.");
+                    }
                 }
             } catch (RepositoryException e) {
                 // should not occure
@@ -323,6 +413,12 @@
 
         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);
@@ -352,6 +448,13 @@
 	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());
@@ -380,6 +483,12 @@
             throw new DavException(DavServletResponse.SC_LOCKED);
         }
 
+        // don't allow removal of nodes, that would be filtered out
+        if (isFilteredResource(member)) {
+            log.debug("Avoid removal of filtered resource: " + member.getDisplayName());
+            throw new DavException(DavServletResponse.SC_FORBIDDEN);
+        }
+
         try {
             // make sure, non-jcr locks are removed.
             if (!isJsrLockable()) {
@@ -412,6 +521,9 @@
         if (isLocked(this)) {
             throw new DavException(DavServletResponse.SC_LOCKED);
         }
+        if (isFilteredResource(destination)) {
+            throw new DavException(DavServletResponse.SC_FORBIDDEN);
+        }
         try {
             session.getRepositorySession().getWorkspace().move(getResourcePath(), destination.getResourcePath());
         } catch (RepositoryException e) {
@@ -429,6 +541,9 @@
         if (isLocked(destination)) {
             throw new DavException(DavServletResponse.SC_LOCKED);
         }
+        if (isFilteredResource(destination)) {
+            throw new DavException(DavServletResponse.SC_FORBIDDEN);
+        }
         // TODO: support shallow and deep copy
         if (shallow) {
             throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow copy.");
@@ -493,7 +608,8 @@
      * @see org.apache.jackrabbit.webdav.DavResource#getLocks()
      */
     public ActiveLock[] getLocks() {
-        return new ActiveLock[] {getLock(Type.WRITE, Scope.EXCLUSIVE)};
+        ActiveLock writeLock = getLock(Type.WRITE, Scope.EXCLUSIVE);
+        return (writeLock != null) ? new ActiveLock[] {writeLock} : new ActiveLock[0];
     }
 
     /**
@@ -604,7 +720,7 @@
         boolean lockable = false;
         if (exists()) {
             try {
-                lockable =  node.isNodeType("mix:lockable");
+                lockable =  node.isNodeType(MIX_LOCKABLE);
             } catch (RepositoryException e) {
                 // not jcr-lockable
             }
@@ -642,5 +758,44 @@
     private DavResource buildResourceFromItem(Item item) throws DavException, RepositoryException {
         DavResourceLocator parentloc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), item.getPath());
         return factory.createResource(parentloc, session);
+    }
+
+    /**
+     * Build jcr property name from dav property name
+     *
+     * @param propName
+     * @return jcr name
+     * @throws RepositoryException
+     */
+    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;
+        }
+        return pName;
+    }
+
+
+    private void setJcrProperty(DavProperty property) throws RepositoryException {
+        // retrieve value
+        String value = property.getValue().toString();
+        // set value; since multivalued-properties are not listed in the set
+        // of available properties, this extra validation-check is omitted.
+        node.setProperty(getJcrName(property.getName()), value);
+    }
+
+    private void removeJcrProperty(DavPropertyName propertyName) throws RepositoryException {
+        node.getProperty(getJcrName(propertyName)).remove();
+    }
+
+    private boolean isFilteredResource(DavResource resource) {
+        // todo: filtered nodetypes should be checked as well in order to prevent problems.
+        return filter != null && filter.isFilteredResource(resource.getDisplayName(), session.getRepositorySession());
+    }
+
+    private boolean isFilteredNode(Node n) {
+        return filter != null && filter.isFilteredItem(n);
     }
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DefaultResourceFilter.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DefaultResourceFilter.java?rev=230679&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DefaultResourceFilter.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DefaultResourceFilter.java Sun Aug  7 09:12:33 2005
@@ -0,0 +1,156 @@
+/*
+ * 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.simple;
+
+import org.apache.log4j.Logger;
+
+import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <code>DefaultResourceFilter</code>...
+ */
+public class DefaultResourceFilter implements ResourceFilter {
+
+    private static Logger log = Logger.getLogger(DefaultResourceFilter.class);
+
+    private List prefixFilter = new ArrayList();
+    private List uriFilter = new ArrayList();
+    private List nodetypeFilter = new ArrayList();
+
+    public DefaultResourceFilter() {
+    }
+
+    /**
+     * @see ResourceFilter#setFilteredURIs(String[])
+     */
+    public void setFilteredURIs(String[] uris) {
+        if (uris != null) {
+            for (int i = 0; i < uris.length; i++) {
+                uriFilter.add(uris[i]);
+            }
+        }
+    }
+
+    /**
+     * @see ResourceFilter#setFilteredPrefixes(String[])
+     */
+    public void setFilteredPrefixes(String[] prefixes) {
+        if (prefixes != null) {
+            for (int i = 0; i < prefixes.length; i++) {
+                prefixFilter.add(prefixes[i]);
+            }
+        }
+    }
+
+    /**
+     * @see ResourceFilter#setFilteredNodetypes(String[])
+     */
+    public void setFilteredNodetypes(String[] nodetypeNames) {
+        if (nodetypeNames != null) {
+            for (int i = 0; i < nodetypeNames.length; i++) {
+                nodetypeFilter.add(nodetypeNames[i]);
+            }
+        }
+    }
+
+    /**
+     * Returns true if the given item matches either one of the namespace or
+     * of the the nodetype filters specified.
+     *
+     * @see ResourceFilter#isFilteredItem(Item)
+     */
+    public boolean isFilteredItem(Item item) {
+        return isFilteredNamespace(item) || isFilteredNodeType(item);
+    }
+
+    /**
+     * @see ResourceFilter#isFilteredResource(String, Session)
+     */
+    public boolean isFilteredResource(String displayName, Session session) {
+        return isFilteredNamespace(displayName, session);
+    }
+
+    /**
+     *
+     * @param name
+     * @param session
+     * @return
+     */
+    private boolean isFilteredNamespace(String name, Session session) {
+        // shortcut
+        if (prefixFilter.isEmpty() && uriFilter.isEmpty()) {
+            return false;
+        }
+        int pos = name.indexOf(":");
+        if (pos < 0) {
+            // no namespace info present
+            return false;
+        }
+        try {
+            String prefix = name.substring(0, pos);
+            String uri = session.getNamespaceURI(prefix);
+            return prefixFilter.contains(prefix) || uriFilter.contains(uri);
+        } catch (RepositoryException e) {
+            log.warn(e.getMessage());
+        }
+        return false;
+    }
+
+    /**
+     *
+     * @param item
+     * @return
+     */
+    private boolean isFilteredNamespace(Item item) {
+        try {
+            return isFilteredNamespace(item.getName(), item.getSession());
+        } catch (RepositoryException e) {
+            log.warn(e.getMessage());
+        }
+        return false;
+    }
+
+    /**
+     *
+     * @param item
+     * @return
+     */
+    private boolean isFilteredNodeType(Item item) {
+        // shortcut
+        if (nodetypeFilter.isEmpty()) {
+            return false;
+        }
+        try {
+            String ntName;
+            if (item.isNode()) {
+                ntName = ((Node) item).getDefinition().getDeclaringNodeType().getName();
+            } else {
+                ntName = ((Property) item).getDefinition().getDeclaringNodeType().getName();
+            }
+            return nodetypeFilter.contains(ntName);
+        } catch (RepositoryException e) {
+            log.warn(e.getMessage());
+        }
+        // nodetype info could not be retrieved
+        return false;
+    }
+}
\ No newline at end of file

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

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

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=230679&r1=230678&r2=230679&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 Sun Aug  7 09:12:33 2005
@@ -59,6 +59,7 @@
     private long modificationTime = new Date().getTime();
     private long contentLength = 0;
     private String contentType = null;
+    private String etag = null;
     private InputStream in = null;
 
     /**
@@ -84,6 +85,7 @@
         this.in = ctx.getInputStream();
         this.creationTime = ctx.getCreationTime();
         this.modificationTime = ctx.getModificationTime();
+        this.etag = ctx.getETag();
     }
 
     /**
@@ -144,21 +146,12 @@
     }
 
     /**
-     * Return the weak ETag
+     * Return the ETag or <code>null</code> if the context does not provide one.
      *
-     * @return weak ETag
+     * @return String representing a strong or weak ETag or <code>null</code>
      */
     public String getETag() {
-	return "W/\"" + this.contentLength + "-" + this.modificationTime + "\"";
-    }
-
-    /**
-     * Return the strong ETag or empty string if it cannot be determined.
-     *
-     * @return strong ETag
-     */
-    public String getStrongETag() {
-	return "";
+        return etag;
     }
 
     /**

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=230679&r1=230678&r2=230679&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 Sun Aug  7 09:12:33 2005
@@ -28,9 +28,15 @@
 public class ResourceFactoryImpl implements DavResourceFactory {
 
     private final LockManager lockMgr;
+    private final ResourceFilter resourceFilter;
 
     public ResourceFactoryImpl(LockManager lockMgr) {
+        this(lockMgr, new DefaultResourceFilter());
+    }
+
+    public ResourceFactoryImpl(LockManager lockMgr, ResourceFilter resourceFilter) {
         this.lockMgr = lockMgr;
+        this.resourceFilter = resourceFilter;
     }
 
     public DavResource createResource(DavResourceLocator locator, DavServletRequest request,
@@ -40,7 +46,7 @@
 
     public DavResource createResource(DavResourceLocator locator, DavSession session) throws DavException {
         try {
-            DavResource res = new DavResourceImpl(locator, this, session);
+            DavResource res = new DavResourceImpl(locator, this, session, resourceFilter);
             res.addLockManager(lockMgr);
             return res;
         } catch (RepositoryException e) {

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFilter.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFilter.java?rev=230679&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFilter.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFilter.java Sun Aug  7 09:12:33 2005
@@ -0,0 +1,67 @@
+/*
+ * 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.simple;
+
+import javax.jcr.Item;
+import javax.jcr.Session;
+
+/**
+ * <code>ResourceFilter</code> 
+ */
+public interface ResourceFilter {
+
+    /**
+     * Define the URIs that should be filtered out if present in the prefix
+     * of an items name.
+     *
+     * @param uris
+     */
+    public void setFilteredURIs(String[] uris);
+
+    /**
+     * Define the namespace prefixes that should be filtered if present in
+     * the prefix of an items name.
+     *
+     * @param prefixes
+     */
+    public void setFilteredPrefixes(String[] prefixes);
+
+    /**
+     * Set the nodetype names that should be used if a given item should be
+     * filtered. Note that not the nodetype(s) defined for a given item
+     * is relevant but rather the nodetype that defined the definition of the item.
+     *
+     * @param nodetypeNames
+     */
+    public void setFilteredNodetypes(String[] nodetypeNames);
+
+    /**
+     * Returns true if the given item should be filtered.
+     *
+     * @param item to be tested
+     * @return true if the given item should be filtered.
+     */
+    public boolean isFilteredItem(Item item);
+
+    /**
+     * Returns true if the resouce with the given name should be filtered.
+     *
+     * @param displayName to be tested for a filtered namespace prefix
+     * @param session used for looking up namespace mappings
+     * @return true if the given resource should be filtered.
+     */
+    public boolean isFilteredResource(String displayName, Session session);
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFilterConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFilterConfig.java?rev=230679&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFilterConfig.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFilterConfig.java Sun Aug  7 09:12:33 2005
@@ -0,0 +1,135 @@
+/*
+ * 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.simple;
+
+import org.apache.log4j.Logger;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * <code>ResourceFilterConfig</code>...
+ */
+public class ResourceFilterConfig {
+
+    private static Logger log = Logger.getLogger(ResourceFilterConfig.class);
+
+    /**
+     * Tries to parse the given xml configuration file. If the parser fails,
+     * <code>null</code> is returned.<p/>
+     * The xml must match the following structure:<br>
+     * <pre>
+     * &lt;!ELEMENT filter (class, namespaces?, nodetypes?) &gt;
+     * &lt;!ELEMENT class &gt;
+     *    &lt;!ATTLIST class
+     *      name  CDATA #REQUIRED
+     *    &gt;
+     * &lt;!ELEMENT namespaces (prefix|uri)* &gt;
+     * &lt;!ELEMENT prefix (CDATA) &gt;
+     * &lt;!ELEMENT uri (CDATA) &gt;
+     * &lt;!ELEMENT nodetypes (nodetype)* &gt;
+     * &lt;!ELEMENT nodetype (CDATA) &gt;
+     * </pre>
+     *
+     * @param filterURL
+     * @return resource filter retrieved from xml configuration or <code>null</code>
+     * if the parser fails.
+     */
+    public ResourceFilter parse(URL filterURL) {
+        ResourceFilter filter = null;
+        try {
+            String className = null;
+            Element nts = null;
+            Element ns = null;
+
+            Document doc = new SAXBuilder().build(filterURL);
+            Element root = doc.getRootElement();
+            Iterator elemIter = root.getChildren().iterator();
+            while (elemIter.hasNext()) {
+                Element child = (Element) elemIter.next();
+                String childName = child.getName();
+                if ("class".equals(childName)) {
+                    className = child.getAttributeValue("name");
+                } else if ("nodetypes".equals(childName)) {
+                    nts = child;
+                } else if ("namespaces".equals(childName)) {
+                    ns = child;
+                }
+            }
+
+            if (className != null) {
+                Class cl = Class.forName(className);
+                Class[] interfaces = cl.getInterfaces();
+                boolean isfilterClass = false;
+                for (int i = 0; i < interfaces.length && !isfilterClass; i++) {
+                    isfilterClass = (interfaces[i].equals(ResourceFilter.class));
+                }
+                if (isfilterClass) {
+                    filter = (ResourceFilter) cl.newInstance();
+                    if (ns != null) {
+                        parseNamespacesEntry(ns, filter);
+                    }
+                    if (nts != null) {
+                        parseNodeTypesEntry(nts, filter);
+                    }
+                } else {
+                    log.warn("Class '" + className + "' specified does not represent a resource filter > using default.");
+                }
+            } else {
+                log.warn("Invalid filter configuration: missing 'class' element");
+            }
+        } catch (Exception e) {
+            log.warn("Error while reading filter configuration. Using empty filter instead.");
+        }
+        return filter;
+    }
+
+    private void parseNamespacesEntry(Element child, ResourceFilter filter) {
+        List l = child.getChildren("prefix");
+        Iterator it = l.iterator();
+        String[] prefixes = new String[l.size()];
+        int i = 0;
+        while(it.hasNext()) {
+            prefixes[i++] = ((Element) it.next()).getText();
+        }
+
+        l = child.getChildren("uri");
+        it = l.iterator();
+        String[] uris = new String[l.size()];
+        i = 0;
+        while(it.hasNext()) {
+            uris[i++] = ((Element) it.next()).getText();
+        }
+
+        filter.setFilteredPrefixes(prefixes);
+        filter.setFilteredURIs(uris);
+    }
+
+    private void parseNodeTypesEntry(Element child, ResourceFilter filter) {
+        List l = child.getChildren("nodetype");
+        Iterator it = l.iterator();
+        String[] ntNames = new String[l.size()];
+        int i = 0;
+        while(it.hasNext()) {
+            ntNames[i++] = ((Element) it.next()).getText();
+        }
+        filter.setFilteredNodetypes(ntNames);
+    }
+}
\ No newline at end of file

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

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



Mime
View raw message