jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r915518 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/
Date Tue, 23 Feb 2010 21:01:48 GMT
Author: angela
Date: Tue Feb 23 21:01:47 2010
New Revision: 915518

URL: http://svn.apache.org/viewvc?rev=915518&view=rev
Log:
JCR-2472: Accessing moved referenceble nodes results in PathNotFoundException

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java?rev=915518&r1=915517&r2=915518&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java
Tue Feb 23 21:01:47 2010
@@ -24,11 +24,16 @@
 import javax.jcr.Property;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
 
 import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.commons.JcrUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.ByteArrayInputStream;
+
 /**
  * <code>MoveTest</code>...
  */
@@ -265,4 +270,43 @@
             doMove(moveNode.getPath(), destProperty.getPath());
         }
     }
+
+
+    public void testMoveFile() throws RepositoryException, NotExecutableException {
+        // create a new file
+        String parentPath;
+        String filePath;
+        try {
+            Node parent = testRootNode.addNode("parent");
+            Node n = JcrUtils.putFile(parent, "file", "text/plain", new ByteArrayInputStream("data".getBytes()));
+            parentPath = parent.getPath();
+            filePath = n.getPath();
+            superuser.save();
+        } catch (RepositoryException e) {
+            throw new NotExecutableException();
+        }
+
+        Session s = getHelper().getSuperuserSession();
+        try {
+            Node n1 = s.getNode(filePath);
+            Node n2 = n1.getNode("jcr:content");
+            n2.setProperty("jcr:data", new java.io.ByteArrayInputStream("data2".getBytes()));
+            n2.save();
+
+            String destPath = parentPath + "1";
+            if (isSessionMove()) {
+                s.move(parentPath, destPath);
+                s.save();
+            } else {
+                s.getWorkspace().move(parentPath, destPath);
+            }
+            Node n3 = s.getNode(destPath + "/file");
+            Node n4 = n3.getNode("jcr:content");
+            n4.refresh(false);
+            // call must succeed (see JCR-2472)
+            Node n5 = n3.getNode("jcr:content");
+        } finally {
+            s.logout();
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java?rev=915518&r1=915517&r2=915518&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
Tue Feb 23 21:01:47 2010
@@ -82,6 +82,11 @@
         log.debug("Removed: ItemId = " + itemId + " URI = " + uri);
     }
 
+    public void clear() {
+        idToUriCache.clear();
+        uriToIdCache.clear();
+    }
+
     private static String getCleanUri(String uri) {
         if (uri.endsWith("/")) {
             return uri.substring(0, uri.length() - 1);

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=915518&r1=915517&r2=915518&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 Feb 23 21:01:47 2010
@@ -390,6 +390,16 @@
         return uriResolver.getItemUri(itemId, sessionInfo.getWorkspaceName(), sessionInfo);
     }
 
+    /**
+     * Clear all URI mappings. This is required after hierarchy operations such
+     * as e.g. MOVE.
+     * 
+     * @param sessionInfo
+     */
+    protected void clearItemUriCache(SessionInfo sessionInfo) {
+        uriResolver.clearCacheEntries(sessionInfo);
+    }
+
     private String getItemUri(NodeId parentId, Name childName,
                               SessionInfo sessionInfo) throws RepositoryException {
         String parentUri = uriResolver.getItemUri(parentId, sessionInfo.getWorkspaceName(),
sessionInfo);
@@ -1272,6 +1282,8 @@
         String destUri = getItemUri(destParentNodeId, destName, sessionInfo);
         MoveMethod method = new MoveMethod(uri, destUri, true);
         execute(method, sessionInfo);
+        // need to clear the cache as the move may have affected nodes with uuid.
+        clearItemUriCache(sessionInfo);
     }
 
     /**
@@ -2230,6 +2242,7 @@
         private String batchId;
 
         private boolean isConsumed = false;
+        private boolean clear = false;
 
         private BatchImpl(ItemId targetId, SessionInfo sessionInfo) throws RepositoryException
{
             this.targetId = targetId;
@@ -2281,6 +2294,9 @@
                 if (sessionInfo instanceof SessionInfoImpl) {
                     ((SessionInfoImpl) sessionInfo).setLastBatchId(batchId);
                 }
+                if (clear) {
+                    clearItemUriCache(sessionInfo);
+                }
             } catch (IOException e) {
                 throw new RepositoryException(e);
             } catch (DavException e) {
@@ -2564,6 +2580,7 @@
             MoveMethod method = new MoveMethod(uri, destUri, true);
 
             methods.add(method);
+            clear = true;
         }
     }
 

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=915518&r1=915517&r2=915518&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 Feb 23 21:01:47 2010
@@ -215,6 +215,11 @@
         }
     }
 
+    void clearCacheEntries(SessionInfo sessionInfo) {
+        IdURICache cache = getCache(sessionInfo.getWorkspaceName());
+        cache.clear();
+    }
+
     private static boolean isSameURI(String uri1, String uri2) {
         return getCleanURI(uri1).equals(getCleanURI(uri2));
 

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java?rev=915518&r1=915517&r2=915518&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
Tue Feb 23 21:01:47 2010
@@ -418,6 +418,9 @@
 
         private PostMethod method; // TODO: use PATCH request instead.
         private boolean isConsumed;
+        // flag to determine if the uri-lookup needs to be cleared... e.g.
+        // after a move operation.
+        private boolean clear;
 
         private BatchImpl(ItemId targetId, SessionInfo sessionInfo) {
             this.targetId = targetId;
@@ -458,6 +461,9 @@
             try {
                 client.executeMethod(method);
                 method.checkSuccess();
+                if (clear) {
+                    RepositoryServiceImpl.super.clearItemUriCache(sessionInfo);
+                }
             }  catch (IOException e) {
                 throw new RepositoryException(e);
             } catch (DavException e) {
@@ -625,6 +631,8 @@
             String destJcrPath = getNamePathResolver(sessionInfo).getJCRPath(destPath);
 
             appendDiff(SYMBOL_MOVE, srcPath, destJcrPath);
+
+            clear = true;
         }
 
         /**



Mime
View raw message