[exo-jcr-commits] exo-jcr SVN: r621 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core and 6 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Nov 12 21:37:52 EST 2009
Author: pnedonosko
Date: 2009-11-12 21:37:50 -0500 (Thu, 12 Nov 2009)
New Revision: 621
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
Log:
EXOJCR-221: optimization of ordernumber and SNS calculations
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -28,48 +28,72 @@
import javax.jcr.RepositoryException;
/**
- * Created by The eXo Platform SAS.
+ * Created by The eXo Platform SAS.<br/>
*
- * @author <a href="mailto:geaz at users.sourceforge.net">Gennady Azarenkov</a>
- * @version $Id: ItemDataConsumer.java 11907 2008-03-13 15:36:21Z ksm $
+ * Basic (Level 1) data flow inmemory operations<br/>
*
- * Basic (Level 1) data flow inmemory operations
- *
* Common Rule for Read : If there is some storage in this manager � try to get the data
* from here first, if not found � call super.someMethod
+ *
+ * @author <a href="mailto:geaz at users.sourceforge.net">Gennady Azarenkov</a>
+ * @version $Id$
*/
public interface ItemDataConsumer
{
/**
- * @param parent
- * @param name
- * @return data by parent and name
+ * Find Item by parent (id) and name (with path index).
+ *
+ * @param parent NodeData
+ * @param name QPathEntry
+ * @return ItemData, data by parent and name
* @throws RepositoryException
*/
ItemData getItemData(NodeData parent, QPathEntry name) throws RepositoryException;
/**
- * @param identifier
- * @return data by identifier
+ * Find Item by identifier.
+ *
+ * @param String identifier
+ * @return ItemData, data by identifier
*/
ItemData getItemData(String identifier) throws RepositoryException;
/**
- * @param parentIdentifier
- * @return children data
+ * Get child Nodes of the parent node.
+ *
+ * @param parent NodeData
+ * @return List of children Nodes
*/
List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException;
/**
- * @param parentIdentifier
- * @return children data
+ * Get children nodes count of the parent node.
+ * @param parent NodeData
+ * @return int, child nodes count
*/
+ int getChildNodesCount(NodeData parent) throws RepositoryException;
+
+ /**
+ * Get child Properties of the parent node.
+ *
+ * @param parent NodeData
+ * @return List of children Properties
+ */
List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException;
- List<PropertyData> listChildPropertiesData(final NodeData nodeData) throws RepositoryException;
+ /**
+ * List child Properties, returned list will contains Properties without actual Values.
+ *
+ * @param parent NodeData
+ * @return List of PropertyData
+ * @throws RepositoryException
+ */
+ List<PropertyData> listChildPropertiesData(final NodeData parent) throws RepositoryException;
/**
+ * Get Referenced properties.
+ *
* @param identifier
* - referenceable id
* @param skipVersionStorage
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -956,7 +956,7 @@
+ itemPath.getAsString(false));
return (NodeImpl)node;
}
-
+
/**
* {@inheritDoc}
*/
@@ -2488,16 +2488,92 @@
// ----------------------------- ExtendedNode -----------------------------
- private int getNextChildOrderNum(List<NodeData> siblings)
+ private int getNextChildOrderNum() throws RepositoryException
{
- int max = -1;
+ // int max = -1;
+ // for (NodeData sibling : siblings)
+ // {
+ // int cur = sibling.getOrderNumber();
+ // if (cur > max)
+ // max = cur;
+ // }
+ // return ++max;
+
+ //return siblings.size();
+
+ return dataManager.getChildNodesCount(nodeData());
+ }
+
+ private int getNextChildIndex(InternalQName nameToAdd, NodeData parentNode) throws RepositoryException,
+ ItemExistsException
+ {
+
+ NodeDefinitionData def =
+ session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(nameToAdd, parentNode.getPrimaryTypeName(),
+ parentNode.getMixinTypeNames());
+
+ boolean allowSns = def.isAllowsSameNameSiblings();
+
+ int ind = 1;
+
+ NodeData sibling = (NodeData)dataManager.getItemData(parentNode, new QPathEntry(nameToAdd, ind));
+ while (sibling != null)
+ {
+ if (allowSns)
+ {
+ ind++;
+ sibling = (NodeData)dataManager.getItemData(parentNode, new QPathEntry(nameToAdd, ind));
+ }
+ else
+ {
+ throw new ItemExistsException("The node " + nameToAdd + " already exists in " + getPath()
+ + " and same name sibling is not allowed ");
+ }
+ };
+
+ return ind;
+
+ // int ind = 0;
+ // for (NodeData sibling : siblings)
+ // {
+ // if (sibling.getQPath().getName().equals(nameToAdd))
+ // {
+ // if (allowSns)
+ // ind++;
+ // else
+ // throw new ItemExistsException("The node " + nameToAdd + " already exists in " + getPath()
+ // + " and same name sibling is not allowed ");
+ // }
+ // }
+ // return ind + 1;
+
+ }
+
+ // old impl
+ @Deprecated
+ private int getNextChildIndex(InternalQName nameToAdd, List<NodeData> siblings, NodeData parentNode)
+ throws RepositoryException, ItemExistsException
+ {
+
+ int ind = 0;
for (NodeData sibling : siblings)
{
- int cur = sibling.getOrderNumber();
- if (cur > max)
- max = cur;
+ if (sibling.getQPath().getName().equals(nameToAdd))
+ {
+ NodeDefinitionData def =
+ session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(nameToAdd,
+ parentNode.getPrimaryTypeName(), parentNode.getMixinTypeNames());
+ if (LOG.isDebugEnabled())
+ LOG.debug("Calculate index for " + nameToAdd + " " + sibling.getQPath().getAsString());
+
+ if (def.isAllowsSameNameSiblings())
+ ind++;
+ else
+ throw new ItemExistsException("The node " + nameToAdd + " already exists in " + getPath()
+ + " and same name sibling is not allowed ");
+ }
}
- return ++max;
+ return ind + 1;
}
private NodeImpl doAddNode(NodeImpl parentNode, InternalQName name, InternalQName primaryTypeName)
@@ -2510,9 +2586,9 @@
InternalQName[] mixinTypeNames = new InternalQName[0];
String identifier = IdGenerator.generate();
- List<NodeData> siblings = dataManager.getChildNodesData(parentNode.nodeData());
- int orderNum = parentNode.getNextChildOrderNum(siblings);
- int index = parentNode.getNextChildIndex(name, siblings, parentNode.nodeData());
+ //List<NodeData> siblings = dataManager.getChildNodesData(parentNode.nodeData());
+ int orderNum = parentNode.getNextChildOrderNum();
+ int index = parentNode.getNextChildIndex(name, parentNode.nodeData());
QPath path = QPath.makeChildPath(parentNode.getInternalPath(), name, index);
@@ -2546,35 +2622,8 @@
session.getActionHandler().postAddNode(node);
return node;
-
}
- private int getNextChildIndex(InternalQName nameToAdd, List<NodeData> siblings, NodeData parentNode)
- throws RepositoryException, ItemExistsException
- {
-
- int ind = 0;
- for (NodeData sibling : siblings)
- {
- if (sibling.getQPath().getName().equals(nameToAdd))
- {
- NodeDefinitionData def =
- session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(nameToAdd,
- parentNode.getPrimaryTypeName(), parentNode.getMixinTypeNames());
- if (LOG.isDebugEnabled())
- LOG.debug("Calculate index for " + nameToAdd + " " + sibling.getQPath().getAsString());
-
- if (def.isAllowsSameNameSiblings())
- ind++;
- else
- throw new ItemExistsException("The node " + nameToAdd + " already exists in " + getPath()
- + " and same name sibling is not allowed ");
- }
- }
- return ind + 1;
-
- }
-
private int getOrderNumber()
{
return nodeData().getOrderNumber();
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -674,6 +674,39 @@
/**
* {@inheritDoc}
*/
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ int childsCount = 0;
+
+ for (ItemState change : changesLog.getAllStates())
+ {
+ if (change.isNode() && change.isPersisted()
+ && change.getData().getParentIdentifier().equals(parent.getIdentifier()))
+ {
+ if (change.isDeleted())
+ {
+ childsCount--;
+ }
+ else if (change.isAdded())
+ {
+ childsCount++;
+ }
+ }
+ }
+
+ childsCount = transactionableManager.getChildNodesCount(parent) + childsCount;
+ if (childsCount < 0)
+ {
+ throw new InvalidItemStateException("Node's child nodes were changed in another Session "
+ + parent.getQPath().getAsString());
+ }
+
+ return childsCount;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException
{
long start = 0;
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -18,6 +18,12 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
+import java.util.Calendar;
+import java.util.List;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.SharedDataManager;
@@ -28,12 +34,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.util.Calendar;
-import java.util.List;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS. Data Manager supported ACL Inheritance
*
@@ -124,6 +124,9 @@
return node;
}
+ /**
+ * {@inheritDoc}
+ */
// ------------ ItemDataConsumer impl ------------
public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException
@@ -133,29 +136,52 @@
initACL(parent, node);
return nodes;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(final NodeData parent) throws RepositoryException
+ {
+ return persistentManager.getChildNodesCount(parent);
+ }
+ /**
+ * {@inheritDoc}
+ */
public ItemData getItemData(NodeData parent, QPathEntry name) throws RepositoryException
{
final ItemData item = persistentManager.getItemData(parent, name);
return item != null && item.isNode() ? initACL(parent, (NodeData)item) : item;
}
+ /**
+ * {@inheritDoc}
+ */
public ItemData getItemData(String identifier) throws RepositoryException
{
final ItemData item = persistentManager.getItemData(identifier);
return item != null && item.isNode() ? initACL(null, (NodeData)item) : item;
}
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException
{
return persistentManager.getChildPropertiesData(parent);
}
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException
{
return persistentManager.listChildPropertiesData(parent);
}
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> getReferencesData(String identifier, boolean skipVersionStorage)
throws RepositoryException
{
@@ -164,12 +190,18 @@
// ------------ SharedDataManager ----------------------
+ /**
+ * {@inheritDoc}
+ */
public void save(ItemStateChangesLog changes) throws InvalidItemStateException, UnsupportedOperationException,
RepositoryException
{
persistentManager.save(changes);
}
+ /**
+ * {@inheritDoc}
+ */
public Calendar getCurrentTime()
{
return persistentManager.getCurrentTime();
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -369,6 +369,18 @@
}
}
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ if (cache.isEnabled())
+ {
+ List<NodeData> childNodes = cache.getChildNodes(parent);
+ if (childNodes != null)
+ return childNodes.size();
+ }
+
+ return super.getChildNodesCount(parent);
+ }
+
/**
* Get child PropertyData.
*
@@ -453,7 +465,7 @@
}
return propertiesList;
}
-
+
/**
* {@inheritDoc}
*/
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -18,6 +18,12 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
import org.exoplatform.services.jcr.dataflow.DataManager;
@@ -36,12 +42,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS. Responsible for: *redirecting repository operations if item is
* descendant of /jcr:system/jcr:versionStorage *adding version history for newly added/assigned
@@ -72,11 +72,8 @@
this.versionDataManager = (ACLInheritanceSupportedWorkspaceDataManager)systemDataManager;
}
- /*
- * (non-Javadoc)
- *
- * @see org.exoplatform.services.jcr.impl.core.WorkspaceDataManager#getChildNodes(org.exoplatform.services
- * .jcr.datamodel.NodeData)
+ /**
+ * {@inheritDoc}
*/
@Override
public List<NodeData> getChildNodesData(final NodeData nodeData) throws RepositoryException
@@ -87,12 +84,22 @@
}
return super.getChildNodesData(nodeData);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getChildNodesCount(final NodeData parent) throws RepositoryException
+ {
+ if (isSystemDescendant(parent.getQPath()) && !this.equals(versionDataManager))
+ {
+ return versionDataManager.getChildNodesCount(parent);
+ }
+ return super.getChildNodesCount(parent);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.exoplatform.services.jcr.impl.core.WorkspaceDataManager#getChildProperties(org.exoplatform
- * .services.jcr.datamodel.NodeData)
+ /**
+ * {@inheritDoc}
*/
@Override
public List<PropertyData> getChildPropertiesData(final NodeData nodeData) throws RepositoryException
@@ -104,6 +111,10 @@
return super.getChildPropertiesData(nodeData);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public List<PropertyData> listChildPropertiesData(final NodeData nodeData) throws RepositoryException
{
if (isSystemDescendant(nodeData.getQPath()) && !this.equals(versionDataManager))
@@ -113,6 +124,10 @@
return super.listChildPropertiesData(nodeData);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
if (parentData != null)
@@ -127,8 +142,9 @@
}
/**
- * @see org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager#getItemData(java.lang.String)
+ * {@inheritDoc}
*/
+ @Override
public ItemData getItemData(String identifier) throws RepositoryException
{
// from cache at first
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -290,6 +290,22 @@
con.close();
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ final WorkspaceStorageConnection con = dataContainer.openConnection();
+ try
+ {
+ return con.getChildNodesCount(parent);
+ }
+ finally
+ {
+ con.close();
+ }
+ }
/**
* {@inheritDoc}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -97,6 +97,9 @@
storageDataManager.save(newLog);
}
+ /**
+ * {@inheritDoc}
+ */
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
return copyItemData(storageDataManager.getItemData(parentData, name));
@@ -117,6 +120,14 @@
{
return copyNodes(storageDataManager.getChildNodesData(parent));
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(final NodeData parent) throws RepositoryException
+ {
+ return storageDataManager.getChildNodesCount(parent);
+ }
/**
* {@inheritDoc}
@@ -126,6 +137,9 @@
return copyProperties(storageDataManager.getChildPropertiesData(parent));
}
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException
{
return copyPropertiesWithoutValues(storageDataManager.listChildPropertiesData(parent));
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -76,11 +76,8 @@
}
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.dataflow.PlainChangesLog#add(org.exoplatform.services.jcr.dataflow
- * .ItemState)
+ /**
+ * {@inheritDoc}
*/
@Override
public PlainChangesLog add(ItemState change)
@@ -91,9 +88,8 @@
return this;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.dataflow.PlainChangesLog#addAll(java.util.List)
+ /**
+ * {@inheritDoc}
*/
@Override
public PlainChangesLog addAll(List<ItemState> changes)
@@ -107,9 +103,8 @@
return this;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.dataflow.PlainChangesLog#clear()
+ /**
+ * {@inheritDoc}
*/
@Override
public void clear()
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -94,6 +94,45 @@
/**
* {@inheritDoc}
*/
+ public int getChildNodesCount(final NodeData parent) throws RepositoryException
+ {
+ if (txStarted())
+ {
+ int txChildsCount = 0;
+ for (ItemState change : transactionLog.getAllStates())
+ {
+ if (change.isNode() && change.isPersisted()
+ && change.getData().getParentIdentifier().equals(parent.getIdentifier()))
+ {
+ if (change.isDeleted())
+ {
+ txChildsCount--;
+ }
+ else if (change.isAdded())
+ {
+ txChildsCount++;
+ }
+ }
+ }
+
+ final int childsCount = storageDataManager.getChildNodesCount(parent) + txChildsCount;
+ if (childsCount < 0)
+ {
+ throw new InvalidItemStateException("Node's child nodes were changed in another Transaction "
+ + parent.getQPath().getAsString());
+ }
+
+ return childsCount;
+ }
+ else
+ {
+ return storageDataManager.getChildNodesCount(parent);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException
{
List<PropertyData> props = storageDataManager.getChildPropertiesData(parent);
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -126,6 +126,11 @@
* FIND_NODES_BY_PARENTID.
*/
protected String FIND_NODES_BY_PARENTID;
+
+ /**
+ * FIND_NODES_COUNT_BY_PARENTID.
+ */
+ protected String FIND_NODES_COUNT_BY_PARENTID;
/**
* FIND_PROPERTIES_BY_PARENTID.
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -600,6 +600,29 @@
throw new RepositoryException(e);
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(NodeData parent) throws RepositoryException {
+ checkIfOpened();
+ try
+ {
+ ResultSet count = findChildNodesCountByParentIdentifier(getInternalId(parent.getIdentifier()));
+ if (count.next())
+ {
+ return count.getInt(1);
+ }
+ else
+ {
+ throw new RepositoryException("FATAL No resulton childNodes count for " + parent.getQPath().getAsString());
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
/**
* {@inheritDoc}
@@ -1871,6 +1894,8 @@
protected abstract ResultSet findItemByName(String parentId, String name, int index) throws SQLException;
protected abstract ResultSet findChildNodesByParentIdentifier(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.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -74,6 +74,7 @@
"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_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.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -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_NODES_COUNT_BY_PARENTID =
+ "select count(ID) from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?";
FIND_PROPERTIES_BY_PARENTID =
"select * from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=2 and CONTAINER_NAME=?" + " order by ID";
}
@@ -135,7 +137,23 @@
findNodesByParentId.setString(2, containerName);
return findNodesByParentId.executeQuery();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
+ {
+ if (findNodesCountByParentId == null)
+ findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ else
+ findNodesCountByParentId.clearParameters();
+ findNodesCountByParentId.setString(1, parentCid);
+ findNodesCountByParentId.setString(2, containerName);
+ return findNodesCountByParentId.executeQuery();
+ }
+
/**
* {@inheritDoc}
*/
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -77,6 +77,8 @@
protected PreparedStatement findValueByPropertyIdOrderNumber;
protected PreparedStatement findNodesByParentId;
+
+ protected PreparedStatement findNodesCountByParentId;
protected PreparedStatement findPropertiesByParentId;
@@ -185,6 +187,8 @@
FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA from JCR_MVALUE where PROPERTY_ID=? and ORDER_NUM=?";
FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
+
+ 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";
@@ -428,6 +432,21 @@
* {@inheritDoc}
*/
@Override
+ protected ResultSet findChildNodesCountByParentIdentifier(String parentIdentifier) throws SQLException
+ {
+ if (findNodesCountByParentId == null)
+ findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ else
+ findNodesCountByParentId.clearParameters();
+
+ findNodesCountByParentId.setString(1, parentIdentifier);
+ return findNodesCountByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException
{
if (findPropertiesByParentId == null)
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -74,6 +74,8 @@
protected PreparedStatement findValueByPropertyIdOrderNumber;
protected PreparedStatement findNodesByParentId;
+
+ protected PreparedStatement findNodesCountByParentId;
protected PreparedStatement findPropertiesByParentId;
@@ -193,6 +195,8 @@
FIND_NODES_BY_PARENTID =
"select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
+ FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
+
FIND_PROPERTIES_BY_PARENTID =
"select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
@@ -334,7 +338,23 @@
findNodesByParentId.setString(2, parentCid);
return findNodesByParentId.executeQuery();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
+ {
+ if (findNodesCountByParentId == null)
+ findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ else
+ findNodesCountByParentId.clearParameters();
+ findNodesCountByParentId.setString(1, containerName);
+ findNodesCountByParentId.setString(2, parentCid);
+ return findNodesCountByParentId.executeQuery();
+ }
+
/**
* {@inheritDoc}
*/
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java 2009-11-12 19:01:52 UTC (rev 620)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -93,6 +93,15 @@
* if connection is closed
*/
List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException;
+
+ /**
+ * Reads count of <code>parent<code/> child nodes.
+ *
+ * @param parent NodeData
+ * @return long, childs count
+ * @throws RepositoryException if error occurs
+ */
+ int getChildNodesCount(NodeData parent) throws RepositoryException;
/**
* Reads <code>List</code> of <code>PropertyData</code> from the storage using item's parent
Added: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java (rev 0)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java 2009-11-13 02:37:50 UTC (rev 621)
@@ -0,0 +1,271 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.core;
+
+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.
+ *
+ * <br/>Date: 13.11.2009
+ *
+ * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a>
+ * @version $Id$
+ */
+public class TestNodeOrder extends JcrImplBaseTest
+{
+
+ public void testOrder() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+ testNode.addNode("z");
+ session.save();
+ testNode.addNode("a");
+ session.save();
+ testNode.addNode("b");
+ session.save();
+ testNode.addNode("c");
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(4, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+ public void testOrderInSession() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("a");
+ testNode.addNode("z");
+ testNode.addNode("a");
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(4, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+ public void testOrderCombined() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("a");
+ testNode.addNode("z");
+ testNode.addNode("a");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("y");
+ session.save();
+
+ testNode.addNode("c");
+ testNode.addNode("a");
+ session.save();
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(8, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+ public void testOrderWithRefreshDiscard() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("a");
+ testNode.addNode("z");
+ testNode.addNode("a");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("y");
+ root.refresh(false); // discard added a and y
+
+ testNode.addNode("c");
+ testNode.addNode("a");
+ session.save();
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(6, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+ public void testOrderWithInvalidation() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("a");
+ testNode.addNode("z");
+ testNode.addNode("a");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("y");
+
+ // add some in another session
+ Session another = repository.login(credentials, root.getSession().getWorkspace().getName());
+ Node anotherTest = another.getRootNode().getNode("testNode");
+ another.save();
+ anotherTest.addNode("a");
+ anotherTest.addNode("y");
+ another.save();
+ another.logout();
+
+ try
+ {
+ session.save();
+ fail("Nodes already added in another session, ItemExistsException should be thrown");
+ }
+ catch (ItemExistsException e)
+ {
+ // ok
+ root.refresh(false); // discard a and y
+ }
+
+ testNode.addNode("c");
+ testNode.addNode("a");
+ session.save();
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(8, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+ public void testOrderWithRefreshKeep() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("a");
+ testNode.addNode("z");
+ testNode.addNode("a");
+ session.save();
+
+ // add some in another session
+ Session another = repository.login(credentials, root.getSession().getWorkspace().getName());
+ Node anotherTest = another.getRootNode().getNode("testNode");
+ another.save();
+ anotherTest.addNode("a");
+ anotherTest.addNode("y");
+ another.save();
+ another.logout();
+
+ //root.refresh(true); // refresh to see another Session
+ testNode.addNode("a");
+ testNode.addNode("y");
+ session.save();
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(8, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+}
Property changes on: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
More information about the exo-jcr-commits
mailing list