jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r988151 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/ jackrabbit-core/src/...
Date Mon, 23 Aug 2010 15:25:11 GMT
Author: stefan
Date: Mon Aug 23 15:25:11 2010
New Revision: 988151

URL: http://svn.apache.org/viewvc?rev=988151&view=rev
Log:
JCR-2490: jackrabbit wrongly think nodetype is changed on nodetype re-registration

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeTypeInstanceHandler.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/JackrabbitRepositoryStub.properties
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrencyTest3.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceManagementTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeTypeInstanceHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeTypeInstanceHandler.java?rev=988151&r1=988150&r2=988151&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeTypeInstanceHandler.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeTypeInstanceHandler.java
Mon Aug 23 15:25:11 2010
@@ -63,7 +63,6 @@ public class NodeTypeInstanceHandler {
      * @param property property state
      * @param parent parent node state
      * @param def property definition
-     * @param userId user identifier associated with the current session
      * @throws RepositoryException if the default values could not be created
      */
     public void setDefaultValues(

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=988151&r1=988150&r2=988151&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 Aug 23 15:25:11 2010
@@ -424,7 +424,7 @@ public class NodeTypeRegistry implements
         }
 
         String message =
-            "The following nodetype change contains non-trivial changes."
+            "The following node type change contains non-trivial changes."
             + "Up until now only trivial changes are supported."
             + " (see javadoc for "
             + NodeTypeDefDiff.class.getName()

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties?rev=988151&r1=988150&r2=988151&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
Mon Aug 23 15:25:11 2010
@@ -46,6 +46,7 @@ javax.jcr.tck.holdname=hold
 
 # repository factory class name
 javax.jcr.tck.repository.factory=org.apache.jackrabbit.core.RepositoryFactoryImpl
+javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.core.JackrabbitRepositoryStub
 
 # sample for per test case config overriding
 # Test class: AddNodeText

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrencyTest3.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrencyTest3.java?rev=988151&r1=988150&r2=988151&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrencyTest3.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrencyTest3.java
Mon Aug 23 15:25:11 2010
@@ -33,9 +33,9 @@ import org.apache.jackrabbit.core.config
 
 public class ConcurrencyTest3 extends TestCase {
 
-    private static final int NUM_ITERATIONS = 1;
+    private static final int NUM_ITERATIONS = 5;
 
-    private static final int NUM_THREADS = 5;
+    private static final int NUM_THREADS = 10;
 
     private File repoDescriptor;
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java?rev=988151&r1=988150&r2=988151&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java
Mon Aug 23 15:25:11 2010
@@ -27,8 +27,8 @@ import javax.jcr.Session;
  */
 public class ConcurrentRenameTest extends AbstractConcurrencyTest {
 
-    private static final int NUM_MOVES = 100;
-    private static final int NUM_THREADS = 2;
+    private static final int NUM_MOVES = 1000;
+    private static final int NUM_THREADS = 20;
 
     public void testConcurrentRename() throws Exception {
         runTask(new Task() {

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceManagementTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceManagementTest.java?rev=988151&r1=988150&r2=988151&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceManagementTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceManagementTest.java
Mon Aug 23 15:25:11 2010
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.test.api;
 
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Workspace;
 import javax.jcr.NoSuchWorkspaceException;
 
@@ -37,6 +36,8 @@ public class WorkspaceManagementTest ext
         super.checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
 
         workspace = superuser.getWorkspace();
+        superuser.getRootNode().addNode("foo" + System.currentTimeMillis());
+        superuser.save();
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java?rev=988151&r1=988150&r2=988151&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java
Mon Aug 23 15:25:11 2010
@@ -167,10 +167,17 @@ public abstract class QItemDefinitionImp
     }
 
     /**
-     * See {@link QNodeDefinition#hashCode()} and {@link QPropertyDefinition#hashCode()}.
-     *
-     * @return the hashcode
+     * {@inheritDoc}
      */
     @Override
-    public abstract int hashCode();
+    public int hashCode() {
+        int h = 17;
+        h = 37 * h + getDeclaringNodeType().hashCode();
+        h = 37 * h + getName().hashCode();
+        h = 37 * h + getOnParentVersion();
+        h = 37 * h + (isProtected() ? 11 : 43);
+        h = 37 * h + (isMandatory() ? 11 : 43);
+        h = 37 * h + (isAutoCreated() ? 11 : 43);
+        return h;
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java?rev=988151&r1=988150&r2=988151&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java
Mon Aug 23 15:25:11 2010
@@ -69,7 +69,7 @@ public class QNodeDefinitionImpl extends
      * Creates a new SPI node definition based on a JCR NodeDefinition.
      *
      * @param name              the name of the child item.
-     * @param declaringNodeType the delaring node type
+     * @param declaringNodeType the declaring node type
      * @param isAutoCreated     if this item is auto created.
      * @param isMandatory       if this is a mandatory item.
      * @param onParentVersion   the on parent version behaviour.
@@ -87,6 +87,10 @@ public class QNodeDefinitionImpl extends
                 onParentVersion, isProtected);
         this.defaultPrimaryType = defaultPrimaryType;
         this.requiredPrimaryTypes.addAll(Arrays.asList(requiredPrimaryTypes));
+        // sanitize field value
+        if (this.requiredPrimaryTypes.isEmpty()) {
+            this.requiredPrimaryTypes.add(NameConstants.NT_BASE);
+        }
         this.allowsSameNameSiblings = allowsSameNameSiblings;
     }
 
@@ -148,7 +152,7 @@ public class QNodeDefinitionImpl extends
     //-------------------------------------------------------------< Object >---
     /**
      * Compares two node definitions for equality. Returns <code>true</code>
-     * if the given object is a node defintion and has the same attributes
+     * if the given object is a node definition and has the same attributes
      * as this node definition.
      *
      * @param obj the object to compare this node definition with
@@ -182,28 +186,14 @@ public class QNodeDefinitionImpl extends
     @Override
     public int hashCode() {
         if (hashCode == 0) {
-            // build hashCode (format: <declaringNodeType>/<name>/<requiredPrimaryTypes>)
-            StringBuffer sb = new StringBuffer();
-
-            if (getDeclaringNodeType() != null) {
-                sb.append(getDeclaringNodeType().toString());
-                sb.append('/');
-            }
-            if (definesResidual()) {
-                sb.append('*');
-            } else {
-                sb.append(getName().toString());
-            }
-            sb.append('/');
-            // set of required node type names, sorted in ascending order
-            TreeSet<Name> set = new TreeSet<Name>();
-            Name[] names = getRequiredPrimaryTypes();
-            set.addAll(Arrays.asList(names));
-            sb.append(set.toString());
-
-            hashCode = sb.toString().hashCode();
+            int h = super.hashCode();
+            h = 37 * h + (defaultPrimaryType == null ? 0 : defaultPrimaryType.hashCode());
+            h = 37 * h + requiredPrimaryTypes.hashCode();
+            h = 37 * h + (allowsSameNameSiblings ? 11 : 43);
+            hashCode = h;
         }
         return hashCode;
+
     }
 
     //-----------------------------------------------------------< internal >---

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=988151&r1=988150&r2=988151&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
Mon Aug 23 15:25:11 2010
@@ -167,7 +167,7 @@ public class QNodeTypeDefinitionImpl imp
         this.primaryItemName = primaryItemName;
         this.propertyDefs = getSerializablePropertyDefs(declaredPropDefs);
         this.childNodeDefs = getSerializableNodeDefs(declaredNodeDefs);
-        // make sure supertypes are sorted
+        // make sure super types are sorted
         SortedSet<Name> types = new TreeSet<Name>();
         types.addAll(Arrays.asList(supertypes));
         this.supertypes = types.toArray(new Name[types.size()]);
@@ -355,7 +355,7 @@ public class QNodeTypeDefinitionImpl imp
             QNodeTypeDefinitionImpl other = (QNodeTypeDefinitionImpl) obj;
             return (name == null ? other.name == null : name.equals(other.name))
                     && (primaryItemName == null ? other.primaryItemName == null :
primaryItemName.equals(other.primaryItemName))
-                    && Arrays.equals(getSupertypes(), other.getSupertypes())
+                    && new HashSet(Arrays.asList(getSupertypes())).equals(new HashSet(Arrays.asList(other.getSupertypes())))
                     && isMixin == other.isMixin
                     && hasOrderableChildNodes == other.hasOrderableChildNodes
                     && isAbstract == other.isAbstract

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java?rev=988151&r1=988150&r2=988151&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
Mon Aug 23 15:25:11 2010
@@ -229,7 +229,7 @@ public class QPropertyDefinitionImpl ext
     //-------------------------------------------------------------< Object >---
     /**
      * Compares two property definitions for equality. Returns <code>true</code>
-     * if the given object is a property defintion and has the same attributes
+     * if the given object is a property definition and has the same attributes
      * as this property definition.
      *
      * @param obj the object to compare this property definition with
@@ -244,51 +244,38 @@ public class QPropertyDefinitionImpl ext
         }
         if (obj instanceof QPropertyDefinition) {
             QPropertyDefinition other = (QPropertyDefinition) obj;
+
             return super.equals(obj)
                     && requiredType == other.getRequiredType()
                     && multiple == other.isMultiple()
                     && fullTextSearchable == other.isFullTextSearchable()
                     && queryOrderable == other.isQueryOrderable()
-                    && Arrays.equals(valueConstraints, other.getValueConstraints())
-                    && Arrays.equals(defaultValues, other.getDefaultValues())
-                    && Arrays.equals(availableQueryOperators, other.getAvailableQueryOperators());
+                    && (valueConstraints == null || other.getValueConstraints() ==
null) ? (valueConstraints == other.getValueConstraints())
+                        : new HashSet(Arrays.asList(valueConstraints)).equals(new HashSet(Arrays.asList(other.getValueConstraints())))
+                    && (defaultValues == null || other.getDefaultValues() == null)
? (defaultValues == other.getDefaultValues())
+                        : new HashSet(Arrays.asList(defaultValues)).equals(new HashSet(Arrays.asList(other.getDefaultValues())))
+                    && new HashSet(Arrays.asList(availableQueryOperators)).equals(new
HashSet(Arrays.asList(other.getAvailableQueryOperators())));
         }
         return false;
     }
 
     /**
-     * Overwrites {@link QItemDefinitionImpl#hashCode()}.
+     * Overrides {@link QItemDefinitionImpl#hashCode()}.
      *
-     * @return the hashcode
+     * @return the hash code
      */
     @Override
     public int hashCode() {
         if (hashCode == 0) {
-            // build hashCode (format: <declaringNodeType>/<name>/<requiredType>/<multiple>)
-            StringBuffer sb = new StringBuffer();
-
-            sb.append(getDeclaringNodeType().toString());
-            sb.append('/');
-            if (definesResidual()) {
-                sb.append('*');
-            } else {
-                sb.append(getName().toString());
-            }
-            sb.append('/');
-            sb.append(requiredType);
-            sb.append('/');
-            sb.append(multiple ? 1 : 0);
-            sb.append('/');
-            sb.append(fullTextSearchable ? 1 : 0);
-            sb.append('/');
-            sb.append(queryOrderable ? 1 : 0);
-            sb.append('/');
-            Set<String> s = new HashSet<String>();
-            String[] names = getAvailableQueryOperators();
-            s.addAll(Arrays.asList(names));
-            sb.append(s.toString());
-
-            hashCode = sb.toString().hashCode();
+            int h = super.hashCode();
+            h = 37 * h + requiredType;
+            h = 37 * h + (multiple ? 11 : 43);
+            h = 37 * h + (queryOrderable ? 11 : 43);
+            h = 37 * h + (fullTextSearchable ? 11 : 43);
+            h = 37 * h + ((valueConstraints != null) ? new HashSet(Arrays.asList(valueConstraints)).hashCode()
: 0);
+            h = 37 * h + ((defaultValues != null) ? new HashSet(Arrays.asList(defaultValues)).hashCode()
: 0);
+            h = 37 * h + new HashSet(Arrays.asList(availableQueryOperators)).hashCode();
+            hashCode = h;
         }
         return hashCode;
     }
@@ -296,7 +283,7 @@ public class QPropertyDefinitionImpl ext
     //-----------------------------------------------------------< internal >---
 
     /**
-     * Convers JCR {@link Value}s to {@link QValue}s.
+     * Converts JCR {@link Value}s to {@link QValue}s.
      *
      * @param values   the JCR values.
      * @param resolver the name/path resolver of the session that provided the
@@ -310,13 +297,14 @@ public class QPropertyDefinitionImpl ext
                                           NamePathResolver resolver,
                                           QValueFactory factory)
             throws RepositoryException {
-        QValue[] defaultValues = null;
         if (values != null) {
-            defaultValues = new QValue[values.length];
+            QValue[] defaultValues = new QValue[values.length];
             for (int i = 0; i < values.length; i++) {
                 defaultValues[i] = ValueFormat.getQValue(values[i], resolver, factory);
             }
+            return defaultValues;
+        }  else {
+            return null;
         }
-        return defaultValues;
     }
 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java?rev=988151&r1=988150&r2=988151&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java
Mon Aug 23 15:25:11 2010
@@ -43,8 +43,8 @@ import java.util.Set;
  * <b><code>NONE</code></b> inidcates that there is no modification
at all.
  * <p/>
  * A <b><code>TRIVIAL</code></b> modification has no impact on the
consistency
- * of existing content and does not affect existing/assigned definition id's.
- * The following modifications are considered <code>TRIVIAL</code>:
+ * of existing content. The following modifications are considered
+ * <code>TRIVIAL</code>:
  * <ul>
  * <li>changing node type <code>orderableChildNodes</code> flag
  * <li>changing node type <code>primaryItemName</code> value
@@ -53,27 +53,22 @@ import java.util.Set;
  * <li>changing property/child node <code>onParentVersion</code> value
  * <li>changing property/child node <code>mandatory</code> flag to <code>false</code>
  * <li>changing property/child node <code>autoCreated</code> flag
+ * <li>changing specific property/child node <code>name</code> to <code>*</code>
  * <li>changing child node <code>defaultPrimaryType</code>
  * <li>changing child node <code>sameNameSiblings</code> flag to <code>true</code>
- * <li>weaken property <code>valueConstraints</code> (e.g. by removing
completely
- * or by adding to existing or by making a single constraint less restrictive)
- * <li>changing property <code>defaultValues</code>
- * </ul>
- * <p/>
- * A <b><code>MINOR</code></b> modification has no impact on the
consistency
- * of existing content but <i>does</i> affect existing/assigned definition id's.
- * The following modifications are considered <code>MINOR</code>:
- * <ul>
- * <li>changing specific property/child node <code>name</code> to <code>*</code>
  * <li>weaken child node <code>requiredPrimaryTypes</code> (e.g. by removing)
+ * <li>weaken property <code>valueConstraints</code> (e.g. by removing
a constraint
+ * or by making a specific constraint less restrictive)
+ * <li>changing property <code>defaultValues</code>
  * <li>changing specific property <code>requiredType</code> to <code>undefined</code>
  * <li>changing property <code>multiple</code> flag to <code>true</code>
  * </ul>
  * <p/>
- * A <b><code>MAJOR</code></b> modification <i>affects</i>
the consistency of
- * existing content and <i>does</i> change existing/assigned definition id's.
- * All modifications that are neither <b><code>TRIVIAL</code></b>
nor
- * <b><code>MINOR</code></b> are considered <b><code>MAJOR</code></b>.
+ * A <b><code>MAJOR</code></b> modification potentially <i>affects</i>
the
+ * consistency of existing content.
+ *
+ * All modifications that are not <b><code>TRIVIAL</code></b> are
considered
+ * <b><code>MAJOR</code></b>.
  *
  * @see #getType()
  */
@@ -84,20 +79,13 @@ public class NodeTypeDefDiff {
      */
     public static final int NONE = 0;
     /**
-     * trivial modification: does neither affect consistency of existing content
-     * nor does it change existing/assigned definition id's
+     * trivial modification: does not affect consistency of existing content
      */
     public static final int TRIVIAL = 1;
     /**
-     * minor modification: does not affect consistency of existing content but
-     * <i>does</i> change existing/assigned definition id's
-     */
-    public static final int MINOR = 2;
-    /**
      * major modification: <i>does</i> affect consistency of existing content
-     * and <i>does</i> change existing/assigned definition id's
      */
-    public static final int MAJOR = 3;
+    public static final int MAJOR = 2;
 
     private final QNodeTypeDefinition oldDef;
     private final QNodeTypeDefinition newDef;
@@ -195,13 +183,6 @@ public class NodeTypeDefDiff {
     }
 
     /**
-     * @return <code>true</code> if minor
-     */
-    public boolean isMinor() {
-        return type == MINOR;
-    }
-
-    /**
      * @return <code>true</code> if major
      */
     public boolean isMajor() {
@@ -212,12 +193,10 @@ public class NodeTypeDefDiff {
      * Returns the type of modification as expressed by the following constants:
      * <ul>
      * <li><b><code>NONE</code></b>: no modification at all
-     * <li><b><code>TRIVIAL</code></b>: does neither affect
consistency of
-     * existing content nor does it change existing/assigned definition id's
-     * <li><b><code>MINOR</code></b>: does not affect consistency
of existing
-     * content but <i>does</i> change existing/assigned definition id's
+     * <li><b><code>TRIVIAL</code></b>: does not affect consistency
of
+     * existing content
      * <li><b><code>MAJOR</code></b>: <i>does</i>
affect consistency of existing
-     * content and <i>does</i> change existing/assigned definition id's
+     * content
      * </ul>
      *
      * @return the type of modification
@@ -244,18 +223,15 @@ public class NodeTypeDefDiff {
      * @return <code>true</code> if supertypes diff
      */
     public int supertypesDiff() {
-        return !Arrays.equals(oldDef.getSupertypes(), newDef.getSupertypes()) ? MAJOR : NONE;
+        Set<Name> set1 = new HashSet<Name>(Arrays.asList(oldDef.getSupertypes()));
+        Set<Name> set2 = new HashSet<Name>(Arrays.asList(newDef.getSupertypes()));
+        return !set1.equals(set2) ? MAJOR : NONE;
     }
 
     /**
      * @return diff type
      */
     private int buildPropDefDiffs() {
-        /**
-         * propDefId determinants: declaringNodeType, name, requiredType, multiple
-         * todo: try also to match entries with modified id's
-         */
-
         int maxType = NONE;
         Map<QPropertyDefinitionId, QPropertyDefinition> oldDefs = new HashMap<QPropertyDefinitionId,
QPropertyDefinition>();
         for (QPropertyDefinition def : oldDef.getPropertyDefs()) {
@@ -303,11 +279,6 @@ public class NodeTypeDefDiff {
      * @return diff type
      */
     private int buildChildNodeDefDiffs() {
-        /**
-         * nodeDefId determinants: declaringNodeType, name, requiredPrimaryTypes
-         * todo: try also to match entries with modified id's
-         */
-
         int maxType = NONE;
         QNodeDefinition[] cnda1 = oldDef.getChildNodeDefs();
         Map<QNodeDefinitionId, QNodeDefinition> defs1 = new HashMap<QNodeDefinitionId,
QNodeDefinition>();
@@ -395,9 +366,6 @@ public class NodeTypeDefDiff {
             case TRIVIAL:
                 typeString = "TRIVIAL";
                 break;
-            case MINOR:
-                typeString = "MINOR";
-                break;
             case MAJOR:
                 typeString = "MAJOR";
                 break;
@@ -449,8 +417,8 @@ public class NodeTypeDefDiff {
                     } else {
                         if (!oldDef.definesResidual()
                                 && newDef.definesResidual()) {
-                            // just making a child item residual is a MINOR change
-                            type = MINOR;
+                            // just making a child item residual is a TRIVIAL change
+                            type = TRIVIAL;
                         } else {
                             if (!oldDef.getName().equals(newDef.getName())) {
                                 // changing the name of a child item is a MAJOR change
@@ -525,15 +493,12 @@ public class NodeTypeDefDiff {
             super.init();
             /**
              * only need to do comparison if base class implementation
-             * detected a non-MAJOR modification (i.e. TRIVIAL or MINOR);
+             * detected a non-MAJOR (i.e. TRIVIAL) modification;
              * no need to check for additions or removals as this is already
              * handled in base class implementation.
              */
-            if (isModified() && type != NONE && type != MAJOR) {
-                /**
-                 * check if valueConstraints were made more restrictive
-                 * (constraints are ORed)
-                 */
+            if (isModified() && type == TRIVIAL) {
+                // check if valueConstraints were made more restrictive
                 QValueConstraint[] vca1 = getOldDef().getValueConstraints();
                 Set<String> set1 = new HashSet<String>();
                 for (QValueConstraint aVca1 : vca1) {
@@ -545,12 +510,20 @@ public class NodeTypeDefDiff {
                     set2.add(aVca2.getString());
                 }
 
-                if (set1.isEmpty() && !set2.isEmpty()) {
-                    // added constraint where there was no constraint (MAJOR change)
-                    type = MAJOR;
-                } else if (!set2.containsAll(set1) && !set2.isEmpty()) {
-                    // removed existing constraint (MAJOR change)
-                    type = MAJOR;
+                if (!set1.equals(set2)) {
+                    // valueConstraints have been modified
+                    if (set2.containsAll(set1)) {
+                        // new set is a superset of old set
+                        // => constraints have been removed
+                        // (TRIVIAL change, since constraints are OR'ed)
+                        type = TRIVIAL;
+                    } else {
+                        // constraint have been removed/modified (MAJOR change);
+                        // since we're unable to semantically compare
+                        // value constraints (e.g. regular expressions), all
+                        // modifications are considered a MAJOR change.
+                        type = MAJOR;
+                    }
                 }
 
                 // no need to check defaultValues (TRIVIAL change)
@@ -562,8 +535,8 @@ public class NodeTypeDefDiff {
                     int t2 = getNewDef().getRequiredType();
                     if (t1 != t2) {
                         if (t2 == PropertyType.UNDEFINED) {
-                            // changed getRequiredType to UNDEFINED (MINOR change)
-                            type = MINOR;
+                            // changed getRequiredType to UNDEFINED (TRIVIAL change)
+                            type = TRIVIAL;
                         } else {
                             // changed getRequiredType to specific type (MAJOR change)
                             type = MAJOR;
@@ -573,8 +546,8 @@ public class NodeTypeDefDiff {
                     boolean b2 = getNewDef().isMultiple();
                     if (b1 != b2) {
                         if (b2) {
-                            // changed multiple flag to true (MINOR change)
-                            type = MINOR;
+                            // changed multiple flag to true (TRIVIAL change)
+                            type = TRIVIAL;
                         } else {
                             // changed multiple flag to false (MAJOR change)
                             type = MAJOR;
@@ -604,11 +577,11 @@ public class NodeTypeDefDiff {
             super.init();
             /**
              * only need to do comparison if base class implementation
-             * detected a non-MAJOR modification (i.e. TRIVIAL or MINOR);
+             * detected a non-MAJOR (i.e. TRIVIAL) modification;
              * no need to check for additions or removals as this is already
              * handled in base class implementation.
              */
-            if (isModified() && type != NONE && type != MAJOR) {
+            if (isModified() && type == TRIVIAL) {
 
                 boolean b1 = getOldDef().allowsSameNameSiblings();
                 boolean b2 = getNewDef().allowsSameNameSiblings();
@@ -623,11 +596,14 @@ public class NodeTypeDefDiff {
                     List<Name> l1 = Arrays.asList(getOldDef().getRequiredPrimaryTypes());
                     List<Name> l2 = Arrays.asList(getNewDef().getRequiredPrimaryTypes());
                     if (!l1.equals(l2)) {
+                        // requiredPrimaryTypes have been modified
                         if (l1.containsAll(l2)) {
-                            // removed requiredPrimaryType (MINOR change)
-                            type = MINOR;
+                            // old list is a superset of new list
+                            // => removed requiredPrimaryType (TRIVIAL change)
+                            type = TRIVIAL;
                         } else {
-                            // added requiredPrimaryType (MAJOR change)
+                            // added/modified requiredPrimaryType (MAJOR change)
+                            // todo check whether aggregate of old requiredTypes would include
aggregate of new requiredTypes => trivial change
                             type = MAJOR;
                         }
                     }



Mime
View raw message