jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1136389 - 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 12:10:37 GMT
Author: mduerig
Date: Thu Jun 16 12:10:36 2011
New Revision: 1136389

URL: http://svn.apache.org/viewvc?rev=1136389&view=rev
Log:
spi2microkernel prototype (WIP)
write: set mixin

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/ItemInfos.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=1136389&r1=1136388&r2=1136389&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 12:10:36 2011
@@ -448,8 +448,12 @@ public class RepositoryServiceImpl exten
         }
 
         public void setMixins(NodeId nodeId, Name[] mixinNodeTypeNames) throws RepositoryException
{
-            // todo implement setMixins
-            throw new UnsupportedRepositoryOperationException("setMixin");
+            if (mixinNodeTypeNames.length == 0) {
+                setProperty(nodeId, NameConstants.JCR_MIXINTYPES, "null");
+            }
+            else {
+                setProperty(nodeId, NameConstants.JCR_MIXINTYPES, Values.create(mixinNodeTypeNames));
+            }
         }
 
         public void setPrimaryType(NodeId nodeId, Name primaryNodeTypeName) throws RepositoryException
{

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/ItemInfos.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/ItemInfos.java?rev=1136389&r1=1136388&r2=1136389&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/ItemInfos.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/ItemInfos.java
Thu Jun 16 12:10:36 2011
@@ -213,8 +213,10 @@ public final class ItemInfos {
                 if (Paths.translateQName(NameConstants.JCR_PRIMARYTYPE).equals(currentKey))
{
                     nodeInfoBuilder.setPrimaryType(Values.create(value).getName());
                 }
-                
-                if (currentKey.startsWith(":")) {  // ignore other internal values
+                else if (Paths.translateQName(NameConstants.JCR_MIXINTYPES).equals(currentKey))
{
+                    nodeInfoBuilder.addMixin(Values.create(value).getName());
+                }
+                else if (currentKey.startsWith(":")) {  // ignore other internal values
                     return !infoListener.done();
                 }
 

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=1136389&r1=1136388&r2=1136389&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 12:10:36 2011
@@ -200,6 +200,24 @@ public final class Values {
         return typeEncode(PropertyType.NAME, JsonBuilder.escape(name.toString()));
     }
 
+    public static String create(Name[] names) {
+        if (names.length == 0) {
+            return "[]";
+        }
+        else {
+            StringBuilder sb = new StringBuilder("[");
+            sb.append(create(names[0]));
+
+            for (int k = 1; k < names.length; k++) {
+                sb.append(',').append(create(names[k]));
+            }
+            sb.append(']');
+
+            return sb.toString();
+
+        }
+    }
+
     public static String create(QValue value) throws RepositoryException {
         int type = value.getType();
         

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=1136389&r1=1136388&r2=1136389&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 12:10:36 2011
@@ -744,7 +744,7 @@ public class RepositoryTest {
         assertEquals("nt:unstructured", testNode.getProperty("jcr:primaryType").getString());
 
         testNode.setPrimaryType("nt:base");
-        testNode.getSession().save();
+        getSession().save();
 
         Session session2 = getRepository().login();
         try {
@@ -771,6 +771,32 @@ public class RepositoryTest {
         assertFalse(ntMgr.hasNodeType("foo"));
     }
 
+    @Test
+    public void mixin() throws RepositoryException {
+        NodeTypeManager ntMgr = getSession().getWorkspace().getNodeTypeManager();
+        NodeTypeTemplate mixTest = ntMgr.createNodeTypeTemplate();
+        mixTest.setName("mix:test");
+        mixTest.setMixin(true);
+        ntMgr.registerNodeType(mixTest, false);
+        
+        Node testNode = getNode(testPath);
+        NodeType[] mix = testNode.getMixinNodeTypes();
+        assertEquals(0, mix.length);
+
+        testNode.addMixin("mix:test");
+        testNode.getSession().save();
+
+        mix = testNode.getMixinNodeTypes();
+        assertEquals(1, mix.length);
+        assertEquals("mix:test", mix[0].getName());
+
+        testNode.removeMixin("mix:test");
+        testNode.getSession().save();
+
+        mix = testNode.getMixinNodeTypes();
+        assertEquals(0, mix.length);
+    }
+
     //------------------------------------------< private >---
 
     private void addProperty(Node parentNode, String name, Value value) throws RepositoryException
{



Mime
View raw message