jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1133762 - in /jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel: RepositoryServiceImpl.java util/Paths.java
Date Thu, 09 Jun 2011 10:02:12 GMT
Author: mduerig
Date: Thu Jun  9 10:02:12 2011
New Revision: 1133762

URL: http://svn.apache.org/viewvc?rev=1133762&view=rev
Log:
spi2microkernel prototype (WIP)
handle jcr:primary type, proper escaping of name space URIs

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.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=1133762&r1=1133761&r2=1133762&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  9 10:02:12 2011
@@ -38,7 +38,9 @@ import org.apache.jackrabbit.spi.Session
 import org.apache.jackrabbit.spi.commons.AbstractRepositoryService;
 import org.apache.jackrabbit.spi.commons.ItemInfoCacheImpl;
 import org.apache.jackrabbit.spi.commons.batch.ConsolidatingChangeLog;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi2microkernel.util.Json;
+import org.apache.jackrabbit.spi2microkernel.util.JsonBuilder;
 import org.apache.jackrabbit.spi2microkernel.util.JsonHandlerBase;
 import org.apache.jackrabbit.spi2microkernel.util.NodeTypes;
 import org.apache.jackrabbit.spi2microkernel.util.Paths;
@@ -53,6 +55,7 @@ import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import java.io.IOException;
+import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -375,7 +378,17 @@ public class RepositoryServiceImpl exten
         }
 
         public void addNode(NodeId parentId, Name nodeName, Name nodetypeName, String uuid)
throws RepositoryException {
-            sb.append('+').append(target(parentId, nodeName)).append(" : {}\n");
+            try {
+                StringWriter sw = new StringWriter();
+                JsonBuilder.create(sw)
+                    .value(Paths.translateQName(NameConstants.JCR_PRIMARYTYPE), Paths.translateQName(nodetypeName))
+                    .build();
+
+                sb.append('+').append(target(parentId, nodeName)).append(" : ").append(sw.toString()).append('\n');
+            }
+            catch (IOException e) {
+                throw new RepositoryException(e);
+            }
         }
 
         public void addProperty(NodeId parentId, Name propertyName, QValue value) throws
RepositoryException {

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java?rev=1133762&r1=1133761&r2=1133762&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java
Thu Jun  9 10:02:12 2011
@@ -36,9 +36,19 @@ public final class Paths {
     private Paths() {}
 
     public static Name translateName(String name) {
-        return name.startsWith("{")
-            ? NAME_FACTORY.create(name)
-            : NAME_FACTORY.create(Name.NS_DEFAULT_URI, name);
+        if (name.startsWith("{")) {
+            int i = name.indexOf('}');
+            if (i == -1 || i == name.length() - 1) {
+                throw new IllegalArgumentException("Invalid name: " + name);
+            }
+
+            String ns = unescapeNameSpaceURI(name.substring(1, i));
+            String localName = name.substring(i + 1);
+            return NAME_FACTORY.create(ns, localName);
+        }
+        else {
+            return NAME_FACTORY.create(Name.NS_DEFAULT_URI, name);
+        }
     }
 
     public static String translateQName(Name name) {



Mime
View raw message