You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by md...@apache.org on 2010/03/04 19:16:23 UTC
svn commit: r919107 - in /jackrabbit/trunk: jackrabbit-jcr2dav/pom.xml
jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
jackrabbit-spi2dav/pom.xml
Author: mduerig
Date: Thu Mar 4 18:16:22 2010
New Revision: 919107
URL: http://svn.apache.org/viewvc?rev=919107&view=rev
Log:
JCR-2528: spi2dav: ItemInfoCache causes failure of (Workspace)RestoreTest#testRestoreWithUUIDConflict and variants
Modified:
jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml
jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
jackrabbit/trunk/jackrabbit-spi2dav/pom.xml
Modified: jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml?rev=919107&r1=919106&r2=919107&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml Thu Mar 4 18:16:22 2010
@@ -114,8 +114,6 @@
org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreWithUUIDConflictJcr2_4
org.apache.jackrabbit.test.api.version.WorkspaceRestoreTest#testWorkspaceRestoreWithUUIDConflict
org.apache.jackrabbit.test.api.version.WorkspaceRestoreTest#testWorkspaceRestoreWithUUIDConflictJcr2
- org.apache.jackrabbit.jcr2spi.MoveTest#testMoveReferenceableNode
- org.apache.jackrabbit.jcr2spi.WorkspaceMoveTest#testMoveReferenceableNode
<!-- not yet debugged, unknown reason -->
org.apache.jackrabbit.jcr2spi.ReorderReferenceableSNSTest#testReorder2
Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?rev=919107&r1=919106&r2=919107&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java Thu Mar 4 18:16:22 2010
@@ -84,16 +84,14 @@
RepositoryException {
try {
- // Get item info from cache and use it if up to date
- long generation = entry.getGeneration();
Entry<NodeInfo> cached = cache.getNodeInfo(nodeId);
NodeInfo info;
- if (isUpToDate(cached, generation)) {
+ if (isUpToDate(cached, entry)) {
info = cached.info;
} else {
// otherwise retreive item info from service and cache the whole batch
Iterator<? extends ItemInfo> infos = service.getItemInfos(sessionInfo, nodeId);
- info = first(infos, cache, generation);
+ info = first(infos, cache, entry.getGeneration());
if (info == null) {
throw new ItemNotFoundException("NodeId: " + nodeId);
}
@@ -138,7 +136,7 @@
} else {
// Now we can check wheter the item info from the cache is up to date
long generation = entry.getGeneration();
- if (isOutdated(cached, generation)) {
+ if (isOutdated(cached, entry)) {
// if not, retreive the item info from the service and put the whole batch into the cache
infos = service.getItemInfos(sessionInfo, nodeId);
info = first(infos, cache, generation);
@@ -167,7 +165,7 @@
// Get item info from cache and use it if up to date
Entry<PropertyInfo> cached = cache.getPropertyInfo(propertyId);
PropertyInfo info;
- if (isUpToDate(cached, entry.getGeneration())) {
+ if (isUpToDate(cached, entry)) {
info = cached.info;
} else {
// otherwise retreive item info from service and cache the whole batch
@@ -208,12 +206,10 @@
throw new ItemNotFoundException(
"HierarchyEntry does not belong to any existing ItemInfo. No ItemState was created.");
} else {
- // Now we can check wheter the item info from the cache is up to date
- long generation = entry.getGeneration();
- if (isOutdated(cached, generation)) {
+ if (isOutdated(cached, entry)) {
// if not, retreive the item info from the service and put the whole batch into the cache
info = service.getPropertyInfo(sessionInfo, propertyId);
- cache.put(info, generation);
+ cache.put(info, entry.getGeneration());
}
assertMatchingPath(info, entry);
@@ -432,7 +428,7 @@
private NodeEntry createNodeEntry(NodeEntry parentEntry, Name name, int index) throws RepositoryException {
Entry<NodeInfo> cached = cache.getNodeInfo(parentEntry.getWorkspaceId());
- if (isUpToDate(cached, parentEntry.getGeneration())) {
+ if (isUpToDate(cached, parentEntry)) {
Iterator<ChildInfo> childInfos = cached.info.getChildInfos();
if (childInfos != null) {
parentEntry.setNodeEntries(childInfos);
@@ -448,9 +444,12 @@
* @param cacheEntry
* @param generation
* @return
+ * @throws RepositoryException
*/
- private static boolean isUpToDate(Entry<?> cacheEntry, long generation) {
- return cacheEntry != null && cacheEntry.generation >= generation;
+ private static boolean isUpToDate(Entry<?> cacheEntry, HierarchyEntry entry) throws RepositoryException {
+ return cacheEntry != null &&
+ cacheEntry.generation >= entry.getGeneration() &&
+ isMatchingPath(cacheEntry.info, entry);
}
/**
@@ -459,9 +458,18 @@
* @param cacheEntry
* @param generation
* @return
+ * @throws RepositoryException
*/
- private static boolean isOutdated(Entry<?> cacheEntry, long generation) {
- return cacheEntry != null && cacheEntry.generation < generation;
+ private static boolean isOutdated(Entry<?> cacheEntry, HierarchyEntry entry) throws RepositoryException {
+ return cacheEntry != null &&
+ (cacheEntry.generation < entry.getGeneration() ||
+ !isMatchingPath(cacheEntry.info, entry));
+ }
+
+ private static boolean isMatchingPath(ItemInfo info, HierarchyEntry entry) throws RepositoryException {
+ Path infoPath = info.getPath();
+ Path wspPath = entry.getWorkspacePath();
+ return infoPath.equals(wspPath);
}
/**
@@ -474,11 +482,9 @@
* @throws RepositoryException
*/
private static void assertMatchingPath(ItemInfo info, HierarchyEntry entry) throws RepositoryException {
- Path infoPath = info.getPath();
- Path wspPath = entry.getWorkspacePath();
- if (!infoPath.equals(wspPath)) {
+ if (!isMatchingPath(info, entry)) {
// TODO: handle external move of nodes (parents) identified by uniqueID
- throw new ItemNotFoundException("HierarchyEntry " + infoPath + " does not match ItemInfo " + wspPath);
+ throw new ItemNotFoundException("HierarchyEntry " + entry.getWorkspacePath() + " does not match ItemInfo " + info.getPath());
}
}
Modified: jackrabbit/trunk/jackrabbit-spi2dav/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/pom.xml?rev=919107&r1=919106&r2=919107&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/pom.xml Thu Mar 4 18:16:22 2010
@@ -112,8 +112,6 @@
org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreWithUUIDConflictJcr2_4
org.apache.jackrabbit.test.api.version.WorkspaceRestoreTest#testWorkspaceRestoreWithUUIDConflict
org.apache.jackrabbit.test.api.version.WorkspaceRestoreTest#testWorkspaceRestoreWithUUIDConflictJcr2
- org.apache.jackrabbit.jcr2spi.MoveTest#testMoveReferenceableNode
- org.apache.jackrabbit.jcr2spi.WorkspaceMoveTest#testMoveReferenceableNode
<!-- not yet debugged, unknown reason -->
org.apache.jackrabbit.jcr2spi.ReorderReferenceableSNSTest#testReorder2