jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1133293 - 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 Wed, 08 Jun 2011 09:04:37 GMT
Author: mduerig
Date: Wed Jun  8 09:04:37 2011
New Revision: 1133293

URL: http://svn.apache.org/viewvc?rev=1133293&view=rev
Log:
spi2microkernel prototype (WIP)
write support: addProperty

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=1133293&r1=1133292&r2=1133293&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
Wed Jun  8 09:04:37 2011
@@ -385,8 +385,8 @@ public class RepositoryServiceImpl exten
         }
 
         public void addProperty(NodeId parentId, Name propertyName, QValue[] values) throws
RepositoryException {
-            // todo implement addProperty
-            throw new UnsupportedRepositoryOperationException("addProperty");
+            String val = Values.create(values);
+            sb.append('^').append(target(parentId, propertyName)).append(" : ").append(val);
         }
 
         public void setValue(PropertyId propertyId, QValue value) 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=1133293&r1=1133292&r2=1133293&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
Wed Jun  8 09:04:37 2011
@@ -100,12 +100,28 @@ public final class Values {
             case PropertyType.REFERENCE:
             case PropertyType.WEAKREFERENCE:
             case PropertyType.URI:
-            default:  // todo implement support for all value types
+            default:  // todo implement support for the other value types
                 throw new UnsupportedRepositoryOperationException("Cannot handle value of
type " +
                         PropertyType.nameFromValue(value.getType()));
         }
     }
 
+    public static String create(QValue[] values) throws RepositoryException {
+        if (values.length == 0) {
+            return "[]";
+        }
+
+        StringBuilder sb = new StringBuilder("[");
+        sb.append(create(values[0]));
+
+        for (int k = 1; k < values.length; k++) {
+            sb.append(',').append(create(values[k]));
+        }
+        sb.append(']');
+
+        return sb.toString();
+    }
+
     //------------------------------------------< private >---
 
     private static QValue create(boolean value) {

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=1133293&r1=1133292&r2=1133293&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
Wed Jun  8 09:04:37 2011
@@ -254,6 +254,31 @@ public class RepositoryTest {
         addProperty(parentNode, "decimal", getSession().getValueFactory().createValue(BigDecimal.valueOf(21)));
     }
 
+    @Ignore  // todo fix in microkernel
+    @Test
+    public void setMultiValuedProperty() throws RepositoryException {
+        Node parentNode = getNode("/bar");
+        Value[] values = new Value[2];
+        values[0] = getSession().getValueFactory().createValue("one");
+        values[1] = getSession().getValueFactory().createValue("two");
+
+        parentNode.setProperty("multi string", values);
+        parentNode.getSession().save();
+
+        Session session2 = getRepository().login();
+        try {
+            Property property = session2.getProperty("/bar/mv");
+            assertTrue(property.isMultiple());
+            Value[] values2 = property.getValues();
+            assertEquals(2, values.length);
+            assertEquals(values[0], values2[0]);
+            assertEquals(values[1], values2[1]);
+        }
+        finally {
+            session2.logout();
+        }
+    }
+
     //------------------------------------------< private >---
 
     private void addProperty(Node parentNode, String name, Value value) throws RepositoryException
{



Mime
View raw message