jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1159642 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/ main/java/org/apache/jackrabbit/spi2microkernel/util/ test/java/org/apache/jackrabbit/spi2microkernel/
Date Fri, 19 Aug 2011 14:17:16 GMT
Author: mduerig
Date: Fri Aug 19 14:17:16 2011
New Revision: 1159642

URL: http://svn.apache.org/viewvc?rev=1159642&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
- handle relative paths correctly

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1159642&r1=1159641&r2=1159642&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Fri Aug 19 14:17:16 2011
@@ -725,8 +725,8 @@ public class RepositoryServiceImpl exten
         }
         
         private String target(NodeId nodeId) throws RepositoryException {
-            return '\"' + JsonBuilder.escape(
-                PathUtils.relativize("/", Paths.pathToString(sessionInfo.getWorkspaceName(),
getPath(nodeId)))) + '\"';
+            return JsonBuilder.quote(JsonBuilder.escape(
+                PathUtils.relativize("/", Paths.pathToString(sessionInfo.getWorkspaceName(),
getPath(nodeId)))));
         }
 
         private String target(NodeId parentId, Name... itemNames) throws RepositoryException
{
@@ -737,7 +737,7 @@ public class RepositoryServiceImpl exten
                 String name = Paths.nameToString(itemName);
                 relPath = PathUtils.concat(relPath, name);
             }
-            return '\"' + JsonBuilder.escape(relPath) + '\"';
+            return JsonBuilder.quote(JsonBuilder.escape(relPath));
         }
 
         private void setProperty(NodeId parentId, Name propertyName, String jsonValue) throws
RepositoryException {

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java?rev=1159642&r1=1159641&r2=1159642&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java
Fri Aug 19 14:17:16 2011
@@ -90,14 +90,17 @@ public final class Paths {
         return '{' + escapeNameSpaceURI(nameSpaceURI) + '}' + name.getLocalName();
     }
 
-    public static String pathToString(Path absPath) throws RepositoryException {
-        return translateQPath(absPath);
+    public static String pathToString(Path path) throws RepositoryException {
+        return translateQPath(path);
     }
 
     public static String pathToString(String wspName, Path absPath) throws RepositoryException
{
         if (wspName == null || "".equals(wspName) || wspName.contains("/")) {
             throw new RepositoryException("Invalid workspace name: " + wspName);
         }
+        if (!absPath.isAbsolute()) {
+            throw new IllegalArgumentException("Path is not absolute: " + absPath);
+        }
 
         String wspPath = '/' + wspName;
 
@@ -129,13 +132,15 @@ public final class Paths {
     }
 
     private static String translateQPath(Path path) throws RepositoryException {
-        if (!path.isAbsolute()) {
-            throw new IllegalArgumentException("Path is not absolute: " + path);
+        if (path.denotesRoot()) {
+            return "/";
+        }
+        else if (path.denotesCurrent()) {
+            return "";
+        }
+        else {
+            return PathUtils.concat(translateQPath(path.getAncestor(1)), nameToString(path.getName()));
         }
-
-        return path.denotesRoot()
-            ? "/"
-            : PathUtils.concat(translateQPath(path.getAncestor(1)), nameToString(path.getName()));
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java?rev=1159642&r1=1159641&r2=1159642&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Fri Aug 19 14:17:16 2011
@@ -620,7 +620,8 @@ public class RepositoryTest {
     @Test
     public void addPathProperty() throws RepositoryException, IOException {
         Node parentNode = getNode(testPath);
-        addProperty(parentNode, "path", getSession().getValueFactory().createValue("/jcr:foo/bar\"",
PropertyType.PATH));
+        addProperty(parentNode, "path1", getSession().getValueFactory().createValue("/jcr:foo/bar\"",
PropertyType.PATH));
+        addProperty(parentNode, "path2", getSession().getValueFactory().createValue("foo/bar\"",
PropertyType.PATH));
     }
 
     @Test



Mime
View raw message