jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1147320 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/SessionImpl.java test/java/org/apache/jackrabbit/core/integration/SessionImplTest.java
Date Fri, 15 Jul 2011 21:18:35 GMT
Author: stefan
Date: Fri Jul 15 21:18:34 2011
New Revision: 1147320

URL: http://svn.apache.org/viewvc?rev=1147320&view=rev
Log:
JCR-3014: Identifier paths for inexistent items throw exception

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/SessionImplTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=1147320&r1=1147319&r2=1147320&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Fri Jul 15 21:18:34 2011
@@ -790,6 +790,15 @@ public class SessionImpl extends Abstrac
      */
     @Override
     public boolean itemExists(String absPath) throws RepositoryException {
+        if (absPath != null && absPath.startsWith("[") && absPath.endsWith("]"))
{
+            // an identifier segment has been specified (JCR-3014)
+            try {
+                NodeId id = NodeId.valueOf(absPath.substring(1, absPath.length() - 1));
+                return getItemManager().itemExists(id);
+            } catch (IllegalArgumentException e) {
+                throw new MalformedPathException(absPath);
+            }
+        }
         return perform(SessionItemOperation.itemExists(absPath));
     }
 
@@ -1111,6 +1120,15 @@ public class SessionImpl extends Abstrac
      */
     @Override
     public boolean nodeExists(String absPath) throws RepositoryException {
+        if (absPath != null && absPath.startsWith("[") && absPath.endsWith("]"))
{
+            // an identifier segment has been specified (JCR-3014)
+            try {
+                NodeId id = NodeId.valueOf(absPath.substring(1, absPath.length() - 1));
+                return getItemManager().itemExists(id);
+            } catch (IllegalArgumentException e) {
+                throw new MalformedPathException(absPath);
+            }
+        }
         return perform(SessionItemOperation.nodeExists(absPath));
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/SessionImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/SessionImplTest.java?rev=1147320&r1=1147319&r2=1147320&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/SessionImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/SessionImplTest.java
Fri Jul 15 21:18:34 2011
@@ -27,6 +27,7 @@ import javax.security.auth.Subject;
 
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.security.principal.PrincipalImpl;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.apache.jackrabbit.test.NotExecutableException;
@@ -162,4 +163,15 @@ public class SessionImplTest extends Abs
             // success
         }
     }
+
+    /**
+     * JCR-3014 Identifier paths for inexistent items throw exception
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-3014">JCR-3014</a>
+     */
+    public void testCheckNonExistingItem() throws Exception {
+        String dummyPath = "[" + NodeId.randomId() + "]";
+        assertFalse(superuser.itemExists(dummyPath));
+        assertFalse(superuser.nodeExists(dummyPath));
+    }
 }



Mime
View raw message