jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r425002 - /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
Date Mon, 24 Jul 2006 10:38:36 GMT
Author: mreutegg
Date: Mon Jul 24 03:38:35 2006
New Revision: 425002

URL: http://svn.apache.org/viewvc?rev=425002&view=rev
Log:
Clean up todos in CachingItemStateManager. Use newly available PathMap.Element.getDescendant()
method.

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java?rev=425002&r1=425001&r2=425002&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
Mon Jul 24 03:38:35 2006
@@ -18,6 +18,7 @@
 
 import org.apache.jackrabbit.util.PathMap;
 import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.MalformedPathException;
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.EventIterator;
@@ -56,7 +57,7 @@
     public CachingItemStateManager(ItemStateManager ism) {
         this.ism = ism;
         this.uuid2PathElement = new HashMap(); // TODO: must use weak references
-        path2State = new PathMap();            // TODO: must use weak references
+        path2State = new PathMap();      // TODO: must use weak references
     }
 
     //---------------------------------------------------< ItemStateManager >---
@@ -242,8 +243,15 @@
                     PathMap.Element parentElement = getPathElement(state.getParentId());
                     // create path element if necessary
                     if (elem == null) {
-                        // TODO TO-BE-FIXED: put element (marcel, here goes your extra method)
-                        // i removed it, since its not present in JR commons (anchela)
+                        Path.PathElement[] elements = new Path.PathElement[]{
+                            getNameElement((NodeState) parentElement.get(), state)};
+                        Path p = null;
+                        try {
+                            p = new Path.PathBuilder(elements).getPath();
+                        } catch (MalformedPathException e) {
+                            // elements is never empty
+                        }
+                        elem = parentElement.getDescendant(p, false);
                     }
                     elem.set(state);
                     // now put current state to cache
@@ -255,16 +263,14 @@
         // at this point we are guaranteed to have an element
         // now resolve relative path part of id if there is one
         if (relPath != null) {
-            // TODO TO-BE-FIXED: map element (Marcel, here goes your extra method)
-            // i removed it, since its not present in JR commons (anchela)
-            PathMap.Element tmp = null;
-            if (tmp == null) {
+            PathMap.Element tmp = elem.getDescendant(relPath, true);
+            if (tmp == null || tmp.get() == null) {
                 // not yet cached, load from ism
                 ItemState state = ism.getItemState(id);
                 // put to cache
-                // TODO TO-BE-FIXED: put element (Marcel, here goes your extra method)
-                // i removed it, since its not present in JR commons (anchela)
-                tmp = null;
+                if (tmp == null) {
+                    tmp = elem.getDescendant(relPath, false);
+                }
                 tmp.set(state);
             }
             elem = tmp;
@@ -281,7 +287,7 @@
      *         present in the cache.
      */
     private PathMap.Element lookup(ItemId id) {
-        PathMap.Element elem = null;
+        PathMap.Element elem;
         // resolve UUID
         if (id.getUUID() != null) {
             elem = (PathMap.Element) uuid2PathElement.get(id.getUUID());
@@ -289,13 +295,14 @@
                 // not cached
                 return null;
             }
+        } else {
+            // start from root
+            elem = path2State.map(Path.ROOT, false);
         }
 
         // resolve relative path
         if (id.getRelativePath() != null) {
-            // TODO TO-BE-FIXED: map element (Marcel, here goes your extra method)
-            // i removed it, since its not present in JR commons (anchela)
-            elem = null;
+            elem = elem.getDescendant(id.getRelativePath(), true);
         }
 
         return elem;



Mime
View raw message