jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r293331 [2/3] - in /incubator/jackrabbit/trunk/contrib/jcr-server: server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/io/ server/src/java/org/apache/jackrabbit/util/ server/src/java/org/apache/jackrab...
Date Mon, 03 Oct 2005 13:13:32 GMT
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=293331&r1=293330&r2=293331&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 Mon Oct  3 06:12:18 2005
@@ -80,6 +80,112 @@
         return sb.toString();
     }
 
+    /**
+     *
+     * @param setProperties
+     * @param removePropertyNames
+     * @throws DavException
+     * @see DefaultItemCollection#alterProperties(org.apache.jackrabbit.webdav.property.DavPropertySet, org.apache.jackrabbit.webdav.property.DavPropertyNameSet)
+     * for additional description of non-compliant behaviour.
+     */
+    public MultiStatusResponse alterProperties(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames) throws DavException {
+        /* first resolve merge conflict since they cannot be handled by
+           setting property values in jcr (and are persisted immediately).
+           NOTE: this violates RFC 2518 that requires that proppatch
+           is processed in the order entries are present in the xml and that
+           required that no changes must be persisted if any set/remove fails.
+        */
+        // TODO: solve violation of RFC 2518
+        resolveMergeConflict(setProperties, removePropertyNames);
+        // alter other properties only if merge-conflicts could be handled
+        return super.alterProperties(setProperties, removePropertyNames);
+    }
+
+    /**
+     * Resolve one or multiple merge conflicts present on this resource. Please
+     * note that the 'setProperties' or 'removeProperties' set my contain additional
+     * resource properties, that need to be changed. Those properties are left
+     * untouched, whereas the {@link #AUTO_MERGE_SET DAV:auto-merge-set}, is
+     * removed from the list upon successful resolution of a merge conflict.<br>
+     * If the removeProperties or setProperties set do not contain the mentioned
+     * merge conflict resource properties or if the value of those properties do
+     * not allow for a resolution of an existing merge conflict, this method
+     * returns silently.
+     *
+     * @param setProperties
+     * @param removePropertyNames
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see Node#doneMerge(Version)
+     * @see Node#cancelMerge(Version)
+     */
+    private void resolveMergeConflict(DavPropertySet setProperties,
+                                     DavPropertyNameSet removePropertyNames)
+        throws DavException {
+
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+
+        try {
+            Node n = (Node)item;
+            if (removePropertyNames.contains(AUTO_MERGE_SET)) {
+                // retrieve the current jcr:mergeFailed property values
+                if (!n.hasProperty(JcrConstants.JCR_MERGEFAILED)) {
+                    throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
+                }
+                Value[] mergeFailed = n.getProperty(JcrConstants.JCR_MERGEFAILED).getValues();
+
+                // resolve all remaining merge conflicts with 'cancel'
+                for (int i = 0; i < mergeFailed.length; i++) {
+                    n.cancelMerge((Version)getRepositorySession().getNodeByUUID(mergeFailed[i].getString()));
+                }
+                // adjust removeProperty set
+                removePropertyNames.remove(AUTO_MERGE_SET);
+
+            } else if (setProperties.contains(AUTO_MERGE_SET) && setProperties.contains(PREDECESSOR_SET)){
+                // retrieve the current jcr:mergeFailed property values
+                if (!n.hasProperty(JcrConstants.JCR_MERGEFAILED)) {
+                    throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
+                }
+                Value[] mergeFailed = n.getProperty(JcrConstants.JCR_MERGEFAILED).getValues();
+
+
+                // check which mergeFailed entries have been removed from the
+                // auto-merge-set (cancelMerge) and have been moved over to the
+                // predecessor set (doneMerge)
+                List mergeset = new HrefProperty(setProperties.get(AUTO_MERGE_SET)).getHrefs();
+                List predecSet = new HrefProperty(setProperties.get(PREDECESSOR_SET)).getHrefs();
+
+                Session session = getRepositorySession();
+                for (int i = 0; i < mergeFailed.length; i++) {
+                    // build version-href from each entry in the jcr:mergeFailed property
+                    Version version = (Version) session.getNodeByUUID(mergeFailed[i].getString());
+                    String href = getLocatorFromItem(version).getHref(true);
+
+                    // Test if that version has been removed from the merge-set.
+                    // thus indicating that the merge-conflict needs to be resolved.
+                    if (!mergeset.contains(href)) {
+                        // Test if the 'href' has been moved over to the
+                        // predecessor-set (thus 'doneMerge' is appropriate) or
+                        // if it is not present in the predecessor set and the
+                        // the conflict is resolved by 'cancelMerge'.
+                        if (predecSet.contains(href)) {
+                            n.doneMerge(version);
+                        } else {
+                            n.cancelMerge(version);
+                        }
+                    }
+                }
+                // adjust setProperty set
+                setProperties.remove(AUTO_MERGE_SET);
+                setProperties.remove(PREDECESSOR_SET);
+            }
+            /* else: no (valid) attempt to resolve merge conflict > return silently */
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
     //--------------------------------< VersionControlledResource interface >---
     /**
      * Adds version control to this resource. If the resource is already under
@@ -118,8 +224,7 @@
         }
         try {
             Version v = ((Node) item).checkin();
-            DavResourceLocator loc = getLocator();
-            String versionHref = loc.getFactory().createResourceLocator(loc.getPrefix(), loc.getWorkspacePath(), v.getPath()).getHref(true);
+            String versionHref = getLocatorFromItem(v).getHref(true);
             return versionHref;
         } catch (RepositoryException e) {
             // UnsupportedRepositoryException should not occur
@@ -177,8 +282,8 @@
      * @return
      * @throws org.apache.jackrabbit.webdav.DavException
      * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#update(org.apache.jackrabbit.webdav.version.UpdateInfo)
-     * @todo with jcr the node must not be versionable in order to perform Node.update.
      */
+    //TODO: with jcr the node must not be versionable in order to perform Node.update.
     public MultiStatus update(UpdateInfo updateInfo) throws DavException {
         if (updateInfo == null) {
             throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Valid update request body required.");
@@ -202,7 +307,8 @@
                 String[] hrefs = updateInfo.getVersionHref();
                 Version[] versions = new Version[hrefs.length];
                 for (int  i = 0; i < hrefs.length; i++) {
-                    versions[i] = vh.getVersion(getResourceName(hrefs[i], true));
+                    String itemPath = getLocatorFromHref(hrefs[i]).getJcrPath();
+                    versions[i] = vh.getVersion(getItemName(itemPath));
                 }
                 if (versions.length == 1) {
                     String relPath = updateInfo.getUpdateElement().getChildText(XML_RELPATH, NAMESPACE);
@@ -227,7 +333,7 @@
                     getRepositorySession().getWorkspace().restore(vs, removeExisting);
                 }
             } else if (updateInfo.getWorkspaceHref() != null) {
-                String workspaceName = getResourceName(updateInfo.getWorkspaceHref(), true);
+                String workspaceName = getLocatorFromHref(updateInfo.getWorkspaceHref()).getWorkspaceName();
                 node.update(workspaceName);
             } else {
                 throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Invalid update request body.");
@@ -247,13 +353,14 @@
      * information present in the given {@link MergeInfo} object.
      *
      * @param mergeInfo
-     * @return <code>MultiStatus</code> reccording all repository items affected
-     * by this merge call.
+     * @return <code>MultiStatus</code> recording all repository items modified
+     * by this merge call as well as the resources that a client must modify to
+     * complete the merge (see <a href="http://www.webdav.org/specs/rfc3253.html#METHOD_MERGE">RFC 3253</a>)
      * @throws org.apache.jackrabbit.webdav.DavException
      * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#merge(org.apache.jackrabbit.webdav.version.MergeInfo)
      * @see Node#merge(String, boolean)
      */
-    //todo with jcr the node must not be versionable in order to perform Node.merge
+    //TODO: with jcr the node must not be versionable in order to perform Node.merge
     public MultiStatus merge(MergeInfo mergeInfo) throws DavException {
         if (mergeInfo == null) {
             throw new DavException(DavServletResponse.SC_BAD_REQUEST);
@@ -266,16 +373,25 @@
         try {
             Node node = (Node)item;
 
-            // register eventListener in order to be able to report the modifications.
+            // register eventListener in order to be able to report all
+            // modified resources.
             EventListener el = new EListener(mergeInfo.getPropertyNameSet(), ms);
             registerEventListener(el, node.getPath());
 
-            String workspaceName = getResourceName(mergeInfo.getSourceHref(), true);
-            node.merge(workspaceName, !mergeInfo.isNoAutoMerge());
+            String workspaceName = getLocatorFromHref(mergeInfo.getSourceHref()).getWorkspaceName();
+            NodeIterator failed = node.merge(workspaceName, !mergeInfo.isNoAutoMerge());
 
             // unregister the event listener again
             unregisterEventListener(el);
 
+            // add resources to the multistatus, that failed to be merged
+            while (failed.hasNext()) {
+                Node failedNode = failed.nextNode();
+                DavResourceLocator loc = getLocatorFromItem(failedNode);
+                DavResource res = createResourceFromLocator(loc);
+                ms.addResponse(new MultiStatusResponse(res, mergeInfo.getPropertyNameSet()));
+            }
+
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
@@ -284,89 +400,6 @@
     }
 
     /**
-     * Resolve the merge conflicts according to the value of the {@link #AUTO_MERGE_SET DAV:auto-merge-set}
-     * property present in the specified <code>DavPropertySet</code>s.
-     *
-     * @param setProperties
-     * @param removePropertyNames
-     * @throws org.apache.jackrabbit.webdav.DavException
-     * @see VersionControlledResource#resolveMergeConflict(DavPropertySet, DavPropertyNameSet)
-     * @see Node#doneMerge(Version)
-     * @see Node#cancelMerge(Version)
-     */
-    public void resolveMergeConflict(DavPropertySet setProperties,
-                                     DavPropertyNameSet removePropertyNames) throws DavException {
-
-        if (!exists()) {
-            throw new DavException(DavServletResponse.SC_NOT_FOUND);
-        }
-        if (!isVersionControlled()) {
-            throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
-        }
-
-        try {
-            Node n = (Node)item;
-            if (removePropertyNames.contains(AUTO_MERGE_SET)) {
-                // retrieve the current jcr:mergeFailed property values
-                if (!((Node)item).hasProperty(JcrConstants.JCR_MERGEFAILED)) {
-                    throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
-                }
-                Value[] mergeFailed = ((Node)item).getProperty(JcrConstants.JCR_MERGEFAILED).getValues();
-
-                // resolve all remaining merge conflicts with 'cancel'
-                for (int i = 0; i < mergeFailed.length; i++) {
-                    n.cancelMerge((Version)getRepositorySession().getNodeByUUID(mergeFailed[i].getString()));
-                }
-                // adjust removeProperty set
-                removePropertyNames.remove(AUTO_MERGE_SET);
-
-            } else if (setProperties.contains(AUTO_MERGE_SET) && setProperties.contains(PREDECESSOR_SET)){
-                // retrieve the current jcr:mergeFailed property values
-                if (!((Node)item).hasProperty(JcrConstants.JCR_MERGEFAILED)) {
-                    throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
-                }
-                Value[] mergeFailed = ((Node)item).getProperty(JcrConstants.JCR_MERGEFAILED).getValues();
-
-
-                // check which mergeFailed entries have been removed from the
-                // auto-merge-set (cancelMerge) and have been moved over to the
-                // predecessor set (doneMerge)
-                List mergeset = new HrefProperty(setProperties.get(AUTO_MERGE_SET)).getHrefs();
-                List predecSet = new HrefProperty(setProperties.get(PREDECESSOR_SET)).getHrefs();
-
-                Session session = getRepositorySession();
-                for (int i = 0; i < mergeFailed.length; i++) {
-                    // build version-href from each entry in the jcr:mergeFailed property
-                    Version version = (Version) session.getNodeByUUID(mergeFailed[i].getString());
-                    String href = this.getLocatorFromItem(version).getHref(true);
-
-                    // Test if that version has been removed from the merge-set.
-                    // thus indicating that the merge-conflict needs to be resolved.
-                    if (!mergeset.contains(href)) {
-                        // Test if the 'href' has been moved over to the
-                        // predecessor-set (thus 'doneMerge' is appropriate) or
-                        // if it is not present in the predecessor set and the
-                        // the conflict is resolved by 'cancelMerge'.
-                        if (predecSet.contains(href)) {
-                            n.doneMerge(version);
-                        } else {
-                            n.cancelMerge(version);
-                        }
-                    }
-                }
-                // adjust setProperty set
-                setProperties.remove(AUTO_MERGE_SET);
-                setProperties.remove(PREDECESSOR_SET);
-            } else {
-                // setPropertySet and removePropertySet do not ask for resolving merge conflicts */
-                log.debug("setProperties and removeProperties sets do not request for merge conflict resolution.");
-            }
-        } catch (RepositoryException e) {
-            throw new JcrDavException(e);
-        }
-    }
-
-    /**
      * Modify the labels present with the versions of this resource.
      *
      * @param labelInfo
@@ -448,13 +481,13 @@
                 // workspace property already set in AbstractResource.initProperties()
                 try {
                     // DAV:version-history (computed)
-                    String vhHref = getLocatorFromResourcePath(n.getVersionHistory().getPath()).getHref(true);
+                    String vhHref = getLocatorFromItem(n.getVersionHistory()).getHref(true);
                     properties.add(new HrefProperty(VERSION_HISTORY, vhHref, true));
 
                     // DAV:auto-version property: there is no auto version, explicit CHECKOUT is required.
                     properties.add(new DefaultDavProperty(AUTO_VERSION, null, false));
 
-                    String baseVHref = getLocatorFromResourcePath(n.getBaseVersion().getPath()).getHref(true);
+                    String baseVHref = getLocatorFromItem(n.getBaseVersion()).getHref(true);
                     if (n.isCheckedOut()) {
                         // DAV:checked-out property (protected)
                         properties.add(new HrefProperty(CHECKED_OUT, baseVHref, true));
@@ -521,6 +554,18 @@
     }
 
     /**
+     * Build a new locator for the given href.
+     * 
+     * @param href
+     * @return
+     */
+    private DavResourceLocator getLocatorFromHref(String href) {
+        DavLocatorFactory f = getLocator().getFactory();
+        String prefix = getLocator().getPrefix();
+        return f.createResourceLocator(prefix, href);
+    }
+
+    /**
      * Register the specified event listener with the observation manager present
      * the repository session.
      *
@@ -567,8 +612,7 @@
             while (events.hasNext()) {
                 try {
                     Event e = events.nextEvent();
-                    String itemPath = e.getPath();
-                    DavResourceLocator loc = getLocatorFromResourcePath(itemPath);
+                    DavResourceLocator loc = getLocatorFromItemPath(e.getPath());
                     DavResource res = createResourceFromLocator(loc);
                     ms.addResponse(new MultiStatusResponse(res, propNameSet));
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java Mon Oct  3 06:12:18 2005
@@ -297,7 +297,7 @@
                 String eHref = "";
                 try {
                     boolean isCollection = (event.getType() == Event.NODE_ADDED || event.getType() == Event.NODE_REMOVED);
-                    eHref = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), event.getPath()).getHref(isCollection);
+                    eHref = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), event.getPath(), false).getHref(isCollection);
                 } catch (RepositoryException e) {
                     // should not occur....
                     log.error(e.getMessage());

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java Mon Oct  3 06:12:18 2005
@@ -98,8 +98,9 @@
             throws DavException {
         try {
             ObservationManager oMgr = session.getRepositorySession().getWorkspace().getObservationManager();
+            String itemPath = subscription.getLocator().getJcrPath();
             oMgr.addEventListener(subscription, subscription.getEventTypes(),
-                    subscription.getLocator().getResourcePath(), subscription.isDeep(),
+                    itemPath, subscription.isDeep(),
                     subscription.getUuidFilters(),
                     subscription.getNodetypeNameFilters(),
                     subscription.isNoLocal());
@@ -203,7 +204,7 @@
     private class SubscriptionMap {
 
         private HashMap subscriptions = new HashMap();
-        private HashMap paths = new HashMap();
+        private HashMap ids = new HashMap();
 
         private boolean contains(String subscriptionId) {
             return subscriptions.containsKey(subscriptionId);
@@ -217,11 +218,11 @@
             subscriptions.put(subscriptionId, subscription);
             DavResourceLocator key = subscription.getLocator();
             Set idSet;
-            if (paths.containsKey(key)) {
-                idSet = (Set) paths.get(key);
+            if (ids.containsKey(key)) {
+                idSet = (Set) ids.get(key);
             } else {
                 idSet = new HashSet();
-                paths.put(key, idSet);
+                ids.put(key, idSet);
             }
             if (!idSet.contains(subscriptionId)) {
                 idSet.add(subscriptionId);
@@ -230,11 +231,11 @@
 
         private void remove(String subscriptionId) {
             SubscriptionImpl sub = (SubscriptionImpl) subscriptions.remove(subscriptionId);
-            ((Set)paths.get(sub.getLocator())).remove(subscriptionId);
+            ((Set)ids.get(sub.getLocator())).remove(subscriptionId);
         }
 
         private Subscription[] getByPath(DavResourceLocator locator) {
-            Set idSet = (Set) paths.get(locator);
+            Set idSet = (Set) ids.get(locator);
             if (idSet != null && !idSet.isEmpty()) {
                 Iterator idIterator = idSet.iterator();
                 Subscription[] subsForResource = new Subscription[idSet.size()];

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=293331&r1=293330&r2=293331&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 Mon Oct  3 06:12:18 2005
@@ -35,7 +35,7 @@
      * @param lengths as retrieved from the JCR property
      */
     public LengthsProperty(long[] lengths) {
-	super(JCR_LENGTHS, false);
+	super(JCR_LENGTHS, true);
 
 	Element[] elems = new Element[lengths.length];
 	for (int i = 0; i < lengths.length; i++) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java Mon Oct  3 06:12:18 2005
@@ -102,11 +102,11 @@
 
         Node rootNode = session.getRepositorySession().getRootNode();
         QueryManager qMgr = session.getRepositorySession().getWorkspace().getQueryManager();
-        String resourcePath = locator.getResourcePath();
 
         // test if query is defined by requested repository node
-        if (!rootNode.getPath().equals(resourcePath)) {
-            String qNodeRelPath = resourcePath.substring(1);
+        String itemPath = locator.getJcrPath();
+        if (!rootNode.getPath().equals(itemPath)) {
+            String qNodeRelPath = itemPath.substring(1);
             if (rootNode.hasNode(qNodeRelPath)) {
                 Node qNode = rootNode.getNode(qNodeRelPath);
                 if (qNode.isNodeType(JcrConstants.NT_QUERY)) {
@@ -119,14 +119,14 @@
         if (sInfo != null) {
             q = qMgr.createQuery(sInfo.getQuery(), sInfo.getLanguageName());
         } else {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, resourcePath + " is not a nt:query node -> searchRequest body required.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, locator.getResourcePath() + " is not a nt:query node -> searchRequest body required.");
         }
 
         /* test if resource path does not exist -> thus indicating that
         the query must be made persistent by calling Query.save(String) */
-        if (!session.getRepositorySession().itemExists(resourcePath)) {
+        if (!session.getRepositorySession().itemExists(itemPath)) {
             try {
-                q.storeAsNode(resourcePath);
+                q.storeAsNode(itemPath);
             } catch (RepositoryException e) {
                 // ItemExistsException should never occur.
                 new JcrDavException(e);
@@ -153,12 +153,13 @@
             Row row = rowIter.nextRow();
             Value[] values = row.getValues();
 
-            // get the jcr:path column indicating the node path
-            String nodePath = row.getValue(JcrConstants.JCR_PATH).getString();
+            // get the jcr:path column indicating the node path and build
+            // a webdav compliant resource path of it.
+            String itemPath = row.getValue(JcrConstants.JCR_PATH).getString();
             // create a new ms-response for this row of the result set
-            DavResourceLocator loc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), nodePath);
-            String nodeHref = loc.getHref(true);
-            MultiStatusResponse resp = new MultiStatusResponse(nodeHref);
+            DavResourceLocator loc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), itemPath, false);
+            String href = loc.getHref(true);
+            MultiStatusResponse resp = new MultiStatusResponse(href);
             // build the s-r-property
             SearchResultProperty srp = new SearchResultProperty(columnNames, values);
             resp.add(srp);

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java Mon Oct  3 06:12:18 2005
@@ -38,6 +38,8 @@
 import org.apache.log4j.Logger;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.Item;
+import javax.jcr.PathNotFoundException;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
@@ -531,8 +533,7 @@
 
         public void commit(TransactionResource resource) throws DavException {
             try {
-                DavSession session = resource.getSession();
-                session.getRepositorySession().getItem(getResourcePath()).save();
+                getItem(resource).save();
             } catch (RepositoryException e) {
                 throw new JcrDavException(e);
             }
@@ -540,11 +541,16 @@
 
         public void rollback(TransactionResource resource) throws DavException {
             try {
-                DavSession session = resource.getSession();
-                session.getRepositorySession().getItem(getResourcePath()).refresh(false);
+                getItem(resource).refresh(false);
             } catch (RepositoryException e) {
                 throw new JcrDavException(e);
             }
+        }
+
+        private Item getItem(TransactionResource resource) throws PathNotFoundException, RepositoryException {
+            DavSession session = resource.getSession();
+            String itemPath = resource.getLocator().getJcrPath();
+            return session.getRepositorySession().getItem(itemPath);
         }
 
         public Transaction put(String key, Transaction value) throws DavException {

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=293331&r1=293330&r2=293331&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 Mon Oct  3 06:12:18 2005
@@ -79,7 +79,7 @@
         if (exists()) {
             VersionHistory versionHistory = (VersionHistory) item;
             try {
-                versionHistory.removeVersion(getResourceName(member.getHref(), true));
+                versionHistory.removeVersion(getItemName(member.getLocator().getJcrPath()));
             } catch (RepositoryException e) {
                 throw new JcrDavException(e);
             }
@@ -131,8 +131,8 @@
 
         // required root-version property for version-history resource
         try {
-            String rootVersionResourcePath = ((VersionHistory)item).getRootVersion().getPath();
-            properties.add(new HrefProperty(VersionHistoryResource.ROOT_VERSION, getLocatorFromResourcePath(rootVersionResourcePath).getHref(true), true));
+            String rootVersionHref = getLocatorFromItem(((VersionHistory)item).getRootVersion()).getHref(true);
+            properties.add(new HrefProperty(VersionHistoryResource.ROOT_VERSION, rootVersionHref, true));
         } catch (RepositoryException e) {
             log.error(e.getMessage());
         }

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=293331&r1=293330&r2=293331&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 Mon Oct  3 06:12:18 2005
@@ -177,8 +177,8 @@
                 addHrefProperty(SUCCESSOR_SET, v.getSuccessors(), true);
 
                 // required DAV:version-history (computed) property
-                String vhPath = getVersionHistoryItem().getPath();
-                properties.add(new HrefProperty(VersionResource.VERSION_HISTORY, getLocatorFromResourcePath(vhPath).getHref(true), true));
+                String vhHref = getLocatorFromItem(getVersionHistoryItem()).getHref(true);
+                properties.add(new HrefProperty(VersionResource.VERSION_HISTORY, vhHref, true));
 
                 // required DAV:checkout-set (computed) property
                 PropertyIterator it = v.getReferences();

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java Mon Oct  3 06:12:18 2005
@@ -63,7 +63,7 @@
      */
     public static final ReportType EXPORTVIEW_REPORT = ReportType.register(REPORT_NAME, ItemResourceConstants.NAMESPACE, ExportViewReport.class);
 
-    private String absPath;
+    private String absItemPath;
     private Session session;
     private ReportInfo info;
 
@@ -95,7 +95,7 @@
             throw new IllegalArgumentException("The resource must provide a non-null session object in order to create the exportview report.");
         }
         session = davSession.getRepositorySession();
-        absPath = resource.getResourcePath();
+        absItemPath = resource.getLocator().getJcrPath();
     }
 
     /**
@@ -125,16 +125,16 @@
 
         try {
             // create tmpFile in default system-tmp directory
-            String prefix = "_tmp_" + Text.getName(absPath);
+            String prefix = "_tmp_" + Text.getName(absItemPath);
             File tmpfile = File.createTempFile(prefix, null, null);
             tmpfile.deleteOnExit();
             FileOutputStream out = new FileOutputStream(tmpfile);
 
             if (reportElem.getChild("sysview", ItemResourceConstants.NAMESPACE) != null) {
-                session.exportSystemView(absPath, out, skipBinary, noRecurse);
+                session.exportSystemView(absItemPath, out, skipBinary, noRecurse);
             } else {
                 // default is docview
-                session.exportDocumentView(absPath, out, skipBinary, noRecurse);
+                session.exportDocumentView(absItemPath, out, skipBinary, noRecurse);
             }
             out.close();
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java Mon Oct  3 06:12:18 2005
@@ -107,8 +107,7 @@
             DavResourceLocator resourceLoc = resource.getLocator();
 
             Node n = session.getRepositorySession().getNodeByUUID(uuid);
-
-            DavResourceLocator loc = resourceLoc.getFactory().createResourceLocator(resourceLoc.getPrefix(), resourceLoc.getWorkspacePath(), n.getPath());
+            DavResourceLocator loc = resourceLoc.getFactory().createResourceLocator(resourceLoc.getPrefix(), resourceLoc.getWorkspacePath(), n.getPath(), false);
             DavResource res = resource.getFactory().createResource(loc, session);
 
             MultiStatus ms = new MultiStatus();

Modified: 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=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java Mon Oct  3 06:12:18 2005
@@ -31,6 +31,7 @@
 import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 
 /**
  * <code>LocateCorrespondingNodeReport</code> is used to identify the resource that
@@ -113,13 +114,14 @@
             throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while running dcr: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());
+            DavResourceLocator rLoc = resource.getLocator();
+            String itemPath = rLoc.getJcrPath();
+            Session s = resource.getSession().getRepositorySession();
+            Item item = s.getItem(itemPath);
             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);
+                DavResourceLocator corrLoc = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), "/" + workspaceName, corrPath, false);
 
                 Element e = new Element("locate-corresponding-node-report", ItemResourceConstants.NAMESPACE);
                 e.addContent(XmlUtil.hrefToXml(corrLoc.getHref(true)));

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=293331&r1=293330&r2=293331&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 Mon Oct  3 06:12:18 2005
@@ -34,6 +34,7 @@
 import org.apache.jackrabbit.server.io.ImportResourceChain;
 import org.apache.jackrabbit.server.io.ImportCollectionChain;
 import org.apache.jackrabbit.util.Text;
+import org.apache.jackrabbit.util.ISO9075;
 import org.apache.log4j.Logger;
 import org.jdom.Namespace;
 
@@ -42,10 +43,13 @@
  */
 public class DavResourceImpl implements DavResource, JcrConstants {
 
-    /** the default logger */
+    /**
+     * the default logger
+     */
     private static final Logger log = Logger.getLogger(DavResourceImpl.class);
 
     private static final HashMap reservedNamespaces = new HashMap();
+
     static {
         reservedNamespaces.put(DavConstants.NAMESPACE.getPrefix(), DavConstants.NAMESPACE.getURI());
         reservedNamespaces.put(ObservationConstants.NAMESPACE.getPrefix(), ObservationConstants.NAMESPACE.getURI());
@@ -61,7 +65,9 @@
     private DavPropertySet properties = new DavPropertySet();
     private boolean isCollection = true;
 
-    /** is created on initProperties */
+    /**
+     * is created on initProperties
+     */
     private NodeResource nodeResource;
 
     private ResourceFilter filter;
@@ -74,15 +80,25 @@
      * @param session
      */
     public DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory,
-                           DavSession session, ResourceFilter filter)
-        throws RepositoryException, DavException {
+                           DavSession session, ResourceConfig config)
+            throws RepositoryException, DavException {
         this.session = session;
         this.factory = factory;
         this.locator = locator;
-        this.filter = filter;
+        this.filter = config.getResourceFilter();
+
         if (locator != null && locator.getResourcePath() != null) {
             try {
-                init(session.getRepositorySession().getItem(locator.getResourcePath()));
+                Item item = session.getRepositorySession().getItem(locator.getJcrPath());
+                if (item != null && item.isNode()) {
+                    node = (Node) item;
+                    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
+                    isCollection = config.isCollectionResource(node);
+                }
             } catch (PathNotFoundException e) {
                 // ignore: exists field evaluates to false
             }
@@ -90,27 +106,6 @@
     }
 
     /**
-     * Init the webdav resource and retrieve the relevant property.
-     *
-     * @param 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;
-        }
-    }
-
-    /**
      * @return DavResource#COMPLIANCE_CLASS
      * @see org.apache.jackrabbit.webdav.DavResource#getComplianceClass()
      */
@@ -172,37 +167,36 @@
     }
 
     /**
+     * Returns the the last segment of the resource path.<p>
+     * Note that this must not correspond to the name of the underlaying
+     * repository item for two reasons:<ul>
+     * <li>SameNameSiblings have an index appended to their item name.</li>
+     * <li>the resource path may differ from the item path.</li>
+     * </ul>
+     * Using the item name as DAV:displayname caused problems with XP built-in
+     * client in case of resources representing SameNameSibling nodes.
+     *
      * @see DavResource#getDisplayName()
      */
     public String getDisplayName() {
-        String name = null;
-        if (exists()) {
-            try {
-                name = node.getName();
-            } catch (RepositoryException e) {
-                // ignore
-            }
-        }
-        if (name == null && getResourcePath() != null) {
-            name = Text.getName(getResourcePath());
-        }
-        return name;
+        String resPath = getResourcePath();
+        return (resPath != null) ? Text.getName(resPath) : resPath;
     }
 
     /**
      * @see org.apache.jackrabbit.webdav.DavResource#getModificationTime()
      */
     public long getModificationTime() {
-	initProperties();
-	return nodeResource == null ? 0 : nodeResource.getModificationTime();
+        initProperties();
+        return nodeResource == null ? 0 : nodeResource.getModificationTime();
     }
 
     /**
      * @see org.apache.jackrabbit.webdav.DavResource#getStream()
      */
     public InputStream getStream() {
-	initProperties();
-	return nodeResource == null ? null : nodeResource.getStream();
+        initProperties();
+        return nodeResource == null ? null : nodeResource.getStream();
     }
 
     /**
@@ -232,60 +226,62 @@
      * Fill the set of properties
      */
     private void initProperties() {
-        if (exists()) {
-            try {
-                nodeResource = new NodeResource(this, node);
-                properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, nodeResource.getContentLength()+""));
-                properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, nodeResource.getCreationDate()));
-                properties.add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED, nodeResource.getLastModified()));
-                setContentType(nodeResource.getContentType());
-                setContentLanguage(nodeResource.getContentLanguage());
-                properties.add(new DefaultDavProperty(DavPropertyName.GETETAG, nodeResource.getETag()));
-            } catch (RepositoryException e) {
-                // should not occure....
-            }
+        if (!exists() || nodeResource != null) {
+            return;
+        }
 
-            if (getDisplayName() != null) {
-                properties.add(new DefaultDavProperty(DavPropertyName.DISPLAYNAME, getDisplayName()));
-            }
-            if (isCollection()) {
-                properties.add(new ResourceType(ResourceType.COLLECTION));
-                // Windows XP support
-                properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "1"));
-            } else {
-                properties.add(new ResourceType(ResourceType.DEFAULT_RESOURCE));
-                // Windows XP support
-                properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "0"));
-            }
+        try {
+            nodeResource = new NodeResource(this, node);
+            properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, nodeResource.getContentLength() + ""));
+            properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, nodeResource.getCreationDate()));
+            properties.add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED, nodeResource.getLastModified()));
+            setContentType(nodeResource.getContentType());
+            setContentLanguage(nodeResource.getContentLanguage());
+            properties.add(new DefaultDavProperty(DavPropertyName.GETETAG, nodeResource.getETag()));
+        } catch (RepositoryException e) {
+            // should not occure....
+        }
 
