[exo-jcr-commits] exo-jcr SVN: r4422 - in jcr/branches/1.12.x: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core and 13 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue May 24 06:24:42 EDT 2011


Author: paristote
Date: 2011-05-24 06:24:41 -0400 (Tue, 24 May 2011)
New Revision: 4422

Added:
   jcr/branches/1.12.x/patch/1.12.9-GA/JCR-1611/readme.txt
Modified:
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/DefaultItemDataCopyVisitor.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCacheInClusterMode.java
Log:
JCR-1611

What is the problem to fix?
We need to backport the fix of the jira EXOJCR-1234 to JCR 1.12.x.

How is the problem fixed?
Change the calculation way of last order number during node adding. The new order number will be as real last order number plus 1. 
In previous impl it was as children nodes count plus 1.



Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -91,6 +91,15 @@
     * @return int, child nodes count
     */
    int getChildNodesCount(NodeData parent) throws RepositoryException;
+   
+   /**
+    * Get order number of parent's last child node.
+    * 
+    * @param parent node
+    * @return int Returns last child nodes order number or -1 if there is no subnodes.
+    * @throws RepositoryException
+    */
+   int getLastOrderNumber(NodeData parent) throws RepositoryException;
 
    /**
     * Get child Properties of the parent node.

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -2829,7 +2829,7 @@
 
    private int getNextChildOrderNum() throws RepositoryException
    {
-      return dataManager.getChildNodesCount(nodeData());
+      return dataManager.getLastOrderNumber(nodeData()) + 1;
    }
 
    /**

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -843,6 +843,17 @@
    /**
     * {@inheritDoc}
     */
