jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r122642 - /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java
Date Fri, 17 Dec 2004 13:25:30 GMT
Author: stefan
Date: Fri Dec 17 05:25:26 2004
New Revision: 122642

URL: http://svn.apache.org/viewcvs?view=rev&rev=122642
Log:
allow re-registering node type definition if change is trivial
Modified:
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?view=diff&rev=122642&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java&r1=122641&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java&r2=122642
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Fri Dec 17 05:25:26 2004
@@ -346,7 +346,7 @@
         }
         registeredNTDefs.put(name, ntd);
 
-        // store poperty & child node definitions of new node type by id
+        // store property & child node definitions of new node type by id
         PropDef[] pda = ntd.getPropertyDefs();
         for (int i = 0; i < pda.length; i++) {
             PropDef def = pda[i];
@@ -374,8 +374,16 @@
 
         NodeTypeDef ntd = (NodeTypeDef) registeredNTDefs.get(name);
         registeredNTDefs.remove(name);
-        // remove all affected effective node types from aggregates cache
+        /**
+         * remove all affected effective node types from aggregates cache
+         * (collect keys first to prevent ConcurrentModificationException)
+         */
         Iterator iter = entCache.keys();
+        ArrayList keys = new ArrayList();
+        while (iter.hasNext()) {
+            keys.add(iter.next());
+        }
+        iter = keys.iterator();
         while (iter.hasNext()) {
             WeightedKey k = (WeightedKey) iter.next();
             EffectiveNodeType ent = (EffectiveNodeType) entCache.get(k);
@@ -384,7 +392,7 @@
             }
         }
 
-        // remove poperty & child node definitions
+        // remove property & child node definitions
         PropDef[] pda = ntd.getPropertyDefs();
         for (int i = 0; i < pda.length; i++) {
             PropDefId id = new PropDefId(pda[i]);
@@ -516,12 +524,6 @@
             throw new InvalidNodeTypeDefException(msg);
         }
 
-        if (registeredNTDefs.containsKey(name)) {
-            String msg = name + " already exists";
-            log.error(msg);
-            throw new InvalidNodeTypeDefException(msg);
-        }
-
         // validate supertypes
         QName[] supertypes = ntd.getSupertypes();
         if (supertypes != null && supertypes.length > 0) {
@@ -1292,6 +1294,9 @@
          */
         NodeTypeDef ntdOld = (NodeTypeDef) registeredNTDefs.get(name);
         NodeTypeDefDiff diff = NodeTypeDefDiff.create(ntdOld, ntd);
+        if (!diff.isModified()) {
+            throw new RepositoryException(name.toString() + ": not modified");
+        }
         if (diff.isTrivial()) {
             /**
              * the change is trivial and has no effect on current content

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java?view=diff&rev=122642&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java&r1=122641&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java&r2=122642
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java	(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java	Fri
Dec 17 05:25:26 2004
@@ -27,7 +27,7 @@
 
     private int requiredType = PropertyType.UNDEFINED;
     private ValueConstraint[] valueConstraints = new ValueConstraint[0];
-    private InternalValue[] defaultValues = null;
+    private InternalValue[] defaultValues = new InternalValue[0];
     private boolean multiple = false;
 
     /**
@@ -62,14 +62,16 @@
      * @param valueConstraints
      */
     public void setValueConstraints(ValueConstraint valueConstraints[]) {
-        this.valueConstraints = valueConstraints;
+        this.valueConstraints =
+                (valueConstraints == null) ? new ValueConstraint[0] : valueConstraints;
     }
 
     /**
      * @param defaultValues
      */
     public void setDefaultValues(InternalValue[] defaultValues) {
-        this.defaultValues = defaultValues;
+        this.defaultValues =
+                (defaultValues == null) ? new InternalValue[0] : defaultValues;
     }
 
     /**

Mime
View raw message