jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1382793 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type: NodeTypeManagerImpl.java PropertyDefinitionImpl.java constraint/StringConstraint.java
Date Mon, 10 Sep 2012 12:27:38 GMT
Author: mduerig
Date: Mon Sep 10 12:27:38 2012
New Revision: 1382793

URL: http://svn.apache.org/viewvc?rev=1382793&view=rev
Log:
OAK-294: nt:propertyDefinition has incorrect value constraints for property types
 converting jcr:requiredType to upper case in propertyDefinitions in order to comply with
nt:propertyDefinition

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/StringConstraint.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java?rev=1382793&r1=1382792&r2=1382793&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
Mon Sep 10 12:27:38 2012
@@ -292,7 +292,7 @@ public class NodeTypeManagerImpl extends
 
         node.setString(
                 JCR_REQUIREDTYPE,
-                PropertyType.nameFromValue(def.getRequiredType()));
+                PropertyType.nameFromValue(def.getRequiredType()).toUpperCase());
         node.setBoolean(JCR_MULTIPLE, def.isMultiple());
         node.setBoolean(JCR_IS_FULLTEXT_SEARCHABLE, def.isFullTextSearchable());
         node.setBoolean(JCR_IS_QUERY_ORDERABLE, def.isQueryOrderable());

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionImpl.java?rev=1382793&r1=1382792&r2=1382793&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionImpl.java
Mon Sep 10 12:27:38 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.type;
 
-import javax.jcr.PropertyType;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.NodeType;
@@ -27,6 +26,33 @@ import org.apache.jackrabbit.oak.util.No
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static javax.jcr.PropertyType.BINARY;
+import static javax.jcr.PropertyType.BOOLEAN;
+import static javax.jcr.PropertyType.DATE;
+import static javax.jcr.PropertyType.DECIMAL;
+import static javax.jcr.PropertyType.DOUBLE;
+import static javax.jcr.PropertyType.LONG;
+import static javax.jcr.PropertyType.NAME;
+import static javax.jcr.PropertyType.PATH;
+import static javax.jcr.PropertyType.REFERENCE;
+import static javax.jcr.PropertyType.STRING;
+import static javax.jcr.PropertyType.TYPENAME_BINARY;
+import static javax.jcr.PropertyType.TYPENAME_BOOLEAN;
+import static javax.jcr.PropertyType.TYPENAME_DATE;
+import static javax.jcr.PropertyType.TYPENAME_DECIMAL;
+import static javax.jcr.PropertyType.TYPENAME_DOUBLE;
+import static javax.jcr.PropertyType.TYPENAME_LONG;
+import static javax.jcr.PropertyType.TYPENAME_NAME;
+import static javax.jcr.PropertyType.TYPENAME_PATH;
+import static javax.jcr.PropertyType.TYPENAME_REFERENCE;
+import static javax.jcr.PropertyType.TYPENAME_STRING;
+import static javax.jcr.PropertyType.TYPENAME_UNDEFINED;
+import static javax.jcr.PropertyType.TYPENAME_URI;
+import static javax.jcr.PropertyType.TYPENAME_WEAKREFERENCE;
+import static javax.jcr.PropertyType.UNDEFINED;
+import static javax.jcr.PropertyType.URI;
+import static javax.jcr.PropertyType.WEAKREFERENCE;
+
 /**
  * <pre>
  * [nt:propertyDefinition]
@@ -56,14 +82,56 @@ class PropertyDefinitionImpl extends Ite
         this.factory = factory;
     }
 
+    /**
+     * Returns the numeric constant value of the type with the specified name.
+     *
+     * In contrast to {@link javax.jcr.PropertyType#valueFromName(String)} this method
+     * requires all type names to be all upper case.
+     * See also: OAK-294 and http://java.net/jira/browse/JSR_283-811
+     *
+     * @param name the name of the property type.
+     * @return the numeric constant value.
+     * @throws IllegalArgumentException if {@code name} is not a valid property type name.
+     */
+    public static int valueFromName(String name) {
+        if (name.equals(TYPENAME_STRING.toUpperCase())) {
+            return STRING;
+        } else if (name.equals(TYPENAME_BINARY.toUpperCase())) {
+            return BINARY;
+        } else if (name.equals(TYPENAME_BOOLEAN.toUpperCase())) {
+            return BOOLEAN;
+        } else if (name.equals(TYPENAME_LONG.toUpperCase())) {
+            return LONG;
+        } else if (name.equals(TYPENAME_DOUBLE.toUpperCase())) {
+            return DOUBLE;
+        } else if (name.equals(TYPENAME_DECIMAL.toUpperCase())) {
+            return DECIMAL;
+        } else if (name.equals(TYPENAME_DATE.toUpperCase())) {
+            return DATE;
+        } else if (name.equals(TYPENAME_NAME.toUpperCase())) {
+            return NAME;
+        } else if (name.equals(TYPENAME_PATH.toUpperCase())) {
+            return PATH;
+        } else if (name.equals(TYPENAME_REFERENCE.toUpperCase())) {
+            return REFERENCE;
+        } else if (name.equals(TYPENAME_WEAKREFERENCE.toUpperCase())) {
+            return WEAKREFERENCE;
+        } else if (name.equals(TYPENAME_URI.toUpperCase())) {
+            return URI;
+        } else if (name.equals(TYPENAME_UNDEFINED.toUpperCase())) {
+            return UNDEFINED;
+        } else {
+            throw new IllegalArgumentException("unknown type: " + name);
+        }
+    }
+
     @Override
     public int getRequiredType() {
         try {
-            return PropertyType.valueFromName(node.getString(
-                    "jcr:requiredType", PropertyType.TYPENAME_UNDEFINED));
+            return valueFromName(node.getString("jcr:requiredType", TYPENAME_UNDEFINED));
         } catch (IllegalArgumentException e) {
             log.warn("Unexpected jcr:requiredType value", e);
-            return PropertyType.UNDEFINED;
+            return UNDEFINED;
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/StringConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/StringConstraint.java?rev=1382793&r1=1382792&r2=1382793&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/StringConstraint.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/StringConstraint.java
Mon Sep 10 12:27:38 2012
@@ -35,10 +35,7 @@ public class StringConstraint implements
     public StringConstraint(String definition) {
         Pattern p;
         try {
-            // FIXME matching case insensitive as a workaround for
-            // for OAK-294: nt:propertyDefinition has incorrect value constraints for property
types
-            int ignoreCase = Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE;
-            p = Pattern.compile(definition, ignoreCase);
+            p = Pattern.compile(definition);
         }
         catch (PatternSyntaxException pse) {
             String msg = '\'' + definition + "' is not valid regular expression syntax";



Mime
View raw message