You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by st...@apache.org on 2010/06/07 17:28:26 UTC

svn commit: r952269 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/ jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ jackrabbit-jcr-...

Author: stefan
Date: Mon Jun  7 15:28:25 2010
New Revision: 952269

URL: http://svn.apache.org/viewvc?rev=952269&view=rev
Log:
JCR-2648: PropertyImpl.getNode() and NamePropertyTest use different exception than documented in the JCR API JavaDoc

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientProperty.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BinaryPropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NamePropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathPropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=952269&r1=952268&r2=952269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java Mon Jun  7 15:28:25 2010
@@ -24,8 +24,10 @@ import java.util.Calendar;
 
 import javax.jcr.Binary;
 import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.ItemVisitor;
 import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -536,7 +538,11 @@ public class PropertyImpl extends ItemIm
                 String path = value.getString();
                 Path p = session.getQPath(path);
                 boolean absolute = p.isAbsolute();
-                return (absolute) ? session.getNode(path) : getParent().getNode(path);
+                try {
+                    return (absolute) ? session.getNode(path) : getParent().getNode(path);
+                } catch (PathNotFoundException e) {
+                    throw new ItemNotFoundException(path);
+                }
 
             case PropertyType.STRING:
                 try {
@@ -547,7 +553,11 @@ public class PropertyImpl extends ItemIm
                     Value pathValue = ValueHelper.convert(value, PropertyType.PATH, session.getValueFactory());
                     p = session.getQPath(pathValue.getString());
                     absolute = p.isAbsolute();
-                    return (absolute) ? session.getNode(pathValue.getString()) : getParent().getNode(pathValue.getString());
+                    try {
+                        return (absolute) ? session.getNode(pathValue.getString()) : getParent().getNode(pathValue.getString());
+                    } catch (PathNotFoundException e1) {
+                        throw new ItemNotFoundException(pathValue.getString());
+                    }
                 }
 
             default:
@@ -566,7 +576,11 @@ public class PropertyImpl extends ItemIm
         } catch (RepositoryException e) {
             throw new ValueFormatException("Property value cannot be converted to a PATH");
         }
-        return (absolute) ? session.getProperty(path) : getParent().getProperty(path);
+        try {
+            return (absolute) ? session.getProperty(path) : getParent().getProperty(path);
+        } catch (PathNotFoundException e) {
+            throw new ItemNotFoundException(path);
+        }
     }
 
     public BigDecimal getDecimal() throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java?rev=952269&r1=952268&r2=952269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java Mon Jun  7 15:28:25 2010