-            /* set current lock information. If no lock is set to this resource,
-            an empty lockdiscovery will be returned in the response. */
-            properties.add(new LockDiscovery(getLock(Type.WRITE, Scope.EXCLUSIVE)));
+        if (getDisplayName() != null) {
+            properties.add(new DefaultDavProperty(DavPropertyName.DISPLAYNAME, getDisplayName()));
+        }
+        if (isCollection()) {
+            properties.add(new ResourceType(ResourceType.COLLECTION));
+            // Windows XP support
+            properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "1"));
+        } else {
+            properties.add(new ResourceType(ResourceType.DEFAULT_RESOURCE));
+            // Windows XP support
+            properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "0"));
+        }
 
-            /* lock support information: all locks are lockable. */
-            SupportedLock supportedLock = new SupportedLock();
-            supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE);
-            properties.add(supportedLock);
+        /* set current lock information. If no lock is set to this resource,
+        an empty lockdiscovery will be returned in the response. */
+        properties.add(new LockDiscovery(getLock(Type.WRITE, Scope.EXCLUSIVE)));
 
-            // non-protected JCR properties defined on the underlaying jcr node
-            try {
-                // todo: should filter be respected for properties as well?
-                PropertyIterator it = node.getProperties();
-                while (it.hasNext()) {
-                    Property p = it.nextProperty();
-                    String pName = p.getName();
-                    PropertyDefinition def = p.getDefinition();
-                    if (def.isMultiple()) {
-                        log.debug("Multivalue property '" +  pName + "' not added to webdav property set.");
-                        continue;
-                    }
-                    DavPropertyName name = getDavName(pName, node.getSession());
-                    String value = p.getValue().getString();
-                    properties.add(new DefaultDavProperty(name, value, def.isProtected()));
+        /* lock support information: all locks are lockable. */
+        SupportedLock supportedLock = new SupportedLock();
+        supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE);
+        properties.add(supportedLock);
+
+        // non-protected JCR properties defined on the underlaying jcr node
+        try {
+            // todo: should filter be respected for properties as well?
+            PropertyIterator it = node.getProperties();
+            while (it.hasNext()) {
+                Property p = it.nextProperty();
+                String pName = p.getName();
+                PropertyDefinition def = p.getDefinition();
+                if (def.isMultiple()) {
+                    log.debug("Multivalue property '" + pName + "' not added to webdav property set.");
+                    continue;
                 }
-            } catch (RepositoryException e) {
-                log.error("Unexpected error while retrieving properties: " + e.getMessage());
+                DavPropertyName name = getDavName(pName, node.getSession());
+                String value = p.getValue().getString();
+                properties.add(new DefaultDavProperty(name, value, def.isProtected()));
             }
+        } catch (RepositoryException e) {
+            log.error("Unexpected error while retrieving properties: " + e.getMessage());
         }
     }
 
