jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r516080 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Date Thu, 08 Mar 2007 15:50:40 GMT
Author: stefan
Date: Thu Mar  8 07:50:39 2007
New Revision: 516080

URL: http://svn.apache.org/viewvc?view=rev&rev=516080
Log:
JCR-776: More verbose message on reference constraint violation

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?view=diff&rev=516080&r1=516079&r2=516080
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Thu Mar  8 07:50:39 2007
@@ -39,6 +39,7 @@
 import org.apache.jackrabbit.name.PathFormat;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.uuid.UUID;
+import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -585,6 +586,7 @@
                                 && def.getRequiredType() == PropertyType.REFERENCE)
{
                             for (int i = 0; i < values.length; i++) {
                                 boolean satisfied = false;
+                                String constraintViolationMsg = null;
                                 try {
                                     UUID targetUUID = (UUID) values[i].internalValue();
                                     Node targetNode = session.getNodeByUUID(targetUUID);
@@ -604,6 +606,22 @@
                                             break;
                                         }
                                     }
+                                    if (!satisfied) {
+                                        NodeType[] mixinNodeTypes = targetNode.getMixinNodeTypes();
+                                        String[] targetMixins = new String[mixinNodeTypes.length];
+                                        for (int j = 0; j < mixinNodeTypes.length; j++)
{
+                                            targetMixins[j] = mixinNodeTypes[j].getName();
+                                        }
+                                        String targetMixinsString = Text.implode(targetMixins,
", ");
+                                        String constraintsString = Text.implode(constraints,
", ");
+                                        constraintViolationMsg = prop.safeGetJCRPath()
+                                                + ": is constraint to ["
+                                                + constraintsString
+                                                + "] but references [primaryType="
+                                                + targetNode.getPrimaryNodeType().getName()
+                                                + ", mixins="
+                                                + targetMixinsString + "]";
+                                    }
                                 } catch (RepositoryException re) {
                                     String msg = prop.safeGetJCRPath()
                                             + ": failed to check REFERENCE value constraint";
@@ -611,11 +629,8 @@
                                     throw new ConstraintViolationException(msg, re);
                                 }
                                 if (!satisfied) {
-                                    String msg = prop.safeGetJCRPath()
-                                            + ": does not satisfy the value constraint "
-                                            + constraints[0];   // just report the 1st
-                                    log.debug(msg);
-                                    throw new ConstraintViolationException(msg);
+                                    log.debug(constraintViolationMsg);
+                                    throw new ConstraintViolationException(constraintViolationMsg);
                                 }
                             }
                         }



Mime
View raw message