Author: nfilotto
Date: 2010-02-08 10:49:38 -0500 (Mon, 08 Feb 2010)
New Revision: 1731
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-305: To avoid calling the LockManager for new nodes, we first check if the node is
new before calling the LockManager, if the node is new we try to check its parent node
until we find an old node to test
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-02-08
15:41:54 UTC (rev 1730)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-02-08
15:49:38 UTC (rev 1731)
@@ -1355,10 +1355,41 @@
{
checkValid();
- return session.getLockManager().isLocked((NodeData)this.getData());
+ return isLocked(this);
}
/**
+ * Checks if a given node is locked only if the node is not new otherwise, we check
the first
+ * ancestor that is not new
+ * @param node the node to check
+ * @return <code>true</code> if the node is locked,
<code>false</code> otherwise
+ * @throws RepositoryException if an error occurs
+ */
+ private boolean isLocked(NodeImpl node) throws RepositoryException
+ {
+ if (dataManager.isNew(node.getInternalIdentifier()))
+ {
+ // The node is new, so we will check directly its parent instead
+ NodeImpl parent = node.getParent();
+ if (parent == null)
+ {
+ // The node is the root node and is new, so we consider it as unlocked
+ return false;
+ }
+ else
+ {
+ // the node has a parent that we need to test
+ return isLocked(parent);
+ }
+ }
+ else
+ {
+ // The node already exists so we need to check if it is locked
+ return session.getLockManager().isLocked((NodeData)node.getData());
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
public boolean isNode()