jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1205029 - in /jackrabbit/trunk: jackrabbit-jcr2dav/ jackrabbit-spi2dav/ jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/
Date Tue, 22 Nov 2011 15:04:56 GMT
Author: reschke
Date: Tue Nov 22 15:04:55 2011
New Revision: 1205029

URL: http://svn.apache.org/viewvc?rev=1205029&view=rev
Log:
JCR-2540: spi2dav : move/reorder not properly handled by observation 

Add fallback when nodeId can't be computed due to removed node, avoid PROPFINDs on nodes that
we know are gone

Modified:
    jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml
    jackrabbit/trunk/jackrabbit-spi2dav/pom.xml
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolver.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml?rev=1205029&r1=1205028&r2=1205029&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml Tue Nov 22 15:04:55 2011
@@ -76,8 +76,6 @@
                       org.apache.jackrabbit.test.api.lock.LockManagerTest#testAddLockTokenToAnotherSession
                       org.apache.jackrabbit.test.api.lock.LockManagerTest#testLockTransfer2
                       org.apache.jackrabbit.jcr2spi.lock.OpenScopedLockTest#testLogoutHasNoEffect

-                      <!-- JCR-2540 : move/reorder (observation) -->
-                      org.apache.jackrabbit.test.api.observation.GetIdentifierTest#testNodeRemoved
                     
                       <!-- JCR-2541 : event journal -->
                       org.apache.jackrabbit.test.api.observation.EventJournalTest
                       <!-- JCR-2533 : missing impl of checkQueryStatement -->     
                

Modified: jackrabbit/trunk/jackrabbit-spi2dav/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/pom.xml?rev=1205029&r1=1205028&r2=1205029&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/pom.xml Tue Nov 22 15:04:55 2011
@@ -73,8 +73,6 @@
                   org.apache.jackrabbit.test.api.lock.LockManagerTest#testAddInvalidLockToken
                   org.apache.jackrabbit.test.api.lock.LockManagerTest#testAddLockTokenToAnotherSession
                   org.apache.jackrabbit.test.api.lock.LockManagerTest#testLockTransfer2
-                  <!-- JCR-2540 : move/reorder (observation) -->
-                  org.apache.jackrabbit.test.api.observation.GetIdentifierTest#testNodeRemoved
                   <!-- JCR-2541 : event journal -->
                   org.apache.jackrabbit.test.api.observation.EventJournalTest
                   <!-- JCR-2533 : missing impl of checkQueryStatement -->

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=1205029&r1=1205028&r2=1205029&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Tue Nov 22 15:04:55 2011
@@ -2231,15 +2231,31 @@ public class RepositoryServiceImpl imple
                 continue;
             }
 
+            boolean isForNode = (type == Event.NODE_ADDED
+                    || type == Event.NODE_REMOVED || type == Event.NODE_MOVED);
+            
             ItemId eventId = null;
             try {
-                if (type == Event.NODE_ADDED || type == Event.NODE_REMOVED || type == Event.NODE_MOVED)
{
-                    eventId = uriResolver.getNodeId(href, sessionInfo);
+                if (isForNode) {
+                    eventId = uriResolver.getNodeIdAfterEvent(href,
+                            sessionInfo, type == Event.NODE_REMOVED);
                 } else {
                     eventId = uriResolver.getPropertyId(href, sessionInfo);
                 }
             } catch (RepositoryException e) {
-                log.warn("Unable to build event itemId: ", e.getMessage());
+                if (isForNode) {
+                    eventId = idFactory.createNodeId((String) null, eventPath);
+                } else {
+                    try {
+                        eventId = idFactory.createPropertyId(
+                                idFactory.createNodeId((String) null,
+                                        eventPath.getAncestor(1)),
+                                eventPath.getName());
+                    } catch (RepositoryException e1) {
+                        log.warn("Unable to build event itemId: ",
+                                e.getMessage());
+                    }
+                }
             }
             String parentHref = Text.getRelativeParent(href, 1, true);
             NodeId parentId = null;

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolver.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolver.java?rev=1205029&r1=1205028&r2=1205029&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolver.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolver.java
Tue Nov 22 15:04:55 2011
@@ -32,5 +32,7 @@ interface URIResolver {
 
     NodeId getNodeId(String uri, SessionInfo sessionInfo) throws RepositoryException;
 
+    NodeId getNodeIdAfterEvent(String uri, SessionInfo sessionInfo, boolean nodeIsGone) throws
RepositoryException;
+
     PropertyId getPropertyId(String uri, SessionInfo sessionInfo) throws RepositoryException;
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java?rev=1205029&r1=1205028&r2=1205029&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
Tue Nov 22 15:04:55 2011
@@ -231,30 +231,8 @@ class URIResolverImpl implements URIReso
             return uri;
         }
     }
