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

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Mar 30 06:54:11 EDT 2010


Author: nzamosenchuk
Date: 2010-03-30 06:54:11 -0400 (Tue, 30 Mar 2010)
New Revision: 2188

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-609: 1. In JbossCacheWSC - if property list is empty - notify with the warning. This is abnormal situation. At least "jcr:primaryType" should exists.
2. In CacheableWorkspaceDM - use equals(), instead of "==" when checking if nodeData in cache is null-stub-nodeData. Cause "==" will not work in cluster.

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java	2010-03-30 09:38:54 UTC (rev 2187)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java	2010-03-30 10:54:11 UTC (rev 2188)
@@ -44,7 +44,7 @@
 import javax.transaction.TransactionManager;
 
 /**
- * Created by The eXo Platform SAS. 
+ * Created by The eXo Platform SAS.
  * 
  * <br/>
  * Author : Peter Nedonosko peter.nedonosko at exoplatform.com.ua
@@ -58,7 +58,7 @@
     * The identifier of the <code>null</code> value
     */
    protected static final String ITEM_DATA_NULL_VALUE_ID = "$";
-   
+
    /**
     * The name of the <code>null</code> value
     */
@@ -121,6 +121,26 @@
          return null;
       }
 
+      @Override
+      public boolean equals(Object obj)
+      {
+         if (obj == this)
+         {
+            return true;
+         }
+
+         if (obj == null)
+         {
+            return false;
+         }
+
+         if (obj instanceof NodeData)
+         {
+            return getIdentifier().equals(((ItemData)obj).getIdentifier());
+         }
+
+         return false;
+      }
    };
 
    /**
@@ -353,7 +373,7 @@
     *          Items cache
     * @param systemDataContainerHolder
     *          System Workspace data container (persistent level)
-    * @param transactionService TransactionService         
+    * @param transactionService TransactionService
     */
    public CacheableWorkspaceDataManager(WorkspaceDataContainer dataContainer, WorkspaceStorageCache cache,
       SystemDataContainerHolder systemDataContainerHolder, TransactionService transactionService)
@@ -409,6 +429,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public int getChildNodesCount(NodeData parent) throws RepositoryException
    {
       if (cache.isEnabled())
@@ -426,6 +447,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public List<NodeData> getChildNodesData(NodeData nodeData) throws RepositoryException
    {
       return getChildNodesData(nodeData, false);
@@ -434,6 +456,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public List<PropertyData> getChildPropertiesData(NodeData nodeData) throws RepositoryException
    {
       List<PropertyData> childs = getChildPropertiesData(nodeData, false);
@@ -448,6 +471,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException
    {
 
@@ -472,7 +496,7 @@
             else if (!data.isNode())
             {
                fixPropertyValues((PropertyData)data);
-            }            
+            }
          }
          finally
          {
@@ -484,12 +508,13 @@
          fixPropertyValues((PropertyData)data);
       }
 
-      return data == ITEM_DATA_NULL_VALUE ? null : data;
+      return ITEM_DATA_NULL_VALUE.equals(data) ? null : data;
    }
 
    /**
     * {@inheritDoc}
     */
+   @Override
    public ItemData getItemData(String identifier) throws RepositoryException
    {
       // 2. Try from cache
@@ -525,14 +550,15 @@
          fixPropertyValues((PropertyData)data);
       }
 
-      return data == ITEM_DATA_NULL_VALUE ? null : data;
+      return ITEM_DATA_NULL_VALUE.equals(data) ? null : data;
    }
 
    /**
     * {@inheritDoc}
     */
+   @Override
    public List<PropertyData> getReferencesData(String identifier, boolean skipVersionStorage)
-      throws RepositoryException
+   throws RepositoryException
    {
       return super.getReferencesData(identifier, skipVersionStorage);
    }
