[exo-jcr-commits] exo-jcr SVN: r4092 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: impl/dataflow/persistent/infinispan and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Mar 15 08:28:11 EDT 2011


Author: tolusha
Date: 2011-03-15 08:28:10 -0400 (Tue, 15 Mar 2011)
New Revision: 4092

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ItemType.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-828: Manager null items more clearly 

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ItemType.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ItemType.java	2011-03-15 11:54:59 UTC (rev 4091)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ItemType.java	2011-03-15 12:28:10 UTC (rev 4092)
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
 package org.exoplatform.services.jcr.datamodel;
 
 

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java	2011-03-15 11:54:59 UTC (rev 4091)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java	2011-03-15 12:28:10 UTC (rev 4092)
@@ -37,37 +37,37 @@
 
    private final String parentId;
 
+   private final QPathEntry name;
+
    private final QPath path;
 
-   public NullItemData(NodeData parentData, QPathEntry name)
+   public NullItemData(NodeData parent, QPathEntry name)
    {
-      this.parentId = parentData.getIdentifier();
-      this.path = QPath.makeChildPath(parentData.getQPath(), name);
+      this.parentId = parent.getIdentifier();
+      this.path = QPath.makeChildPath(parent.getQPath(), name);
+      this.name = name;
       this.id = NULL_ID;
    }
 
-   /** 
-    * This constructor must never be used for null nodes placed in cache. Only for returned values.
-    * 
-    * @param parentId
-    * @param name
-    */
-   public NullItemData(String parentId, QPathEntry name)
+   public NullItemData(String id)
    {
-      this.parentId = parentId;
+      this.parentId = null;
       this.path = null;
-      this.id = NULL_ID;
+      this.name = null;
+      this.id = id;
    }
 
-   public NullItemData(String id)
+   public NullItemData()
    {
       this.parentId = null;
       this.path = null;
-      this.id = id;
+      this.name = null;
+      this.id = NULL_ID;
    }
 
    public void accept(ItemDataVisitor visitor) throws RepositoryException
    {
+      throw new UnsupportedOperationException("Method is not supported");
    }
 
    public String getIdentifier()
@@ -82,7 +82,7 @@
 
    public int getPersistedVersion()
    {
-      return 0;
+      throw new UnsupportedOperationException("Method is not supported");
    }
 
    public QPath getQPath()
@@ -90,4 +90,9 @@
       return path;
    }
 
+   public QPathEntry getName()
+   {
+      return name;
+   }
+
 }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java	2011-03-15 11:54:59 UTC (rev 4091)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java	2011-03-15 12:28:10 UTC (rev 4092)
@@ -29,20 +29,10 @@
  */
 public class NullNodeData extends NullItemData implements NodeData
 {
-   public NullNodeData(NodeData parentData, QPathEntry name)
-   {
-      super(parentData, name);
-   }
 
-   /** 
-    * This constructor must never be used for null nodes placed in cache. Only for returned values.
-    * 
-    * @param parentId
-    * @param name
-    */
-   public NullNodeData(String parentId, QPathEntry name)
+   public NullNodeData(NodeData parent, QPathEntry name)
    {
-      super(parentId, name);
+      super(parent, name);
    }
 
    public NullNodeData(String id)
@@ -50,6 +40,11 @@
       super(id);
    }
 
+   public NullNodeData()
+   {
+      super();
+   }
+
    /**
     * {@inheritDoc}
     */
@@ -63,7 +58,7 @@
     */
    public AccessControlList getACL()
    {
-      return null;
+      throw new UnsupportedOperationException("Method is not supported");
    }
 
    /**
@@ -71,7 +66,7 @@
     */
    public InternalQName[] getMixinTypeNames()
    {
-      return null;
+      throw new UnsupportedOperationException("Method is not supported");
    }
 
    /**
@@ -79,7 +74,7 @@
     */
    public int getOrderNumber()
    {
-      return 0;
+      throw new UnsupportedOperationException("Method is not supported");
    }
 
    /**
@@ -87,7 +82,7 @@
     */
    public InternalQName getPrimaryTypeName()
    {
-      return null;
+      throw new UnsupportedOperationException("Method is not supported");
    }
 
 }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java	2011-03-15 11:54:59 UTC (rev 4091)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java	2011-03-15 12:28:10 UTC (rev 4092)
@@ -29,9 +29,9 @@
 public class NullPropertyData extends NullItemData implements PropertyData
 {
 
-   public NullPropertyData(NodeData parentData, QPathEntry name)
+   public NullPropertyData(NodeData parent, QPathEntry name)
    {
-      super(parentData, name);
+      super(parent, name);
    }
 
    public NullPropertyData(String id)
@@ -39,12 +39,17 @@
       super(id);
    }
 
