jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1330884 - in /jackrabbit/oak/trunk: oak-it/jcr/ oak-it/jcr/src/test/resources/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/
Date Thu, 26 Apr 2012 14:44:25 GMT
Author: angela
Date: Thu Apr 26 14:44:24 2012
New Revision: 1330884

URL: http://svn.apache.org/viewvc?rev=1330884&view=rev
Log:
OAK-72 - Implement JCR API

- add missing check for null values in Node#setProperty, Property#setValue
- uncomment some TCK tests related to property modification
- add check for single-value <-> mv conversion (with TODO)
- change test-node type name to nt:unstructured

Modified:
    jackrabbit/oak/trunk/oak-it/jcr/pom.xml
    jackrabbit/oak/trunk/oak-it/jcr/src/test/resources/repositoryStubImpl.properties
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java

Modified: jackrabbit/oak/trunk/oak-it/jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/jcr/pom.xml?rev=1330884&r1=1330883&r2=1330884&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-it/jcr/pom.xml Thu Apr 26 14:44:24 2012
@@ -62,24 +62,11 @@ org.apache.jackrabbit.test.api.NodeTest
 org.apache.jackrabbit.test.api.NodeUUIDTest
 org.apache.jackrabbit.test.api.NodeOrderableChildNodesTest
 org.apache.jackrabbit.test.api.PropertyTest
-org.apache.jackrabbit.test.api.SetValueBinaryTest
-org.apache.jackrabbit.test.api.SetValueBooleanTest
-org.apache.jackrabbit.test.api.SetValueDateTest
-org.apache.jackrabbit.test.api.SetValueDecimalTest
-org.apache.jackrabbit.test.api.SetValueDoubleTest
-org.apache.jackrabbit.test.api.SetValueLongTest
 org.apache.jackrabbit.test.api.SetValueReferenceTest
-org.apache.jackrabbit.test.api.SetValueStringTest
 org.apache.jackrabbit.test.api.SetValueConstraintViolationExceptionTest
 org.apache.jackrabbit.test.api.SetValueValueFormatExceptionTest
 org.apache.jackrabbit.test.api.SetValueFormatExceptionTest
 org.apache.jackrabbit.test.api.SetValueVersionExceptionTest
-org.apache.jackrabbit.test.api.SetPropertyBooleanTest
-org.apache.jackrabbit.test.api.SetPropertyCalendarTest
-org.apache.jackrabbit.test.api.SetPropertyDecimalTest
-org.apache.jackrabbit.test.api.SetPropertyDoubleTest
-org.apache.jackrabbit.test.api.SetPropertyInputStreamTest
-org.apache.jackrabbit.test.api.SetPropertyLongTest
 org.apache.jackrabbit.test.api.SetPropertyNodeTest
 org.apache.jackrabbit.test.api.SetPropertyNodeTest
 org.apache.jackrabbit.test.api.SetPropertyStringTest

Modified: jackrabbit/oak/trunk/oak-it/jcr/src/test/resources/repositoryStubImpl.properties
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/jcr/src/test/resources/repositoryStubImpl.properties?rev=1330884&r1=1330883&r2=1330884&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/src/test/resources/repositoryStubImpl.properties (original)
+++ jackrabbit/oak/trunk/oak-it/jcr/src/test/resources/repositoryStubImpl.properties Thu Apr
26 14:44:24 2012
@@ -108,7 +108,7 @@ javax.jcr.tck.SetValueVersionExceptionTe
 javax.jcr.tck.SetValueVersionExceptionTest.propertyname3=jcr:content
 
 # Test class: SetValueValueFormatExceptionTest
-javax.jcr.tck.SetValueValueFormatExceptionTest.nodetype=test:canSetProperty
+javax.jcr.tck.SetValueValueFormatExceptionTest.nodetype=nt:unstructured
 javax.jcr.tck.SetValueValueFormatExceptionTest.testValue.propertyname1=Boolean
 javax.jcr.tck.SetValueValueFormatExceptionTest.testValueArray.propertyname1=BooleanMultiple
 javax.jcr.tck.SetValueValueFormatExceptionTest.testString.propertyname1=Date
@@ -122,7 +122,7 @@ javax.jcr.tck.SetValueValueFormatExcepti
 javax.jcr.tck.SetValueValueFormatExceptionTest.testNodeNotReferenceable.propertyname1=ReferenceConstraints
 
 # Test class: SetPropertyAssumeTypeTest
-javax.jcr.tck.SetPropertyAssumeTypeTest.nodetype=test:canSetProperty
+javax.jcr.tck.SetPropertyAssumeTypeTest.nodetype=nt:unstructured
 javax.jcr.tck.SetPropertyAssumeTypeTest.testStringConstraintViolationExceptionBecauseOfInvalidTypeParameter.propertyname1=String
 javax.jcr.tck.SetPropertyAssumeTypeTest.testValueConstraintViolationExceptionBecauseOfInvalidTypeParameter.propertyname1=String
 javax.jcr.tck.SetPropertyAssumeTypeTest.testValuesConstraintViolationExceptionBecauseOfInvalidTypeParameter.propertyname1=StringMultiple
@@ -233,17 +233,17 @@ javax.jcr.tck.NodeOrderableChildNodesTes
 
 # Test class: SetPropertyNodeTest
 # nodetype which is referenceable