@@ -21,13 +21,16 @@ import java.io.InputStream;
 import java.util.Calendar;
 
 import javax.jcr.Item;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.ItemVisitor;
 import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
 
 /**
  * Abstract base class for implementing the JCR {@link Property} interface.
@@ -205,25 +208,138 @@ public abstract class AbstractProperty e
     }
 
     /**
-     * Returns the node referenced by this property.
-     * <p>
-     * The default implementation checks that this property is a reference
-     * property (or tries to convert the property value to a reference) and
-     * uses {@link Session#getNodeByUUID(String)} to retrieve the
-     * referenced node.
-     *
-     * @return node referenced by this property
-     * @throws RepositoryException if an error occurs
-     */
-    public Node getNode() throws RepositoryException {
-        Session session = getSession();
-        Value value = getValue();
-        if (value.getType() != PropertyType.REFERENCE
-                && value.getType() != PropertyType.WEAKREFERENCE) {
-            value = session.getValueFactory().createValue(
-                    value.getString(), PropertyType.REFERENCE);
+      * If this property is of type <code>REFERENCE</code>,
+      * <code>WEAKREFERENCE</code> or <code>PATH</code> (or convertible to one of
+      * these types) this method returns the <code>Node</code> to which this
+      * property refers.
+      * <p>
+      * If this property is of type <code>PATH</code> and it contains a relative
+      * path, it is interpreted relative to the parent node of this property. For
+      * example "<code>.</code>" refers to the parent node itself,
+      * "<code>..</code>" to the parent of the parent node and "<code>foo</code>"
+      * to a sibling node of this property.
+      *
+      * @return the referenced Node
+      * @throws ValueFormatException  if this property cannot be converted to a
+      *                               referring type (<code>REFERENCE</code>, <code>WEAKREFERENCE</code> or
+      *                               <code>PATH</code>), if the property is multi-valued or if this property
+      *                               is a referring type but is currently part of the frozen state of a
+      *                               version in version storage.
+      * @throws ItemNotFoundException If this property is of type
+      *                               <code>PATH</code> or <code>WEAKREFERENCE</code> and no target node
+      *                               accessible by the current <code>Session</code> exists in this workspace.
+      *                               Note that this applies even if the property is a <code>PATHS</code> and a
+      *                               <i>property</i> exists at the specified location. To dereference to a
+      *                               target property (as opposed to a target node), the method
+      *                               <code>Property.getProperty</code> is used.
+      * @throws RepositoryException   if another error occurs.
+      */
+    public Node getNode() throws ValueFormatException, RepositoryException {
+        String value = getString();
+
+        switch (getType()) {
+            case PropertyType.REFERENCE:
+            case PropertyType.WEAKREFERENCE:
+                return getSession().getNodeByIdentifier(value);
+
+            case PropertyType.PATH:
+                try {
+                    return (value.startsWith("/")) ? getSession().getNode(value) : getParent().getNode(value);
+                } catch (PathNotFoundException e) {
+                    throw new ItemNotFoundException(value);
+                }
+
+            case PropertyType.NAME:
+                try {
+                    return getParent().getNode(value);
+                } catch (PathNotFoundException e) {
+                    throw new ItemNotFoundException(value);
+                }
+
+            case PropertyType.STRING:
+                try {
+                    // interpret as identifier
+                    Value refValue = getSession().getValueFactory().createValue(value, PropertyType.REFERENCE);
+                    return getSession().getNodeByIdentifier(refValue.getString());
+                } catch (ItemNotFoundException e) {
+                    throw e;
+                } catch (RepositoryException e) {
+                    // try if STRING value can be interpreted as PATH value
+                    Value pathValue = getSession().getValueFactory().createValue(value, PropertyType.PATH);
+                    try {
+                        return (value.startsWith("/")) ? getSession().getNode(pathValue.getString()) : getParent().getNode(pathValue.getString());
+                    } catch (PathNotFoundException e1) {
+                        throw new ItemNotFoundException(pathValue.getString());
+                    }
+                }
+
+            default:
+                throw new ValueFormatException("Property value cannot be converted to a PATH, REFERENCE or WEAKREFERENCE: " + value);
+        }
+    }
+
+    /**
+     * If this property is of type <code>PATH</code> (or convertible to this
+     * type) this method returns the <code>Property</code> to which <i>this</i>
+     * property refers.
+     * <p>
+     * If this property contains a relative path, it is interpreted relative to
+     * the parent node of this property. Therefore, when resolving such a
+     * relative path, the segment "<code>.</code>" refers to
+     * the parent node itself, "<code>..</code>" to the parent of the parent
+     * node and "<code>foo</code>" to a sibling property of this property or
+     * this property itself.
+     * <p>
+     * For example, if this property is located at
+     * <code>/a/b/c</code> and it has a value of "<code>../d</code>" then this
+     * method will return the property at <code>/a/d</code> if such exists.
+     * <p>
+     * If this property is multi-valued, this method throws a
+     * <code>ValueFormatException</code>.
+     * <p>
+     * If this property cannot be converted to a <code>PATH</code> then a
+     * <code>ValueFormatException</code> is thrown.
+     * <p>
+     * If this property is currently part of the frozen state of a version in
+     * version storage, this method will throw a <code>ValueFormatException</code>.
+     *
+     * @return the referenced property
+     * @throws ValueFormatException  if this property cannot be converted to a
+     *                               <code>PATH</code>, if the property is multi-valued or if this property is
+     *                               a referring type but is currently part of the frozen state of a version
+     *                               in version storage.
+     * @throws ItemNotFoundException If no property accessible by the current
+     *                               <code>Session</code> exists in this workspace at the specified path. Note
+     *                               that this applies even if a <i>node</i> exists at the specified location.
+     *                               To dereference to a target node, the method <code>Property.getNode</code>
+     *                               is used.
+     * @throws RepositoryException   if another error occurs.
+     */
+    public Property getProperty() throws RepositoryException {
+        String value = getString();
+        switch (getType()) {
+            case PropertyType.PATH:
+                try {
+                    return (value.startsWith("/")) ? getSession().getProperty(value) : getParent().getProperty(value);
+                } catch (PathNotFoundException e) {
+                    throw new ItemNotFoundException(value);
+                }
+
+            case PropertyType.NAME:
+                try {
+                    return getParent().getProperty(value);
+                } catch (PathNotFoundException e) {
+                    throw new ItemNotFoundException(value);
+                }
+
+            default:
+                try {
+                    String path = getSession().getValueFactory().createValue(value, PropertyType.PATH).getString();
+                    return (path.startsWith("/")) ? getSession().getProperty(path) : getParent().getProperty(path);
+                } catch (PathNotFoundException e) {
+                    throw new ItemNotFoundException(value);
+                }
         }
-        return session.getNodeByUUID(value.getString());
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientProperty.java?rev=952269&r1=952268&r2=952269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientProperty.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientProperty.java Mon Jun  7 15:28:25 2010
@@ -335,22 +335,50 @@ public class ClientProperty extends Clie
      */
     public Node getNode() throws RepositoryException {
         String value = getString();
-        try {
-            if (getType() != PropertyType.PATH) {
+
+        switch (getType()) {
+            case PropertyType.REFERENCE:
+            case PropertyType.WEAKREFERENCE:
                 return getSession().getNodeByIdentifier(value);
-            } else if (value.startsWith("/")) {
-                return getSession().getNode(value);
-            } else {
-                return getParent().getNode(value);
-            }
-        } catch (RepositoryException e) {
-            // JCRRMI-15: Throw ValueFormatException where appropriate
-            if (e instanceof ItemNotFoundException
-                    || getType() == PropertyType.REFERENCE) {
-                throw e;
-            } else {
-                throw new ValueFormatException("Invalid identifier: " + value, e);
-            }
+
+            case PropertyType.PATH:
+                try {
+                    if (value.startsWith("/")) {
+                        return getSession().getNode(value);
+                    } else {
+                        return getParent().getNode(value);
+                    }
+                } catch (PathNotFoundException e) {
+                    throw new ItemNotFoundException(value);
+                }
+
+            case PropertyType.NAME:
+                try {
+                    return getParent().getNode(value);
+                } catch (PathNotFoundException e) {
+                    throw new ItemNotFoundException(value);
+                }
+
+            case PropertyType.STRING:
+                try {
+                    // interpret as identifier
+                    Value refValue = getSession().getValueFactory().createValue(value, PropertyType.REFERENCE);
+                    return getSession().getNodeByIdentifier(refValue.getString());
+                } catch (ItemNotFoundException e) {
+                    throw e;
+                } catch (RepositoryException e) {
+                    // try if STRING value can be interpreted as PATH value
+                    Value pathValue = getSession().getValueFactory().createValue(value, PropertyType.PATH);
+                    boolean absolute = value.startsWith("/");
+                    try {
+                        return (absolute) ? getSession().getNode(pathValue.getString()) : getParent().getNode(pathValue.getString());
+                    } catch (PathNotFoundException e1) {
+                        throw new ItemNotFoundException(pathValue.getString());
+                    }
+                }
+
+            default:
+                throw new ValueFormatException("Property value cannot be converted to a PATH, REFERENCE or WEAKREFERENCE: " + value);
         }
     }
 
@@ -360,10 +388,14 @@ public class ClientProperty extends Clie
             throw new ValueFormatException("Not a path property");
         } else {
             String value = getString();
-            if (value.startsWith("/")) {
-                return getSession().getProperty(value);
-            } else {
-                return getParent().getProperty(value);
+            try {
+                if (value.startsWith("/")) {
+                    return getSession().getProperty(value);
+                } else {
+                    return getParent().getProperty(value);
+                }
+            } catch (PathNotFoundException e) {
+                throw new ItemNotFoundException(value);
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BinaryPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BinaryPropertyTest.java?rev=952269&r1=952268&r2=952269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BinaryPropertyTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BinaryPropertyTest.java Mon Jun  7 15:28:25 2010
@@ -348,7 +348,7 @@ public class BinaryPropertyTest extends 
             // not testable since format of ID is implementation specific
         } else {
             try {
-                prop.getNode();
+                prop.getProperty();
                 fail("Property.getProperty() called on a multivalue property " +
                         "should throw a ValueFormatException.");
             } catch (ValueFormatException vfe) {

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java?rev=952269&r1=952268&r2=952269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java Mon Jun  7 15:28:25 2010
@@ -207,7 +207,7 @@ public class DoublePropertyTest extends 
         } else {
             try {
                 prop.getProperty();
-                fail("Property.getNode() called on a multivalue property " +
+                fail("Property.getProperty() called on a multivalue property " +
                         "should throw a ValueFormatException.");
             } catch (ValueFormatException vfe) {
                 // ok

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java?rev=952269&r1=952268&r2=952269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java Mon Jun  7 15:28:25 2010
@@ -206,7 +206,7 @@ public class LongPropertyTest extends Ab
         } else {
             try {
                 prop.getProperty();
-                fail("Property.getNode() called on a multivalue property " +
+                fail("Property.getProperty() called on a multivalue property " +
                         "should throw a ValueFormatException.");
             } catch (ValueFormatException vfe) {
                 // ok

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NamePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NamePropertyTest.java?rev=952269&r1=952268&r2=952269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NamePropertyTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NamePropertyTest.java Mon Jun  7 15:28:25 2010
@@ -16,12 +16,12 @@
  */
 package org.apache.jackrabbit.test.api;
 
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
 import javax.jcr.PropertyType;
 import javax.jcr.Property;
-import javax.jcr.PathNotFoundException;
 import javax.jcr.Node;
 
 /**
@@ -151,12 +151,12 @@ public class NamePropertyTest extends Ab
             String path = prop.getString();
             if (prop.getParent().hasNode(path)) {
                 Node n = prop.getNode();
-                assertEquals("The path of the dereferenced property must be equal to the value", path, n.getPath());
+                assertEquals("The name of the dereferenced property must be equal to the value", path, n.getName());
             } else {
                 try {
                     prop.getNode();
-                    fail("Calling Property.getNode() for a PATH value that doesn't have a corresponding Node, PathNotFoundException is expected");
-                } catch (PathNotFoundException e) {
+                    fail("Calling Property.getNode() for a NAME value that doesn't have a corresponding Node, ItemNotFoundException is expected");
+                } catch (ItemNotFoundException e) {
                     // success.
                 }
             }
@@ -181,12 +181,12 @@ public class NamePropertyTest extends Ab
             String path = prop.getString();
             if (prop.getParent().hasProperty(path)) {
                 Property p = prop.getProperty();
-                assertEquals("The path of the dereferenced property must be equal to the value", path, p.getPath());
+                assertEquals("The name of the dereferenced property must be equal to the value", path, p.getName());
             } else {
                 try {
                     prop.getProperty();
-                    fail("Calling Property.getProperty() for a PATH value that doesn't have a corresponding Node, PathNotFoundException is expected");
-                } catch (PathNotFoundException e) {
+                    fail("Calling Property.getProperty() for a NAME value that doesn't have a corresponding Node, ItemNotFoundException is expected");
+                } catch (ItemNotFoundException e) {
                     // success.
                 }
             }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathPropertyTest.java?rev=952269&r1=952268&r2=952269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathPropertyTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathPropertyTest.java Mon Jun  7 15:28:25 2010
@@ -16,12 +16,12 @@
  */
 package org.apache.jackrabbit.test.api;
 
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
 import javax.jcr.PropertyType;
 import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
 
 /**
@@ -148,10 +148,8 @@ public class PathPropertyTest extends Ab
 
             // relative node path
             prop.getParent().setProperty(propName, ".", PropertyType.PATH);
-            value = prop.getString();
             n = prop.getNode();
-            assertEquals("The path of the dereferenced property must be equal to the value", ".", value);
-            assertTrue("The property value must be resolved to the correct node.", prop.getParent().isSame(n));
+            assertTrue("The property value must be resolved to the correct node.", prop.getParent().getNode(".").isSame(n));
 
             // non-existing property path
             while (session.nodeExists(nodePath)) {
@@ -159,9 +157,9 @@ public class PathPropertyTest extends Ab
             }
             prop.getParent().setProperty(propName, nodePath, PropertyType.PATH);
             try {
-                prop.getProperty();
-                fail("Calling Property.getNode() for a PATH value that doesn't have a corresponding Node, PathNotFoundException is expected");
-            } catch (PathNotFoundException e) {
+                prop.getNode();
+                fail("Calling Property.getNode() for a PATH value that doesn't have a corresponding Node, ItemNotFoundException is expected");
+            } catch (ItemNotFoundException e) {
                 //ok
             }
         } else {
@@ -197,7 +195,7 @@ public class PathPropertyTest extends Ab
             path = prop.getString();
             p = prop.getProperty();
             assertEquals("The path of the dereferenced property must be equal to the value", path, p.getName());
-            assertTrue("The property value must be resolved to the correct property.", prop.isSame(p));
+            assertTrue("The property value must be resolved to the correct property.", prop.getParent().getProperty(path).isSame(p));
 
             // non-existing property path
             while (session.propertyExists(propPath)) {
@@ -206,8 +204,8 @@ public class PathPropertyTest extends Ab
             prop.getParent().setProperty(propName, propPath, PropertyType.PATH);
             try {
                 prop.getProperty();
-                fail("Calling Property.getNode() for a PATH value that doesn't have a corresponding Property, PathNotFoundException is expected");
-            } catch (PathNotFoundException e) {
+                fail("Calling Property.getProperty() for a PATH value that doesn't have a corresponding Property, ItemNotFoundException is expected");
+            } catch (ItemNotFoundException e) {
                 //ok
             }
         } else {

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java?rev=952269&r1=952268&r2=952269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java Mon Jun  7 15:28:25 2010
@@ -22,8 +22,10 @@ import java.util.Calendar;
 
 import javax.jcr.Binary;
 import javax.jcr.Item;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.ItemVisitor;
 import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -358,29 +360,36 @@ public class PropertyImpl extends ItemIm
      */
     public Node getNode() throws ValueFormatException, RepositoryException {
         Value value = getValue();
-        int type = value.getType();
-        switch (type) {
+        switch (value.getType()) {
             case PropertyType.REFERENCE:
             case PropertyType.WEAKREFERENCE:
-                return session.getNodeByUUID(value.getString());
+                return session.getNodeByIdentifier(value.getString());
 
             case PropertyType.PATH:
             case PropertyType.NAME:
                 String path = value.getString();
                 Path p = session.getPathResolver().getQPath(path);
-                boolean absolute = p.isAbsolute();
-                return (absolute) ? session.getNode(path) : getParent().getNode(path);
+                try {
+                    return (p.isAbsolute()) ? session.getNode(path) : getParent().getNode(path);
+                } catch (PathNotFoundException e) {
+                    throw new ItemNotFoundException(path);
+                }
 
             case PropertyType.STRING:
                 try {
                     Value refValue = ValueHelper.convert(value, PropertyType.REFERENCE, session.getValueFactory());
-                    return session.getNodeByUUID(refValue.getString());
+                    return session.getNodeByIdentifier(refValue.getString());
+                } catch (ItemNotFoundException e) {
+                    throw e;
                 } catch (RepositoryException e) {
                     // try if STRING value can be interpreted as PATH value
                     Value pathValue = ValueHelper.convert(value, PropertyType.PATH, session.getValueFactory());
                     p = session.getPathResolver().getQPath(pathValue.getString());
-                    absolute = p.isAbsolute();
-                    return (absolute) ? session.getNode(pathValue.getString()) : getParent().getNode(pathValue.getString());
+                    try {
+                        return (p.isAbsolute()) ? session.getNode(pathValue.getString()) : getParent().getNode(pathValue.getString());
+                    } catch (PathNotFoundException e1) {
+                        throw new ItemNotFoundException(pathValue.getString());
+                    }
                 }
 
             default:
@@ -402,7 +411,11 @@ public class PropertyImpl extends ItemIm
         } catch (RepositoryException e) {
             throw new ValueFormatException("Property value cannot be converted to a PATH");
         }
-        return (absolute) ? session.getProperty(path) : getParent().getProperty(path);
+        try {
+            return (absolute) ? session.getProperty(path) : getParent().getProperty(path);
+        } catch (PathNotFoundException e) {
+            throw new ItemNotFoundException(path);
+        }
     }
 
     /**