Author: jverhaeg(a)redhat.com
Date: 2008-09-17 12:01:02 -0400 (Wed, 17 Sep 2008)
New Revision: 526
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNode.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java
Log:
Corrected JcrNode's getParent() method to use new getNode(UUID) method on JcrSession
instead of getNodeByUUID(String), which is currently an unsupported operation.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNode.java 2008-09-17 15:37:31 UTC
(rev 525)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNode.java 2008-09-17 16:01:02 UTC
(rev 526)
@@ -22,6 +22,7 @@
package org.jboss.dna.jcr;
import java.util.UUID;
+import javax.jcr.ItemNotFoundException;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -79,8 +80,12 @@
*
* @see javax.jcr.Item#getParent()
*/
- public Node getParent() throws RepositoryException {
- return getSession().getNodeByUUID(parentUuid.toString());
+ public Node getParent() throws ItemNotFoundException {
+ Node node = ((JcrSession)getSession()).getNode(parentUuid);
+ if (node == null) {
+ throw new ItemNotFoundException();
+ }
+ return node;
}
/**
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2008-09-17 15:37:31 UTC
(rev 525)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2008-09-17 16:01:02 UTC
(rev 526)
@@ -67,7 +67,7 @@
* @author Randall Hauch
*/
@NotThreadSafe
-final class JcrSession implements Session {
+class JcrSession implements Session {
private final Repository repository;
private final ExecutionContext executionContext;
@@ -300,12 +300,9 @@
if (dnaUuidProp == null) dnaUuidProp =
command.getPropertiesByName().get(DnaLexicon.UUID);
if (dnaUuidProp != null) {
UUID uuid =
executionContext.getValueFactories().getUuidFactory().create(dnaUuidProp.getValues()).next();
- WeakReference<Node> ref = nodesByUuid.get(uuid);
- if (ref != null) {
- Node node = ref.get();
- if (node != null) {
- return node;
- }
+ Node node = getNode(uuid);
+ if (node != null) {
+ return node;
}
}
// If not create a new one & populate it
@@ -317,6 +314,11 @@
return node;
}
+ Node getNode( UUID uuid ) {
+ WeakReference<Node> ref = nodesByUuid.get(uuid);
+ return (ref == null ? null : ref.get());
+ }
+
/**
* {@inheritDoc}
*
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java 2008-09-17 15:37:31 UTC
(rev 525)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java 2008-09-17 16:01:02 UTC
(rev 526)
@@ -30,7 +30,6 @@
import javax.jcr.ItemNotFoundException;
import javax.jcr.Node;
import javax.jcr.Property;
-import javax.jcr.Session;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path.Segment;
import org.junit.Before;
@@ -47,7 +46,7 @@
private JcrNode node;
private Node root;
@Mock
- private Session session;
+ private JcrSession session;
@Before
public void before() throws Exception {
@@ -60,7 +59,7 @@
stub(segment.getIndex()).toReturn(2);
UUID uuid = UUID.randomUUID();
node = new JcrNode(session, uuid, segment);
- stub(session.getNodeByUUID(uuid.toString())).toReturn(root);
+ stub(session.getNode(uuid)).toReturn(root);
node.setProperties(new HashSet<Property>());
node.setChildren(new ArrayList<Segment>());
}
Show replies by date