jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r385540 [2/3] - in /incubator/jackrabbit/trunk/jcr-server: server/src/java/org/apache/jackrabbit/server/jcr/ server/src/java/org/apache/jackrabbit/webdav/jcr/ server/src/java/org/apache/jackrabbit/webdav/jcr/observation/ server/src/java/org...
Date Mon, 13 Mar 2006 13:07:07 GMT
Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java Mon Mar 13 05:07:02 2006
@@ -34,6 +34,7 @@
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.property.HrefProperty;
 import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
@@ -62,7 +63,9 @@
      * @param session
      * @param factory
      */
-    public VersionItemCollection(DavResourceLocator locator, DavSession session, DavResourceFactory factory, Item item) {
+    public VersionItemCollection(DavResourceLocator locator,
+                                 JcrDavSession session,
+                                 DavResourceFactory factory, Item item) {
         super(locator, session, factory, item);
         if (item == null || !(item instanceof Version)) {
             throw new IllegalArgumentException("Version item expected.");

Added: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/AbstractJcrReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/AbstractJcrReport.java?rev=385540&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/AbstractJcrReport.java (added)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/AbstractJcrReport.java Mon Mar 13 05:07:02 2006
@@ -0,0 +1,82 @@
+/*
+ * 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.jackrabbit.webdav.version.report.Report;
+import org.apache.jackrabbit.webdav.version.report.ReportInfo;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
+
+import javax.jcr.Session;
+
+/**
+ * <code>AbstractJcrReport</code>...
+ */
+public abstract class AbstractJcrReport implements Report {
+
+    private Session session;
+    private ReportInfo reportInfo;
+
+    /**
+     * Performs basic validation checks common to all JCR specific reports.
+     *
+     * @param resource
+     * @param info
+     * @throws DavException
+     * @see Report#init(DavResource, ReportInfo)
+     */
+    public void init(DavResource resource, ReportInfo info) throws DavException {
+        if (resource == null || info == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Unable to run report: WebDAV Resource and ReportInfo must not be null.");
+        }
+        if (!getType().isRequestedReportType(info)) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Expected report type: '" + getType().getReportName() + "', found: '" + info.getReportName() + ";" + "'.");
+        }
+        if (info.getDepth() > DavConstants.DEPTH_0) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Invalid Depth header: " + info.getDepth());
+        }
+
+        DavSession davSession = resource.getSession();
+        if (davSession == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create '" + getType().getReportName()+ "' report.");
+        }
+        session = JcrDavSession.getRepositorySession(resource.getSession());
+        if (session == null) {
+            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal error: Unable to access repository session.");
+        }
+        reportInfo = info;
+    }
+
+    //-----------------------------------------------------< implementation >---
+    /**
+     * @return session Session object as obtained from the {@link DavSession}.
+     */
+    Session getRepositorySession() {
+        return session;
+    }
+
+    /**
+     * @return reportInfo the <code>ReportInfo</code> specifying the requested
+     * report details.
+     */
+    ReportInfo getReportInfo() {
+        return reportInfo;
+    }
+}
\ No newline at end of file

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

Propchange: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/AbstractJcrReport.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java Mon Mar 13 05:07:02 2006
@@ -18,13 +18,11 @@
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
-import org.apache.jackrabbit.webdav.version.DeltaVResource;
 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.DavException;
-import org.apache.jackrabbit.webdav.DavSession;
-import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.util.Text;
 import org.xml.sax.SAXException;
 import org.w3c.dom.Element;
@@ -60,7 +58,7 @@
  * </pre>
  * If no view type is specified the DocView is generated.
  */
-public class ExportViewReport implements Report {
+public class ExportViewReport extends AbstractJcrReport {
 
     private static Logger log = Logger.getLogger(ExportViewReport.class);
 
@@ -71,9 +69,7 @@
      */
     public static final ReportType EXPORTVIEW_REPORT = ReportType.register(REPORT_NAME, ItemResourceConstants.NAMESPACE, ExportViewReport.class);
 
-    private String absItemPath;
-    private Session session;
-    private ReportInfo info;
+    private String absNodePath;
 
     /**
      * Returns {@link #EXPORTVIEW_REPORT} report type.
@@ -95,31 +91,22 @@
     }
 
     /**
-     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo)
+     * @see Report#init(DavResource, ReportInfo)
      */
-    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
-        if (!getType().isRequestedReportType(info)) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:exportview element expected.");
-        }
-        if (resource == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
-        }
-
-        this.info = info;
-
-        DavSession davSession = resource.getSession();
-        if (davSession == null || davSession.getRepositorySession() == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the exportview report.");
-        }
-        session = davSession.getRepositorySession();
-        absItemPath = resource.getLocator().getJcrPath();
+    public void init(DavResource resource, ReportInfo info) throws DavException {
+        // delegate validation to super class
+        super.init(resource, info);
+        // report specific validation: resource must represent an existing
+        // repository node
+        absNodePath = resource.getLocator().getRepositoryPath();
         try {
-            if (!session.itemExists(absItemPath)) {
-                throw new JcrDavException(new PathNotFoundException(absItemPath + " does not exist."));
-    }
+            if (!(getRepositorySession().itemExists(absNodePath) && getRepositorySession().getItem(absNodePath).isNode())) {
+                throw new JcrDavException(new PathNotFoundException(absNodePath + " does not exist."));
+            }
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
+
     }
 
     /**
@@ -130,22 +117,21 @@
      * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
      */
     public Element toXml(Document document) {
-        boolean skipBinary = info.containsContentElement("skipbinary", ItemResourceConstants.NAMESPACE);
-        boolean noRecurse = info.containsContentElement("norecurse", ItemResourceConstants.NAMESPACE);
-
+        boolean skipBinary = getReportInfo().containsContentElement("skipbinary", ItemResourceConstants.NAMESPACE);
+        boolean noRecurse = getReportInfo().containsContentElement("norecurse", ItemResourceConstants.NAMESPACE);
         // todo improve...
         try {
             // create tmpFile in default system-tmp directory
-            String prefix = "_tmp_" + Text.getName(absItemPath);
+            String prefix = "_tmp_" + Text.getName(absNodePath);
             File tmpfile = File.createTempFile(prefix, null, null);
             tmpfile.deleteOnExit();
 
             FileOutputStream out = new FileOutputStream(tmpfile);
-            if (info.containsContentElement("sysview", ItemResourceConstants.NAMESPACE)) {
-                session.exportSystemView(absItemPath, out, skipBinary, noRecurse);
+            if (getReportInfo().containsContentElement("sysview", ItemResourceConstants.NAMESPACE)) {
+                getRepositorySession().exportSystemView(absNodePath, out, skipBinary, noRecurse);
             } else {
                 // default is docview
-                session.exportDocumentView(absItemPath, out, skipBinary, noRecurse);
+                getRepositorySession().exportDocumentView(absNodePath, out, skipBinary, noRecurse);
             }
             out.close();
 

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java Mon Mar 13 05:07:02 2006
@@ -16,7 +16,6 @@
 package org.apache.jackrabbit.webdav.jcr.version.report;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.version.DeltaVResource;
 import org.apache.jackrabbit.webdav.version.report.Report;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
 import org.apache.jackrabbit.webdav.version.report.ReportInfo;
@@ -27,7 +26,6 @@
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.DavConstants;
-import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavResource;
 import org.w3c.dom.Element;
@@ -46,7 +44,7 @@
  * </pre>
  * The response to a successful report request will be a Multi-Status response.
  */
-public class LocateByUuidReport implements Report {
+public class LocateByUuidReport extends AbstractJcrReport {
 
     private static Logger log = Logger.getLogger(LocateByUuidReport.class);
 
@@ -80,30 +78,23 @@
     }
 
     /**
-     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo)
+     * @see Report#init(DavResource, ReportInfo)
      */
-    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
-        if (!getType().isRequestedReportType(info)) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:locate-by-uuid element expected.");
-        }
+    public void init(DavResource resource, ReportInfo info) throws DavException {
+        // delegate basic validation to super class
+        super.init(resource, info);
+        // make also sure, the info contains a DAV:href child element
         if (!info.containsContentElement(DavConstants.XML_HREF, DavConstants.NAMESPACE)) {
             throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:locate-by-uuid element must at least contain a single DAV:href child.");
         }
-        if (resource == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
-        }
-        DavSession davSession = resource.getSession();
-        if (davSession == null || davSession.getRepositorySession() == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the locate-by-uuid report.");
-    }
-
+        // immediately build the final multistatus element
         try {
             Element hrefElem = info.getContentElement(DavConstants.XML_HREF, DavConstants.NAMESPACE);
             String uuid = DomUtil.getTextTrim(hrefElem);
             DavResourceLocator resourceLoc = resource.getLocator();
-            Node n = davSession.getRepositorySession().getNodeByUUID(uuid);
+            Node n = getRepositorySession().getNodeByUUID(uuid);
             DavResourceLocator loc = resourceLoc.getFactory().createResourceLocator(resourceLoc.getPrefix(), resourceLoc.getWorkspacePath(), n.getPath(), false);
-            DavResource locatedResource = resource.getFactory().createResource(loc, davSession);
+            DavResource locatedResource = resource.getFactory().createResource(loc, resource.getSession());
             ms = new MultiStatus();
             ms.addResourceProperties(locatedResource, info.getPropertyNameSet(), info.getDepth());
         } catch (RepositoryException e) {

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java Mon Mar 13 05:07:02 2006
@@ -19,16 +19,15 @@
 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.xml.DomUtil;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavResource;
 import org.w3c.dom.Element;
 import org.w3c.dom.Document;
 
@@ -60,7 +59,7 @@
  *
  * @see javax.jcr.Node#getCorrespondingNodePath(String)
  */
-public class LocateCorrespondingNodeReport implements Report {
+public class LocateCorrespondingNodeReport extends AbstractJcrReport {
 
     private static Logger log = Logger.getLogger(LocateCorrespondingNodeReport.class);
 
@@ -94,27 +93,20 @@
     }
 
     /**
-     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo)
+     * @see Report#init(DavResource, ReportInfo)
      */
-    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
-        if (resource == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
-        }
-        DavSession davSession = resource.getSession();
-        if (davSession == null || davSession.getRepositorySession() == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the dcr:locate-corresponding-node report.");
-        }
-        if (!getType().isRequestedReportType(info)) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:locate-corresponding-node expected.");
-    }
-
+    public void init(DavResource resource, ReportInfo info) throws DavException {
+        // general validation checks
+        super.init(resource, info);
+        // specific for this report: a workspace href must be provided
         Element workspace = info.getContentElement(DeltaVConstants.WORKSPACE.getName(), DeltaVConstants.WORKSPACE.getNamespace());
         String workspaceHref = DomUtil.getChildTextTrim(workspace, DavConstants.XML_HREF, DavConstants.NAMESPACE);
         if (workspaceHref == null || "".equals(workspaceHref)) {
             throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Request body must define the href of a source workspace");
         }
+        // retrieve href of the corresponding resource in the other workspace
         try {
-            this.correspHref = getCorrespondingResourceHref(resource, workspaceHref);
+            this.correspHref = getCorrespondingResourceHref(resource, getRepositorySession(), workspaceHref);
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
@@ -129,19 +121,28 @@
             elem.appendChild(DomUtil.hrefToXml(correspHref, document));
         }
         return elem;
-        }
+    }
 
-    private static String getCorrespondingResourceHref(DeltaVResource resource, String workspaceHref) throws RepositoryException {
-            DavResourceLocator rLoc = resource.getLocator();
-            String itemPath = rLoc.getJcrPath();
-            Session s = resource.getSession().getRepositorySession();
-            Item item = s.getItem(itemPath);
-            if (item.isNode()) {
-                String workspaceName = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), workspaceHref).getWorkspaceName();
-                String corrPath = ((Node)item).getCorrespondingNodePath(workspaceName);
-                DavResourceLocator corrLoc = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), "/" + workspaceName, corrPath, false);
+    /**
+     * Retrieve the href of the corresponding resource in the indicated workspace.
+     *
+     * @param resource
+     * @param session Session object used to access the {@link Node} object
+     * represented by the given resource.
+     * @param workspaceHref
+     * @return
+     * @throws RepositoryException
+     */
+    private static String getCorrespondingResourceHref(DavResource resource, Session session, String workspaceHref) throws RepositoryException {
+        DavResourceLocator rLoc = resource.getLocator();
+        String itemPath = rLoc.getRepositoryPath();
+        Item item = session.getItem(itemPath);
+        if (item.isNode()) {
+            String workspaceName = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), workspaceHref).getWorkspaceName();
+            String corrPath = ((Node)item).getCorrespondingNodePath(workspaceName);
+            DavResourceLocator corrLoc = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), "/" + workspaceName, corrPath, false);
             return corrLoc.getHref(true);
-            } else {
+        } else {
             throw new PathNotFoundException("Node with path " + itemPath + " does not exist.");
         }
     }

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java Mon Mar 13 05:07:02 2006
@@ -16,13 +16,12 @@
 package org.apache.jackrabbit.webdav.jcr.version.report;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.version.DeltaVResource;
 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.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.jcr.nodetype.NodeTypeConstants;
 import org.apache.jackrabbit.webdav.jcr.nodetype.PropertyDefinitionImpl;
@@ -59,12 +58,11 @@
  * </pre>
  *
  * @see NodeTypeConstants#NAMESPACE
- *
- * @todo currently the nodetype report is not consistent with the general way of representing nodetype names (with NodetypeElement) in order to be compatible with the jackrabbit nodetype registry...
- * @todo for the same reason, not the complete nodetype-definition, but only the nodetype def as stored is represented.
- * @todo no namespace definition with response (> jackrabbit)... and nodetype element has same name as the one used with dav-properties
  */
-public class NodeTypesReport implements Report, NodeTypeConstants {
+//todo: currently the nodetype report is not consistent with the general way of representing nodetype names (with NodetypeElement) in order to be compatible with the jackrabbit nodetype registry...
+//todo: for the same reason, not the complete nodetype-definition, but only the nodetype def as stored is represented.
+//todo: no namespace definition with response (> jackrabbit)... and nodetype element has same name as the one used with dav-properties
+public class NodeTypesReport extends AbstractJcrReport implements NodeTypeConstants {
 
     private static Logger log = Logger.getLogger(NodeTypesReport.class);
 
@@ -73,7 +71,6 @@
      */
     public static final ReportType NODETYPES_REPORT = ReportType.register("nodetypes", NodeTypeConstants.NAMESPACE, NodeTypesReport.class);
 
-    private Session session;
     private NodeTypeIterator ntIter;
 
     /**
@@ -96,26 +93,18 @@
     }
 
     /**
-     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo)
+     * @see Report#init(DavResource, ReportInfo)
      */
-    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
-        if (resource == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
-        }
-        if (!getType().isRequestedReportType(info)) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:nodetypes element expected.");
-        }
-        DavSession davSession = resource.getSession();
-        if (davSession == null || davSession.getRepositorySession() == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the nodetypes report.");
-    }
-        session = davSession.getRepositorySession();
+    public void init(DavResource resource, ReportInfo info) throws DavException {
+        // delegate basic validation to super class
+        super.init(resource, info);
+        // report specific validation and preparation for xml serialization
         try {
-            ntIter = getNodeTypes(session, info);
+            ntIter = getNodeTypes(getRepositorySession(), info);
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
-        if (session == null || ntIter == null) {
+        if (ntIter == null) {
             throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
         }
     }
@@ -131,40 +120,40 @@
     public Element toXml(Document document) {
         Element report = document.createElement(NODETYPES_ELEMENT);
         // loop over the nodetypes to be returned in the report
-            while (ntIter.hasNext()) {
-                NodeType nt = ntIter.nextNodeType();
+        while (ntIter.hasNext()) {
+            NodeType nt = ntIter.nextNodeType();
             Element ntDef = document.createElement(NODETYPE_ELEMENT);
-                ntDef.setAttribute(NAME_ATTRIBUTE, nt.getName());
-                ntDef.setAttribute(ISMIXIN_ATTRIBUTE, Boolean.toString(nt.isMixin()));
-                ntDef.setAttribute(HASORDERABLECHILDNODES_ATTRIBUTE, Boolean.toString(nt.hasOrderableChildNodes()));
+            ntDef.setAttribute(NAME_ATTRIBUTE, nt.getName());
+            ntDef.setAttribute(ISMIXIN_ATTRIBUTE, Boolean.toString(nt.isMixin()));
+            ntDef.setAttribute(HASORDERABLECHILDNODES_ATTRIBUTE, Boolean.toString(nt.hasOrderableChildNodes()));
 
-		// declared supertypes
-		NodeType[] snts = nt.getDeclaredSupertypes();
+            // declared supertypes
+            NodeType[] snts = nt.getDeclaredSupertypes();
             Element supertypes = DomUtil.addChildElement(ntDef, SUPERTYPES_ELEMENT, null);
-		for (int i = 0; i < snts.length; i++) {
+            for (int i = 0; i < snts.length; i++) {
                 DomUtil.addChildElement(supertypes, SUPERTYPE_ELEMENT, null, snts[i].getName());
-		}
+            }
 
-		// declared childnode defs
-		NodeDefinition[] cnd = nt.getChildNodeDefinitions();
-		for (int i = 0; i < cnd.length; i++) {
-		    if (cnd[i].getDeclaringNodeType().getName().equals(nt.getName())) {
+            // declared childnode defs
+            NodeDefinition[] cnd = nt.getChildNodeDefinitions();
+            for (int i = 0; i < cnd.length; i++) {
+                if (cnd[i].getDeclaringNodeType().getName().equals(nt.getName())) {
                     ntDef.appendChild(NodeDefinitionImpl.create(cnd[i]).toXml(document));
-		    }
-		}
+                }
+            }
 
-		// declared propertyDefs
-		PropertyDefinition[] pd = nt.getPropertyDefinitions();
-		for (int i = 0; i < pd.length; i++) {
-		    if (pd[i].getDeclaringNodeType().getName().equals(nt.getName())) {
+            // declared propertyDefs
+            PropertyDefinition[] pd = nt.getPropertyDefinitions();
+            for (int i = 0; i < pd.length; i++) {
+                if (pd[i].getDeclaringNodeType().getName().equals(nt.getName())) {
                     ntDef.appendChild(PropertyDefinitionImpl.create(pd[i]).toXml(document));
-		    }
-		}
-
-                String primaryItemName = nt.getPrimaryItemName();
-                if (primaryItemName != null) {
-                    ntDef.setAttribute(PRIMARYITEMNAME_ATTRIBUTE, primaryItemName);
                 }
+            }
+
+            String primaryItemName = nt.getPrimaryItemName();
+            if (primaryItemName != null) {
+                ntDef.setAttribute(PRIMARYITEMNAME_ATTRIBUTE, primaryItemName);
+            }
             report.appendChild(ntDef);
         }
         return report;
@@ -184,12 +173,12 @@
 
         // check the simple types first...
         if (info.containsContentElement(XML_REPORT_ALLNODETYPES, NAMESPACE)) {
-                    ntIter = ntMgr.getAllNodeTypes();
+            ntIter = ntMgr.getAllNodeTypes();
         } else if (info.containsContentElement(XML_REPORT_MIXINNODETYPES, NAMESPACE)) {
-                    ntIter = ntMgr.getMixinNodeTypes();
+            ntIter = ntMgr.getMixinNodeTypes();
         } else if (info.containsContentElement(XML_REPORT_PRIMARYNODETYPES, NAMESPACE)) {
-                    ntIter = ntMgr.getPrimaryNodeTypes();
-                }
+            ntIter = ntMgr.getPrimaryNodeTypes();
+        }
         // None of the simple types. test if a report for individual nodetypes
         // was request. If not, the request body is not valid.
         if (ntIter == null) {

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java Mon Mar 13 05:07:02 2006
@@ -16,13 +16,12 @@
 package org.apache.jackrabbit.webdav.jcr.version.report;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.version.DeltaVResource;
 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.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.w3c.dom.Element;
@@ -50,7 +49,7 @@
  *
  * @see javax.jcr.Workspace#getNamespaceRegistry() 
  */
-public class RegisteredNamespacesReport implements Report, ItemResourceConstants {
+public class RegisteredNamespacesReport extends AbstractJcrReport implements ItemResourceConstants {
 
     private static Logger log = Logger.getLogger(RegisteredNamespacesReport.class);
 
@@ -81,24 +80,13 @@
     }
 
     /**
-     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo)
+     * @see Report#init(DavResource, ReportInfo)
      */
-    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
-        if (info == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ReportInfo must not be null.");
-        }
-        if (resource == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
-        }
-        if (!getType().isRequestedReportType(info)) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "registerednamespaces element expected.");
-        }
+    public void init(DavResource resource, ReportInfo info) throws DavException {
+        // delegate validation to abstract super class
+        super.init(resource, info);
         try {
-            DavSession session = resource.getSession();
-            if (session == null || session.getRepositorySession() == null) {
-                throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the registerednamespaces report.");
-            }
-            nsReg = session.getRepositorySession().getWorkspace().getNamespaceRegistry();
+            nsReg = getRepositorySession().getWorkspace().getNamespaceRegistry();
         } catch (RepositoryException e) {
             throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
         }
@@ -115,8 +103,8 @@
     public Element toXml(Document document)  {
         Element report = DomUtil.createElement(document, "registerednamespaces-report", NAMESPACE);
         try {
-	    String[] prefixes = nsReg.getPrefixes();
-	    for (int i = 0; i < prefixes.length; i++) {
+            String[] prefixes = nsReg.getPrefixes();
+            for (int i = 0; i < prefixes.length; i++) {
                 Element elem = DomUtil.addChildElement(report, XML_NAMESPACE, NAMESPACE);
                 DomUtil.addChildElement(elem, XML_PREFIX, NAMESPACE, prefixes[i]);
                 DomUtil.addChildElement(elem, XML_URI, NAMESPACE, nsReg.getURI(prefixes[i]));

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java Mon Mar 13 05:07:02 2006
@@ -16,13 +16,11 @@
 package org.apache.jackrabbit.webdav.jcr.version.report;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.version.DeltaVResource;
 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.DavException;
-import org.apache.jackrabbit.webdav.DavSession;
-import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.w3c.dom.Element;
@@ -49,7 +47,7 @@
  * @see javax.jcr.Repository#getDescriptorKeys()
  * @see javax.jcr.Repository#getDescriptor(String)
  */
-public class RepositoryDescriptorsReport implements Report, ItemResourceConstants {
+public class RepositoryDescriptorsReport extends AbstractJcrReport implements ItemResourceConstants {
 
     private static Logger log = Logger.getLogger(RepositoryDescriptorsReport.class);
 
@@ -58,8 +56,6 @@
      */
     public static final ReportType REPOSITORY_DESCRIPTORS_REPORT = ReportType.register("repositorydescriptors", ItemResourceConstants.NAMESPACE, RepositoryDescriptorsReport.class);
 
-    private Repository repository;
-
     /**
      * Returns {@link #REPOSITORY_DESCRIPTORS_REPORT} type.
      * @return {@link #REPOSITORY_DESCRIPTORS_REPORT}
@@ -80,20 +76,11 @@
     }
 
     /**
-     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo) 
+     * @see Report#init(DavResource, ReportInfo) 
      */
-    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
-        if (resource == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
-        }
-        if (!getType().isRequestedReportType(info)) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "repositorydescriptors element expected.");
-        }
-        DavSession session = resource.getSession();
-        if (session == null || session.getRepositorySession() == null) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the repositorydescriptors report.");
-        }
-        repository = session.getRepositorySession().getRepository();
+    public void init(DavResource resource, ReportInfo info) throws DavException {
+        // delegate validation to abstract super classe
+        super.init(resource, info);
     }
 
     /**
@@ -105,6 +92,7 @@
      * @param document
      */
     public Element toXml(Document document) {
+        Repository repository = getRepositorySession().getRepository();
         Element report = DomUtil.createElement(document, "repositorydescriptors-report", NAMESPACE);
         String[] keys = repository.getDescriptorKeys();
         for (int i = 0; i < keys.length; i++) {
@@ -114,5 +102,4 @@
         }
         return report;
     }
-
 }

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java Mon Mar 13 05:07:02 2006
@@ -39,6 +39,7 @@
 import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.io.OutputContext;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 import org.apache.jackrabbit.webdav.jcr.lock.JcrActiveLock;
 import org.apache.jackrabbit.webdav.lock.ActiveLock;
 import org.apache.jackrabbit.webdav.lock.LockDiscovery;
@@ -96,7 +97,7 @@
 
     private DavResourceFactory factory;
     private LockManager lockManager;
-    private DavSession session;
+    private JcrDavSession session;
     private Node node;
     private DavResourceLocator locator;
 
@@ -117,8 +118,9 @@
      * @param session
      */
     public DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory,
-                           DavSession session, ResourceConfig config) throws RepositoryException, DavException {
-        this.session = session;
+                           DavSession session, ResourceConfig config) throws DavException {
+        JcrDavSession.checkImplementation(session);
+        this.session = (JcrDavSession)session;
         this.factory = factory;
         this.locator = locator;
         this.filter = config.getItemFilter();
@@ -126,7 +128,7 @@
 
         if (locator != null && locator.getResourcePath() != null) {
             try {
-                Item item = session.getRepositorySession().getItem(locator.getJcrPath());
+                Item item = getJcrSession().getItem(locator.getRepositoryPath());
                 if (item != null && item.isNode()) {
                     node = (Node) item;
                     // define what is a collection in webdav
@@ -134,6 +136,9 @@
                 }
             } catch (PathNotFoundException e) {
                 // ignore: exists field evaluates to false
+            } catch (RepositoryException e) {
+                // some other error
+                throw new JcrDavException(e);
             }
         } else {
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
@@ -522,7 +527,7 @@
             throw new DavException(DavServletResponse.SC_FORBIDDEN);
         }
         try {
-            String memberName = Text.getName(member.getLocator().getJcrPath());
+            String memberName = Text.getName(member.getLocator().getRepositoryPath());
             ImportContext ctx = getImportContext(inputContext, memberName);
             if (!ioManager.importContent(ctx, member)) {
                 // any changes should have been reverted in the importer
@@ -556,23 +561,25 @@
             throw new DavException(DavServletResponse.SC_FORBIDDEN);
         }
 
+
         try {
-            // make sure, non-jcr locks are removed.
-            if (!isJsrLockable()) {
-                ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE);
-                if (lock != null) {
-                    lockManager.releaseLock(lock.getToken(), member);
+            String itemPath = member.getLocator().getRepositoryPath();
+            Item memItem = getJcrSession().getItem(itemPath);
+            memItem.remove();
+            getJcrSession().save();
+
+            // make sure, non-jcr locks are removed, once the removal is completed
+            try {
+                if (!isJsrLockable()) {
+                    ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE);
+                    if (lock != null) {
+                        lockManager.releaseLock(lock.getToken(), member);
+                    }
                 }
+            } catch (DavException e) {
+                // since check for 'locked' exception has been performed before
+                // ignore any error here
             }
-            ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE);
-            if (lock != null && lockManager.hasLock(lock.getToken(), member)) {
-                lockManager.releaseLock(lock.getToken(), member);
-            }
-
-            String itemPath = member.getLocator().getJcrPath();
-            Item memItem = session.getRepositorySession().getItem(itemPath);
-            memItem.remove();
-            session.getRepositorySession().save();
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
@@ -592,8 +599,8 @@
             throw new DavException(DavServletResponse.SC_FORBIDDEN);
         }
         try {
-            String destItemPath = destination.getLocator().getJcrPath();
-            session.getRepositorySession().getWorkspace().move(locator.getJcrPath(), destItemPath);
+            String destItemPath = destination.getLocator().getRepositoryPath();
+            getJcrSession().getWorkspace().move(locator.getRepositoryPath(), destItemPath);
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
@@ -617,8 +624,8 @@
             throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow copy.");
         }
         try {
-            String destItemPath = destination.getLocator().getJcrPath();
-            session.getRepositorySession().getWorkspace().copy(locator.getJcrPath(), destItemPath);
+            String destItemPath = destination.getLocator().getRepositoryPath();
+            getJcrSession().getWorkspace().copy(locator.getRepositoryPath(), destItemPath);
         } catch (PathNotFoundException e) {
             // according to rfc 2518: missing parent
             throw new DavException(DavServletResponse.SC_CONFLICT, e.getMessage());
@@ -770,6 +777,13 @@
     }
 
     /**
+     * @see org.apache.jackrabbit.webdav.DavResource#getSession()
+     */
+    public DavSession getSession() {
+        return session;
+    }
+
+    /**
      * Returns the node that is wrapped by this resource.
      *
      * @return
@@ -887,7 +901,7 @@
         String pName = ISO9075.decode(propName.getName());
         String uri = propName.getNamespace().getURI();
         if (uri != null && !"".equals(uri)) {
-            Session s = session.getRepositorySession();
+            Session s = getJcrSession();
             String prefix;
             try {
                 // lookup 'prefix' in the session-ns-mappings / namespace-registry
@@ -934,9 +948,13 @@
         // removal of non existing property succeeds
     }
 
+    private Session getJcrSession() {
+        return session.getRepositorySession();
+    }
+
     private boolean isFilteredResource(DavResource resource) {
         // TODO: filtered nodetypes should be checked as well in order to prevent problems.
-        return filter != null && filter.isFilteredItem(resource.getDisplayName(), session.getRepositorySession());
+        return filter != null && filter.isFilteredItem(resource.getDisplayName(), getJcrSession());
     }
 
     private boolean isFilteredItem(Item item) {

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java Mon Mar 13 05:07:02 2006
@@ -16,6 +16,7 @@
 package org.apache.jackrabbit.webdav.simple;
 
 import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 
 import javax.jcr.Session;
 import java.util.HashSet;
@@ -24,10 +25,7 @@
  * Simple implementation of the {@link DavSession} interface. Stores
  * lock tokens but does not yet store references.
  */
-public class DavSessionImpl implements DavSession {
-
-    /** the underlying jcr session */
-    private final Session session;
+public class DavSessionImpl extends JcrDavSession {
 
     /** the lock tokens of this session */
     private final HashSet lockTokens = new HashSet();
@@ -37,7 +35,7 @@
      * @param session
      */
     public DavSessionImpl(Session session) {
-        this.session = session;
+        super(session);
     }
 
     /**
@@ -55,18 +53,11 @@
     }
 
     /**
-     * @see DavSession#getRepositorySession()
-     */
-    public Session getRepositorySession() {
-        return session;
-    }
-
-    /**
      * @see DavSession#addLockToken(String)
      */
     public void addLockToken(String token) {
+        super.addLockToken(token);
         lockTokens.add(token);
-        session.addLockToken(token);
     }
 
     /**
@@ -80,7 +71,7 @@
      * @see DavSession#removeLockToken(String)
      */
     public void removeLockToken(String token) {
+        super.removeLockToken(token);
         lockTokens.remove(token);
-        session.removeLockToken(token);
     }
 }

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java Mon Mar 13 05:07:02 2006
@@ -112,8 +112,8 @@
      */
     public void releaseSession(WebdavRequest request) {
         DavSession ds = request.getDavSession();
-        if (ds != null) {
-            Session repSession = ds.getRepositorySession();
+        if (ds != null && ds instanceof DavSessionImpl) {
+            Session repSession = ((DavSessionImpl)ds).getRepositorySession();
             String[] lockTokens = repSession.getLockTokens();
             for (int i = 0; i < lockTokens.length; i++) {
                 repSession.removeLockToken(lockTokens[i]);

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java Mon Mar 13 05:07:02 2006
@@ -118,9 +118,9 @@
         /**
          * Returns the same as {@link #getResourcePath()}. No encoding is performed
          * at all.
-         * @see DavResourceLocator#getJcrPath()
+         * @see DavResourceLocator#getRepositoryPath()
          */
-        public String getJcrPath() {
+        public String getRepositoryPath() {
             return getResourcePath();
         }
 

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java Mon Mar 13 05:07:02 2006
@@ -92,12 +92,8 @@
      * @see DavResourceFactory#createResource(DavResourceLocator, DavSession)
      */
     public DavResource createResource(DavResourceLocator locator, DavSession session) throws DavException {
-        try {
-            DavResourceImpl res = new DavResourceImpl(locator, this, session, resourceConfig);
-            res.addLockManager(lockMgr);
-            return res;
-        } catch (RepositoryException e) {
-            throw new JcrDavException(e);
-        }
+        DavResourceImpl res = new DavResourceImpl(locator, this, session, resourceConfig);
+        res.addLockManager(lockMgr);
+        return res;
     }
 }

Modified: incubator/jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/JCRWebdavServerServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/JCRWebdavServerServlet.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/JCRWebdavServerServlet.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/JCRWebdavServerServlet.java Mon Mar 13 05:07:02 2006
@@ -18,6 +18,7 @@
 import org.apache.jackrabbit.server.AbstractWebdavServlet;
 import org.apache.jackrabbit.server.BasicCredentialsProvider;
 import org.apache.jackrabbit.server.SessionProviderImpl;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 import org.apache.jackrabbit.server.jcr.JCRWebdavServer;
 import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.DavLocatorFactory;
@@ -25,6 +26,7 @@
 import org.apache.jackrabbit.webdav.DavResourceFactory;
 import org.apache.jackrabbit.webdav.DavSessionProvider;
 import org.apache.jackrabbit.webdav.WebdavRequest;
+import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.jcr.DavLocatorFactoryImpl;
 import org.apache.jackrabbit.webdav.jcr.DavResourceFactoryImpl;
 import org.apache.jackrabbit.webdav.jcr.observation.SubscriptionManagerImpl;
@@ -33,6 +35,7 @@
 import org.apache.log4j.Logger;
 
 import javax.jcr.Repository;
+import javax.jcr.Session;
 import javax.servlet.ServletException;
 import javax.servlet.ServletContext;
 
@@ -93,7 +96,7 @@
     public void init() throws ServletException {
         super.init();
 
-	// set resource path prefix
+        // set resource path prefix
         pathPrefix = getInitParameter(INIT_PARAM_RESOURCE_PATH_PREFIX);
         getServletContext().setAttribute(CTX_ATTR_RESOURCE_PATH_PREFIX, pathPrefix);
         log.debug(INIT_PARAM_RESOURCE_PATH_PREFIX + " = " + pathPrefix);
@@ -130,11 +133,18 @@
 
         // test if the requested path matches to the existing session
         // this may occur if the session was retrieved from the cache.
-        String wsName = request.getDavSession().getRepositorySession().getWorkspace().getName();
-        if (!resource.getLocator().isSameWorkspace(wsName)) {
+        try {
+            Session repositorySesssion = JcrDavSession.getRepositorySession(request.getDavSession());
+            String wsName = repositorySesssion.getWorkspace().getName();
+            if (!resource.getLocator().isSameWorkspace(wsName)) {
+                return false;
+            }
+        } catch (DavException e) {
+            log.error(e);
             return false;
         }
 
+
         // make sure, the TransactionId header is valid
         String txId = request.getTransactionId();
         return txId == null || txMgr.hasLock(txId, resource);
@@ -188,7 +198,7 @@
     }
 
     /**
-     * Returns the <code>DavResourceFactory</code>. 
+     * Returns the <code>DavResourceFactory</code>.
      *
      * @see AbstractWebdavServlet#getResourceFactory()
      */

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/project.properties?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/project.properties (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/project.properties Mon Mar 13 05:07:02 2006
@@ -1,2 +1,2 @@
-maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/,http://www.day.com/maven/jsr170/javadocs/jcr-0.16.1-pfd/
+maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/
 maven.repo.remote = http://www.ibiblio.org/maven/,http://www.day.com/maven/

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/project.xml?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/project.xml (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/project.xml Mon Mar 13 05:07:02 2006
@@ -32,12 +32,6 @@
             <artifactId>jackrabbit-commons</artifactId>
             <version>${jackrabbit.build.version.jackrabbit}</version>
         </dependency>
-        <dependency>
-            <groupId>jsr170</groupId>
-            <artifactId>jcr</artifactId>
-            <version>${jackrabbit.build.version.jcr}</version>
-        </dependency>
-        
         <!-- non-jackrabbit dependencies -->
         <dependency>
             <groupId>log4j</groupId>

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavException.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavException.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavException.java Mon Mar 13 05:07:02 2006
@@ -17,6 +17,7 @@
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.w3c.dom.Element;
 import org.w3c.dom.Document;
 
@@ -44,6 +45,7 @@
     public static final String XML_ERROR = "error";
 
     private int errorCode = DavServletResponse.SC_INTERNAL_SERVER_ERROR;
+    private Element errorCondition;
 
     /**
      * Create a new <code>DavException</code>.
@@ -51,11 +53,22 @@
      * @param errorCode integer specifying any of the status codes defined by
      * {@link DavServletResponse}.
      * @param message Human readable error message.
+     * @see DavException#DavException(int, String, Throwable, Element)
      */
     public DavException(int errorCode, String message) {
-        super(message);
-        this.errorCode = errorCode;
-        log.debug("DavException: (" + errorCode + ") " + message);
+        this(errorCode, message, null, null);
+    }
+
+    /**
+     * Create a new <code>DavException</code>.
+     *
+     * @param errorCode integer specifying any of the status codes defined by
+     * {@link DavServletResponse}.
+     * @param cause Cause of this DavException
+     * @see DavException#DavException(int, String, Throwable, Element)
+     */
+    public DavException(int errorCode, Throwable cause) {
+        this(errorCode, null, cause, null);
     }
 
     /**
@@ -63,9 +76,27 @@
      *
      * @param errorCode integer specifying any of the status codes defined by
      * {@link DavServletResponse}.
+     * @see DavException#DavException(int, String, Throwable, Element)
      */
     public DavException(int errorCode) {
-        this(errorCode, statusPhrases.getProperty(String.valueOf(errorCode)));
+        this(errorCode, statusPhrases.getProperty(String.valueOf(errorCode)), null, null);
+    }
+
+    /**
+     * Create a new <code>DavException</code>.
+     *
+     * @param errorCode integer specifying any of the status codes defined by
+     * {@link DavServletResponse}.
+     * @param message Human readable error message.
+     * @param cause Cause of this <code>DavException</code>.
+     * @param errorCondition Xml element providing detailled information about
+     * the error. If the condition is not <code>null</code>, {@link #toXml(Document)}
+     */
+    public DavException(int errorCode, String message, Throwable cause, Element errorCondition) {
+        super(message, cause);
+        this.errorCode = errorCode;
+        this.errorCondition = errorCondition;
+        log.debug("DavException: (" + errorCode + ") " + message);
     }
 
     /**
@@ -99,21 +130,30 @@
     }
 
     /**
-     * @return Always false
+     * @return true if a error condition has been specified, false otherwise.
      */
     public boolean hasErrorCondition() {
-        return false;
+        return errorCondition != null;
     }
 
     /**
-     * Returns <code>null</code>
+     * Returns a DAV:error element containing the error condition or
+     * <code>null</code> if no specific condition is available. See
+     * <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a>
+     * Section 1.6 "Method Preconditions and Postconditions" for additional
+     * information.
      *
      * @param document
-     * @return <code>null</code>
+     * @return A DAV:error element indicating the error cause or <code>null</code>.
      * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
      */
     public Element toXml(Document document) {
-        return null;
+        if (hasErrorCondition()) {
+            Element error = DomUtil.createElement(document, XML_ERROR, DavConstants.NAMESPACE);
+            error.appendChild(document.importNode(errorCondition, true));
+            return error;
+        } else {
+            return null;
+        }
     }
-
 }

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavLocatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavLocatorFactory.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavLocatorFactory.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavLocatorFactory.java Mon Mar 13 05:07:02 2006
@@ -55,13 +55,14 @@
      * @param path
      * @param isResourcePath If true this method returns the same as
      * {@link DavLocatorFactory#createResourceLocator(String, String, String)},
-     * otherwise the given path is treated as {@link javax.jcr.Item#getPath JCR path}.
-     * The implementation may choose to modify the given item path if it contains
-     * escaped characters due to incompatibility of the JCR path with the URI
-     * definition. I.e. it would undo the modification that was applied when
-     * calling {@link DavResourceLocator#getJcrPath()}.
+     * otherwise the given path is treated as internal repository path.
+     * The implementation may choose to implement a conversion of the repository
+     * path to a valid resource path, e.g. (un)escaping of certain characters, due
+     * to incompatibility with the URI definition (or vice versa). Note that
+     * {@link DavResourceLocator#getRepositoryPath()} should in this case implement
+     * the reverse operation.
      * @return
-     * @see DavResourceLocator#getJcrPath()
+     * @see DavResourceLocator#getRepositoryPath()
      */
     public DavResourceLocator createResourceLocator(String prefix, String workspacePath, String path, boolean isResourcePath);
 }

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java Mon Mar 13 05:07:02 2006
@@ -323,5 +323,12 @@
      * @return the factory that created this resource.
      */
     public DavResourceFactory getFactory();
+
+    /**
+     * Retrieve the <code>DavSession</code> associated with this resource.
+     *
+     * @return session object associated with this resource.
+     */
+    public DavSession getSession();
 }
 

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResourceLocator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResourceLocator.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResourceLocator.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResourceLocator.java Mon Mar 13 05:07:02 2006
@@ -100,14 +100,15 @@
     public DavLocatorFactory getFactory();
 
     /**
-     * An implementation may choose to circumvent the incompatibility of the
-     * JCR path with the URI path by applying an appropriate escaping. This
-     * utility method allows to retrieve the jcr path that corresponds to
-     * the resource path as returned by {#link getResourcePath()}.
+     * An implementation may choose to circumvent the incompatibility of a
+     * repository path with the URI path by applying an appropriate conversion.
+     * This utility method allows to retrieve this transformed repository path.
+     * By default this method should return the same as {@link #getResourcePath()}
      *
-     * @return a jcr compatible form if the resource path.
+     * @return a repository compatible form if the resource path.
      * @see DavLocatorFactory#createResourceLocator(String, String, String, boolean)
-     * that allows to build a valid <code>DavResourceLocator</code> from a jcr path.
+     * that allows to build a valid <code>DavResourceLocator</code> from a given
+     * repository path.
      */
-    public String getJcrPath();
+    public String getRepositoryPath();
 }

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSession.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSession.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSession.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSession.java Mon Mar 13 05:07:02 2006
@@ -15,20 +15,15 @@
  */
 package org.apache.jackrabbit.webdav;
 
-import javax.jcr.Session;
-
 /**
- * <code>DavSession</code> wraps a {@link Session repository session}
- * object, that is obtained on
- * {@link javax.jcr.Repository#login(javax.jcr.Credentials, String) login} to
- * the underlying repository.
+ * <code>DavSession</code> allows to pass session information between request,
+ * response and resource(s).
  */
 public interface DavSession {
 
     /**
-     * Adds a reference to this <code>DavSession</code> indicating that
-     * the underlying {@link Session} object is needed for actions spanning over
-     * multiple requests.
+     * Adds a reference to this <code>DavSession</code> indicating that this
+     * session must not be discarded after completion of the current request.
      *
      * @param reference to be added.
      */
@@ -36,18 +31,11 @@
 
     /**
      * Releasing a reference to this <code>DavSession</code>. If no more
-     * references are present, the underlying {@link Session} may be discarded.
+     * references are present, this session may be discarded.
      *
      * @param reference to be removed.
      */
     public void removeReference(Object reference);
-
-    /**
-     * Unwrap the {@link Session repository session} object.
-     *
-     * @return the session object wrapped by this <code>DavSession</code>
-     */
-    public Session getRepositorySession();
 
     /**
      * Adds a lock token to this <code>DavSession</code>.

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java Mon Mar 13 05:07:02 2006
@@ -75,7 +75,12 @@
 
     private static Logger log = Logger.getLogger(WebdavRequestImpl.class);
     private static final DocumentBuilderFactory BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
-
+    static {
+        BUILDER_FACTORY.setNamespaceAware(true);
+        BUILDER_FACTORY.setIgnoringComments(true);
+        BUILDER_FACTORY.setIgnoringElementContentWhitespace(true);
+        BUILDER_FACTORY.setCoalescing(true);
+    }
     private final HttpServletRequest httpRequest;
     private final DavLocatorFactory factory;
     private final IfHeader ifHeader;
@@ -114,7 +119,7 @@
     public void setDavSession(DavSession session) {
         this.session = session;
         // set lock-tokens from header to the current session
-        if (session != null && session.getRepositorySession() != null) {
+        if (session != null) {
             String lt = getLockToken();
             if (lt != null) {
                 session.addLockToken(lt);
@@ -247,21 +252,20 @@
         if (httpRequest.getContentLength() == 0) {
             return requestDocument;
         }
-            // try to parse the request body
-            try {
-                InputStream in = httpRequest.getInputStream();
-                if (in != null) {
-                BUILDER_FACTORY.setNamespaceAware(true);
+        // try to parse the request body
+        try {
+            InputStream in = httpRequest.getInputStream();
+            if (in != null) {
                 DocumentBuilder docBuilder = BUILDER_FACTORY.newDocumentBuilder();
                 requestDocument = docBuilder.parse(in);
-                }
-            } catch (IOException e) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Unable to build an XML Document from the request body: " + e.getMessage());
-                }
+            }
+        } catch (IOException e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Unable to build an XML Document from the request body: " + e.getMessage());
+            }
         } catch (ParserConfigurationException e) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Unable to build an XML Document from the request body: " + e.getMessage());
+            if (log.isDebugEnabled()) {
+                log.debug("Unable to build an XML Document from the request body: " + e.getMessage());
             }
         } catch (SAXException e) {
             log.debug("Unable to build an XML Document from the request body: " + e.getMessage());
@@ -388,7 +392,7 @@
         }
 
         ElementIterator it = DomUtil.getChildren(root, XML_SET, NAMESPACE);
-                while (it.hasNext()) {
+        while (it.hasNext()) {
             Element propEl = DomUtil.getChildElement(it.nextElement(), XML_PROP, NAMESPACE);
             if (propEl != null) {
                 ElementIterator properties = DomUtil.getChildren(propEl);
@@ -400,7 +404,7 @@
 
         // get <remove> properties
         it = DomUtil.getChildren(root, XML_REMOVE, NAMESPACE);
-                while (it.hasNext()) {
+        while (it.hasNext()) {
             Element propEl = DomUtil.getChildElement(it.nextElement(), XML_PROP, NAMESPACE);
             if (propEl != null) {
                 ElementIterator names = DomUtil.getChildren(propEl);
@@ -514,7 +518,7 @@
      * @param eTag
      * @return true, if its a strong etag
      */
-    private boolean isStrongETag(String eTag) {
+    private static boolean isStrongETag(String eTag) {
         return eTag != null && eTag.length() > 0 && !eTag.startsWith("W\\");
     }
 
@@ -532,7 +536,7 @@
     public TransactionInfo getTransactionInfo() throws DavException {
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
-                return new TransactionInfo(requestDocument.getDocumentElement());
+            return new TransactionInfo(requestDocument.getDocumentElement());
         }
         return null;
     }
@@ -597,7 +601,7 @@
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
             Element root = requestDocument.getDocumentElement();
-                op = OrderPatch.createFromXml(root);
+            op = OrderPatch.createFromXml(root);
         } else {
             log.error("Error while building xml document from ORDERPATH request body.");
         }
@@ -625,7 +629,7 @@
         if (requestDocument != null) {
             Element root = requestDocument.getDocumentElement();
             int depth = getDepth(DEPTH_0);
-                lInfo = new LabelInfo(root, depth);
+            lInfo = new LabelInfo(root, depth);
         }
         return lInfo;
     }
@@ -637,7 +641,7 @@
         MergeInfo mInfo = null;
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
-                mInfo = new MergeInfo(requestDocument.getDocumentElement());
+            mInfo = new MergeInfo(requestDocument.getDocumentElement());
         }
         return mInfo;
     }
@@ -649,7 +653,7 @@
         UpdateInfo uInfo = null;
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
-                uInfo = new UpdateInfo(requestDocument.getDocumentElement());
+            uInfo = new UpdateInfo(requestDocument.getDocumentElement());
         }
         return uInfo;
     }

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java Mon Mar 13 05:07:02 2006
@@ -31,11 +31,13 @@
      */
     public static final Namespace NAMESPACE = Namespace.getNamespace("dcr", "http://www.day.com/jcr/webdav/1.0");
 
+    //---< Headers >------------------------------------------------------------
     /**
      * The SubscriptionId request header<br>
      */
     public static final String HEADER_SUBSCRIPTIONID = "SubscriptionId";
 
+    //---< XML Element, Attribute Names >---------------------------------------
     /**
      * subscription Xml element<br>
      * Mandatory element inside the {@link #SUBSCRIPTIONDISCOVERY subscriptiondiscovery}
@@ -61,36 +63,7 @@
     public static final String XML_EVENT = "event";
     public static final String XML_EVENTUSERID = "eventuserid";
 
-    /**
-     * Element representing the 'nodeadded' event type.
-     * @see javax.jcr.observation.Event#NODE_ADDED
-     */
-    public static final String EVENT_NODEADDED = "nodeadded";
-
-    /**
-     * Element representing the 'noderemoved' event type.
-     * @see javax.jcr.observation.Event#NODE_REMOVED
-     */
-    public static final String EVENT_NODEREMOVED = "noderemoved";
-
-    /**
-     * Element representing the 'propertyadded' event type.
-     * @see javax.jcr.observation.Event#PROPERTY_ADDED
-     */
-    public static final String EVENT_PROPERTYADDED = "propertyadded";
-
-    /**
-     * Element representing the 'propertyremoved' event type.
-     * @see javax.jcr.observation.Event#PROPERTY_REMOVED
-     */
-    public static final String EVENT_PROPERTYREMOVED = "propertyremoved";
-
-    /**
-     * Element representing the 'propertychanged' event type.
-     * @see javax.jcr.observation.Event#PROPERTY_CHANGED
-     */
-    public static final String EVENT_PROPERTYCHANGED = "propertychanged";
-
+    //---< Property Names >-----------------------------------------------------
     /**
      * The protected subscription discovery property is used to find out about
      * existing subscriptions present on the specified resource.

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java Mon Mar 13 05:07:02 2006
@@ -17,7 +17,6 @@
 
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
-import org.apache.jackrabbit.webdav.DavSession;
 
 /**
  * <code>ObservationResource</code> extends the {@link DavResource} interface by
@@ -34,13 +33,6 @@
      * @param subsMgr subscription manager object
      */
     public void init(SubscriptionManager subsMgr);
-
-    /**
-     * Retrieve the <code>DavSession</code> associated with this resource.
-     *
-     * @return session object associated with this resource.
-     */
-    public DavSession getSession();
 
     /**
      * Subscribe this resource for event listening defined by the specified

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionConstants.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionConstants.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionConstants.java Mon Mar 13 05:07:02 2006
@@ -19,7 +19,6 @@
 import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.jackrabbit.webdav.lock.Type;
 import org.apache.jackrabbit.webdav.lock.Scope;
-import org.apache.jackrabbit.webdav.property.DavPropertyName;
 
 /**
  * <code>TransactionConstants</code> interface provide constants for request
@@ -35,11 +34,13 @@
      */
     public static final Namespace NAMESPACE = Namespace.getNamespace("dcr", "http://www.day.com/jcr/webdav/1.0");
 
+    //---< Headers >------------------------------------------------------------
     /**
      * TransactionId Header
      */
     public static final String HEADER_TRANSACTIONID = "TransactionId";
 
+    //---< XML Element, Attribute Names >---------------------------------------
     /**
      * transaction XML element<br>
      * Used as element inside the {@link DavConstants#XML_LOCKTYPE locktype}
@@ -51,7 +52,6 @@
     /**
      * global XML element<br>
      * Used as element inside of the {@link DavConstants#XML_LOCKSCOPE lockscope} element.
-     * It indicates the transaction to be global (e.g. a JCR transaction).
      *
      * @see DavConstants#XML_LOCKSCOPE
      */
@@ -98,24 +98,7 @@
      */
     public static final String XML_ROLLBACK = "rollback";
 
-    /**
-     * String defining the 'isnew' property, that identifies a {@link TransactionResource}
-     * to be new within the given local transaction, meaning that it exists only in
-     * transient storage. This property is not defined by any of the Webdav RTFs.
-     * @see javax.jcr.Item#isNew()
-     * @see #XML_LOCAL
-     */
-    public static final DavPropertyName ISNEW = DavPropertyName.create("isnew", NAMESPACE);
-
-    /**
-     * String defining the 'ismodified' property, that is present on any {@link TransactionResource}
-     * that has been modified whithout the corresponding local transaction
-     * being completed yet. This property is not defined by any of the Webdav RTFs.
-     * @see javax.jcr.Item#isModified()
-     * @see #XML_LOCAL
-     */
-    public static final DavPropertyName ISMODIFIED = DavPropertyName.create("ismodified", NAMESPACE);
-
+    //---< Lock Type, Lock Scope >----------------------------------------------
     /**
      * "transaction" lock type constant.
      * @see #XML_TRANSACTION

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionResource.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionResource.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionResource.java Mon Mar 13 05:07:02 2006
@@ -17,7 +17,6 @@
 
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
-import org.apache.jackrabbit.webdav.DavSession;
 
 /**
  * <code>TransactionResource</code> extends the {@link DavResource} interface by
@@ -35,13 +34,6 @@
      * @param transactionId
      */
     public void init(TxLockManager txMgr, String transactionId);
-
-    /**
-     * Retrieve the <code>DavSession</code> associated with this resource.
-     *
-     * @return session object associated with this resource.
-     */
-    public DavSession getSession();
 
     /**
      * The TransactionId or <code>null</code> according to the value of the

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVResource.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVResource.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVResource.java Mon Mar 13 05:07:02 2006
@@ -17,7 +17,6 @@
 
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 import org.apache.jackrabbit.webdav.version.report.Report;
@@ -52,10 +51,17 @@
     /**
      * The generic deltaV complient resource defines one additional method REPORT.
      *
-     * @see DeltaVResource#METHODS
      * @see org.apache.jackrabbit.webdav.DavResource#METHODS
      */
-    public String METHODS = "REPORT, MKWORKSPACE";
+    public String METHODS = "REPORT";
+
+    /**
+     * If the server support the Workspace featured defined by RFC 3253 certain
+     * <code>DeltaVResource</code>s may also support the MKWORKSPACE method.
+     *
+     * @see #addWorkspace(DavResource)
+     */
+    public String METHODS_INCL_MKWORKSPACE = "REPORT, MKWORKSPACE";
 
     /**
      * Retrieves the information requested in the OPTIONS request body and
@@ -84,8 +90,8 @@
      * @param workspace resource representing the new workspace to be created as
      * member of this resource.
      * @throws DavException if creating the new workspace fails.
-     * @todo MKWORKSPACE may include an xml request body...
      */
+    // TODO: MKWORKSPACE may include an xml request body...
     public void addWorkspace(DavResource workspace) throws DavException;
 
     /**
@@ -103,11 +109,4 @@
      * @see org.apache.jackrabbit.webdav.property.HrefProperty
      */
     public DavResource[] getReferenceResources(DavPropertyName hrefPropertyName) throws DavException;
-
-    /**
-     * Retrieve the <code>DavSession</code> associated with this resource.
-     *
-     * @return session object associated with this resource.
-     */
-    public DavSession getSession();
 }

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ExpandPropertyReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ExpandPropertyReport.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ExpandPropertyReport.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ExpandPropertyReport.java Mon Mar 13 05:07:02 2006
@@ -63,7 +63,7 @@
 
     private static Logger log = Logger.getLogger(ExpandPropertyReport.class);
 
-    private DeltaVResource resource;
+    private DavResource resource;
     private ReportInfo info;
     private Iterator propertyElements;
 
@@ -88,9 +88,9 @@
     }
 
     /**
-     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, ReportInfo)
+     * @see Report#init(DavResource, ReportInfo)
      */
-    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
+    public void init(DavResource resource, ReportInfo info) throws DavException {
         setResource(resource);
         setInfo(info);
     }
@@ -101,7 +101,7 @@
      * @param resource
      * @throws DavException if the specified resource is <code>null</code>
      */
-    private void setResource(DeltaVResource resource) throws DavException {
+    private void setResource(DavResource resource) throws DavException {
         if (resource == null) {
             throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource specified must not be null.");
         }
@@ -116,6 +116,9 @@
      * does not contain a DAV:expand-property element.
      */
     private void setInfo(ReportInfo info) throws DavException {
+        if (info == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The report info specified must not be null.");
+        }
         if (!getType().isRequestedReportType(info)) {
             throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:expand-property element expected.");
         }
@@ -143,10 +146,6 @@
      * @throws NullPointerException if info and resource have not been set.
      */
     private MultiStatus getMultiStatus() {
-        if (info == null || resource == null) {
-            throw new NullPointerException("Error while running DAV:version-tree report");
-        }
-
         MultiStatus ms = new MultiStatus();
         addResponses(resource, info.getDepth(), ms);
         return ms;



Mime
View raw message