-    //-------------------------------------------------------< URI resolver >---
-    /**
-     * @inheritDoc
-     */
-    public Path getQPath(String uri, SessionInfo sessionInfo) throws RepositoryException
{
-        String rootUri = getRootItemUri(sessionInfo.getWorkspaceName());
-        String jcrPath;
-        if (uri.startsWith(rootUri)) {
-            jcrPath = uri.substring(rootUri.length());
-        } else {
-            // todo: probably rather an error?
-            jcrPath = uri;
-        }
-        try {
-            return service.getNamePathResolver(sessionInfo).getQPath(Text.unescape(jcrPath));
-        } catch (NameException e) {
-            throw new RepositoryException(e);
-        }
-    }
 
-    /**
-     * @inheritDoc
-     */
-    public NodeId getNodeId(String uri, SessionInfo sessionInfo) throws RepositoryException
{
+    private NodeId getNodeId(String uri, SessionInfo sessionInfo, boolean nodeIsGone) throws
RepositoryException {
         IdURICache cache = getCache(sessionInfo.getWorkspaceName());
         if (cache.containsUri(uri)) {
             // id has been accessed before and is cached
@@ -264,13 +242,17 @@ class URIResolverImpl implements URIReso
             }
         }
 
+        if (nodeIsGone) {
+            throw new RepositoryException("Can't reconstruct nodeId from URI when the remote
node is gone.");
+        }
+        
         // retrieve parentId from cache or by recursive calls
         NodeId parentId;
         if (isSameURI(uri, getRootItemUri(sessionInfo.getWorkspaceName()))) {
             parentId = null;
         } else {
             String parentUri = Text.getRelativeParent(uri, 1, true);
-            parentId = getNodeId(parentUri, sessionInfo);
+            parentId = getNodeId(parentUri, sessionInfo, false);
         }
 
         DavPropertyNameSet nameSet = new DavPropertyNameSet();
@@ -299,6 +281,40 @@ class URIResolverImpl implements URIReso
         }
     }
 
+    //-------------------------------------------------------< URI resolver >---
+    /**
+     * @inheritDoc
+     */
+    public Path getQPath(String uri, SessionInfo sessionInfo) throws RepositoryException
{
+        String rootUri = getRootItemUri(sessionInfo.getWorkspaceName());
+        String jcrPath;
+        if (uri.startsWith(rootUri)) {
+            jcrPath = uri.substring(rootUri.length());
+        } else {
+            // todo: probably rather an error?
+            jcrPath = uri;
+        }
+        try {
+            return service.getNamePathResolver(sessionInfo).getQPath(Text.unescape(jcrPath));
+        } catch (NameException e) {
+            throw new RepositoryException(e);
+        }
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public NodeId getNodeId(String uri, SessionInfo sessionInfo) throws RepositoryException
{
+        return getNodeId(uri, sessionInfo, false);
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public NodeId getNodeIdAfterEvent(String uri, SessionInfo sessionInfo, boolean nodeIsGone)
throws RepositoryException {
+        return getNodeId(uri, sessionInfo, nodeIsGone);
+    }
+    
     /**
      * @inheritDoc
      */
@@ -316,7 +332,7 @@ class URIResolverImpl implements URIReso
         // make sure propName is unescaped
         String propName = Text.unescape(Text.getName(uri, true));
         // retrieve parent node id
-        NodeId parentId = getNodeId(parentUri, sessionInfo);
+        NodeId parentId = getNodeId(parentUri, sessionInfo, false);
         // build property id
         try {
             Name name = service.getNamePathResolver(sessionInfo).getQName(propName);



Mime
View raw message