@@ -540,6 +566,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public List<PropertyData> listChildPropertiesData(NodeData nodeData) throws RepositoryException
    {
       return listChildPropertiesData(nodeData, false);
@@ -558,7 +585,7 @@
       }
       else
       {
-         // save normaly 
+         // save normaly
          super.save(changesLog);
 
          // notify listeners after storage commit
@@ -608,7 +635,7 @@
     *           Repository error
     */
    protected List<NodeData> getChildNodesData(NodeData nodeData, boolean forcePersistentRead)
-      throws RepositoryException
+   throws RepositoryException
    {
 
       List<NodeData> childNodes = null;
@@ -665,7 +692,7 @@
     *           Repository error
     */
    protected List<PropertyData> getChildPropertiesData(NodeData nodeData, boolean forcePersistentRead)
-      throws RepositoryException
+   throws RepositoryException
    {
 
       List<PropertyData> childProperties = null;
@@ -761,7 +788,7 @@
     *           Repository error
     */
    protected List<PropertyData> listChildPropertiesData(NodeData nodeData, boolean forcePersistentRead)
-      throws RepositoryException
+   throws RepositoryException
    {
 
       List<PropertyData> propertiesList;
@@ -852,10 +879,10 @@
     * @param prop PropertyData, original Property data
     * @return PropertyData
     * @throws IllegalStateException
-    * @throws RepositoryException 
+    * @throws RepositoryException
     */
    protected ValueData getPropertyValue(String propertyId, int orderNumb, int persistedVersion)
-      throws IllegalStateException, RepositoryException
+   throws IllegalStateException, RepositoryException
    {
       // TODO use interface not JDBC
       JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();

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	2010-03-30 09:38:54 UTC (rev 2187)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java	2010-03-30 10:54:11 UTC (rev 2188)
@@ -65,24 +65,24 @@
  *      <ul>
  *      <li>/$ITEMS - stores items by Id (i.e. /$ITEMS/itemId)</li>
  *      <li>/$CHILD_NODES, /$CHILD_PROPS - stores items by parentId and name (i.e. /$CHILD_NODES/parentId/childName.$ITEM_ID)</li>
- *      <li>/$CHILD_NODES_LIST, /$CHILD_PROPS_LIST - stores child list by parentId and child Id 
+ *      <li>/$CHILD_NODES_LIST, /$CHILD_PROPS_LIST - stores child list by parentId and child Id
  *      (i.e. /$CHILD_NODES_LIST/parentId.lists = serialized Set<Object>)</li>
  *      </ul>
- * </li>     
+ * </li>
  * <li>all child properties/nodes lists should be evicted from parent at same time
  *      i.e. for /$CHILD_NODES_LIST, /$CHILD_PROPS_LIST we need customized eviction policy (EvictionActionPolicy) to evict
  *      whole list on one of childs eviction
- * </li>          
+ * </li>
  * </ul>
  * 
- * <p/> 
- * Current state notes (subject of change): 
+ * <p/>
+ * Current state notes (subject of change):
  * <ul>
  * <li>cache implements WorkspaceStorageCache, without any stuff about references and locks</li>
  * <li>transaction style implemented via JBC barches, do with JTA (i.e. via exo's TransactionService + JBoss TM)</li>
  * <li>we need customized eviction policy (EvictionActionPolicy) for /$CHILD_NODES_LIST, /$CHILD_PROPS_LIST</li>
  * </ul>
- *  
+ * 
  * @author <a href="mailto:peter.nedonosko at exoplatform.com">Peter Nedonosko</a>
  * @version $Id: JBossCacheWorkspaceStorageCache.java 13869 2008-05-05 08:40:10Z pnedonosko $
  */
@@ -253,7 +253,7 @@
     */
    public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, TransactionService transactionService,
       ConfigurationManager cfm) throws RepositoryException, RepositoryConfigurationException
-   {
+      {
       if (wsConfig.getCache() == null)
       {
          throw new RepositoryConfigurationException("Cache configuration not found");
@@ -287,17 +287,17 @@
       createResidentNode(childProps);
       createResidentNode(childPropsList);
       createResidentNode(itemsRoot);
-   }
+      }
 
    /**
     * Cache constructor with JBossCache JTA transaction support.
     * 
-    * @param wsConfig WorkspaceEntry workspace config 
+    * @param wsConfig WorkspaceEntry workspace config
     * @throws RepositoryException if error of initialization
     * @throws RepositoryConfigurationException if error of configuration
     */
    public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, ConfigurationManager cfm)
-      throws RepositoryException, RepositoryConfigurationException
+   throws RepositoryException, RepositoryConfigurationException
    {
       this(wsConfig, null, cfm);
    }
@@ -336,7 +336,7 @@
    /**
     * Return TransactionManager used by JBossCache backing the JCR cache.
     * 
-    * @return TransactionManager 
+    * @return TransactionManager
     */
    public TransactionManager getTransactionManager()
    {
@@ -406,8 +406,8 @@
             {
                if (state.isPersisted())
                {
-                  // There was a problem with removing a list of samename siblings in on transaction, 
-                  // so putItemInBufferedCache(..) and updateInBufferedCache(..) used instead put(..) and update (..) methods.  
+                  // There was a problem with removing a list of samename siblings in on transaction,
+                  // so putItemInBufferedCache(..) and updateInBufferedCache(..) used instead put(..) and update (..) methods.
                   ItemData prevItem = putItemInBufferedCache(state.getData());
                   if (prevItem != null && state.isNode())
                   {
@@ -446,8 +446,8 @@
    }
 
    /**
-   * {@inheritDoc}
-   */
+    * {@inheritDoc}
+    */
    public void addChildNodes(NodeData parent, List<NodeData> childs)
    {
       boolean inTransaction = cache.isTransactionActive();
@@ -517,7 +517,9 @@
          }
          else
          {
-            cache.put(makeChildListFqn(childPropsList, parent.getIdentifier()), ITEM_LIST, Collections.EMPTY_SET);
+            // This is really critical situation! Anywhere at least jcr:primaryType should be!
+            // At least warn to know is something happens.
+            LOG.warn("Empty properties list cached " + (parent != null ? parent.getQPath().getAsString() : parent));
          }
       }
       finally
@@ -540,7 +542,7 @@
       //      {
       //         cache.beginTransaction();
       //         cache.setLocal(true);
-      //         
+      //
       //      }
       //      finally
       //      {
@@ -631,7 +633,7 @@
    /**
     * Internal get child properties.
     *
-    * @param parentId String 
+    * @param parentId String
     * @param withValue boolean, if true only "full" Propeties can be returned
     * @return List of PropertyData
     */
@@ -776,7 +778,7 @@
       {
          // add in CHILD_NODES
          cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
-            .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+                                                                                                     .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
          // if MODIFY and List present OR FORCE_MODIFY, then write
          if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
             .getParentIdentifier())) != null)
@@ -797,7 +799,7 @@
       {
          // add in CHILD_NODES
          cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
-            .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+                                                                                                     .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
          // if MODIFY and List present OR FORCE_MODIFY, then write
          if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
             .getParentIdentifier())) != null)
@@ -821,7 +823,7 @@
    {
       // add in CHILD_PROPS
       cache.put(makeChildFqn(childProps, prop.getParentIdentifier(), prop.getQPath().getEntries()[prop.getQPath()
-         .getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
+                                                                                                  .getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
       // if MODIFY and List present OR FORCE_MODIFY, then write
       if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childPropsList, prop
          .getParentIdentifier())) != null)
@@ -843,7 +845,7 @@
 
             // remove from CHILD_NODES of parent
             cache.removeNode(makeChildFqn(childNodes, item.getParentIdentifier(), item.getQPath().getEntries()[item
-               .getQPath().getEntries().length - 1]));
+                                                                                                               .getQPath().getEntries().length - 1]));
 
             // remove from CHILD_NODES_LIST of parent
             cache.removeFromList(makeChildListFqn(childNodesList, item.getParentIdentifier()), ITEM_LIST, item
@@ -866,7 +868,7 @@
       {
          // remove from CHILD_PROPS
          cache.removeNode(makeChildFqn(childProps, item.getParentIdentifier(), item.getQPath().getEntries()[item
-            .getQPath().getEntries().length - 1]));
+                                                                                                            .getQPath().getEntries().length - 1]));
 
          // remove from CHILD_PROPS_LIST
          cache.removeFromList(makeChildListFqn(childPropsList, item.getParentIdentifier()), ITEM_LIST, item
@@ -899,7 +901,7 @@
    }
 
    /**
-    * Update Node hierachy in case of same-name siblings reorder. 
+    * Update Node hierachy in case of same-name siblings reorder.
     * Assumes the new (updated) nodes already putted in the cache. Previous name of updated nodes will be calculated
     * and that node will be deleted (if has same id as the new node). Childs paths will be updated to a new node path.
     *
@@ -911,7 +913,7 @@
       // get previously cached NodeData and using its name remove child on the parent
       Fqn<String> prevFqn =
          makeChildFqn(childNodes, node.getParentIdentifier(), prevNode.getQPath().getEntries()[prevNode.getQPath()
-            .getEntries().length - 1]);
+                                                                                               .getEntries().length - 1]);
       if (node.getIdentifier().equals(cache.get(prevFqn, ITEM_ID)))
       {
          // it's same-name siblings re-ordering, delete previous child
@@ -941,7 +943,7 @@
       // get previously cached NodeData and using its name remove child on the parent
       Fqn<String> prevFqn =
          makeChildFqn(childNodes, node.getParentIdentifier(), prevNode.getQPath().getEntries()[prevNode.getQPath()
-            .getEntries().length - 1]);
+                                                                                               .getEntries().length - 1]);
       if (node.getIdentifier().equals(cache.getFromBuffer(prevFqn, ITEM_ID)))
       {
          // it's same-name siblings re-ordering, delete previous child
@@ -977,15 +979,15 @@
          PropertyData prevProp = iter.next();
 
          if (inheritACL
-            && (prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath().getName()
-               .equals(Constants.EXO_OWNER)))
+                  && (prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath().getName()
+                           .equals(Constants.EXO_OWNER)))
          {
             inheritACL = false;
          }
          // recreate with new path for child Props only
          QPath newPath =
             QPath
-               .makeChildPath(rootPath, prevProp.getQPath().getEntries()[prevProp.getQPath().getEntries().length - 1]);
+            .makeChildPath(rootPath, prevProp.getQPath().getEntries()[prevProp.getQPath().getEntries().length - 1]);
          TransientPropertyData newProp =
             new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
                .getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
@@ -999,7 +1001,7 @@
          // recreate with new path for child Nodes only
          QPath newPath =
             QPath
-               .makeChildPath(rootPath, prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1]);
+            .makeChildPath(rootPath, prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1]);
          TransientNodeData newNode =
             new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
                .getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
@@ -1034,7 +1036,7 @@
          TransientNodeData newNode =
             new TransientNodeData(prevNode.getQPath(), prevNode.getIdentifier(), prevNode.getPersistedVersion(),
                prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
-                  .getParentIdentifier(), acl);
+               .getParentIdentifier(), acl);
          // update this node
          cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
          // update childs recursive



More information about the exo-jcr-commits mailing list