jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r649548 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/...
Date Fri, 18 Apr 2008 14:15:13 GMT
Author: reschke
Date: Fri Apr 18 07:15:10 2008
New Revision: 649548

URL: http://svn.apache.org/viewvc?rev=649548&view=rev
Log:
JCR-1543: add QNodeTypeDefinition.getSupportedMixins(), use it for JCR2SPI's Node.canAddMixin.

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeType.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QNodeTypeDefinition.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=649548&r1=649547&r2=649548&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Fri Apr 18 07:15:10 2008
@@ -1446,6 +1446,12 @@
         Name[] existingNts = getNodeState().getNodeTypeNames();
         // build effective node type representing primary type including existing mixin's
         EffectiveNodeType entExisting = session.getEffectiveNodeTypeProvider().getEffectiveNodeType(existingNts);
+        
+        // check if the base type supports adding this mixin
+        if (! entExisting.supportsMixin(mixinName)) {
+            log.debug(mixin.getName() + ": not supported on node type " + primaryTypeName);
+            return false;
+        }
 
         // check if adding new mixin conflicts with existing nodetypes
         if (entExisting.includesNodeType(mixinName)) {

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeType.java?rev=649548&r1=649547&r2=649548&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeType.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeType.java
Fri Apr 18 07:15:10 2008
@@ -43,6 +43,15 @@
      *         <code>false</code>
      */
     public boolean includesNodeType(Name nodeTypeName);
+    
+    /**
+     * Determines whether this effective node type supports adding
+     * the specified mixin.
+     * @param mixin name of mixin type
+     * @return <code>true</code> if the mixin type is supported, otherwise
+     *         <code>false</code>
+     */
+    public boolean supportsMixin(Name mixin);
 
     /**
      * Determines whether this effective node type representation includes

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeImpl.java?rev=649548&r1=649547&r2=649548&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeImpl.java
Fri Apr 18 07:15:10 2008
@@ -58,6 +58,8 @@
     private final HashMap namedItemDefs;
     // list of unnamed item definitions (i.e. residual definitions)
     private final ArrayList unnamedItemDefs;
+    // (optional) set of additional mixins supported on node type
+    private Set supportedMixins;
 
     /**
      * private constructor.
@@ -68,6 +70,7 @@
         allNodeTypes = new TreeSet();
         namedItemDefs = new HashMap();
         unnamedItemDefs = new ArrayList();
+        supportedMixins = null;
     }
 
     /**
@@ -93,6 +96,15 @@
         ent.mergedNodeTypes.add(ntName);
         ent.allNodeTypes.add(ntName);
 
+        Name[] smixins = ntd.getSupportedMixinTypes();
+    
+        if (smixins != null) {
+            ent.supportedMixins = new HashSet();
+            for (int i = 0; i < smixins.length; i++) {
+                ent.supportedMixins.add(smixins[i]);
+            }
+        }
+        
         // map of all item definitions (maps id to definition)
         // used to effectively detect ambiguous child definitions where
         // ambiguity is defined in terms of definition identity
@@ -206,15 +218,6 @@
         return ent;
     }
 
-    /**
-     * Factory method: creates a new 'empty' effective node type instance
-     *
-     * @return a new EffectiveNodeType
-     */
-    static EffectiveNodeType create() {
-        return new EffectiveNodeTypeImpl();
-    }
-
     //--------------------------------------------------< EffectiveNodeType >---
     /**
      * @see EffectiveNodeType#getInheritedNodeTypes()
@@ -511,6 +514,19 @@
 
     /**
      * @inheritDoc
+     * @see EffectiveNodeType#supportsMixin(Name)
+     */
+    public boolean supportsMixin(Name mixin) {
+        if (supportedMixins == null) {
+            return true;
+        }
+        else {
+            return supportedMixins.contains(mixin);
+        }
+    }
+
+    /**
+     * @inheritDoc
      * @see EffectiveNodeType#checkAddNodeConstraints(Name, ItemDefinitionProvider)
      */
     public void checkAddNodeConstraints(Name name, ItemDefinitionProvider definitionProvider)
@@ -812,6 +828,11 @@
             clone.namedItemDefs.put(key, new ArrayList(list));
         }
         clone.unnamedItemDefs.addAll(unnamedItemDefs);
