jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1331479 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/ oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/ oak-it/jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/main/jav...
Date Fri, 27 Apr 2012 15:58:55 GMT
Author: angela
Date: Fri Apr 27 15:58:54 2012
New Revision: 1331479

URL: http://svn.apache.org/viewvc?rev=1331479&view=rev
Log:
OAK-77 : Consolidate Utilities (WIP)

- replace Paths by PathMapper
- simplify SessionContext
- comment failing test (oak-jcr throws IllegalArgumentException instead of NamespaceException)

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapper.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathMapper.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImplTest.java
      - copied, changed from r1331432, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/PathsTest.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/Paths.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/PathsTest.java
Modified:
    jackrabbit/oak/trunk/oak-it/jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.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/WorkspaceImpl.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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapper.java?rev=1331479&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapper.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapper.java
Fri Apr 27 15:58:54 2012
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.namepath;
+
+/**
+ * NamePathMapper...
+ */
+public interface NamePathMapper extends NameMapper, PathMapper {
+}
\ No newline at end of file

Added: 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=1331479&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
Fri Apr 27 15:58:54 2012
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.namepath;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * NamePathMapperImpl...
+ */
+public class NamePathMapperImpl implements NamePathMapper {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(NamePathMapperImpl.class);
+
+    private final NameMapper nameMapper;
+
+    public NamePathMapperImpl(NameMapper nameMapper) {
+        this.nameMapper = nameMapper;
+    }
+
+    //---------------------------------------------------------< NameMapper >---
+    @Override
+    public String getOakName(String jcrName) {
+        return nameMapper.getOakName(jcrName);
+    }
+
+    @Override
+    public String getJcrName(String oakName) {
+        return nameMapper.getJcrName(oakName);
+    }
+
+    //---------------------------------------------------------< PathMapper >---
+    @Override
+    public String toOakPath(String jcrPath) {
+        final List<String> elements = new ArrayList<String>();
+
+        if ("/".equals(jcrPath)) {
+            // avoid the need to special case the root path later on
+            return "/";
+        }
+
+        JcrPathParser.Listener listener = new JcrPathParser.Listener() {
+
+            // TODO: replace RuntimeException by something that oak-jcr can deal with (e.g.
ValueFactory)
+
+            @Override
+            public void root() {
+                if (!elements.isEmpty()) {
+                    throw new RuntimeException("/ on non-empty path");
+                }
+                elements.add("");
+            }
+
+            @Override
+            public void identifier(String identifier) {
+                if (!elements.isEmpty()) {
+                    throw new RuntimeException("[identifier] on non-empty path");
+                }
+                elements.add(identifier);  // todo resolve identifier
+                // todo seal
+            }
+
+            @Override
+            public void current() {
+                // nothing to do here
+            }
+
+            @Override
+            public void parent() {
+                if (elements.isEmpty()) {
+                    throw new RuntimeException(".. of empty path");
+                }
+                elements.remove(elements.size() - 1);
+            }
+
+            @Override
+            public void index(int index) {
+                if (index > 1) {
+                    throw new RuntimeException("index > 1");
+                }
+            }
+
+            @Override
+            public void error(String message) {
+                throw new RuntimeException(message);
+            }
+
+            @Override
+            public void name(String name) {
+                String p = nameMapper.getOakName(name);
+                elements.add(p);
+            }
+        };
+
+        JcrPathParser.parse(jcrPath, listener);
+
+        StringBuilder oakPath = new StringBuilder();
+        for (String element : elements) {
+            if (element.isEmpty()) {
+                // root
+                oakPath.append('/');
+            }
+            else {
+                oakPath.append(element);
+                oakPath.append('/');
+            }
+        }
+
+        // root path is special-cased early on so it does not need to
+        // be considered here
+        oakPath.deleteCharAt(oakPath.length() - 1);
+        return oakPath.toString();
+    }
+
+    @Override
+    public String toJcrPath(String oakPath) {
+        final List<String> elements = new ArrayList<String>();
+
+        if ("/".equals(oakPath)) {
+            // avoid the need to special case the root path later on
+            return "/";
+        }
+
+        JcrPathParser.Listener listener = new JcrPathParser.Listener() {
+            @Override
+            public void root() {
+                if (!elements.isEmpty()) {
+                    throw new RuntimeException("/ on non-empty path");
+                }
+                elements.add("");
+            }
+
+            @Override
+            public void identifier(String identifier) {
+                if (!elements.isEmpty()) {
+                    throw new RuntimeException("[identifier] on non-empty path");
+                }
+                elements.add(identifier);  // todo resolve identifier
+                // todo seal
+            }
+
+            @Override
+            public void current() {
+                // nothing to do here
+            }
+
+            @Override
+            public void parent() {
+                if (elements.isEmpty()) {
+                    throw new RuntimeException(".. of empty path");
+                }
+                elements.remove(elements.size() - 1);
+            }
+
+            @Override
+            public void index(int index) {
+                if (index > 1) {
+                    throw new RuntimeException("index > 1");
+                }
+            }
+
+            @Override
+            public void error(String message) {
+                throw new RuntimeException(message);
+            }
+
+            @Override
+            public void name(String name) {
+                String p = nameMapper.getJcrName(name);
+                elements.add(p);
+            }
+        };
+
+        JcrPathParser.parse(oakPath, listener);
+
+        StringBuilder jcrPath = new StringBuilder();
+        for (String element : elements) {
+            if (element.isEmpty()) {
+                // root
+                jcrPath.append('/');
+            }
+            else {
+                jcrPath.append(element);
+                jcrPath.append('/');
+            }
+        }
+
+        jcrPath.deleteCharAt(jcrPath.length() - 1);
+        return jcrPath.toString();
+    }
+}
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathMapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathMapper.java?rev=1331479&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathMapper.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathMapper.java
Fri Apr 27 15:58:54 2012
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.namepath;
+
+/**
+ * TODO
+ */
+public interface PathMapper {
+
+    String toOakPath(String jcrPath);
+
+    String toJcrPath(String oakPath);
+
+}

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImplTest.java
(from r1331432, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/PathsTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImplTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImplTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/PathsTest.java&r1=1331432&r2=1331479&rev=1331479&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/PathsTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImplTest.java
Fri Apr 27 15:58:54 2012
@@ -27,14 +27,15 @@ import java.util.UUID;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
-public class PathsTest {
+public class NamePathMapperImplTest {
 
     private TestNameMapper mapper = new TestNameMapper();
+    private NamePathMapper npMapper = new NamePathMapperImpl(mapper);
 
     @Test
     public void testValidIdentifierPath() {
         String idPath = '[' + UUID.randomUUID().toString()+ ']';
-        Paths.toOakPath(idPath, mapper);
+        npMapper.toOakPath(idPath);
     }
 
     @Test
@@ -45,7 +46,7 @@ public class PathsTest {
 
         for (String jcrPath : invalid) {
             try {
-                Paths.toOakPath(jcrPath, mapper);
+                npMapper.toOakPath(jcrPath);
                 fail("Invalid identifier path");
             } catch (Exception e) {
                 // success
@@ -55,33 +56,33 @@ public class PathsTest {
 
     @Test
     public void testJcrToOak() {
-        assertEquals("/", Paths.toOakPath("/", mapper));
-        assertEquals("foo", Paths.toOakPath("{}foo", mapper));
-        assertEquals("/oak-foo:bar", Paths.toOakPath("/foo:bar", mapper));
+        assertEquals("/", npMapper.toOakPath("/"));
+        assertEquals("foo", npMapper.toOakPath("{}foo"));
+        assertEquals("/oak-foo:bar", npMapper.toOakPath("/foo:bar"));
         assertEquals("/oak-foo:bar/oak-quu:qux",
-                Paths.toOakPath("/foo:bar/quu:qux", mapper));
-        assertEquals("oak-foo:bar", Paths.toOakPath("foo:bar", mapper));
-        assertEquals("oak-nt:unstructured", Paths.toOakPath(
-                "{http://www.jcp.org/jcr/nt/1.0}unstructured", mapper));
-        assertEquals("foobar/oak-jcr:content", Paths.toOakPath(
-                "foobar/{http://www.jcp.org/jcr/1.0}content", mapper));
+                npMapper.toOakPath("/foo:bar/quu:qux"));
+        assertEquals("oak-foo:bar", npMapper.toOakPath("foo:bar"));
+        assertEquals("oak-nt:unstructured", npMapper.toOakPath(
+                "{http://www.jcp.org/jcr/nt/1.0}unstructured"));
+        assertEquals("foobar/oak-jcr:content", npMapper.toOakPath(
+                "foobar/{http://www.jcp.org/jcr/1.0}content"));
     }
 
     @Test
     public void testOakToJcr() {
-        assertEquals("/jcr-foo:bar", Paths.toJcrPath("/foo:bar", mapper));
+        assertEquals("/jcr-foo:bar", npMapper.toJcrPath("/foo:bar"));
         assertEquals("/jcr-foo:bar/jcr-quu:qux",
-                Paths.toJcrPath("/foo:bar/quu:qux", mapper));
-        assertEquals("jcr-foo:bar", Paths.toJcrPath("foo:bar", mapper));
+                npMapper.toJcrPath("/foo:bar/quu:qux"));
+        assertEquals("jcr-foo:bar", npMapper.toJcrPath("foo:bar"));
 
         try {
-            Paths.toJcrPath("{http://www.jcp.org/jcr/nt/1.0}unstructured", mapper);
+            npMapper.toJcrPath("{http://www.jcp.org/jcr/nt/1.0}unstructured");
             fail("expanded name should not be accepted");
         } catch (IllegalStateException expected) {
         }
 
         try {
-            Paths.toJcrPath("foobar/{http://www.jcp.org/jcr/1.0}content", mapper);
+            npMapper.toJcrPath("foobar/{http://www.jcp.org/jcr/1.0}content");
             fail("expanded name should not be accepted");
         } catch (IllegalStateException expected) {
         }

Modified: jackrabbit/oak/trunk/oak-it/jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/jcr/pom.xml?rev=1331479&r1=1331478&r2=1331479&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-it/jcr/pom.xml Fri Apr 27 15:58:54 2012
@@ -48,6 +48,7 @@ org.apache.jackrabbit.test.api.NodeReadM
 org.apache.jackrabbit.test.api.PropertyReadMethodsTest
 org.apache.jackrabbit.test.api.NodeDiscoveringNodeTypesTest#testIsNodeType
 org.apache.jackrabbit.test.api.NamespaceRemappingTest#testNamespaceRemapping
+org.apache.jackrabbit.test.api.NamespaceRemappingTest#testExceptionOnUnknownPrefix
 org.apache.jackrabbit.test.api.SessionReadMethodsTest#testGetNodeByUUIDFailure
 org.apache.jackrabbit.test.api.ExportSysViewTest
 org.apache.jackrabbit.test.api.ExportDocViewTest

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1331479&r1=1331478&r2=1331479&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
Fri Apr 27 15:58:54 2012
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.oak.jcr;
 
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.namepath.Paths;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -166,10 +165,10 @@ abstract class ItemImpl implements Item 
 
     
     String toOakPath(String jcrPath) throws RepositoryException {
-        return sessionContext.toOakPath(jcrPath);
+        return sessionContext.getNamePathMapper().toOakPath(jcrPath);
     }
 
     String toJcrPath(String oakPath) {
-        return sessionContext.toJcrPath(oakPath);
+        return sessionContext.getNamePathMapper().toJcrPath(oakPath);
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java?rev=1331479&r1=1331478&r2=1331479&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
Fri Apr 27 15:58:54 2012
@@ -20,7 +20,6 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.namepath.Paths;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java?rev=1331479&r1=1331478&r2=1331479&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
Fri Apr 27 15:58:54 2012
@@ -22,7 +22,7 @@ import org.apache.jackrabbit.oak.api.Con
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.jcr.value.ValueFactoryImpl;
-import org.apache.jackrabbit.oak.namepath.NameMapper;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.lock.LockManager;
@@ -34,11 +34,9 @@ public interface SessionContext {
     String getWorkspaceName();
     ContentSession getContentSession();
     ValueFactoryImpl getValueFactory();
-    NameMapper getNameMapper();
     LockManager getLockManager() throws RepositoryException;
     VersionManager getVersionManager() throws RepositoryException;
     Root getRoot();
     Tree getTree(String path);
-    String toOakPath(String jcrPath) throws RepositoryException;
-    String toJcrPath(String oakPath);
+    NamePathMapper getNamePathMapper();
 }

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=1331479&r1=1331478&r2=1331479&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
Fri Apr 27 15:58:54 2012
@@ -29,7 +29,8 @@ import org.apache.jackrabbit.oak.jcr.nam
 import org.apache.jackrabbit.oak.jcr.value.ValueFactoryImpl;
 import org.apache.jackrabbit.oak.namepath.AbstractNameMapper;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
-import org.apache.jackrabbit.oak.namepath.Paths;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
@@ -68,6 +69,7 @@ public class SessionImpl extends Abstrac
     private final NamespaceRegistry nsreg;
     private final SessionContext sessionContext = new Context();
     private final NameMapper nameMapper = new SessionNameMapper();
+    private final NamePathMapper namePathMapper = new NamePathMapperImpl(nameMapper);
 
     private boolean isAlive = true;
     private Root root;
@@ -76,7 +78,7 @@ public class SessionImpl extends Abstrac
             throws RepositoryException {
         this.globalContext = globalContext;
         this.contentSession = contentSession;
-        this.valueFactory = new ValueFactoryImpl(contentSession.getCoreValueFactory(), nameMapper);
+        this.valueFactory = new ValueFactoryImpl(contentSession.getCoreValueFactory(), namePathMapper);
         this.nsreg = new NamespaceRegistryImpl(contentSession);
         this.workspace = new WorkspaceImpl(sessionContext, this.nsreg);
         this.root = contentSession.getCurrentRoot();
@@ -155,7 +157,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public void move(String srcAbsPath, String destAbsPath) throws RepositoryException {
-        internalMove(sessionContext.toOakPath(srcAbsPath), sessionContext.toOakPath(destAbsPath));
+        internalMove(sessionContext.getNamePathMapper().toOakPath(srcAbsPath), sessionContext.getNamePathMapper().toOakPath(destAbsPath));
     }
 
     private void internalMove(String srcAbsPath, String destAbsPath) throws RepositoryException
{
@@ -226,7 +228,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior)
throws RepositoryException {
-        return internalGetImportContentHandler(sessionContext.toOakPath(parentAbsPath), uuidBehavior);
+        return internalGetImportContentHandler(sessionContext.getNamePathMapper().toOakPath(parentAbsPath),
uuidBehavior);
     }
 
     private ContentHandler internalGetImportContentHandler(String parentAbsPath, int uuidBehavior)
throws RepositoryException {
@@ -276,7 +278,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public boolean hasPermission(String absPath, String actions) throws RepositoryException
{
-        return internalHasPermission(sessionContext.toOakPath(absPath), actions);
+        return internalHasPermission(sessionContext.getNamePathMapper().toOakPath(absPath),
actions);
     }
 
     private boolean internalHasPermission(String absPath, String actions) throws RepositoryException
{
@@ -513,11 +515,6 @@ public class SessionImpl extends Abstrac
         }
 
         @Override
-        public NameMapper getNameMapper() {
-            return nameMapper;
-        }
-
-        @Override
         public LockManager getLockManager() throws RepositoryException {
             return getWorkspace().getLockManager();
         }
@@ -538,17 +535,8 @@ public class SessionImpl extends Abstrac
         }
 
         @Override
-        public String toOakPath(String jcrPath) throws RepositoryException {
-            try {
-                return Paths.toOakPath(jcrPath, sessionContext.getNameMapper());
-            } catch (IllegalArgumentException ex) {
-                throw new RepositoryException(ex);
-            }
-        }
-
-        @Override
-        public String toJcrPath(String oakPath) {
-            return Paths.toJcrPath(oakPath, sessionContext.getNameMapper());
+        public NamePathMapper getNamePathMapper() {
+            return namePathMapper;
         }
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1331479&r1=1331478&r2=1331479&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
Fri Apr 27 15:58:54 2012
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.oak.commons
 import org.apache.jackrabbit.oak.jcr.nodetype.NodeTypeManagerImpl;
 import org.apache.jackrabbit.oak.jcr.query.QueryManagerImpl;
 import org.apache.jackrabbit.oak.jcr.security.privileges.PrivilegeManagerImpl;
-import org.apache.jackrabbit.oak.namepath.Paths;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
@@ -68,8 +67,7 @@ public class WorkspaceImpl implements Ja
 
         this.sessionContext = sessionContext;
         this.nsRegistry = nsRegistry;
-        this.nodeTypeManager =
-                new NodeTypeManagerImpl(sessionContext.getNameMapper());
+        this.nodeTypeManager = new NodeTypeManagerImpl(sessionContext.getNamePathMapper());
     }
 
     //----------------------------------------------------------< Workspace >---

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=1331479&r1=1331478&r2=1331479&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
Fri Apr 27 15:58:54 2012
@@ -19,8 +19,7 @@ package org.apache.jackrabbit.oak.jcr.va
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.namepath.NameMapper;
-import org.apache.jackrabbit.oak.namepath.Paths;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.util.ISO8601;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,18 +50,18 @@ public class ValueFactoryImpl implements
     private static final Logger log = LoggerFactory.getLogger(ValueFactoryImpl.class);
 
     private final CoreValueFactory factory;
-    private final NameMapper nameMapper;
+    private final NamePathMapper namePathMapper;
 
     /**
      * Creates a new instance of {@code ValueFactory}.
      *
      * @param factory The core value factory.
-     * @param nameMapper The name mapping used for converting JCR names/paths to
+     * @param namePathMapper The name/path mapping used for converting JCR names/paths to
      * the internal representation.
      */
-    public ValueFactoryImpl(CoreValueFactory factory, NameMapper nameMapper) {
+    public ValueFactoryImpl(CoreValueFactory factory, NamePathMapper namePathMapper) {
         this.factory = factory;
-        this.nameMapper = nameMapper;
+        this.namePathMapper = namePathMapper;
     }
 
     public CoreValueFactory getCoreValueFactory() {
@@ -70,7 +69,7 @@ public class ValueFactoryImpl implements
     }
 
     public Value createValue(CoreValue coreValue) {
-        return new ValueImpl(coreValue, nameMapper);
+        return new ValueImpl(coreValue, namePathMapper);
     }
 
     public CoreValue getCoreValue(Value jcrValue) {
@@ -99,39 +98,39 @@ public class ValueFactoryImpl implements
     @Override
     public Value createValue(String value) {
         CoreValue cv = factory.createValue(value, PropertyType.STRING);
-        return new ValueImpl(cv, nameMapper);
+        return new ValueImpl(cv, namePathMapper);
     }
 
     @Override
     public Value createValue(long value) {
         CoreValue cv = factory.createValue(value);
-        return new ValueImpl(cv, nameMapper);
+        return new ValueImpl(cv, namePathMapper);
     }
 
     @Override
     public Value createValue(double value) {
         CoreValue cv = factory.createValue(value);
-        return new ValueImpl(cv, nameMapper);
+        return new ValueImpl(cv, namePathMapper);
     }
 
     @Override
     public Value createValue(boolean value) {
         CoreValue cv = factory.createValue(value);
-        return new ValueImpl(cv, nameMapper);
+        return new ValueImpl(cv, namePathMapper);
     }
 
     @Override
     public Value createValue(Calendar value) {
         String dateStr = ISO8601.format(value);
         CoreValue cv = factory.createValue(dateStr, PropertyType.DATE);
-        return new ValueImpl(cv, nameMapper);
+        return new ValueImpl(cv, namePathMapper);
     }
 
     @Override
     public Value createValue(InputStream value) {
         try {
             CoreValue cv = factory.createValue(value);
-            return new ValueImpl(cv, nameMapper);
+            return new ValueImpl(cv, namePathMapper);
         } catch (IOException ex) {
             throw new RuntimeException(ex);
         } finally {
@@ -150,9 +149,10 @@ public class ValueFactoryImpl implements
         CoreValue cv;
         try {
             if (type == PropertyType.NAME) {
-                cv = factory.createValue(nameMapper.getOakName(value), type);
+                cv = factory.createValue(namePathMapper.getOakName(value), type);
             } else if (type == PropertyType.PATH) {
-                cv = factory.createValue(Paths.toOakPath(value, nameMapper), type);
+                String oakPath = namePathMapper.toOakPath(value);
+                cv = factory.createValue(oakPath, type);
             } else if (type == PropertyType.DATE) {
                 if (ISO8601.parse(value) == null) {
                     throw new ValueFormatException("Invalid date " + value);
@@ -172,7 +172,7 @@ public class ValueFactoryImpl implements
             throw new ValueFormatException("Invalid value " + value + " for type " + PropertyType.nameFromValue(type));
         }
 
-        return new ValueImpl(cv, nameMapper);
+        return new ValueImpl(cv, namePathMapper);
     }
 
     @Override
@@ -193,12 +193,12 @@ public class ValueFactoryImpl implements
     @Override
     public Value createValue(BigDecimal value) {
         CoreValue cv = factory.createValue(value);
-        return new ValueImpl(cv, nameMapper);
+        return new ValueImpl(cv, namePathMapper);
     }
 
     @Override
     public Value createValue(Node value, boolean weak) throws RepositoryException {
         CoreValue cv = factory.createValue(value.getUUID(), weak ? PropertyType.WEAKREFERENCE
: PropertyType.REFERENCE);
-        return new ValueImpl(cv, nameMapper);
+        return new ValueImpl(cv, namePathMapper);
     }
 }
\ No newline at end of file

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=1331479&r1=1331478&r2=1331479&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
Fri Apr 27 15:58:54 2012
@@ -18,8 +18,7 @@ package org.apache.jackrabbit.oak.jcr.va
 
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.namepath.NameMapper;
-import org.apache.jackrabbit.oak.namepath.Paths;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.util.ISO8601;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -48,17 +47,17 @@ class ValueImpl implements Value {
     private static final Logger log = LoggerFactory.getLogger(ValueImpl.class);
 
     private final CoreValue value;
-    private final NameMapper nameMapper;
+    private final NamePathMapper namePathMapper;
 
     /**
      * Constructs a {@code ValueImpl} object based on a {@code CoreValue}
      *
      * @param value the value object this {@code ValueImpl} should represent
-     * @param nameMapper
+     * @param namePathMapper
      */
-    public ValueImpl(CoreValue value, NameMapper nameMapper) {
+    public ValueImpl(CoreValue value, NamePathMapper namePathMapper) {
         this.value = value;
-        this.nameMapper = nameMapper;
+        this.namePathMapper = namePathMapper;
     }
 
     CoreValue unwrap() {
@@ -151,9 +150,9 @@ class ValueImpl implements Value {
     public String getString() throws RepositoryException {
         switch (getType()) {
             case PropertyType.NAME :
-                return nameMapper.getJcrName(value.toString());
+                return namePathMapper.getJcrName(value.toString());
             case PropertyType.PATH:
-                return Paths.toJcrPath(value.toString(), nameMapper);
+                return namePathMapper.toJcrPath(value.toString());
             case PropertyType.BINARY:
                 InputStream stream = getStream();
                 try {



Mime
View raw message