jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1136336 - in /jackrabbit/sandbox/spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/ main/java/org/apache/jackrabbit/spi2microkernel/util/ test/java/org/apache/jackrabbit/spi2microkernel/
Date Thu, 16 Jun 2011 09:25:47 GMT
Author: mduerig
Date: Thu Jun 16 09:25:47 2011
New Revision: 1136336

URL: http://svn.apache.org/viewvc?rev=1136336&view=rev
Log:
spi2microkernel prototype (WIP)
fixed escaping

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

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1136336&r1=1136335&r2=1136336&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Thu Jun 16 09:25:47 2011
@@ -454,13 +454,14 @@ public class RepositoryServiceImpl exten
         }
 
         private String target(NodeId nodeId) throws RepositoryException {
-            return '\"' + PathUtil.relativize("/", Paths.translateQPath(sessionInfo.getWorkspaceName(),
nodeId.getPath())) + '\"';
+            return '\"' + JsonBuilder.escape(
+                PathUtil.relativize("/", Paths.translateQPath(sessionInfo.getWorkspaceName(),
nodeId.getPath()))) + '\"';
         }
 
         private String target(NodeId parentId, Name itemName) throws RepositoryException
{
             String path = Paths.translateQPath(sessionInfo.getWorkspaceName(), parentId.getPath());
             String name = Paths.translateQName(itemName);
-            return '\"' + PathUtil.concat(PathUtil.relativize("/", path), name) + '\"';
+            return '\"' + JsonBuilder.escape(PathUtil.concat(PathUtil.relativize("/", path),
name)) + '\"';
         }
 
         private void setProperty(NodeId parentId, Name propertyName, String jsonValue) throws
RepositoryException {

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java?rev=1136336&r1=1136335&r2=1136336&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
Thu Jun 16 09:25:47 2011
@@ -216,13 +216,15 @@ public final class Values {
             
             case PropertyType.DECIMAL:
             case PropertyType.DATE:
+                return typeEncode(type, value.getString());
+
             case PropertyType.URI:
             case PropertyType.NAME:
             case PropertyType.PATH:
-                return typeEncode(type, value.getString());
+                return typeEncode(type, JsonBuilder.escape(value.getString()));
             
             case PropertyType.BINARY:
-                return typeEncode(type, value.getString());  // todo improve handling of
binary values
+                return typeEncode(type, JsonBuilder.escape(value.getString()));  // todo
improve handling of binary values
 
             case PropertyType.REFERENCE:      // todo handle reference values
             case PropertyType.WEAKREFERENCE:  // todo handle weak reference values

Modified: jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java?rev=1136336&r1=1136335&r2=1136336&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Thu Jun 16 09:25:47 2011
@@ -219,11 +219,11 @@ public class RepositoryTest {
     @Test
     public void addNode() throws RepositoryException {
         Session session = getSession();
-        String newNode = testPath + "/new";
+        String newNode = testPath + "/new\"";
         assertFalse(session.nodeExists(newNode));
 
         Node node = getNode(testPath);
-        node.addNode("new");
+        node.addNode("new\"");
         session.save();
 
         Session session2 = getRepository().login();
@@ -240,6 +240,7 @@ public class RepositoryTest {
         Node parentNode = getNode(testPath);
         addProperty(parentNode, "string", getSession().getValueFactory().createValue("string
value"));
         addProperty(parentNode, "string2", getSession().getValueFactory().createValue("s:string
value"));
+        addProperty(parentNode, "string\"", getSession().getValueFactory().createValue("s:string
value\""));
     }
 
     @Test
@@ -247,7 +248,7 @@ public class RepositoryTest {
         Node parentNode = getNode(testPath);
         Value[] values = new Value[2];
         values[0] = getSession().getValueFactory().createValue("one");
-        values[1] = getSession().getValueFactory().createValue("two");
+        values[1] = getSession().getValueFactory().createValue("two\"");
 
         parentNode.setProperty("multi string", values);
         parentNode.getSession().save();
@@ -452,7 +453,7 @@ public class RepositoryTest {
     @Test
     public void addNameProperty() throws RepositoryException {
         Node parentNode = getNode(testPath);
-        addProperty(parentNode, "name", getSession().getValueFactory().createValue("jcr:something",
PropertyType.NAME));
+        addProperty(parentNode, "name", getSession().getValueFactory().createValue("jcr:something\"",
PropertyType.NAME));
     }
 
     @Test
@@ -482,7 +483,7 @@ public class RepositoryTest {
     @Test
     public void addPathProperty() throws RepositoryException {
         Node parentNode = getNode(testPath);
-        addProperty(parentNode, "path", getSession().getValueFactory().createValue("/jcr:foo/bar",
PropertyType.PATH));
+        addProperty(parentNode, "path", getSession().getValueFactory().createValue("/jcr:foo/bar\"",
PropertyType.PATH));
     }
 
     @Test
@@ -512,7 +513,7 @@ public class RepositoryTest {
     @Test
     public void addBinaryProperty() throws RepositoryException {
         Node parentNode = getNode(testPath);
-        InputStream is = new ByteArrayInputStream("foo".getBytes());
+        InputStream is = new ByteArrayInputStream("foo\"".getBytes());
         Binary bin = getSession().getValueFactory().createBinary(is);
         addProperty(parentNode, "binary", getSession().getValueFactory().createValue(bin));
     }
@@ -706,12 +707,12 @@ public class RepositoryTest {
     @Test
     public void removeNode() throws RepositoryException {
         Node parentNode = getNode(testPath);
-        parentNode.addNode("newNode");
+        parentNode.addNode("newNode\"");
         parentNode.getSession().save();
 
         Session session2 = getRepository().login();
         try {
-            session2.getNode(testPath + "/newNode").remove();
+            session2.getNode(testPath + "/newNode\"").remove();
             session2.save();
         }
         finally {
@@ -720,7 +721,7 @@ public class RepositoryTest {
 
         Session session3 = getRepository().login();
         try {
-            assertFalse(session3.nodeExists(testPath + "/newNode"));
+            assertFalse(session3.nodeExists(testPath + "/newNode\""));
         }
         finally {
             session3.logout();



Mime
View raw message