+        
+        if (supportedMixins != null) {
+            clone.supportedMixins = new HashSet();
+            clone.supportedMixins.addAll(supportedMixins);
+        }
 
         return clone;
     }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java?rev=649548&r1=649547&r2=649548&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
Fri Apr 18 07:15:10 2008
@@ -46,6 +46,11 @@
     private final Name[] supertypes;
 
     /**
+     * The names of the supported mixins on this node type (or <code>null</code>)
+     */
+    private final Name[] supportedMixins;
+
+    /**
      * Indicates whether this is a mixin node type definition.
      */
     private final boolean isMixin;
@@ -99,9 +104,42 @@
      *                               <code>null</code>.
      * @param declaredPropDefs       the declared property definitions.
      * @param declaredNodeDefs       the declared child node definitions.
+     * @deprecated use {@link #QNodeTypeDefinitionImpl(Name, Name[], Name[], boolean, boolean,
Name, QPropertyDefinition[], QNodeDefinition[])}
+     */
+    public QNodeTypeDefinitionImpl(Name name,
+                                   Name[] supertypes,
+                                   boolean isMixin,
+                                   boolean hasOrderableChildNodes,
+                                   Name primaryItemName,
+                                   QPropertyDefinition[] declaredPropDefs,
+                                   QNodeDefinition[] declaredNodeDefs) {
+        this.name = name;
+        this.supertypes = supertypes;
+        this.supportedMixins = null;
+        this.isMixin = isMixin;
+        this.hasOrderableChildNodes = hasOrderableChildNodes;
+        this.primaryItemName = primaryItemName;
+        this.propertyDefs = getSerializablePropertyDefs(declaredPropDefs);
+        this.childNodeDefs = getSerializableNodeDefs(declaredNodeDefs);
+    }
+
+    /**
+     * Creates a new serializable qualified node type definition.
+     *
+     * @param name                   the name of the node type
+     * @param supertypes             the names of the supertypes
+     * @param supportedMixins        the names of supported mixins (or <code>null</code>)
+     * @param isMixin                if this is a mixin node type
+     * @param hasOrderableChildNodes if this node type has orderable child
+     *                               nodes.
+     * @param primaryItemName        the name of the primary item, or
+     *                               <code>null</code>.
+     * @param declaredPropDefs       the declared property definitions.
+     * @param declaredNodeDefs       the declared child node definitions.
      */
     public QNodeTypeDefinitionImpl(Name name,
                                    Name[] supertypes,
+                                   Name[] supportedMixins,
                                    boolean isMixin,
                                    boolean hasOrderableChildNodes,
                                    Name primaryItemName,
@@ -109,6 +147,7 @@
                                    QNodeDefinition[] declaredNodeDefs) {
         this.name = name;
         this.supertypes = supertypes;
+        this.supportedMixins = supportedMixins;
         this.isMixin = isMixin;
         this.hasOrderableChildNodes = hasOrderableChildNodes;
         this.primaryItemName = primaryItemName;
@@ -216,7 +255,18 @@
         }
         return dependencies;
     }
-
+    
+    public Name[] getSupportedMixinTypes() {
+        if (supportedMixins == null) {
+            return null;
+        }
+        else {
+            Name[] mixins = new Name[supportedMixins.length];
+            System.arraycopy(supportedMixins, 0, mixins, 0, supportedMixins.length);
+            return mixins;
+        }
+    }
+    
     //-------------------------------< internal >-------------------------------
 
     /**

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QNodeTypeDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QNodeTypeDefinition.java?rev=649548&r1=649547&r2=649548&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QNodeTypeDefinition.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QNodeTypeDefinition.java
Fri Apr 18 07:15:10 2008
@@ -48,6 +48,17 @@
     public Name[] getSupertypes();
 
     /**
+     * Returns an array containing the names of additional mixin types
+     * supported on this node type.
+     * <p>
+     * The returned array must not be modified by the application.
+     *
+     * @return an array of mixin type names, or <code>null</code>
+     * when there are no known constraints.
+     */
+    public Name[] getSupportedMixinTypes();
+
+    /**
      * Returns the value of the mixin flag.
      *
      * @return true if this is a mixin node type; false otherwise.



Mime
View raw message