jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r784824 - in /jackrabbit/trunk/jackrabbit-core/src/main: java/org/apache/jackrabbit/core/nodetype/ resources/org/apache/jackrabbit/core/nodetype/
Date Mon, 15 Jun 2009 15:43:51 GMT
Author: stefan
Date: Mon Jun 15 15:43:51 2009
New Revision: 784824

URL: http://svn.apache.org/viewvc?rev=784824&view=rev
Log:
JCR-1947: JSR 283: Node Type Attribute Subtyping Rules

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java?rev=784824&r1=784823&r2=784824&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
Mon Jun 15 15:43:51 2009
@@ -55,6 +55,11 @@
     // list of unnamed item definitions (i.e. residual definitions)
     private final ArrayList unnamedItemDefs;
 
+    // flag indicating whether any included node type supports orderable child nodes
+    private boolean orderableChildNodes;
+
+    private Name primaryItemName;
+
     /**
      * private constructor.
      */
@@ -64,6 +69,8 @@
         allNodeTypes = new TreeSet();
         namedItemDefs = new HashMap();
         unnamedItemDefs = new ArrayList();
+        orderableChildNodes = false;
+        primaryItemName = null;
     }
 
     /**
@@ -204,6 +211,34 @@
             ent.internalMerge(base, true);
         }
 
+        // resolve 'orderable child nodes' attribute value (JCR-1947)
+        if (ntd.hasOrderableChildNodes()) {
+            ent.orderableChildNodes = true;
+        } else {
+            Name[] nta = ent.getInheritedNodeTypes();
+            for (int i = 0; i < nta.length; i++) {
+                NodeTypeDef def = (NodeTypeDef) ntdCache.get(nta[i]);
+                if (def.hasOrderableChildNodes()) {
+                    ent.orderableChildNodes = true;
+                    break;
+                }
+            }
+        }
+
+        // resolve 'primary item' attribute value (JCR-1947)
+        if (ntd.getPrimaryItemName() != null) {
+            ent.primaryItemName = ntd.getPrimaryItemName();
+        } else {
+            Name[] nta = ent.getInheritedNodeTypes();
+            for (int i = 0; i < nta.length; i++) {
+                NodeTypeDef def = (NodeTypeDef) ntdCache.get(nta[i]);
+                if (def.getPrimaryItemName() != null) {
+                    ent.primaryItemName = def.getPrimaryItemName();
+                    break;
+                }
+            }
+        }
+
         // we're done
         return ent;
     }
@@ -218,6 +253,18 @@
         return new EffectiveNodeType();
     }
 
+    /**
+     * Returns true if any of the included node types supports
+     * 'orderable child nodes'; returns alse otherwise.
+     */
+    public boolean hasOrderableChildNodes() {
+        return orderableChildNodes;
+    }
+    
+    public Name getPrimaryItemName() {
+        return primaryItemName;
+    }
+
     public Name[] getMergedNodeTypes() {
         return (Name[]) mergedNodeTypes.toArray(new Name[mergedNodeTypes.size()]);
     }
@@ -1151,6 +1198,15 @@
                 inheritedNodeTypes.add(nta[i]);
             }
         }
+
+        // update 'orderable child nodes' attribute value (JCR-1947)
+        if (other.hasOrderableChildNodes()) {
+            orderableChildNodes = true;
+        }
+        // update 'primary item' attribute value (JCR-1947)
+        if (primaryItemName == null && other.getPrimaryItemName() != null) {
+            primaryItemName = other.getPrimaryItemName();
+        }
     }
 
     protected Object clone() {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java?rev=784824&r1=784823&r2=784824&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
Mon Jun 15 15:43:51 2009
@@ -305,13 +305,14 @@
      * {@inheritDoc}
      */
     public boolean hasOrderableChildNodes() {
-        return ntd.hasOrderableChildNodes();
+        return ent.hasOrderableChildNodes();
     }
 
     /**
      * {@inheritDoc}
      */
     public String getPrimaryItemName() {
+        // TODO JCR-1947: JSR 283: Node Type Attribute Subtyping Rules
         try {
             Name piName = ntd.getPrimaryItemName();
             if (piName != null) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?rev=784824&r1=784823&r2=784824&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Mon Jun 15 15:43:51 2009
@@ -1466,6 +1466,15 @@
                     log.debug(msg);
                     throw new InvalidNodeTypeDefException(msg);
                 }
+                // check whether specified node type definition overrides
+                // a supertypes's primaryItem -> illegal (JCR-1947)
+                if (ntd.getPrimaryItemName() != null
+                        && est.getPrimaryItemName() != null) {
+                    String msg = "[" + name + "] primaryItemName is already specified by
a supertype and must therefore not be overridden.";
+                    log.debug(msg);
+                    throw new InvalidNodeTypeDefException(msg);
+
+                }
             } catch (NodeTypeConflictException ntce) {
                 String msg = "[" + name + "] failed to validate supertypes";
                 log.debug(msg);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd?rev=784824&r1=784823&r2=784824&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
Mon Jun 15 15:43:51 2009
@@ -195,7 +195,6 @@
   + * (nt:nodeType) = nt:nodeType protected abort
 
 [rep:root] > nt:unstructured
-  orderable
   + jcr:system (rep:system) = rep:system mandatory ignore
 
 [rep:system]



Mime
View raw message