jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1330853 - in /jackrabbit/oak/trunk/oak-jcr/src/main: java/org/apache/jackrabbit/oak/jcr/nodetype/ resources/org/apache/jackrabbit/oak/jcr/nodetype/
Date Thu, 26 Apr 2012 13:52:12 GMT
Author: jukka
Date: Thu Apr 26 13:52:12 2012
New Revision: 1330853

URL: http://svn.apache.org/viewvc?rev=1330853&view=rev
Log:
OAK-66: JCR Node Type Management

Fix more CND parsing problems

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/resources/org/apache/jackrabbit/oak/jcr/nodetype/builtin_nodetypes.cnd

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeImpl.java?rev=1330853&r1=1330852&r2=1330853&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeImpl.java
Thu Apr 26 13:52:12 2012
@@ -43,13 +43,14 @@ import org.apache.jackrabbit.oak.namepat
 class NodeTypeImpl implements NodeType {
 
     private static final Pattern CND_PATTERN = Pattern.compile(
-            "( > (\\S+(, \\S+)*))?(\n  mixin)?(\n  abstract)?"
-            + "(\n  orderable)?(\n  primaryitem (\\S+))?(\n.*)*");
+            "( > (([\\S, ]+)))?(\n  mixin)?(\n  abstract)?"
+            + "(\n  orderable)?(\n  primaryitem (\\S+))?\n?(.*)",
+            Pattern.DOTALL);
 
     private static final Pattern DEF_PATTERN = Pattern.compile(
-            "  ([\\+\\-]) (\\S+) \\((.+?)\\)( = (\\S+))"
+            "  ([\\+\\-]) (\\S+) \\((\\S+?)\\)( = (\\S+))?"
             + "(( (mandatory|autocreated|protected|multiple))*)"
-            + "( ([A-Z])+)?.*");
+            + "( ([A-Z]+))?(.*)");
 
     private final NodeTypeManager manager;
 
@@ -98,11 +99,12 @@ class NodeTypeImpl implements NodeType {
         }
 
         String defs = matcher.group(9);
-        if (defs != null) {
-            defs = defs.trim();
+        if (defs != null && defs.length() > 0) {
             for (String line : defs.split("\n")) {
                 matcher = DEF_PATTERN.matcher(line);
-                matcher.matches();
+                if (!matcher.matches()) {
+                    continue;
+                }
 
                 String defName = matcher.group(2);
                 String defType = matcher.group(3);
@@ -113,9 +115,9 @@ class NodeTypeImpl implements NodeType {
                 boolean multiple = matcher.group(6).contains(" multiple");
 
                 int onParentVersionAction = OnParentVersionAction.COPY;
-                if (matcher.group(9) != null) {
+                if (matcher.group(10) != null) {
                     onParentVersionAction =
-                            OnParentVersionAction.valueFromName(matcher.group(9));
+                            OnParentVersionAction.valueFromName(matcher.group(10));
                 }
 
                 if ("+".equals(matcher.group(1))) {
@@ -123,16 +125,48 @@ class NodeTypeImpl implements NodeType {
                             this, mapper, defName, autoCreated, mandatory,
                             onParentVersionAction, isProtected, manager,
                             defType.split(", "), matcher.group(5), false));
-                } else {
+                } else if ("+".equals(matcher.group(1))) {
                     declaredPropertyDefinitions.add(new PropertyDefinitionImpl(
                             this, mapper, defName, autoCreated, mandatory,
                             onParentVersionAction, isProtected,
-                            PropertyType.valueFromName(defType), multiple));
+                            valueFromName(defType), multiple));
                 }
             }
         }
     }
 
+    private static int valueFromName(String name) {
+        if (name.equalsIgnoreCase(PropertyType.TYPENAME_STRING)) {
+            return PropertyType.STRING;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_BINARY)) {
+            return PropertyType.BINARY;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_BOOLEAN)) {
+            return PropertyType.BOOLEAN;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_LONG)) {
+            return PropertyType.LONG;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_DOUBLE)) {
+            return PropertyType.DOUBLE;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_DECIMAL)) {
+            return PropertyType.DECIMAL;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_DATE)) {
+            return PropertyType.DATE;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_NAME)) {
+            return PropertyType.NAME;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_PATH)) {
+            return PropertyType.PATH;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_REFERENCE)) {
+            return PropertyType.REFERENCE;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_WEAKREFERENCE)) {
+            return PropertyType.WEAKREFERENCE;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_URI)) {
+            return PropertyType.URI;
+        } else if (name.equalsIgnoreCase(PropertyType.TYPENAME_UNDEFINED)) {
+            return PropertyType.UNDEFINED;
+        } else {
+            throw new IllegalArgumentException("unknown type: " + name);
+        }
+    }
+
     @Override
     public String getName() {
         return mapper.getJcrName(name);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java?rev=1330853&r1=1330852&r2=1330853&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
Thu Apr 26 13:52:12 2012
@@ -45,7 +45,7 @@ import org.apache.jackrabbit.oak.namepat
 public class NodeTypeManagerImpl implements NodeTypeManager {
 
     private static final Pattern CND_PATTERN =
-            Pattern.compile("\\[(\\S*)?\\]([.\n]*?)\n\n");
+            Pattern.compile("\\[(\\S*)?\\](.*?)\n\n", Pattern.DOTALL);
 
     private final NameMapper mapper;
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/resources/org/apache/jackrabbit/oak/jcr/nodetype/builtin_nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/resources/org/apache/jackrabbit/oak/jcr/nodetype/builtin_nodetypes.cnd?rev=1330853&r1=1330852&r2=1330853&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/resources/org/apache/jackrabbit/oak/jcr/nodetype/builtin_nodetypes.cnd
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/resources/org/apache/jackrabbit/oak/jcr/nodetype/builtin_nodetypes.cnd
Thu Apr 26 13:52:12 2012
@@ -95,7 +95,7 @@
 [nt:resource] > mix:mimeType, mix:lastModified, mix:referenceable
   primaryitem jcr:data
   - jcr:data (BINARY) mandatory
-  
+
 /**
  * This mixin node type can be used to add standardized title and description
  * properties to a node.
@@ -618,7 +618,7 @@
   orderable
   + * (rep:Members) = rep:Members protected multiple
   - * (WEAKREFERENCE) protected < 'rep:Authorizable'
-    
+
 // -----------------------------------------------------------------------------
 // J A C K R A B B I T  R E T E N T I O N  M A N A G E M E N T
 // -----------------------------------------------------------------------------
@@ -627,3 +627,4 @@
   mixin
   - rep:hold (UNDEFINED) protected  multiple IGNORE
   - rep:retentionPolicy (UNDEFINED) protected IGNORE
+



Mime
View raw message