]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5227: Improved error messages when attempting to save an authority item record...
authorAron Roberts <aron@socrates.berkeley.edu>
Mon, 9 Jul 2012 18:21:04 +0000 (11:21 -0700)
committerAron Roberts <aron@socrates.berkeley.edu>
Mon, 9 Jul 2012 18:21:04 +0000 (11:21 -0700)
services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptValidatorHandler.java
services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationValidatorHandler.java
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationValidatorHandler.java
services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonValidatorHandler.java
services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceValidatorHandler.java
services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonValidatorHandler.java

index 100c4cdd63b1965282f65984df6cf338cc039335..926c1bb3ced9e7a58f389474fe9d06ce8219dc0e 100644 (file)
@@ -46,15 +46,13 @@ public class ConceptValidatorHandler extends ValidatorHandlerImpl {
     final Logger logger = LoggerFactory.getLogger(ConceptValidatorHandler.class);
     // 'Bad pattern' for shortIdentifiers matches any non-word characters
     private static final Pattern SHORT_ID_BAD_PATTERN = Pattern.compile("[\\W]");
-    private static final String VALIDATION_ERROR =
-            "The record payload was invalid. See log file for more details.";
     private static final String SHORT_ID_BAD_CHARS_ERROR =
             "shortIdentifier must only contain standard word characters";
     private static final String HAS_NO_TERMS_ERROR =
             "Authority items must contain at least one term.";
     private static final String TERM_HAS_EMPTY_DISPLAYNAME_ERROR =
-            "Each term group in an authority item must contain "
-            + "a non-empty term display name.";
+            "Each term in an authority item must contain "
+            + "a non-empty display name.";
 
     @Override
     protected Class getCommonPartClass() {
@@ -77,7 +75,7 @@ public class ConceptValidatorHandler extends ValidatorHandlerImpl {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
@@ -105,7 +103,7 @@ public class ConceptValidatorHandler extends ValidatorHandlerImpl {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
index d2dc263aefee60baf920ba956bdb700a31dd63a6..cca8f5cd4d93750816686468df4340f341696fa5 100644 (file)
@@ -46,15 +46,13 @@ public class LocationValidatorHandler extends ValidatorHandlerImpl {
     final Logger logger = LoggerFactory.getLogger(LocationValidatorHandler.class);
     // 'Bad pattern' for shortIdentifiers matches any non-word characters
     private static final Pattern SHORT_ID_BAD_PATTERN = Pattern.compile("[\\W]");
-    private static final String VALIDATION_ERROR =
-               "The record payload was invalid. See log file for more details.";
     private static final String SHORT_ID_BAD_CHARS_ERROR =
             "shortIdentifier must only contain standard word characters";
     private static final String HAS_NO_TERMS_ERROR =
             "Authority items must contain at least one term.";
     private static final String TERM_HAS_EMPTY_DISPLAYNAME_ERROR =
-            "Each term group in an authority item must contain "
-            + "a non-empty term display name.";
+            "Each term in an authority item must contain "
+            + "a non-empty display name.";
 
     @Override
     protected Class getCommonPartClass() {
@@ -77,7 +75,7 @@ public class LocationValidatorHandler extends ValidatorHandlerImpl {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
@@ -105,7 +103,7 @@ public class LocationValidatorHandler extends ValidatorHandlerImpl {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
index 26ae057cf930f2ad568b8d5d1439ee02436e0a9b..bb6c2574ae116d95c3d9fcb6d73685df59c52353 100644 (file)
@@ -46,15 +46,13 @@ public class OrganizationValidatorHandler extends ValidatorHandlerImpl {
     final Logger logger = LoggerFactory.getLogger(OrganizationValidatorHandler.class);
     // 'Bad pattern' for shortIdentifiers matches any non-word characters
     private static final Pattern SHORT_ID_BAD_PATTERN = Pattern.compile("[\\W]");
-    private static final String VALIDATION_ERROR =
-            "The record payload was invalid. See log file for more details.";
     private static final String SHORT_ID_BAD_CHARS_ERROR =
             "shortIdentifier must only contain standard word characters";
     private static final String HAS_NO_TERMS_ERROR =
             "Authority items must contain at least one term.";
     private static final String TERM_HAS_EMPTY_DISPLAYNAME_ERROR =
-            "Each term group in an authority item must contain "
-            + "a non-empty term display name.";
+            "Each term in an authority item must contain "
+            + "a non-empty display name.";
 
     @Override
     protected Class getCommonPartClass() {
@@ -77,7 +75,7 @@ public class OrganizationValidatorHandler extends ValidatorHandlerImpl {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
@@ -105,7 +103,7 @@ public class OrganizationValidatorHandler extends ValidatorHandlerImpl {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
index 6c80dbe046ceedfe680356382152794d8a8e3c7a..3c6f814aab5475e61f849c7a6b6fa814b8d0dad7 100644 (file)
@@ -45,15 +45,13 @@ public class PersonValidatorHandler extends ValidatorHandlerImpl {
     final Logger logger = LoggerFactory.getLogger(PersonValidatorHandler.class);
     // 'Bad pattern' for shortIdentifiers matches any non-word characters
     private static final Pattern SHORT_ID_BAD_PATTERN = Pattern.compile("[\\W]");
-    private static final String VALIDATION_ERROR =
-            "The record payload was invalid. See log file for more details.";
     private static final String SHORT_ID_BAD_CHARS_ERROR =
             "shortIdentifier must only contain standard word characters";
     private static final String HAS_NO_TERMS_ERROR =
             "Authority items must contain at least one term.";
     private static final String TERM_HAS_EMPTY_DISPLAYNAME_ERROR =
-            "Each term group in an authority item must contain "
-            + "a non-empty term display name.";
+            "Each term in an authority item must contain "
+            + "a non-empty display name.";
 
     @Override
     protected Class getCommonPartClass() {
@@ -76,7 +74,7 @@ public class PersonValidatorHandler extends ValidatorHandlerImpl {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
@@ -104,7 +102,7 @@ public class PersonValidatorHandler extends ValidatorHandlerImpl {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
index e8401602b9320c01cec18cb98d38a1ca36dafce8..11995de3c20cca5f067122780a11ae64a6c673a0 100644 (file)
@@ -47,15 +47,13 @@ public class PlaceValidatorHandler extends ValidatorHandlerImpl {
     final Logger logger = LoggerFactory.getLogger(PlaceValidatorHandler.class);
     // 'Bad pattern' for shortIdentifiers matches any non-word characters
     private static final Pattern SHORT_ID_BAD_PATTERN = Pattern.compile("[\\W]");
-    private static final String VALIDATION_ERROR =
-            "The record payload was invalid. See log file for more details.";
     private static final String SHORT_ID_BAD_CHARS_ERROR =
             "shortIdentifier must only contain standard word characters";
     private static final String HAS_NO_TERMS_ERROR =
             "Authority items must contain at least one term.";
     private static final String TERM_HAS_EMPTY_DISPLAYNAME_ERROR =
-            "Each term group in an authority item must contain "
-            + "a non-empty term display name.";
+            "Each term in an authority item must contain "
+            + "a non-empty display name.";
 
     @Override
     protected Class getCommonPartClass() {
@@ -78,7 +76,7 @@ public class PlaceValidatorHandler extends ValidatorHandlerImpl {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
@@ -106,7 +104,7 @@ public class PlaceValidatorHandler extends ValidatorHandlerImpl {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
index 2849df8f9716c5694bc6310d2556fedb6f22f260..31464394a1f5f0a97c02d1c2edc6c4dbe28ca1f1 100644 (file)
@@ -46,15 +46,13 @@ public class TaxonValidatorHandler extends ValidatorHandlerImpl {
     final Logger logger = LoggerFactory.getLogger(TaxonValidatorHandler.class);
     // 'Bad pattern' for shortIdentifiers matches any non-word characters
     private static final Pattern SHORT_ID_BAD_PATTERN = Pattern.compile("[\\W]");
-    private static final String VALIDATION_ERROR =
-            "The record payload was invalid. See log file for more details.";
     private static final String SHORT_ID_BAD_CHARS_ERROR =
             "shortIdentifier must only contain standard word characters";
     private static final String HAS_NO_TERMS_ERROR =
             "Authority items must contain at least one term.";
     private static final String TERM_HAS_EMPTY_DISPLAYNAME_ERROR =
-            "Each term group in an authority item must contain "
-            + "a non-empty term display name.";
+            "Each term in an authority item must contain "
+            + "a non-empty display name.";
 
     @Override
     protected Class getCommonPartClass() {
@@ -63,21 +61,21 @@ public class TaxonValidatorHandler extends ValidatorHandlerImpl {
 
     @Override
     protected void handleCreate() throws InvalidDocumentException {
-        TaxonCommon organization = (TaxonCommon) getCommonPart();
+        TaxonCommon taxon = (TaxonCommon) getCommonPart();
         // No guarantee that there is a common part in every post/update.
-        if (organization != null) {
+        if (taxon != null) {
             try {
-                String shortId = organization.getShortIdentifier();
+                String shortId = taxon.getShortIdentifier();
                 if (shortId != null) {
                     CS_ASSERT(shortIdentifierContainsOnlyValidChars(shortId), SHORT_ID_BAD_CHARS_ERROR);
                 }
-                CS_ASSERT(containsAtLeastOneTerm(organization), HAS_NO_TERMS_ERROR);
-                CS_ASSERT(allTermsContainDisplayName(organization), TERM_HAS_EMPTY_DISPLAYNAME_ERROR);
+                CS_ASSERT(containsAtLeastOneTerm(taxon), HAS_NO_TERMS_ERROR);
+                CS_ASSERT(allTermsContainDisplayName(taxon), TERM_HAS_EMPTY_DISPLAYNAME_ERROR);
             } catch (AssertionError e) {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
@@ -92,20 +90,20 @@ public class TaxonValidatorHandler extends ValidatorHandlerImpl {
 
     @Override
     protected void handleUpdate() throws InvalidDocumentException {
-        TaxonCommon organization = (TaxonCommon) getCommonPart();
+        TaxonCommon taxon = (TaxonCommon) getCommonPart();
         // No guarantee that there is a common part in every post/update.
-        if (organization != null) {
+        if (taxon != null) {
             try {
                 // shortIdentifier is among a set of fields that are
                 // prevented from being changed on an update, and thus
                 // we don't need to check its value here.
-                CS_ASSERT(containsAtLeastOneTerm(organization), HAS_NO_TERMS_ERROR);
-                CS_ASSERT(allTermsContainDisplayName(organization), TERM_HAS_EMPTY_DISPLAYNAME_ERROR);
+                CS_ASSERT(containsAtLeastOneTerm(taxon), HAS_NO_TERMS_ERROR);
+                CS_ASSERT(allTermsContainDisplayName(taxon), TERM_HAS_EMPTY_DISPLAYNAME_ERROR);
             } catch (AssertionError e) {
                 if (logger.isErrorEnabled()) {
                     logger.error(e.getMessage(), e);
                 }
-                throw new InvalidDocumentException(VALIDATION_ERROR, e);
+                throw new InvalidDocumentException(e.getMessage(), e);
             }
         }
     }
@@ -122,8 +120,8 @@ public class TaxonValidatorHandler extends ValidatorHandlerImpl {
         return true;
     }
 
-    private boolean containsAtLeastOneTerm(TaxonCommon organization) {
-        TaxonTermGroupList termGroupList = organization.getTaxonTermGroupList();
+    private boolean containsAtLeastOneTerm(TaxonCommon taxon) {
+        TaxonTermGroupList termGroupList = taxon.getTaxonTermGroupList();
         if (termGroupList == null) {
             return false;
         }
@@ -134,8 +132,8 @@ public class TaxonValidatorHandler extends ValidatorHandlerImpl {
         return true;
     }
 
-    private boolean allTermsContainDisplayName(TaxonCommon organization) {
-        TaxonTermGroupList termGroupList = organization.getTaxonTermGroupList();
+    private boolean allTermsContainDisplayName(TaxonCommon taxon) {
+        TaxonTermGroupList termGroupList = taxon.getTaxonTermGroupList();
         List<TaxonTermGroup> termGroups = termGroupList.getTaxonTermGroup();
         for (TaxonTermGroup termGroup : termGroups) {
             if (Tools.isBlank(termGroup.getTermDisplayName())) {