jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r555992 - /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
Date Fri, 13 Jul 2007 13:39:23 GMT
Author: reschke
Date: Fri Jul 13 06:39:22 2007
New Revision: 555992

URL: http://svn.apache.org/viewvc?view=rev&rev=555992
Log:
JCR-1029: modify ItemDefinitionProviderImpl.java so that the SPI is consulted when there are
multiple matching property definitions (this is relevant, when, for instance, a residual property
can either have OnParentVersionAction == IGNORE or == COPY).

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java?view=diff&rev=555992&r1=555991&r2=555992
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
Fri Jul 13 06:39:22 2007
@@ -129,7 +129,7 @@
              evaluated upon creating the workspace state.
              */
             EffectiveNodeType ent = entProvider.getEffectiveNodeType(propertyState.getParent().getNodeTypeNames());
-            definition = getQPropertyDefinition(ent, propertyState.getQName(), propertyState.getType(),
propertyState.isMultiValued());
+            definition = getQPropertyDefinition(ent, propertyState.getQName(), propertyState.getType(),
propertyState.isMultiValued(), true);
         } catch (RepositoryException e) {
             definition = service.getPropertyDefinition(sessionInfo, ((PropertyEntry) propertyState.getHierarchyEntry()).getWorkspaceId());
         } catch (NodeTypeConflictException e) {
@@ -145,7 +145,7 @@
                                                       int type, boolean multiValued)
             throws ConstraintViolationException, NoSuchNodeTypeException {
         EffectiveNodeType ent = entProvider.getEffectiveNodeType(ntName);
-        return getQPropertyDefinition(ent, propName, type, multiValued);
+        return getQPropertyDefinition(ent, propName, type, multiValued, false);
     }
 
     /**
@@ -156,7 +156,7 @@
                                                       boolean multiValued)
             throws ConstraintViolationException, NoSuchNodeTypeException {
         EffectiveNodeType ent = entProvider.getEffectiveNodeType(parentState);
-        return getQPropertyDefinition(ent, name, type, multiValued);
+        return getQPropertyDefinition(ent, name, type, multiValued, false);
     }
 
     /**
@@ -248,11 +248,11 @@
      */
     private static QPropertyDefinition getQPropertyDefinition(EffectiveNodeType ent,
                                                               QName name, int type,
-                                                              boolean multiValued)
+                                                              boolean multiValued, boolean
throwWhenAmbiguous)
            throws ConstraintViolationException {
         // try named property definitions first
         QPropertyDefinition[] defs = ent.getNamedQPropertyDefinitions(name);
-        QPropertyDefinition match = getMatchingPropDef(defs, type, multiValued);
+        QPropertyDefinition match = getMatchingPropDef(defs, type, multiValued, throwWhenAmbiguous);
         if (match != null) {
             return match;
         }
@@ -260,7 +260,7 @@
         // no item with that name defined;
         // try residual property definitions
         defs = ent.getUnnamedQPropertyDefinitions();
-        match = getMatchingPropDef(defs, type, multiValued);
+        match = getMatchingPropDef(defs, type, multiValued, throwWhenAmbiguous);
         if (match != null) {
             return match;
         }
@@ -339,7 +339,8 @@
     }
 
     private static QPropertyDefinition getMatchingPropDef(QPropertyDefinition[] defs, int
type,
-                                                   boolean multiValued) {
+                                                   boolean multiValued, boolean throwWhenAmbiguous)
+        throws ConstraintViolationException {
         QPropertyDefinition match = null;
         for (int i = 0; i < defs.length; i++) {
             QItemDefinition qDef = defs[i];
@@ -354,8 +355,12 @@
                     if (multiValued == pd.isMultiple()) {
                         // found match
                         if (pd.getRequiredType() != PropertyType.UNDEFINED) {
-                            // found best possible match, get outta here
-                            return pd;
+                            if (match != null && throwWhenAmbiguous) {
+                                throw new ConstraintViolationException("ambiguous property
definitions found: " + match + " vs " + pd);
+                            }
+                          
+                            // found best possible match
+                            match = pd;
                         } else {
                             if (match == null) {
                                 match = pd;
@@ -367,4 +372,5 @@
         }
         return match;
     }
+
 }



Mime
View raw message