@@ -306,12 +302,13 @@
             node.save();
         } catch (RepositoryException e) {
             // revert any changes made so far an throw exception
+            JcrDavException je = new JcrDavException(e);
             try {
                 node.refresh(false);
             } catch (RepositoryException re) {
-                throw new JcrDavException(e);
+                // should not happen...
             }
-            throw new JcrDavException(e);
+            throw je;
         }
     }
 
@@ -331,38 +328,89 @@
             removeJcrProperty(propertyName);
             node.save();
         } catch (RepositoryException e) {
-            throw new JcrDavException(e);
+            JcrDavException je = new JcrDavException(e);
+            try {
+                node.refresh(false);
+            } catch (RepositoryException re) {
+                // should not happen...
+            }
+            throw je;
         }
     }
 
-    public void alterProperties(DavPropertySet setProperties,
-                                DavPropertyNameSet removePropertyNames)
-        throws DavException {
+    /**
+     * @see DavResource#alterProperties(org.apache.jackrabbit.webdav.property.DavPropertySet, org.apache.jackrabbit.webdav.property.DavPropertyNameSet)
+     */
+    public MultiStatusResponse 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();
+
+        MultiStatusResponse msr = new MultiStatusResponse(getHref());
+        boolean success = true;
+
+        // loop over set and remove Sets and remember all properties and propertyNames
+        // that have successfully been altered
+        List successList = new ArrayList();
+        DavPropertyIterator setIter = setProperties.iterator();
+        while (setIter.hasNext()) {
+            DavProperty prop = setIter.nextProperty();
+            try {
                 setJcrProperty(prop);
+                successList.add(prop);
+            } catch (RepositoryException e) {
+                msr.add(prop.getName(), new JcrDavException(e).getErrorCode());
+                success = false;
             }
-            Iterator remNameIter = removePropertyNames.iterator();
-            while (remNameIter.hasNext()) {
-                DavPropertyName propName = (DavPropertyName) remNameIter.next();
+        }
+
+        Iterator remNameIter = removePropertyNames.iterator();
+        while (remNameIter.hasNext()) {
+            DavPropertyName propName = (DavPropertyName) remNameIter.next();
+            try {
                 removeJcrProperty(propName);
+                successList.add(propName);
+            } catch (RepositoryException e) {
+                msr.add(propName, new JcrDavException(e).getErrorCode());
+                success = false;
             }
-            // save all changes together (reverted in case this fails)
-            node.save();
+        }
+
+        try {
+            if (success) {
+                // save all changes together (reverted in case this fails)
+                node.save();
+            } else {
+                // set/remove of at least a single prop failed: undo modifications.
+                node.refresh(false);
+            }
+            /* loop over list of properties/names that were successfully altered
+               and them to the multistatus response respecting the resulte of the
+               complete action. in case of failure set the status to 'failed-dependency'
+               in order to indicate, that altering those names/properties would
+               have succeeded, if no other error occured.*/
+            Iterator it = successList.iterator();
+            while (it.hasNext()) {
+                Object o = it.next();
+                int status = (success) ? DavServletResponse.SC_OK : DavServletResponse.SC_FAILED_DEPENDENCY;
+                if (o instanceof DavProperty) {
+                    msr.add(((DavProperty) o).getName(), status);
+                } else {
+                    msr.add((DavPropertyName) o, status);
+                }
+            }
+            return msr;
         } catch (RepositoryException e) {
             // revert any changes made so far an throw exception
             try {
                 node.refresh(false);
             } catch (RepositoryException re) {
-                throw new JcrDavException(e);
+                // should not happen
             }
             throw new JcrDavException(e);
         }
@@ -398,7 +446,7 @@
         if (getResourcePath() != null && !getResourcePath().equals("/")) {
             String parentPath = Text.getRelativeParent(getResourcePath(), 1);
             if (parentPath.equals("")) {
-                parentPath="/";
+                parentPath = "/";
             }
             DavResourceLocator parentloc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), parentPath);
             try {
@@ -418,10 +466,12 @@
         if (exists() && isCollection()) {
             try {
                 NodeIterator it = node.getNodes();
-                while(it.hasNext()) {
+                while (it.hasNext()) {
                     Node n = it.nextNode();
                     if (!isFilteredNode(n)) {
-                        list.add(buildResourceFromItem(n));
+                        DavResourceLocator resourceLocator = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), n.getPath(), false);
+                        DavResource childRes = factory.createResource(resourceLocator, session);
+                        list.add(childRes);
                     } else {
                         log.debug("Filtered resource '" + n.getName() + "'.");
                     }
@@ -444,7 +494,7 @@
         if (!exists()) {
             throw new DavException(DavServletResponse.SC_CONFLICT);
         }
-        if (isLocked(this)) {
+        if (isLocked(this) || isLocked(member)) {
             throw new DavException(DavServletResponse.SC_LOCKED);
         }
         // don't allow creation of nodes, that would be filtered out
@@ -454,7 +504,8 @@
         }
         try {
             ImportContext ctx = new ImportContext(node);
-            ctx.setSystemId(member.getDisplayName());
+            String sysId = Text.getName(member.getLocator().getJcrPath());
+            ctx.setSystemId(sysId);
             boolean hasContent = inputCxt != null && inputCxt.getInputStream() != null;
             if (hasContent) {
                 ctx.setInputStream(inputCxt.getInputStream());
@@ -482,7 +533,11 @@
         } catch (RepositoryException e) {
             log.error("Error while executing import chain: " + e.toString());
             throw new JcrDavException(e);
+        } catch (DavException e) {
+            // TODO: hack needed in order not to fall into the general Exception
+            throw e;
         } catch (Exception e) {
+            // TODO: remove this! why do the commands throw an unspecific exception?
             log.error("Error while executing import chain: " + e.toString());
             throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
         }
@@ -522,15 +577,15 @@
                     lockManager.releaseLock(lock.getToken(), member);
                 }
             }
-	    ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE);
-	    if (lock != null && lockManager.hasLock(lock.getToken(), member)) {
-		lockManager.releaseLock(lock.getToken(), member);
-	    }
+            ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE);
+            if (lock != null && lockManager.hasLock(lock.getToken(), member)) {
+                lockManager.releaseLock(lock.getToken(), member);
+            }
 
-            Session s = session.getRepositorySession();
-            Item memItem = s.getItem(member.getResourcePath());
+            String itemPath = member.getLocator().getJcrPath();
+            Item memItem = session.getRepositorySession().getItem(itemPath);
             memItem.remove();
-            s.save();
+            session.getRepositorySession().save();
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
@@ -550,7 +605,8 @@
             throw new DavException(DavServletResponse.SC_FORBIDDEN);
         }
         try {
-            session.getRepositorySession().getWorkspace().move(getResourcePath(), destination.getResourcePath());
+            String destItemPath = destination.getLocator().getJcrPath();
+            session.getRepositorySession().getWorkspace().move(locator.getJcrPath(), destItemPath);
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
@@ -574,7 +630,8 @@
             throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow copy.");
         }
         try {
-            session.getRepositorySession().getWorkspace().copy(getResourcePath(), destination.getResourcePath());
+            String destItemPath = destination.getLocator().getJcrPath();
+            session.getRepositorySession().getWorkspace().copy(locator.getJcrPath(), destItemPath);
         } catch (PathNotFoundException e) {
             // according to rfc 2518: missing parent
             throw new DavException(DavServletResponse.SC_CONFLICT, e.getMessage());
@@ -607,21 +664,19 @@
         ActiveLock lock = null;
         if (exists() && Type.WRITE.equals(type) && Scope.EXCLUSIVE.equals(scope)) {
             // try to retrieve the repository lock information first
-	    if (isJsrLockable()) {
-                try {
+            try {
+                if (node.isLocked()) {
                     Lock jcrLock = node.getLock();
                     if (jcrLock != null && jcrLock.isLive()) {
                         lock = new JcrActiveLock(jcrLock);
                     }
-                } catch (RepositoryException e) {
-                    // LockException: no lock applies to this node >> ignore
-                    // RepositoryException, AccessDeniedException or another error >> ignore
                 }
+            } catch (RepositoryException e) {
+                // LockException (no lock applies) >> should never occur
+                // RepositoryException, AccessDeniedException or another error >> ignore
             }
 
-            // could not retrieve jcr-lock (either not jcr-lockable or the lock has
-            // been created before the node was made jcr-lockable. test if a simple
-            // webdav lock is present.
+            // could not retrieve a jcr-lock. test if a simple webdav lock is present.
             if (lock == null) {
                 lock = lockManager.getLock(type, scope, this);
             }
@@ -634,48 +689,48 @@
      */
     public ActiveLock[] getLocks() {
         ActiveLock writeLock = getLock(Type.WRITE, Scope.EXCLUSIVE);
-        return (writeLock != null) ? new ActiveLock[] {writeLock} : new ActiveLock[0];
+        return (writeLock != null) ? new ActiveLock[]{writeLock} : new ActiveLock[0];
     }
 
     /**
      * @see DavResource#lock(LockInfo)
      */
     public ActiveLock lock(LockInfo lockInfo) throws DavException {
-	ActiveLock lock = null;
+        ActiveLock lock = null;
         if (isLockable(lockInfo.getType(), lockInfo.getScope())) {
-            // todo: deal with existing locks, that may have been created, before the node was jcr-lockable...            
+            // TODO: deal with existing locks, that may have been created, before the node was jcr-lockable...
             if (isJsrLockable()) {
-		try {
-		    // try to execute the lock operation
-		    Lock jcrLock = node.lock(lockInfo.isDeep(), false);
-		    if (jcrLock != null) {
-			lock = new JcrActiveLock(jcrLock);
-		    }
-		} catch (RepositoryException e) {
-		    throw new JcrDavException(e);
-		}
-	    } else {
-		// create a new webdav lock
-		lock = lockManager.createLock(lockInfo, this);
-	    }
-	} else {
-	    throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "Unsupported lock type or scope.");
-	}
-	return lock;
+                try {
+                    // try to execute the lock operation
+                    Lock jcrLock = node.lock(lockInfo.isDeep(), false);
+                    if (jcrLock != null) {
+                        lock = new JcrActiveLock(jcrLock);
+                    }
+                } catch (RepositoryException e) {
+                    throw new JcrDavException(e);
+                }
+            } else {
+                // create a new webdav lock
+                lock = lockManager.createLock(lockInfo, this);
+            }
+        } else {
+            throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "Unsupported lock type or scope.");
+        }
+        return lock;
     }
 
     /**
      * @see DavResource#refreshLock(LockInfo, String)
      */