-javax.jcr.tck.SetPropertyNodeTest.nodetype=test:setProperty
+javax.jcr.tck.SetPropertyNodeTest.nodetype=nt:unstructured
 
 # Test class: SetPropertyValueTest
 # property that allows multiple values
 javax.jcr.tck.SetPropertyValueTest.propertyname2=test:multiProperty
-javax.jcr.tck.SetPropertyValueTest.nodetype=test:setProperty
+javax.jcr.tck.SetPropertyValueTest.nodetype=nt:unstructured
 
 # Test class: SetPropertyStringTest
 # property that allows multiple values
 javax.jcr.tck.SetPropertyStringTest.propertyname2=test:multiProperty
-javax.jcr.tck.SetPropertyStringTest.nodetype=test:setProperty
+javax.jcr.tck.SetPropertyStringTest.nodetype=nt:unstructured
 
 # Test class: WorkspaceCloneSameNameSibsTest
 javax.jcr.tck.WorkspaceCloneSameNameSibsTest.sameNameSibsFalseNodeType=test:sameNameSibsFalseChildNodeDefinition

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1330884&r1=1330883&r2=1330884&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Thu Apr 26 14:44:24 2012
@@ -191,11 +191,15 @@ public class NodeImpl extends ItemImpl i
         checkStatus();
 
         int targetType = getTargetType(value, type);
-        Value targetValue = ValueHelper.convert(value, targetType,
-                getValueFactory());
-        CoreValue oakValue = ValueConverter.toCoreValue(targetValue,
-                sessionContext);
-        return new PropertyImpl(dlg.setProperty(toOakPath(jcrName), oakValue));
+        Value targetValue = ValueHelper.convert(value, targetType, getValueFactory());
+        if (value == null) {
+            Property p = getProperty(jcrName);
+            p.remove();
+            return p;
+        } else {
+            CoreValue oakValue = ValueConverter.toCoreValue(targetValue, sessionContext);
+            return new PropertyImpl(dlg.setProperty(toOakPath(jcrName), oakValue));
+        }
     }
 
     /**
@@ -213,16 +217,19 @@ public class NodeImpl extends ItemImpl i
     }
 
     @Override
-    public Property setProperty(String jcrName, Value[] values, int type)
-            throws RepositoryException {
+    public Property setProperty(String jcrName, Value[] values, int type) throws RepositoryException
{
         checkStatus();
 
         int targetType = getTargetType(values, type);
-        Value[] targetValue = ValueHelper.convert(values, targetType,
-                getValueFactory());
-        List<CoreValue> oakValue = ValueConverter.toCoreValues(targetValue,
-                sessionContext);
-        return new PropertyImpl(dlg.setProperty(toOakPath(jcrName), oakValue));
+        Value[] targetValues = ValueHelper.convert(values, targetType, getValueFactory());
+        if (targetValues == null) {
+            Property p = getProperty(jcrName);
+            p.remove();
+            return p;
+        } else {
+            List<CoreValue> oakValue = ValueConverter.toCoreValues(targetValues, sessionContext);
+            return new PropertyImpl(dlg.setProperty(toOakPath(jcrName), oakValue));
+        }
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1330884&r1=1330883&r2=1330884&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Thu Apr 26 14:44:24 2012
@@ -18,7 +18,9 @@ package org.apache.jackrabbit.oak.jcr;
 
 import java.io.InputStream;
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.List;
 
 import javax.jcr.Binary;
 import javax.jcr.Item;
@@ -188,16 +190,17 @@ public class PropertyImpl extends ItemIm
         checkStatus();
 
         int reqType = getRequiredType(PropertyType.STRING);
-        Value[] vs;
         if (values == null) {
-            vs = null;
+            setValues(null, reqType);
         } else {
-            vs = new Value[values.length];
-            for (int i = 0; i < values.length; i++) {
-                vs[i] = getValueFactory().createValue(values[i]);
+            List<Value> vs = new ArrayList<Value>(values.length);
+            for (String value : values) {
+                if (value != null) {
+                    vs.add(getValueFactory().createValue(value));
+                }
             }
+            setValues(vs.toArray(new Value[vs.size()]), reqType);
         }
-        setValues(vs, reqType);
     }
 
     /**
@@ -261,7 +264,11 @@ public class PropertyImpl extends ItemIm
         checkStatus();
 
         int reqType = getRequiredType(PropertyType.DECIMAL);
-        setValue(getValueFactory().createValue(value), reqType);
+        if (value == null) {
+            setValue(null, reqType);
+        } else {
+            setValue(getValueFactory().createValue(value), reqType);
+        }
     }
 
     /**
@@ -544,9 +551,12 @@ public class PropertyImpl extends ItemIm
     * @throws RepositoryException
     */
    private void setValue(Value value, int requiredType) throws RepositoryException {
-       
        assert(requiredType != PropertyType.UNDEFINED);
-       
+
+      // TODO check again if definition validation should be respected here.
+       if (isMultiple()) {
+           throw new ValueFormatException("Attempt to set a single value to multi-valued
property.");
+       }
        if (value == null) {
            dlg.remove();
        } else {
@@ -562,9 +572,12 @@ public class PropertyImpl extends ItemIm
    * @throws RepositoryException
    */
   private void setValues(Value[] values, int requiredType) throws RepositoryException {
-      
       assert(requiredType != PropertyType.UNDEFINED);
 
+      // TODO check again if definition validation should be respected here.
+      if (!isMultiple()) {
+          throw new ValueFormatException("Attempt to set multiple values to single valued
property.");
+      }
       if (values == null) {
           remove();
       } else {



Mime
View raw message