jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1382002 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java oak-jcr/pom.xml
Date Fri, 07 Sep 2012 12:55:49 GMT
Author: mduerig
Date: Fri Sep  7 12:55:49 2012
New Revision: 1382002

URL: http://svn.apache.org/viewvc?rev=1382002&view=rev
Log:
OAK-66: JCR Node Type Management
value constraints for multi valued properties

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java?rev=1382002&r1=1382001&r2=1382002&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java
Fri Sep  7 12:55:49 2012
@@ -275,12 +275,10 @@ class NodeTypeImpl implements NodeType {
             if ((propertyName.equals(name) && !isProtected(definition))
                     || "*".equals(name)) {
                 if (!definition.isMultiple()) {
-
-                    // TODO: Check value type, etc.
                     if (!meetsValueConstraints(value, definition.getValueConstraints()))
{
                         return false;
                     }
-
+                    // TODO: Check value type, etc.
                     return true;
                 }
             }
@@ -299,7 +297,10 @@ class NodeTypeImpl implements NodeType {
             if ((propertyName.equals(name) && !isProtected(definition))
                     || "*".equals(name)) {
                 if (definition.isMultiple()) {
-                    // TODO: Check value type, constraints, etc.
+                    if (!meetsValueConstraints(values, definition.getValueConstraints()))
{
+                        return false;
+                    }
+                    // TODO: Check value type, etc.
                     return true;
                 }
             }
@@ -312,6 +313,7 @@ class NodeTypeImpl implements NodeType {
             return true;
         }
 
+        // Any of the constraints must be met
         for (String constraint : constraints) {
             if (Constraints.valueConstraint(value.getType(), constraint).apply(value)) {
                 return true;
@@ -321,6 +323,21 @@ class NodeTypeImpl implements NodeType {
         return false;
     }
 
+    private static boolean meetsValueConstraints(Value[] values, String[] constraints) {
+        if (constraints == null || constraints.length == 0) {
+            return true;
+        }
+
+        // Constraints must be met by all values
+        for (Value value : values) {
+            if (!meetsValueConstraints(value, constraints)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
     @Override
     public boolean canAddChildNode(String childNodeName) {
         for (NodeDefinition definition : getChildNodeDefinitions()) {

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1382002&r1=1382001&r2=1382002&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Fri Sep  7 12:55:49 2012
@@ -73,7 +73,6 @@ org.apache.jackrabbit.test.api.lock.Lock
 org.apache.jackrabbit.test.api.SetPropertyConstraintViolationExceptionTest<!-- OAK-66
-->
 org.apache.jackrabbit.test.api.SetValueConstraintViolationExceptionTest<!-- OAK-66 -->
 org.apache.jackrabbit.test.api.nodetype.PropertyDefTest#testIsMandatory
-org.apache.jackrabbit.test.api.nodetype.CanSetPropertyBinaryTest#testValueConstraintNotSatisfiedMultiple<!--
OAK-66 -->
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyDateTest#testConversions
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyPathTest#testConversions
 org.apache.jackrabbit.test.api.nodetype.CanAddChildNodeCallWithNodeTypeTest#testCanAddAbstractType
<!-- OAK-66 -->



Mime
View raw message