Author: reschke
Date: Wed May 16 13:53:25 2012
New Revision: 1339166
URL: http://svn.apache.org/viewvc?rev=1339166&view=rev
Log:
JCR-3312: add support for identifier paths in AbstractSession.getItem(String)
Modified:
jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java
Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java?rev=1339166&r1=1339165&r2=1339166&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java
Wed May 16 13:53:25 2012
@@ -374,26 +374,32 @@ public abstract class AbstractSession im
* <p>
* The default implementation:
* <ul>
- * <li>Throws a {@link PathNotFoundException} if the given path
- * does not start with a slash.
* <li>Returns the root node if the given path is "/"
- * <li>Calls {@link Node#getNode(String)} on the root node with the
- * part of the given path after the first slash
- * <li>Calls {@link Node#getProperty(String)} similarly in case the
- * above call fails with a {@link PathNotFoundException}
+ * <li>Delegates to {@link Node#getNodeByIdentifier(String)} for identifier
+ * paths
+ * <li>Throws a {@link PathNotFoundException} if the given path does not
+ * start with a slash.
+ * <li>Calls {@link Node#getNode(String)} on the root node with the part of
+ * the given path after the first slash
+ * <li>Calls {@link Node#getProperty(String)} similarly in case the above
+ * call fails with a {@link PathNotFoundException}
* </ul>
- *
+ *
* @see Session#getItem(String)
- * @param absPath absolute path
+ * @param absPath
+ * absolute path
* @return the node or property with the given path
- * @throws PathNotFoundException if the given path is invalid or not found
- * @throws RepositoryException if another error occurs
+ * @throws PathNotFoundException
+ * if the given path is invalid or not found
+ * @throws RepositoryException
+ * if another error occurs
*/
- public Item getItem(String absPath)
- throws PathNotFoundException, RepositoryException {
+ public Item getItem(String absPath) throws PathNotFoundException, RepositoryException
{
Node root = getRootNode();
if (absPath.equals("/")) {
return root;
+ } else if (absPath.startsWith("[") && absPath.endsWith("]")) {
+ return getNodeByIdentifier(absPath.substring(1, absPath.length() - 1));
} else {
String relPath = toRelativePath(absPath);
if (root.hasNode(relPath)) {
|