[dna-commits] DNA SVN: r810 - in trunk/dna-jcr/src: main/resources/org/jboss/dna/jcr and 1 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Tue Apr 7 18:21:03 EDT 2009


Author: rhauch
Date: 2009-04-07 18:21:03 -0400 (Tue, 07 Apr 2009)
New Revision: 810

Modified:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrValue.java
   trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
Log:
DNA-194 Implement update JCR capability

Uncommented more TCK unit tests for Level 2.


Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-04-07 21:23:28 UTC (rev 809)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-04-07 22:21:03 UTC (rev 810)
@@ -727,6 +727,10 @@
     public final Property setProperty( String name,
                                        Calendar value )
         throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            // If there is an existing property, then remove it ...
+            return removeExistingSingleValuedProperty(name);
+        }
         return cache.findJcrProperty(editor().setProperty(nameFrom(name), valueFrom(value)));
 
     }
@@ -751,6 +755,10 @@
     public final Property setProperty( String name,
                                        InputStream value )
         throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            // If there is an existing property, then remove it ...
+            return removeExistingSingleValuedProperty(name);
+        }
         return cache.findJcrProperty(editor().setProperty(nameFrom(name), valueFrom(value)));
     }
 
@@ -774,6 +782,10 @@
     public final Property setProperty( String name,
                                        Node value )
         throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            // If there is an existing property, then remove it ...
+            return removeExistingSingleValuedProperty(name);
+        }
         return cache.findJcrProperty(editor().setProperty(nameFrom(name), valueFrom(value)));
     }
 
@@ -785,6 +797,10 @@
     public final Property setProperty( String name,
                                        String value )
         throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            // If there is an existing property, then remove it ...
+            return removeExistingSingleValuedProperty(name);
+        }
         return cache.findJcrProperty(editor().setProperty(nameFrom(name), valueFrom(PropertyType.STRING, value)));
     }
 
@@ -797,6 +813,10 @@
                                        String value,
                                        int type )
         throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            // If there is an existing property, then remove it ...
+            return removeExistingSingleValuedProperty(name);
+        }
         return cache.findJcrProperty(editor().setProperty(nameFrom(name), valueFrom(type, value)));
     }
 
@@ -831,9 +851,26 @@
     public final Property setProperty( String name,
                                        Value value )
         throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            // If there is an existing property, then remove it ...
+            return removeExistingSingleValuedProperty(name);
+        }
         return cache.findJcrProperty(editor().setProperty(nameFrom(name), (JcrValue)value));
     }
 
