jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1330836 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype: NodeTypeImpl.java NodeTypeManagerImpl.java
Date Thu, 26 Apr 2012 13:17:46 GMT
Author: jukka
Date: Thu Apr 26 13:17:46 2012
New Revision: 1330836

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

Fix CND regexps

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

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=1330836&r1=1330835&r2=1330836&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:17:46 2012
@@ -61,7 +61,7 @@ class NodeTypeImpl implements NodeType {
 
     private boolean isAbstract;
 
-    private final boolean isMixin;
+    private final boolean mixin;
 
     private final boolean hasOrderableChildNodes;
 
@@ -83,40 +83,52 @@ class NodeTypeImpl implements NodeType {
         Matcher matcher = CND_PATTERN.matcher(cnd.replace("\r\n", "\n"));
         matcher.matches();
 
-        this.declaredSuperTypeNames = matcher.group(2).split(", ");
         this.isAbstract = matcher.group(5) != null;
-        this.isMixin = matcher.group(4) != null;
+        this.mixin = matcher.group(4) != null;
         this.hasOrderableChildNodes = matcher.group(7) != null;
         this.primaryItemName = matcher.group(8);
 
-        for (String line : matcher.group(9).split("\n")) {
-            matcher = DEF_PATTERN.matcher(line);
-            matcher.matches();
-
-            String defName = matcher.group(2);
-            String defType = matcher.group(3);
-
-            boolean mandatory = matcher.group(6).contains(" mandatory");
-            boolean autoCreated = matcher.group(6).contains(" autocreated");
-            boolean isProtected = matcher.group(6).contains(" protected");
-            boolean multiple = matcher.group(6).contains(" multiple");
-
-            int onParentVersionAction = OnParentVersionAction.COPY;
-            if (matcher.group(9) != null) {
-                onParentVersionAction =
-                        OnParentVersionAction.valueFromName(matcher.group(9));
-            }
+        String supertypes = matcher.group(2);
+        if (supertypes != null)  {
+            this.declaredSuperTypeNames = supertypes.split(", ");
+        } else if (mixin) {
+            this.declaredSuperTypeNames = new String[0];
+        } else {
+            this.declaredSuperTypeNames = new String[] { "nt:base" };
+        }
 
-            if ("+".equals(matcher.group(1))) {
-                declaredChildNodeDefinitions.add(new NodeDefinitionImpl(
-                        this, mapper, defName, autoCreated, mandatory,
-                        onParentVersionAction, isProtected, manager,
-                        defType.split(", "), matcher.group(5), false));
-            } else {
-                declaredPropertyDefinitions.add(new PropertyDefinitionImpl(
-                        this, mapper, defName, autoCreated, mandatory,
-                        onParentVersionAction, isProtected,
-                        PropertyType.valueFromName(defType), multiple));
+        String defs = matcher.group(9);
+        if (defs != null) {
+            defs = defs.trim();
+            for (String line : defs.split("\n")) {
+                matcher = DEF_PATTERN.matcher(line);
+                matcher.matches();
+
+                String defName = matcher.group(2);
+                String defType = matcher.group(3);
+
+                boolean mandatory = matcher.group(6).contains(" mandatory");
+                boolean autoCreated = matcher.group(6).contains(" autocreated");
+                boolean isProtected = matcher.group(6).contains(" protected");
+                boolean multiple = matcher.group(6).contains(" multiple");
+
+                int onParentVersionAction = OnParentVersionAction.COPY;
+                if (matcher.group(9) != null) {
+                    onParentVersionAction =
+                            OnParentVersionAction.valueFromName(matcher.group(9));
+                }
+
+                if ("+".equals(matcher.group(1))) {
+                    declaredChildNodeDefinitions.add(new NodeDefinitionImpl(
+                            this, mapper, defName, autoCreated, mandatory,
+                            onParentVersionAction, isProtected, manager,
+                            defType.split(", "), matcher.group(5), false));
+                } else {
+                    declaredPropertyDefinitions.add(new PropertyDefinitionImpl(
+                            this, mapper, defName, autoCreated, mandatory,
+                            onParentVersionAction, isProtected,
+                            PropertyType.valueFromName(defType), multiple));
+                }
             }
         }
     }
@@ -142,7 +154,7 @@ class NodeTypeImpl implements NodeType {
 
     @Override
     public boolean isMixin() {
-        return isMixin;
+        return mixin;
     }
 
     @Override

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=1330836&r1=1330835&r2=1330836&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:17:46 2012
@@ -45,7 +45,7 @@ import org.apache.jackrabbit.oak.namepat
 public class NodeTypeManagerImpl implements NodeTypeManager {
 
     private static final Pattern CND_PATTERN =
-            Pattern.compile("\\[(.*)?\\](.*?\n)\n");
+            Pattern.compile("\\[(\\S*)?\\]([.\n]*?)\n\n");
 
     private final NameMapper mapper;
 
@@ -62,7 +62,8 @@ public class NodeTypeManagerImpl impleme
                 Matcher matcher = CND_PATTERN.matcher(cnd);
                 while (matcher.find()) {
                     String name = matcher.group(1);
-                    types.put(name, new NodeTypeImpl(this, mapper, name, matcher.group(2)));
+                    types.put(name, new NodeTypeImpl(
+                            this, mapper, name, matcher.group(2)));
                 }
             } finally {
                 stream.close();



Mime
View raw message