-    public ActiveLock refreshLock(LockInfo lockInfo, String lockToken) throws DavException{
+    public ActiveLock refreshLock(LockInfo lockInfo, String lockToken) throws DavException {
         if (!exists()) {
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
         ActiveLock lock = getLock(lockInfo.getType(), lockInfo.getScope());
         if (lock == null) {
-           throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock with the given type/scope present on resource " + getResourcePath());
+            throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock with the given type/scope present on resource " + getResourcePath());
         }
-        
+
         if (lock instanceof JcrActiveLock) {
             try {
                 // refresh JCR lock and return the original lock object.
@@ -729,15 +784,17 @@
 
     /**
      * Returns the node that is wrapped by this resource.
+     *
      * @return
      */
     protected Node getNode() {
         return node;
     }
-    
+
     /**
-     * Returns true, if this webdav resource allows for locking without checking
-     * its current lock status.
+     * Returns true, if the underlaying node is nodetype jcr:lockable,
+     * without checking its current lock status. If the node is not jcr-lockable
+     * an attempt is made to add the mix:lockable mixin type.
      *
      * @return true if this resource is lockable.
      */
@@ -745,9 +802,15 @@
         boolean lockable = false;
         if (exists()) {
             try {
-                lockable =  node.isNodeType(MIX_LOCKABLE);
+                lockable = node.isNodeType(MIX_LOCKABLE);
+                // not jcr-lockable: try to make the node jcr-lockable
+                if (!lockable && node.canAddMixin(MIX_LOCKABLE)) {
+                    node.addMixin(MIX_LOCKABLE);
+                    node.save();
+                    lockable = true;
+                }
             } catch (RepositoryException e) {
-                // not jcr-lockable
+                // -> node is definitely not jcr-lockable.
             }
         }
         return lockable;
@@ -767,7 +830,7 @@
             String[] sLockTokens = session.getLockTokens();
             for (int i = 0; i < sLockTokens.length; i++) {
                 if (sLockTokens[i].equals(lock.getToken())) {
-                   return false;
+                    return false;
                 }
             }
             return true;
@@ -775,25 +838,19 @@
     }
 
     /**
-     * @param item
-     * @return
-     * @throws DavException
-     * @throws RepositoryException
-     */
-    private DavResource buildResourceFromItem(Item item) throws DavException, RepositoryException {
-        DavResourceLocator parentloc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), item.getPath());
-        return factory.createResource(parentloc, session);
-    }
-
-    /**
      * Builds a webdav property name from the given jcrName. In case the jcrName
      * contains a namespace prefix that would conflict with any of the predefined
-     * webdav namespaces a new prefix is assigned.
+     * webdav namespaces a new prefix is assigned.<br>
+     * Please note, that the local part of the jcrName is checked for XML
+     * compatibility by calling {@link ISO9075#encode(String)}
      *
      * @param jcrName
-     * @return namespace
+     * @param session
+     * @return a <code>DavPropertyName</code> for the given jcr name.
      */
     private DavPropertyName getDavName(String jcrName, Session session) throws RepositoryException {
+        // make sure the local name is xml compliant
+        String localName = ISO9075.encode(Text.getLocalName(jcrName));
         String prefix = Text.getNamespacePrefix(jcrName);
         String uri = session.getNamespaceURI(prefix);
         // check for conflicts with reserved webdav-namespaces
@@ -801,7 +858,7 @@
             prefix = prefix + "0";
         }
         Namespace namespace = Namespace.getNamespace(prefix, uri);
-        DavPropertyName name = DavPropertyName.create(Text.getLocalName(jcrName), namespace);
+        DavPropertyName name = DavPropertyName.create(localName, namespace);
         return name;
     }
 
@@ -809,16 +866,16 @@
      * Build jcr property name from dav property name. If the property name
      * defines a namespace uri, that has not been registered yet, an attempt
      * is made to register the uri with the prefix defined. Note, that no
-     * extra effort is made to generated a unique prefix. 
+     * extra effort is made to generated a unique prefix.
      *
      * @param propName
      * @return jcr name
      * @throws RepositoryException
      */
     private String getJcrName(DavPropertyName propName) throws RepositoryException {
-        String pName = propName.getName();
+        // remove any encoding necessary for xml compliance
+        String pName = ISO9075.decode(propName.getName());
         String uri = propName.getNamespace().getURI();
-
         if (uri != null && !"".equals(uri)) {
             Session s = session.getRepositorySession();
             String prefix;
@@ -829,6 +886,10 @@
                 // namespace uri has not been registered yet
                 NamespaceRegistry nsReg = s.getWorkspace().getNamespaceRegistry();
                 prefix = propName.getNamespace().getPrefix();
+                // avoid trouble with default namespace
+                if (prefix == null || "".equals(prefix)) {
+                    prefix = "_pre" + nsReg.getPrefixes().length + 1;
+                }
                 // NOTE: will fail if prefix is already in use in the namespace registry
                 nsReg.registerNamespace(prefix, uri);
             }
@@ -840,7 +901,6 @@
     }
 
     /**
-     *
      * @param property
      * @throws RepositoryException
      */
@@ -857,11 +917,15 @@
      * @throws RepositoryException
      */
     private void removeJcrProperty(DavPropertyName propertyName) throws RepositoryException {
-        node.getProperty(getJcrName(propertyName)).remove();
+        String jcrName = getJcrName(propertyName);
+        if (node.hasProperty(jcrName)) {
+            node.getProperty(jcrName).remove();
+        }
+        // removal of non existing property succeeds
     }
 
     private boolean isFilteredResource(DavResource resource) {
-        // todo: filtered nodetypes should be checked as well in order to prevent problems.
+        // TODO: filtered nodetypes should be checked as well in order to prevent problems.
         return filter != null && filter.isFilteredResource(resource.getDisplayName(), session.getRepositorySession());
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java Mon Oct  3 06:12:18 2005
@@ -16,10 +16,11 @@
 package org.apache.jackrabbit.webdav.simple;
 
 import javax.jcr.Session;
-import java.util.HashSet;
 
 import org.apache.jackrabbit.webdav.DavSession;
 
+import java.util.HashSet;
+
 /**
  * Simple implementation of the {@link DavSession} interface. Stores
  * lock tokens but does not yet store references.
@@ -66,6 +67,7 @@
      */
     public void addLockToken(String token) {
         lockTokens.add(token);
+        session.addLockToken(token);
     }
 
     /**
@@ -80,5 +82,6 @@
      */
     public void removeLockToken(String token) {
         lockTokens.remove(token);
+        session.removeLockToken(token);
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java Mon Oct  3 06:12:18 2005
@@ -22,6 +22,7 @@
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.server.CredentialsProvider;
 import org.apache.jackrabbit.server.SessionProvider;
+import org.apache.log4j.Logger;
 
 /**
  * Simple implementation of the {@link DavSessionProvider}
@@ -31,6 +32,8 @@
  */
 public class DavSessionProviderImpl implements DavSessionProvider {
 
+    private static Logger log = Logger.getLogger(DavSessionProviderImpl.class);
+
     /**
      * the repository
      */
@@ -66,9 +69,11 @@
             // login to repository
             Session repSession = sesProvider.getSession(request, repository, null);
             if (repSession == null) {
+                log.debug("Could not to retrieve a repository session.");
                 return false;
             }
             DavSession ds = new DavSessionImpl(repSession);
+            log.debug("Attaching session '"+ ds + "' to request '" + request + "'");
             request.setDavSession(ds);
             return true;
         } catch (LoginException e) {
@@ -82,13 +87,28 @@
 
     /**
      * Only removes the <code>DavSession</code> object from the given request object.
-     * No further actions required, since <code>DavSessionImpl</code> does not
-     * allow to keep track of references to it.
+     * and remove all the lock tokens from the underlaying repository session
+     * in order make sure they can be reset when attaching a session to the
+     * next request. Finally the session is logged-out. The latter is a workaround
+     * only, since the SessionProvider may not clean up unused sessions properly.
      *
      * @param request
      * @see DavSessionProvider#releaseSession(org.apache.jackrabbit.webdav.WebdavRequest)
      */
     public void releaseSession(WebdavRequest request) {
+        DavSession ds = request.getDavSession();
+        if (ds != null) {
+            Session repSession = ds.getRepositorySession();
+            String[] lockTokens = repSession.getLockTokens();
+            for (int i = 0; i < lockTokens.length; i++) {
+                repSession.removeLockToken(lockTokens[i]);
+            }
+            // TODO: not quite correct. the SessionProvider should take care of removing session.
+            repSession.logout();
+            log.debug("Releasing session '"+ ds + "' from request '" + request + "'");
+        } else {
+            // session is null. nothing to be done.
+        }
         request.setDavSession(null);
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java Mon Oct  3 06:12:18 2005
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.webdav.simple;
 
 import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.util.Text;
 import org.apache.log4j.Logger;
 
 /**
@@ -34,38 +35,45 @@
         this.repositoryPrefix = repositoryPrefix;
     }
 
-    public DavResourceLocator createResourceLocator(String prefix, String requestHandle) {
+    public DavResourceLocator createResourceLocator(String prefix, String href) {
         String rPrefix = prefix + repositoryPrefix;
-        String rHandle = requestHandle;
-	// remove the configured repository prefix from the path
-        if (rHandle != null && rHandle.startsWith(repositoryPrefix)) {
-            rHandle = rHandle.substring(repositoryPrefix.length());
-        }
-	// special treatment for root item, that has no name but '/' path.
-        if (rHandle == null || "".equals(rHandle)) {
-            rHandle = "/";
+        String escPath = href;
+        // remove the configured repository prefix from the path
+        if (escPath != null && escPath.startsWith(repositoryPrefix)) {
+            escPath = escPath.substring(repositoryPrefix.length());
+        }
+        // special treatment for root item, that has no name but '/' path.
+        if (escPath == null || "".equals(escPath)) {
+            escPath = "/";
         }
-        return new Locator(rPrefix, rHandle, this);
+        return new Locator(rPrefix, Text.unescape(escPath), this);
     }
 
     public DavResourceLocator createResourceLocator(String prefix, String workspacePath, String resourcePath) {
-        return new Locator(prefix, resourcePath, this);
+        return createResourceLocator(prefix, workspacePath, resourcePath, true);
     }
 
+    public DavResourceLocator createResourceLocator(String prefix, String workspacePath, String path, boolean isResourcePath) {
+        return new Locator(prefix, path, this);
+    }
+
+    //--------------------------------------------------------------------------
     private class Locator implements DavResourceLocator {
 
         private final String prefix;
-        private final String itemPath;
+        private final String resourcePath;
         private final DavLocatorFactory factory;
+        private final String href;
 
-        private Locator(String prefix, String itemPath, DavLocatorFactory factory) {
+        private Locator(String prefix, String resourcePath, DavLocatorFactory factory) {
             this.prefix = prefix;
             this.factory = factory;
-	    // remove trailing '/' that is not part of the itemPath except for the root item.
-            if (itemPath.endsWith("/") && !"/".equals(itemPath)) {
-                itemPath = itemPath.substring(0, itemPath.length()-1);
+            // remove trailing '/' that is not part of the resourcePath except for the root item.
+            if (resourcePath.endsWith("/") && !"/".equals(resourcePath)) {
+                resourcePath = resourcePath.substring(0, resourcePath.length()-1);
             }
-            this.itemPath = itemPath;
+            this.resourcePath = resourcePath;
+            href = prefix + Text.escapePath(resourcePath);
         }
 
         public String getPrefix() {
@@ -73,7 +81,7 @@
         }
 
         public String getResourcePath() {
-            return itemPath;
+            return resourcePath;
         }
 
         public String getWorkspacePath() {
@@ -84,8 +92,8 @@
             return "";
         }
 
-        public boolean isSameWorkspace(DavResourceLocator path) {
-            return isSameWorkspace(path.getWorkspaceName());
+        public boolean isSameWorkspace(DavResourceLocator locator) {
+            return isSameWorkspace(locator.getWorkspaceName());
         }
 
         public boolean isSameWorkspace(String workspaceName) {
@@ -93,13 +101,13 @@
         }
 
         public String getHref(boolean isCollection) {
-	    // avoid doubled trainling '/' for the root item
-	    String suffix = (isCollection && !isRootLocation()) ? "/" : "";
-            return prefix + itemPath + suffix;
+            // avoid doubled trailing '/' for the root item
+            String suffix = (isCollection && !isRootLocation()) ? "/" : "";
+            return href + suffix;
         }
 
         public boolean isRootLocation() {
-            return "/".equals(itemPath);
+            return "/".equals(resourcePath);
         }
 
         public DavLocatorFactory getFactory() {
@@ -107,22 +115,27 @@
         }
 
         /**
-         * Computes the hash code using the prefix and the itemPath
+         * Returns the same as {@link #getResourcePath()}. No encoding is performed
+         * at all.
+         * @see DavResourceLocator#getJcrPath()
+         */
+        public String getJcrPath() {
+            return getResourcePath();
+        }
+
+        /**
+         * Computes the hash code from the href, which is built using the final
+         * fields prefix and resourcePath.
          *
          * @return the hash code
          */
         public int hashCode() {
-            int hashCode = prefix.hashCode();
-            if (itemPath != null) {
-                hashCode += itemPath.hashCode();
-            }
-            return hashCode % Integer.MAX_VALUE;
+            return href.hashCode();
         }
 
         /**
          * Equality of path is achieved if the specified object is a <code>DavResourceLocator</code>
-         * and the return values of the two <code>getHref(boolean)</code> methods are
-         * equal.
+         * object with the same hash code.
          *
          * @param obj the object to compare to
          * @return <code>true</code> if the 2 objects are equal;
@@ -130,8 +143,8 @@
          */
         public boolean equals(Object obj) {
             if (obj instanceof DavResourceLocator) {
-                DavResourceLocator path = (DavResourceLocator) obj;
-                this.getHref(true).equals(path.getHref(true));
+                DavResourceLocator other = (DavResourceLocator) obj;
+                return hashCode() == other.hashCode();
             }
             return false;
         }

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=293331&r1=293330&r2=293331&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 Mon Oct  3 06:12:18 2005
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.server.io.ExportContext;
 import org.apache.jackrabbit.server.io.ExportCollectionChain;
 import org.apache.jackrabbit.server.io.ExportResourceChain;
+import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.commons.chain.Command;
 
 import javax.jcr.*;
@@ -47,13 +48,13 @@
      * modificationDate date format per RFC 1123
      */
     public static SimpleDateFormat modificationDateFormat =
-	new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
+            new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
 
     /**
      * Simple date format for the creation date ISO representation (partial).
      */
     public static SimpleDateFormat creationDateFormat =
-	new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+            new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
 
     private long creationTime = 0;
     private long modificationTime = new Date().getTime();
@@ -70,7 +71,7 @@
      * @throws RepositoryException
      * @throws IllegalArgumentException if the given item is <code>null</code>
      */
-    public NodeResource(DavResourceImpl davResource, Node node) throws ItemNotFoundException, RepositoryException {
+    public NodeResource(DavResource davResource, Node node) throws ItemNotFoundException, RepositoryException {
         ExportContext ctx = new ExportContext(node);
         Command exportChain = davResource.isCollection()
                 ? ExportCollectionChain.getChain()
@@ -96,7 +97,7 @@
      * @return content Length or '0' if it could not be determined.
      */
     public long getContentLength() {
-	return contentLength;
+        return contentLength;
     }
 
     /**
@@ -105,7 +106,7 @@
      * @return creation time or '0' if it could not be determined.
      */
     public long getCreationTime() {
-	return creationTime;
+        return creationTime;
     }
 
     /**
@@ -113,10 +114,10 @@
      * time.
      *
      * @return time of last modification or the current time, if it could not
-     * be determined.
+     *         be determined.
      */
     public long getModificationTime() {
-	return modificationTime;
+        return modificationTime;
     }
 
     /**
@@ -126,11 +127,11 @@
      * @see NodeResource#modificationDateFormat
      */
     public String getLastModified() {
-	if (modificationTime >= 0) {
-	    return modificationDateFormat.format(new Date(modificationTime));
-	} else {
-	    return null;
-	}
+        if (modificationTime >= 0) {
+            return modificationDateFormat.format(new Date(modificationTime));
+        } else {
+            return null;
+        }
     }
 
     /**
@@ -140,11 +141,11 @@
      * @see NodeResource#creationDateFormat
      */
     public String getCreationDate() {
-	if (creationTime >= 0) {
-	    return creationDateFormat.format(new Date(creationTime));
-	} else {
-	    return null;
-	}
+        if (creationTime >= 0) {
+            return creationDateFormat.format(new Date(creationTime));
+        } else {
+            return null;
+        }
     }
 
     /**
@@ -162,7 +163,7 @@
      * @return content type
      */
     public String getContentType() {
-	return contentType;
+        return contentType;
     }
 
     /**
@@ -180,6 +181,6 @@
      * @return
      */
     public InputStream getStream() {
-	return in;
+        return in;
     }
 }



Mime
View raw message