+   public NullPropertyData()
+   {
+      super();
+   }
+
    /**
     * {@inheritDoc}
     */
    public int getType()
    {
-      return -1;
+      throw new UnsupportedOperationException("Method is not supported");
    }
 
    /**
@@ -52,7 +57,7 @@
     */
    public List<ValueData> getValues()
    {
-      return null;
+      throw new UnsupportedOperationException("Method is not supported");
    }
 
    /**
@@ -60,7 +65,7 @@
     */
    public boolean isMultiValued()
    {
-      return false;
+      throw new UnsupportedOperationException("Method is not supported");
    }
 
    /**

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java	2011-03-15 11:54:59 UTC (rev 4091)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java	2011-03-15 12:28:10 UTC (rev 4092)
@@ -487,8 +487,14 @@
       {
          if (itemId.equals(NullItemData.NULL_ID))
          {
-            // this NullNodeData object will not be placed at cache, so we can use unsafe constructor 
-            return new NullNodeData(parentIdentifier, name);
+            if (itemType == ItemType.UNKNOWN || itemType == ItemType.NODE)
+            {
+               return new NullNodeData();
+            }
+            else
+            {
+               return new NullPropertyData();
+            }
          }
          else
          {
@@ -694,9 +700,9 @@
    /**
     * Internal put NullNode.
     *
-    * @param node, NodeData, new data to put in the cache
+    * @param item, NullItemData, new data to put in the cache
     */
-   protected void putNullItem(NullItemData node)
+   protected void putNullItem(NullItemData item)
    {
       boolean inTransaction = cache.isTransactionActive();
       try
@@ -707,16 +713,14 @@
          }
          cache.setLocal(true);
 
-         if (node.getQPath() == null)
+         if (!item.getIdentifier().equals(NullItemData.NULL_ID))
          {
-            //put in $ITEMS
-            cache.put(new CacheId(node.getIdentifier()), node);
+            cache.put(new CacheId(item.getIdentifier()), item);
          }
-         else
+         else if (item.getName() != null && item.getParentIdentifier() != null)
          {
-
-            cache.put(new CacheQPath(node.getParentIdentifier(), node.getQPath(), (node.isNode() ? ItemType.NODE
-               : ItemType.PROPERTY)), node.getIdentifier());
+            cache.put(new CacheQPath(item.getParentIdentifier(), item.getName(), ItemType.getItemType(item)),
+               NullItemData.NULL_ID);
          }
       }
       finally
@@ -875,10 +879,8 @@
             {
                // check is this descendant of prevRootPath
                QPath nodeQPath = data.getQPath();
-               // NullNodeData's qPath==null;
                if (nodeQPath != null && nodeQPath.isDescendantOf(prevRootPath))
                {
-
                   //make relative path
                   QPathEntry[] relativePath = null;
                   try

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java	2011-03-15 11:54:59 UTC (rev 4091)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java	2011-03-15 12:28:10 UTC (rev 4092)
@@ -32,6 +32,7 @@
 import org.exoplatform.services.jcr.datamodel.NodeData;
 import org.exoplatform.services.jcr.datamodel.NullItemData;
 import org.exoplatform.services.jcr.datamodel.NullNodeData;
+import org.exoplatform.services.jcr.datamodel.NullPropertyData;
 import org.exoplatform.services.jcr.datamodel.PropertyData;
 import org.exoplatform.services.jcr.datamodel.QPath;
 import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -221,7 +222,7 @@
             do
             {
                String itemId = (String)cache.get(makeChildFqn(root, parentId, (String)childs.next()), ITEM_ID);
-               if (itemId != null && !itemId.equals(NullItemData.NULL_ID))
+               if (itemId != null)
                {
                   n = (T)cache.get(makeItemFqn(itemId), ITEM_DATA);
                }
@@ -712,8 +713,14 @@
       {
          if (itemId.equals(NullItemData.NULL_ID))
          {
-            // this NullNodeData object will not be placed at cache, so we can use unsafe constructor 
-            return new NullNodeData(parentId, name);
+            if (itemType == ItemType.UNKNOWN || itemType == ItemType.NODE)
+            {
+               return new NullNodeData();
+            }
+            else
+            {
+               return new NullPropertyData();
+            }
          }
          else
          {
@@ -1082,9 +1089,9 @@
    /**
     * Internal put NullNode.
     *
-    * @param node, NodeData, new data to put in the cache
+    * @param item, NullItemData, new data to put in the cache
     */
-   protected void putNullItem(NullItemData node)
+   protected void putNullItem(NullItemData item)
    {
       boolean inTransaction = cache.isTransactionActive();
       try
@@ -1095,24 +1102,24 @@
          }
          cache.setLocal(true);
 
-         if (node.getQPath() == null)
+         if (!item.getIdentifier().equals(NullItemData.NULL_ID))
          {
             //put in $ITEMS
-            cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+            cache.put(makeItemFqn(item.getIdentifier()), ITEM_DATA, item);
          }
-         else
+         else if (item.getName() != null && item.getParentIdentifier() != null)
          {
-            if (node.isNode())
+            if (item.isNode())
             {
                // put in $CHILD_NODES
-               cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node
-                  .getQPath().getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+               cache.put(makeChildFqn(childNodes, item.getParentIdentifier(), item.getName()), ITEM_ID,
+                  NullItemData.NULL_ID);
             }
             else
             {
                // put in $CHILD_PROPERTIES
-               cache.put(makeChildFqn(childProps, node.getParentIdentifier(), node.getQPath().getEntries()[node
-                  .getQPath().getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+               cache.put(makeChildFqn(childProps, item.getParentIdentifier(), item.getName()), ITEM_ID,
+                  NullItemData.NULL_ID);
             }
          }
       }
@@ -1355,7 +1362,6 @@
 
          // check is this descendant of prevRootPath
          QPath nodeQPath = data.getQPath();
-         // NullNodeData's qPath==null;
          if (nodeQPath != null && nodeQPath.isDescendantOf(prevRootPath))
          {
             //make relative path



More information about the exo-jcr-commits mailing list