jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1374976 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/ oak-jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/
Date Mon, 20 Aug 2012 11:33:12 GMT
Author: reschke
Date: Mon Aug 20 11:33:11 2012
New Revision: 1374976

URL: http://svn.apache.org/viewvc?rev=1374976&view=rev
Log:
OAK-23: move handling of identifier paths into path mapper

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java?rev=1374976&r1=1374975&r2=1374976&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
Mon Aug 20 11:33:11 2012
@@ -21,6 +21,7 @@ import java.util.List;
 
 import javax.annotation.Nonnull;
 
+import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,9 +36,16 @@ public class NamePathMapperImpl implemen
     private static final Logger log = LoggerFactory.getLogger(NamePathMapperImpl.class);
 
     private final NameMapper nameMapper;
+    private final IdentifierManager idManager;
 
     public NamePathMapperImpl(NameMapper nameMapper) {
         this.nameMapper = nameMapper;
+        this.idManager = null;
+    }
+
+    public NamePathMapperImpl(NameMapper nameMapper, IdentifierManager idManager) {
+        this.nameMapper = nameMapper;
+        this.idManager = idManager;
     }
 
     //---------------------------------------------------------< NameMapper >---
@@ -151,13 +159,28 @@ public class NamePathMapperImpl implemen
             return "/";
         }
 
+        int length = jcrPath.length();
+
+        // identifier path?
+        if (length > 0 && jcrPath.charAt(0) == '[') {
+            if (jcrPath.charAt(length - 1) != ']') {
+                // TODO error handling?
+                return null;
+            }
+            if (this.idManager == null) {
+                // TODO error handling?
+                return null;
+            }
+            return this.idManager.getPath(jcrPath.substring(1, length - 1));
+        }
+
         boolean hasClarkBrackets = false;
         boolean hasIndexBrackets = false;
         boolean hasColon = false;
         boolean hasNameStartingWithDot = false;
 
         char prev = 0;
-        for (int i = 0; i < jcrPath.length(); i++) {
+        for (int i = 0; i < length; i++) {
             char c = jcrPath.charAt(i);
 
             if (c == '{' || c == '}') {

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1374976&r1=1374975&r2=1374976&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Mon Aug 20 11:33:11 2012
@@ -34,7 +34,6 @@
   <properties>
     <known.issues>
 org.apache.jackrabbit.test.api.AddNodeTest#testSameNameSiblings<!-- OAK-203 -->
-org.apache.jackrabbit.test.api.PathTest#testGetItem<!-- OAK-23 -->
 org.apache.jackrabbit.test.api.SessionTest#testMoveConstraintViolationExceptionSrc<!--OAK-132-->
 org.apache.jackrabbit.test.api.SessionTest#testMoveConstraintViolationExceptionDest<!--OAK-132-->
 org.apache.jackrabbit.test.api.SessionTest#testSaveConstraintViolationException<!--OAK-66-->

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1374976&r1=1374975&r2=1374976&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Mon Aug 20 11:33:11 2012
@@ -462,16 +462,10 @@ public class PropertyImpl extends ItemIm
                     case PropertyType.PATH:
                     case PropertyType.NAME:
                         String path = value.getString();
-                        if (path.startsWith("[") && path.endsWith("]")) {
-                            // TODO OAK-23
-                            // TODO correct for NAME?
-                            return getSession().getNodeByIdentifier(path.substring(1, path.length()
- 1));
-                        } else {
-                            try {
-                                return (path.charAt(0) == '/') ? getSession().getNode(path)
: getParent().getNode(path);
-                            } catch (PathNotFoundException e) {
-                                throw new ItemNotFoundException(path);
-                            }
+                        try {
+                            return (path.charAt(0) == '/') ? getSession().getNode(path) :
getParent().getNode(path);
+                        } catch (PathNotFoundException e) {
+                            throw new ItemNotFoundException(path);
                         }
 
                     case PropertyType.STRING:

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java?rev=1374976&r1=1374975&r2=1374976&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
Mon Aug 20 11:33:11 2012
@@ -61,7 +61,7 @@ import org.slf4j.LoggerFactory;
 public class SessionDelegate {
     static final Logger log = LoggerFactory.getLogger(SessionDelegate.class);
 
-    private final NamePathMapper namePathMapper = new NamePathMapperImpl(new SessionNameMapper());
+    private final NamePathMapper namePathMapper;
     private final Repository repository;
     private final ScheduledExecutorService executor;
     private final ContentSession contentSession;
@@ -88,13 +88,14 @@ public class SessionDelegate {
         this.repository = repository;
         this.executor = executor;
         this.contentSession = contentSession;
-        this.valueFactory = new ValueFactoryImpl(contentSession.getCoreValueFactory(), namePathMapper);
         this.workspace = new WorkspaceImpl(this);
         this.session = new SessionImpl(this);
         this.root = contentSession.getCurrentRoot();
         this.conflictHandler = new AnnotatingConflictHandler(contentSession.getCoreValueFactory());
         this.autoRefresh = autoRefresh;
         this.idManager = new IdentifierManager(contentSession, root);
+        this.namePathMapper = new NamePathMapperImpl(new SessionNameMapper(), idManager);
+        this.valueFactory = new ValueFactoryImpl(contentSession.getCoreValueFactory(), namePathMapper);
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1374976&r1=1374975&r2=1374976&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
Mon Aug 20 11:33:11 2012
@@ -178,8 +178,6 @@ public class SessionImpl extends Abstrac
     public Node getNode(final String absPath) throws RepositoryException {
         ensureIsAlive();
 
-        // FIXME: deal with identifier path (OAK-23)
-
         return dlg.perform(new SessionOperation<NodeImpl>() {
             @Override
             public NodeImpl perform() throws RepositoryException {
@@ -197,8 +195,6 @@ public class SessionImpl extends Abstrac
     public boolean nodeExists(final String absPath) throws RepositoryException {
         ensureIsAlive();
 
-        // FIXME: deal with identifier path (OAK-23)
-
         return dlg.perform(new SessionOperation<Boolean>() {
             @Override
             public Boolean perform() throws RepositoryException {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java?rev=1374976&r1=1374975&r2=1374976&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java
Mon Aug 20 11:33:11 2012
@@ -163,17 +163,9 @@ public class ValueFactoryImpl implements
                     break;
 
                 case PropertyType.PATH:
-                    // TODO we special case identifier paths here for now
-                    // eventually this should be done in the path mapper (OAK-23)
-
-                    String oakValue;
-                    if (value.startsWith("[") && value.endsWith("]")) {
-                        oakValue = value;
-                    } else {
-                        oakValue = namePathMapper.getOakPath(value);
-                        if (oakValue == null) {
-                            throw new ValueFormatException("Invalid path: " + value);
-                        }
+                    String oakValue = namePathMapper.getOakPath(value);
+                    if (oakValue == null) {
+                        throw new ValueFormatException("Invalid path: " + value);
                     }
                     cv = factory.createValue(oakValue, type);
                     break;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueImpl.java?rev=1374976&r1=1374975&r2=1374976&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueImpl.java
Mon Aug 20 11:33:11 2012
@@ -175,8 +175,8 @@ class ValueImpl implements Value {
                 return namePathMapper.getJcrName(value.toString());
             case PropertyType.PATH:
                 String s = value.toString();
-                // TODO special handling for identifier paths; should happen in path mapper
(OAK-23)
                 if (s.startsWith("[") && s.endsWith("]")) {
+                    // identifier paths are returned as-is (JCR 2.0, 3.4.3.1)
                     return s;
                 } else {
                     return namePathMapper.getJcrPath(value.toString());



Mime
View raw message