+   public int getLastOrderNumber(NodeData parent) throws RepositoryException
+   {
+      int lastOrderNumber = changesLog.getLastChildOrderNumber(parent.getIdentifier());
+      int lastPersistedNodeOrderNumber = transactionableManager.getLastOrderNumber(parent);
+
+      return Math.max(lastPersistedNodeOrderNumber, lastOrderNumber);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public int getChildNodesCount(NodeData parent) throws RepositoryException
    {
       int childsCount =

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/DefaultItemDataCopyVisitor.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/DefaultItemDataCopyVisitor.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/DefaultItemDataCopyVisitor.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -154,7 +154,8 @@
       // If ordering is supported by the node type of the parent node of the new
       // location, then the newly moved node is appended to the end of the child node list.
       int orderNum = 0;
-      if (ntManager.isOrderableChildNodesSupported(parent.getPrimaryTypeName(), parent.getMixinTypeNames()))
+      if (level == 0
+         && ntManager.isOrderableChildNodesSupported(parent.getPrimaryTypeName(), parent.getMixinTypeNames()))
       {
          orderNum = calculateNewNodeOrderNumber();
       }
@@ -264,7 +265,7 @@
 
    protected int calculateNewNodeOrderNumber() throws RepositoryException
    {
-      return dataManager.getChildNodesCount(curParent());
+      return dataManager.getLastOrderNumber(curParent()) + 1;
    }
 
    protected QPath calculateNewNodePath(NodeData node, int level) throws RepositoryException

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -158,6 +158,14 @@
    /**
     * {@inheritDoc}
     */
+   public int getLastOrderNumber(final NodeData parent) throws RepositoryException
+   {
+      return persistentManager.getLastOrderNumber(parent);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public int getChildNodesCount(final NodeData parent) throws RepositoryException
    {
       return persistentManager.getChildNodesCount(parent);

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -473,10 +473,27 @@
          con.close();
       }
    }
-
+   
    /**
     * {@inheritDoc}
     */
+   @Override
+   public int getLastOrderNumber(final NodeData nodeData) throws RepositoryException
+   {
+      final WorkspaceStorageConnection con = dataContainer.openConnection();
+      try
+      {
+         return con.getLastOrderNumber(nodeData);
+      }
+      finally
+      {
+         con.close();
+      }
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
    public int getChildNodesCount(NodeData parent) throws RepositoryException
    {
       final WorkspaceStorageConnection con = dataContainer.openConnection();

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -135,6 +135,14 @@
    /**
     * {@inheritDoc}
     */
+   public int getLastOrderNumber(final NodeData parent) throws RepositoryException
+   {
+      return storageDataManager.getLastOrderNumber(parent);
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
    public int getChildNodesCount(final NodeData parent) throws RepositoryException
    {
       return storageDataManager.getChildNodesCount(parent);

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -62,11 +62,24 @@
       new HashMap<String, Map<String, ItemState>>();
 
    /**
-    * Stores persisted child nodes count.  
+    * Stores info for persisted child nodes by parent identifier.
+    * <br>Index in array points to:
+    * <br>0 - child nodes count 
+    * <br>1 - last child order number
     */
-   protected Map<String, int[]> childNodesCount = new HashMap<String, int[]>();
+   protected Map<String, int[]> childNodesInfo = new HashMap<String, int[]>();
 
    /**
+    * Index in <code>childNodesInfo<code> value array to store child nodes count.
+    */
+   protected final int CHILD_NODES_COUNT_INDEX = 0;
+
+   /**
+    * Index in <code>childNodesInfo<code> value array to store last child order number.
+    */
+   protected final int CHILD_NODES_LAST_ORDER_NUMBER_INDEX = 1;
+
+   /**
     * Create empty ChangesLog.
     * 
     * @param sessionId
@@ -129,7 +142,7 @@
       index.clear();
       lastChildNodeStates.clear();
       lastChildPropertyStates.clear();
-      childNodesCount.clear();
+      childNodesInfo.clear();
    }
 
    /**
@@ -153,21 +166,25 @@
             index.remove(item.getData().getQPath());
             index.remove(new ParentIDQPathBasedKey(item));
             index.remove(new IDStateBasedKey(item.getData().getIdentifier(), item.getState()));
-            childNodesCount.remove(item.getData().getIdentifier());
+            childNodesInfo.remove(item.getData().getIdentifier());
             lastChildNodeStates.remove(item.getData().getIdentifier());
             lastChildPropertyStates.remove(item.getData().getIdentifier());
 
             if (item.isNode() && item.isPersisted())
             {
-               int childCount[] = childNodesCount.get(item.getData().getParentIdentifier());
-               if (childCount != null)
+               int childInfo[] = childNodesInfo.get(item.getData().getParentIdentifier());
+               if (childInfo != null)
                {
                   if (item.isDeleted())
-                     ++childCount[0];
+                  {
+                     ++childInfo[CHILD_NODES_COUNT_INDEX];
+                  }
                   else if (item.isAdded())
-                     --childCount[0];
+                  {
+                     --childInfo[CHILD_NODES_COUNT_INDEX];
+                  }
 
-                  childNodesCount.put(item.getData().getParentIdentifier(), childCount);
+                  childNodesInfo.put(item.getData().getParentIdentifier(), childInfo);
                }
             }
 
@@ -412,10 +429,17 @@
 
    public int getChildNodesCount(String rootIdentifier)
    {
-      int[] childCount = childNodesCount.get(rootIdentifier);
-      return childCount == null ? 0 : childCount[0];
+      int[] childInfo = childNodesInfo.get(rootIdentifier);
+      return childInfo == null ? 0 : childInfo[CHILD_NODES_COUNT_INDEX];
    }
 
+   public int getLastChildOrderNumber(String rootIdentifier)
+   {
+
+      int[] childInfo = childNodesInfo.get(rootIdentifier);
+      return childInfo == null ? -1 : childInfo[CHILD_NODES_LAST_ORDER_NUMBER_INDEX];
+   }
+
    /**
     * Collect last in ChangesLog order item child changes.
     * 
@@ -663,16 +687,22 @@
 
       if (item.isNode() && item.isPersisted())
       {
-         int[] childCount = childNodesCount.get(item.getData().getParentIdentifier());
-         if (childCount == null)
-            childCount = new int[1];
+         int[] childInfo = childNodesInfo.get(item.getData().getParentIdentifier());
+         if (childInfo == null)
+         {
+            childInfo = new int[2];
+         }
 
          if (item.isDeleted())
-            --childCount[0];
+         {
+            --childInfo[CHILD_NODES_COUNT_INDEX];
+         }
          else if (item.isAdded())
-            ++childCount[0];
-
-         childNodesCount.put(item.getData().getParentIdentifier(), childCount);
+         {
+            ++childInfo[CHILD_NODES_COUNT_INDEX];
+            childInfo[CHILD_NODES_LAST_ORDER_NUMBER_INDEX] = ((NodeData)item.getData()).getOrderNumber();
+         }
+         childNodesInfo.put(item.getData().getParentIdentifier(), childInfo);
       }
    }
 

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -114,6 +114,37 @@
    /**
     * {@inheritDoc}
     */
+   public int getLastOrderNumber(final NodeData parent) throws RepositoryException
+   {
+      if (txStarted())
+      {
+         int txLastOrderNumber = -1;
+         for (ItemState change : transactionLog.getAllStates())
+         {
+            if (change.isNode() && change.isPersisted() && change.isAdded()
+               && change.getData().getParentIdentifier().equals(parent.getIdentifier()))
+            {
+               int orderNumber = ((NodeData)change.getData()).getOrderNumber();
+               if (orderNumber > txLastOrderNumber)
+               {
+                  txLastOrderNumber = orderNumber;
+               }
+            }
+         }
+
+         int lastOrderNumber = storageDataManager.getLastOrderNumber(parent);
+
+         return Math.max(lastOrderNumber, txLastOrderNumber);
+      }
+      else
+      {
+         return storageDataManager.getLastOrderNumber(parent);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public int getChildNodesCount(final NodeData parent) throws RepositoryException
    {
       if (txStarted())

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -126,6 +126,11 @@
       return null;
    }
 
+   public int getLastOrderNumber(NodeData nodeData) throws RepositoryException
+   {
+      return -1;
+   }
+   
    public int getChildNodesCount(NodeData nodeData) throws RepositoryException
    {
       return 0;

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -128,8 +128,13 @@
     * FIND_NODES_BY_PARENTID.
     */
    protected String FIND_NODES_BY_PARENTID;
-   
+
    /**
+    * FIND_LAST_ORDER_NUMBER_BY_PARENTID.
+    */
+   protected String FIND_LAST_ORDER_NUMBER_BY_PARENTID;
+      
+   /**
     * FIND_NODES_COUNT_BY_PARENTID.
     */
    protected String FIND_NODES_COUNT_BY_PARENTID;

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -151,6 +151,8 @@
 
    protected PreparedStatement findNodesByParentId;
 
+   protected PreparedStatement findLastOrderNumberByParentId;
+
    protected PreparedStatement findNodesCountByParentId;
 
    protected PreparedStatement findPropertiesByParentId;
@@ -459,6 +461,11 @@
             findNodesByParentId.close();
          }
 
+         if (findLastOrderNumberByParentId != null)
+         {
+            findLastOrderNumberByParentId.close();
+         }
+
          if (findNodesCountByParentId != null)
          {
             findNodesCountByParentId.close();
@@ -921,6 +928,44 @@
    /**
     * {@inheritDoc}
     */
+   public int getLastOrderNumber(NodeData parent) throws RepositoryException
+   {
+      checkIfOpened();
+      try
+      {
+         ResultSet count = findLastOrderNumberByParentIdentifier(getInternalId(parent.getIdentifier()));
+         try
+         {
+            if (count.next() && count.getInt(1) > 0)
+            {
+               return count.getInt(2);
+            }
+            else
+            {
+               return -1;
+            }
+         }
+         finally
+         {
+            try
+            {
+               count.close();
+            }
+            catch (SQLException e)
+            {
+               LOG.error("Can't close the ResultSet: " + e);
+            }
+         }
+      }
+      catch (SQLException e)
+      {
+         throw new RepositoryException(e);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public int getChildNodesCount(NodeData parent) throws RepositoryException
    {
       checkIfOpened();
@@ -2454,6 +2499,8 @@
 
    protected abstract ResultSet findChildNodesByParentIdentifier(String parentIdentifier) throws SQLException;
 
+   protected abstract ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException;
+
    protected abstract ResultSet findChildNodesCountByParentIdentifier(String parentIdentifier) throws SQLException;
 
    protected abstract ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException;

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -74,6 +74,8 @@
          "select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
             + " where I.PARENT_ID=? and I.I_CLASS=2 and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
       FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=1" + " order by N_ORDER_NUM";
+      FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+         "select count(*), max(N_ORDER_NUM) from JCR_MITEM where PARENT_ID=? and I_CLASS=1";
       FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=1";
       FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=2" + " order by ID";
    }

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -81,6 +81,8 @@
             + " where I.PARENT_ID=? and I.I_CLASS=2 and I.CONTAINER_NAME=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
       FIND_NODES_BY_PARENTID =
          "select * from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?" + " order by N_ORDER_NUM";
+      FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+         "select count(*), max(N_ORDER_NUM) from JCR_SITEM where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?";
       FIND_NODES_COUNT_BY_PARENTID =
          "select count(ID) from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?";
       FIND_PROPERTIES_BY_PARENTID =
@@ -142,6 +144,23 @@
     * {@inheritDoc}
     */
    @Override
+   protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
+   {
+      if (findLastOrderNumberByParentId == null)
+         findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+      else
+         findLastOrderNumberByParentId.clearParameters();
+
+      findLastOrderNumberByParentId.setString(1, parentIdentifier);
+      findLastOrderNumberByParentId.setString(2, containerName);
+
+      return findLastOrderNumberByParentId.executeQuery();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
    protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
    {
       if (findNodesCountByParentId == null)

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -127,6 +127,9 @@
 
       FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
 
+      FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+         "select count(*), max(N_ORDER_NUM) from JCR_MITEM where I_CLASS=1 and PARENT_ID=?";
+
       FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?";
 
       FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by ID";
@@ -371,6 +374,21 @@
     * {@inheritDoc}
     */
    @Override
+   protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
+   {
+      if (findLastOrderNumberByParentId == null)
+         findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+      else
+         findLastOrderNumberByParentId.clearParameters();
+
+      findLastOrderNumberByParentId.setString(1, parentIdentifier);
+      return findLastOrderNumberByParentId.executeQuery();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
    protected ResultSet findChildNodesCountByParentIdentifier(String parentIdentifier) throws SQLException
    {
       if (findNodesCountByParentId == null)

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -133,6 +133,9 @@
       FIND_NODES_BY_PARENTID =
          "select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
 
+      FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+         "select count(*), max(N_ORDER_NUM) from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
+
       FIND_NODES_COUNT_BY_PARENTID =
          "select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
 
@@ -282,6 +285,22 @@
     * {@inheritDoc}
     */
    @Override
+   protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
+   {
+      if (findLastOrderNumberByParentId == null)
+         findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+      else
+         findLastOrderNumberByParentId.clearParameters();
+
+      findLastOrderNumberByParentId.setString(1, containerName);
+      findLastOrderNumberByParentId.setString(2, parentIdentifier);
+      return findLastOrderNumberByParentId.executeQuery();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
    protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
    {
       if (findNodesCountByParentId == null)

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -78,6 +78,10 @@
          "select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
             + " where I.PARENT_ID=? and I.I_CLASS=2 and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
       FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=1" + " order by N_ORDER_NUM";
+
+      FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+         "select count(*), max(N_ORDER_NUM) from JCR_MITEM where PARENT_ID=? and I_CLASS=1";
+
       FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=1";
       FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=2" + " order by ID";
       FIND_NODES_BY_PARENTID_CQ =

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -85,6 +85,10 @@
             + " where I.PARENT_ID=? and I.I_CLASS=2 and I.CONTAINER_NAME=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
       FIND_NODES_BY_PARENTID =
          "select * from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?" + " order by N_ORDER_NUM";
+
+      FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+         "select count(*), max(N_ORDER_NUM) from JCR_SITEM where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?";
+
       FIND_NODES_COUNT_BY_PARENTID =
          "select count(ID) from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?";
       FIND_PROPERTIES_BY_PARENTID =
@@ -165,6 +169,23 @@
     * {@inheritDoc}
     */
    @Override
+   protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
+   {
+      if (findLastOrderNumberByParentId == null)
+         findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+      else
+         findLastOrderNumberByParentId.clearParameters();
+
+      findLastOrderNumberByParentId.setString(1, parentIdentifier);
+      findLastOrderNumberByParentId.setString(2, containerName);
+
+      return findLastOrderNumberByParentId.executeQuery();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
    protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
    {
       if (findNodesCountByParentId == null)

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -151,6 +151,9 @@
             + " from JCR_MITEM I, (SELECT ID, PARENT_ID from JCR_MITEM where ID=?) J"
             + " where I.ID = J.ID or I.ID = J.PARENT_ID";
 
+      FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+         "select count(*), max(N_ORDER_NUM) from JCR_MITEM where I_CLASS=1 and PARENT_ID=?";
+
       FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?";
 
       FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by NAME";
@@ -413,6 +416,21 @@
     * {@inheritDoc}
     */
    @Override
+   protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
+   {
+      if (findLastOrderNumberByParentId == null)
+         findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+      else
+         findLastOrderNumberByParentId.clearParameters();
+
+      findLastOrderNumberByParentId.setString(1, parentIdentifier);
+      return findLastOrderNumberByParentId.executeQuery();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
    protected ResultSet findChildNodesCountByParentIdentifier(String parentIdentifier) throws SQLException
    {
       if (findNodesCountByParentId == null)

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -157,6 +157,9 @@
             + " from JCR_SITEM I, (SELECT ID, PARENT_ID from JCR_SITEM where ID=?) J"
             + " where I.ID = J.ID or I.ID = J.PARENT_ID";
 
+      FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+         "select count(*), max(N_ORDER_NUM) from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
+
       FIND_NODES_COUNT_BY_PARENTID =
          "select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
 
@@ -308,6 +311,22 @@
     * {@inheritDoc}
     */
    @Override
+   protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
+   {
+      if (findLastOrderNumberByParentId == null)
+         findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+      else
+         findLastOrderNumberByParentId.clearParameters();
+
+      findLastOrderNumberByParentId.setString(1, containerName);
+      findLastOrderNumberByParentId.setString(2, parentIdentifier);
+      return findLastOrderNumberByParentId.executeQuery();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
    protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
    {
       if (findNodesCountByParentId == null)

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -117,6 +117,12 @@
     * <code>getChildNodesCount(NodeData parent)</code>
     */
    private static final String GET_CHILD_NODES_COUNT_DESCR = "getChildNodesCount";
+   
+   /**
+    * The description of the statistics corresponding to the method 
+    * <code>getLastOrderNumber(NodeData parent)</code>
+    */
+   private static final String GET_LAST_ORDER_NUMBER_DESCR = "getLastOrderNumber";
 
    /**
     * The description of the statistics corresponding to the method 
@@ -171,6 +177,8 @@
          GET_ITEM_DATA_BY_NODE_DATA_NQ_PATH_ENTRY_DESCR));
       ALL_STATISTICS.put(GET_CHILD_NODES_DATA_DESCR, new Statistics(GLOBAL_STATISTICS, GET_CHILD_NODES_DATA_DESCR));
       ALL_STATISTICS.put(GET_CHILD_NODES_COUNT_DESCR, new Statistics(GLOBAL_STATISTICS, GET_CHILD_NODES_COUNT_DESCR));
+      ALL_STATISTICS.put(GET_LAST_ORDER_NUMBER_DESCR, new Statistics(GLOBAL_STATISTICS, GET_LAST_ORDER_NUMBER_DESCR));
+      
       ALL_STATISTICS.put(GET_CHILD_PROPERTIES_DATA_DESCR, new Statistics(GLOBAL_STATISTICS,
          GET_CHILD_PROPERTIES_DATA_DESCR));
       ALL_STATISTICS.put(LIST_CHILD_PROPERTIES_DATA_DESCR, new Statistics(GLOBAL_STATISTICS,
@@ -227,7 +235,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#add(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public void add(NodeData data) throws RepositoryException, UnsupportedOperationException, InvalidItemStateException,
       IllegalStateException
@@ -245,7 +253,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#add(org.exoplatform.services.jcr.datamodel.PropertyData)
+    * {@inheritDoc}
     */
    public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException
@@ -263,7 +271,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#close()
+    * {@inheritDoc}
     */
    public void close() throws IllegalStateException, RepositoryException
    {
@@ -280,7 +288,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#commit()
+    * {@inheritDoc}
     */
    public void commit() throws IllegalStateException, RepositoryException
    {
@@ -297,7 +305,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#delete(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException
@@ -315,7 +323,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#delete(org.exoplatform.services.jcr.datamodel.PropertyData)
+    * {@inheritDoc}
     */
    public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException
@@ -333,8 +341,25 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getChildNodesCount(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
+   public int getLastOrderNumber(NodeData parent) throws RepositoryException
+   {
+      Statistics s = ALL_STATISTICS.get(GET_LAST_ORDER_NUMBER_DESCR);
+      try
+      {
+         s.begin();
+         return wcs.getLastOrderNumber(parent);
+      }
+      finally
+      {
+         s.end();
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public int getChildNodesCount(NodeData parent) throws RepositoryException
    {
       Statistics s = ALL_STATISTICS.get(GET_CHILD_NODES_COUNT_DESCR);
@@ -350,7 +375,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getChildNodesData(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
    {
@@ -367,7 +392,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getChildPropertiesData(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
    {
@@ -410,7 +435,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getItemData(java.lang.String)
+    * {@inheritDoc}
     */
    public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
    {
@@ -427,7 +452,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getReferencesData(java.lang.String)
+    * {@inheritDoc}
     */
    public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
       IllegalStateException, UnsupportedOperationException
@@ -445,7 +470,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#isOpened()
+    * {@inheritDoc}
     */
    public boolean isOpened()
    {
@@ -462,7 +487,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#listChildPropertiesData(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
    {
@@ -479,7 +504,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#rename(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException
@@ -497,7 +522,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#rollback()
+    * {@inheritDoc}
     */
    public void rollback() throws IllegalStateException, RepositoryException
    {
@@ -514,7 +539,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#update(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException
@@ -532,7 +557,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#update(org.exoplatform.services.jcr.datamodel.PropertyData)
+    * {@inheritDoc}
     */
    public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -126,6 +126,15 @@
    int getChildNodesCount(NodeData parent) throws RepositoryException;
 
    /**
+    * Reads order number of last <code>parent<code/> child nodes.
+    *
+    * @param parent NodeData
+    * @return long, order number of last parent's child node.
+    * @throws RepositoryException if error occurs
+    */
+   int getLastOrderNumber(NodeData parent) throws RepositoryException;
+   
+   /**
     * Reads <code>List</code> of <code>PropertyData</code> from the storage using item's parent
     * location.
     * 

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -36,14 +36,14 @@
  */
 package org.exoplatform.services.jcr.impl.core;
 
+import org.exoplatform.services.jcr.JcrImplBaseTest;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+
 import javax.jcr.ItemExistsException;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.Session;
 
-import org.exoplatform.services.jcr.JcrImplBaseTest;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-
 /**
  * Created by The eXo Platform SAS.
  * 
@@ -227,7 +227,7 @@
          assertEquals(order++, orderNumb);
       }
    }
-   
+
    public void testOrderWithRefreshKeep() throws Exception
    {
       Node testNode = root.addNode("testNode");
@@ -268,4 +268,41 @@
       }
    }
 
+   public void testRemoveOrder() throws Exception
+   {
+      Node list = session.getRootNode().addNode("list");
+      assertTrue(list.getPrimaryNodeType().hasOrderableChildNodes());
+      list.addNode("foo", "nt:unstructured");
+      list.addNode("bar", "nt:unstructured");
+      list.addNode("juu", "nt:unstructured");
+      session.save();
+
+      list = session.getRootNode().getNode("list");
+      list.getNode("bar").remove();
+      session.save();
+
+      list = session.getRootNode().getNode("list");
+      list.addNode("daa", "nt:unstructured");
+      session.save();
+
+      //check order numbers
+      NodeImpl foo = (NodeImpl)list.getNode("foo");
+      assertEquals(0, ((NodeData)foo.getData()).getOrderNumber());
+      NodeImpl juu = (NodeImpl)list.getNode("juu");
+      assertEquals(2, ((NodeData)juu.getData()).getOrderNumber());
+      NodeImpl daa = (NodeImpl)list.getNode("daa");
+      assertEquals(3, ((NodeData)daa.getData()).getOrderNumber());
+
+      //     list.orderBefore("daa", null);
+      NodeIterator it = list.getNodes();
+      foo = (NodeImpl)it.nextNode();
+      assertEquals("foo", foo.getName());
+      juu = (NodeImpl)it.nextNode();
+      assertEquals("juu", juu.getName());
+      daa = (NodeImpl)it.nextNode();
+      assertEquals("daa", daa.getName());
+      assertFalse(it.hasNext());
+      session.save();
+   }
+
 }

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -526,6 +526,12 @@
       {
       }
 
+      @Override
+      public int getLastOrderNumber(NodeData parent) throws RepositoryException
+      {
+         return -1;
+      }
+
    };
 
    private static class MyWorkspaceDataContainer extends WorkspaceDataContainerBase

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCacheInClusterMode.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCacheInClusterMode.java	2011-05-24 10:07:21 UTC (rev 4421)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCacheInClusterMode.java	2011-05-24 10:24:41 UTC (rev 4422)
@@ -96,6 +96,7 @@
          // Test getChildNodesData
          Action readAction = new Action(cwdmNode2)
          {
+            @Override
             public void execute(NodeData parentNode) throws Exception
             {
                cwdm.getChildNodesData(parentNode);
@@ -103,6 +104,7 @@
          };
          Action writeAction = new Action(cwdmNode1)
          {
+            @Override
             public void execute(NodeData parentNode) throws Exception
             {
                PlainChangesLog chlog = new PlainChangesLogImpl();            
@@ -127,6 +129,7 @@
          // Test getChildPropertiesData
          readAction = new Action(cwdmNode2)
          {
+            @Override
             public void execute(NodeData parentNode) throws Exception
             {
                cwdm.getChildPropertiesData(parentNode);
@@ -134,6 +137,7 @@
          };
          writeAction = new Action(cwdmNode1)
          {
+            @Override
             public void execute(NodeData parentNode) throws Exception
             {
                PlainChangesLog chlog = new PlainChangesLogImpl();            
@@ -161,6 +165,7 @@
          // Test getReferencesData
          readAction = new Action(cwdmNode2)
          {
+            @Override
             public void execute(NodeData parentNode) throws Exception
             {
                cwdm.getReferencesData(parentNode.getIdentifier(), false);
@@ -168,6 +173,7 @@
          };
          writeAction = new Action(cwdmNode1)
          {
+            @Override
             public void execute(NodeData parentNode) throws Exception
             {
                PlainChangesLog chlog = new PlainChangesLogImpl();            
@@ -196,6 +202,7 @@
          // Test getItemData by Id
          readAction = new Action(cwdmNode2)
          {
+            @Override
             public void execute(NodeData parentNode) throws Exception
             {
                cwdm.getItemData(parentNode.getIdentifier());
@@ -203,6 +210,7 @@
          };
          writeAction = new Action(cwdmNode1)
          {
+            @Override
             public void execute(NodeData parentNode) throws Exception
             {
                PlainChangesLog chlog = new PlainChangesLogImpl();
@@ -231,6 +239,7 @@
          final QPathEntry qpe = new QPathEntry(null, "my-property", 1);
          readAction = new Action(cwdmNode2)
          {
+            @Override
             public void execute(NodeData parentNode) throws Exception
             {
                cwdm.getItemData(parentNode, qpe, ItemType.PROPERTY);
@@ -238,6 +247,7 @@
          };
          writeAction = new Action(cwdmNode1)
          {
+            @Override
             public void execute(NodeData parentNode) throws Exception
             {
                PlainChangesLog chlog = new PlainChangesLogImpl();
@@ -308,6 +318,7 @@
       final CountDownLatch doneSignal = new CountDownLatch(2);
       Thread writer = new Thread()
       {
+         @Override
          public void run()
          {
             try
@@ -331,6 +342,7 @@
       writer.start();
       Thread reader = new Thread()
       {
+         @Override
          public void run()
          {
             try
@@ -593,6 +605,11 @@
          InvalidItemStateException, IllegalStateException
       {
       }
+
+      public int getLastOrderNumber(NodeData parent) throws RepositoryException
+      {
+         return -1;
+      }
    };
    
    private static class MyWorkspaceDataContainer extends WorkspaceDataContainerBase

Added: jcr/branches/1.12.x/patch/1.12.9-GA/JCR-1611/readme.txt
===================================================================
--- jcr/branches/1.12.x/patch/1.12.9-GA/JCR-1611/readme.txt	                        (rev 0)
+++ jcr/branches/1.12.x/patch/1.12.9-GA/JCR-1611/readme.txt	2011-05-24 10:24:41 UTC (rev 4422)
@@ -0,0 +1,63 @@
+Summary
+
+    Status: Create testing repositories for version 1.12.x
+    CCP Issue: JCR-1234, Product Jira Issue: JCR-1611.
+    Complexity: Low
+
+The Proposal
+Problem description
+
+What is the problem to fix?
+We need to backport the fix of the jira EXOJCR-1234 to JCR 1.12.x.
+Fix description
+
+How is the problem fixed?
+
+     Change the calculation way of last order number during node adding. The new order number will be as real last order number plus 1. In previous impl it was as children nodes count plus 1.
+
+Patch information: JCR-1611.patch
+
+Tests to perform
+
+Reproduction test
+
+* TestNodeOrder.java* *
+
+Tests performed at DevLevel
+  * functional testing in jcr core project
+
+Tests performed at QA/Support Level
+*
+
+Documentation changes
+
+Documentation changes:
+  * no
+
+Configuration changes
+
+Configuration changes:
+  * No
+
+Will previous configuration continue to work?
+  * Yes
+
+Risks and impacts
+
+Can this bug fix have any side effects on current client projects?
+
+    No
+
+Is there a performance risk/cost?
+  * Workspace.copy() method could be a bit slower. See tests results http://tests.exoplatform.org/JCR/1.12.9-GA/rev.4331_testukr_230/daily-performance-testing-results/jcr.core/index.html
+Validation (PM/Support/QA)
+
+PM Comment
+* PL review: Patch validated
+
+Support Comment
+* Support review: Patch validated
+
+QA Feedbacks
+*
+



More information about the exo-jcr-commits mailing list