[exo-jcr-commits] exo-jcr SVN: r1457 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jan 18 03:56:04 EST 2010


Author: nzamosenchuk
Date: 2010-01-18 03:56:04 -0500 (Mon, 18 Jan 2010)
New Revision: 1457

Modified:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-409: SetLocalMode enclosed in try{} finally {}. This is needed to set Local mode to false state even if exception took place.

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java	2010-01-18 08:53:57 UTC (rev 1456)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java	2010-01-18 08:56:04 UTC (rev 1457)
@@ -353,16 +353,22 @@
     */
    public void put(ItemData item)
    {
-      cache.setLocal(true);
-      if (item.isNode())
+      try
       {
-         putNode((NodeData)item, ModifyChildOption.NOT_MODIFY);
+         cache.setLocal(true);
+         if (item.isNode())
+         {
+            putNode((NodeData)item, ModifyChildOption.NOT_MODIFY);
+         }
+         else
+         {
+            putProperty((PropertyData)item, ModifyChildOption.NOT_MODIFY);
+         }
       }
-      else
+      finally
       {
-         putProperty((PropertyData)item, ModifyChildOption.NOT_MODIFY);
+         cache.setLocal(false);
       }
-      cache.setLocal(false);
    }
 
    /**
@@ -423,24 +429,30 @@
    */
    public void addChildNodes(NodeData parent, List<NodeData> childs)
    {
-      cache.setLocal(true);
-      // remove previous all (to be sure about consistency)
-      cache.removeNode(makeChildListFqn(childNodesList, parent.getIdentifier()));
+      try
+      {
+         cache.setLocal(true);
+         // remove previous all (to be sure about consistency)
+         cache.removeNode(makeChildListFqn(childNodesList, parent.getIdentifier()));
 
-      if (childs.size() > 0)
-      {
-         // add all new
-         for (NodeData child : childs)
+         if (childs.size() > 0)
          {
-            putNode(child, ModifyChildOption.FORCE_MODIFY);
+            // add all new
+            for (NodeData child : childs)
+            {
+               putNode(child, ModifyChildOption.FORCE_MODIFY);
+            }
          }
+         else
+         {
+            // cache fact of empty childs list
+            cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST, new HashSet<Object>());
+         }
       }
-      else
+      finally
       {
-         // cache fact of empty childs list
-         cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST, new HashSet<Object>());
+         cache.setLocal(false);
       }
-      cache.setLocal(false);
    }
 
    /**
@@ -448,22 +460,28 @@
     */
    public void addChildProperties(NodeData parent, List<PropertyData> childs)
    {
-      cache.setLocal(true);
-      // remove previous all (to be sure about consistency)
-      cache.removeNode(makeChildListFqn(childPropsList, parent.getIdentifier()));
-      if (childs.size() > 0)
+      try
       {
-         // add all new
-         for (PropertyData child : childs)
+         cache.setLocal(true);
+         // remove previous all (to be sure about consistency)
+         cache.removeNode(makeChildListFqn(childPropsList, parent.getIdentifier()));
+         if (childs.size() > 0)
          {
-            putProperty(child, ModifyChildOption.FORCE_MODIFY);
+            // add all new
+            for (PropertyData child : childs)
+            {
+               putProperty(child, ModifyChildOption.FORCE_MODIFY);
+            }
          }
+         else
+         {
+            LOG.warn("Empty properties list cached " + (parent != null ? parent.getQPath().getAsString() : parent));
+         }
       }
-      else
+      finally
       {
-         LOG.warn("Empty properties list cached " + (parent != null ? parent.getQPath().getAsString() : parent));
+         cache.setLocal(false);
       }
-      cache.setLocal(false);
    }
 
    /**
@@ -471,9 +489,15 @@
     */
    public void addChildPropertiesList(NodeData parent, List<PropertyData> childProperties)
    {
-      cache.setLocal(true);
-      // TODO not implemented, will force read from DB
-      cache.setLocal(false);
+      try
+      {
+         cache.setLocal(true);
+         // TODO not implemented, will force read from DB
+      }
+      finally
+      {
+         cache.setLocal(false);
+      }
    }
 
    /**



More information about the exo-jcr-commits mailing list