+    protected final Property removeExistingSingleValuedProperty( String name )
+        throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+        PropertyId id = new PropertyId(nodeUuid, nameFrom(name));
+        AbstractJcrProperty property = cache.findJcrProperty(id);
+        if (property != null) {
+            assert !property.isMultiple();
+            property.remove();
+            return property;
+        }
+        // else the property doesn't exist ...
+        throw new RepositoryException(JcrI18n.propertyNotFoundOnNode.text(name, getPath(), cache.workspaceName()));
+    }
+
     /**
      * {@inheritDoc}
      * 

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java	2009-04-07 21:23:28 UTC (rev 809)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java	2009-04-07 22:21:03 UTC (rev 810)
@@ -69,6 +69,7 @@
     public static I18n itemNotFoundWithUuid;
     public static I18n itemNotFoundAtPath;
     public static I18n itemNotFoundAtPathRelativeToReferenceNode;
+    public static I18n propertyNotFoundOnNode;
     public static I18n propertyNotFoundAtPathRelativeToReferenceNode;
     public static I18n nodeNotFoundAtPathRelativeToReferenceNode;
     public static I18n childNotFoundUnderNode;

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrValue.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrValue.java	2009-04-07 21:23:28 UTC (rev 809)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrValue.java	2009-04-07 22:21:03 UTC (rev 810)
@@ -50,6 +50,8 @@
 @NotThreadSafe
 final class JcrValue implements Value {
 
+    static final JcrValue[] EMPTY_ARRAY = new JcrValue[] {};
+
     private final SessionCache sessionCache;
     private final ValueFactories valueFactories;
     private final int type;

Modified: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties	2009-04-07 21:23:28 UTC (rev 809)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties	2009-04-07 22:21:03 UTC (rev 810)
@@ -59,6 +59,7 @@
 itemNotFoundWithUuid = An item with UUID "{0}" could not be found in workspace "{1}": {2}
 itemNotFoundAtPath = An item at "{0}" could not be found in workspace "{1}"
 itemNotFoundAtPathRelativeToReferenceNode = An item at "{0}" relative to "{1}" could not be found in workspace "{2}"
+propertyNotFoundOnNode = Property "{0}" does not exist on node "{1}" in workspace "{2}"
 propertyNotFoundAtPathRelativeToReferenceNode = A property at "{0}" relative to "{1}" could not be found in workspace "{2}"
 nodeNotFoundAtPathRelativeToReferenceNode = A node at "{0}" relative to "{1}" could not be found in workspace "{2}"
 childNotFoundUnderNode = The child "{0}" could not be found under "{1}" in workspace "{2}"

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java	2009-04-07 21:23:28 UTC (rev 809)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java	2009-04-07 22:21:03 UTC (rev 810)
@@ -41,11 +41,20 @@
 import org.apache.jackrabbit.test.api.PropertyTest;
 import org.apache.jackrabbit.test.api.RepositoryLoginTest;
 import org.apache.jackrabbit.test.api.SessionUUIDTest;
+import org.apache.jackrabbit.test.api.SetPropertyBooleanTest;
+import org.apache.jackrabbit.test.api.SetPropertyCalendarTest;
+import org.apache.jackrabbit.test.api.SetPropertyConstraintViolationExceptionTest;
+import org.apache.jackrabbit.test.api.SetPropertyDoubleTest;
+import org.apache.jackrabbit.test.api.SetPropertyInputStreamTest;
+import org.apache.jackrabbit.test.api.SetPropertyLongTest;
+import org.apache.jackrabbit.test.api.SetValueBinaryTest;
 import org.apache.jackrabbit.test.api.SetValueBooleanTest;
+import org.apache.jackrabbit.test.api.SetValueConstraintViolationExceptionTest;
 import org.apache.jackrabbit.test.api.SetValueDateTest;
 import org.apache.jackrabbit.test.api.SetValueDoubleTest;
 import org.apache.jackrabbit.test.api.SetValueLongTest;
 import org.apache.jackrabbit.test.api.SetValueReferenceTest;
+import org.apache.jackrabbit.test.api.SetValueVersionExceptionTest;
 import org.apache.jackrabbit.test.api.ValueFactoryTest;
 import org.jboss.dna.graph.DnaLexicon;
 import org.jboss.dna.graph.ExecutionContext;
@@ -164,26 +173,26 @@
             // addTestSuite(NodeOrderableChildNodesTest.class);
             addTestSuite(PropertyTest.class);
             //
-            // addTestSuite(SetValueBinaryTest.class);
+            addTestSuite(SetValueBinaryTest.class);
             addTestSuite(SetValueBooleanTest.class);
             addTestSuite(SetValueDateTest.class);
             addTestSuite(SetValueDoubleTest.class);
             addTestSuite(SetValueLongTest.class);
             addTestSuite(SetValueReferenceTest.class);
             // addTestSuite(SetValueStringTest.class);
-            // addTestSuite(SetValueConstraintViolationExceptionTest.class);
+            addTestSuite(SetValueConstraintViolationExceptionTest.class);
             // addTestSuite(SetValueValueFormatExceptionTest.class);
-            // addTestSuite(SetValueVersionExceptionTest.class);
-            //
-            // addTestSuite(SetPropertyBooleanTest.class);
-            // addTestSuite(SetPropertyCalendarTest.class);
-            // addTestSuite(SetPropertyDoubleTest.class);
-            // addTestSuite(SetPropertyInputStreamTest.class);
-            // addTestSuite(SetPropertyLongTest.class);
+            addTestSuite(SetValueVersionExceptionTest.class);
+
+            addTestSuite(SetPropertyBooleanTest.class);
+            addTestSuite(SetPropertyCalendarTest.class);
+            addTestSuite(SetPropertyDoubleTest.class);
+            addTestSuite(SetPropertyInputStreamTest.class);
+            addTestSuite(SetPropertyLongTest.class);
             // addTestSuite(SetPropertyNodeTest.class);
             // addTestSuite(SetPropertyStringTest.class);
             // addTestSuite(SetPropertyValueTest.class);
-            // addTestSuite(SetPropertyConstraintViolationExceptionTest.class);
+            addTestSuite(SetPropertyConstraintViolationExceptionTest.class);
             // addTestSuite(SetPropertyAssumeTypeTest.class);
             //
             // addTestSuite(NodeItemIsModifiedTest.class);




More information about the dna-commits mailing list