]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6610: Return error message if no valid records found in import request. Suppre...
authorAron Roberts <aron@socrates.berkeley.edu>
Sat, 2 May 2015 00:08:49 +0000 (17:08 -0700)
committerAron Roberts <aron@socrates.berkeley.edu>
Sat, 2 May 2015 00:08:49 +0000 (17:08 -0700)
services/imports/service/src/main/java/org/collectionspace/services/imports/ImportsResource.java
services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java

index 296e4eb864ae7ad42bd8e94eb1e9ce9183221745..a67eff5c5b4deab1817529850b52fbb13dced6ac 100644 (file)
@@ -247,7 +247,7 @@ public class ImportsResource extends AbstractCollectionSpaceResourceImpl<PoxPayl
                                        + report + "</import>";
                } catch (Exception e) {
                        result = "<?xml version=\"1.0\"?><import><msg>ERROR</msg><report>"
-                                       + Tools.errorToString(e, true) + "</report></import>";
+                                       + e.getMessage() + "</report></import>";
                }
                return result;
        }
@@ -278,7 +278,7 @@ public class ImportsResource extends AbstractCollectionSpaceResourceImpl<PoxPayl
                                        + report + "</import>";
                } catch (Exception e) {
                        result = "<?xml version=\"1.0\"?><import><msg>ERROR</msg><report>"
-                                       + Tools.errorToString(e, true) + "</report></import>";
+                                       + e.getMessage() + "</report></import>";
                }
                return result;
        }
index 7e66710419cf488c2bab279605b206eaef09cdb5..1d758ee829f74d346b591ab485a2223627a9f5c5 100644 (file)
@@ -77,6 +77,9 @@ public class ImportCommand {
             pipe.setWriter(writer);
             DocumentTranslationMap dtm = pipe.run();
             Map<DocumentRef, DocumentRef> documentRefs = dtm.getDocRefMap(); // FIXME: Should be checking for null here!
+            if (documentRefs != null && documentRefs.isEmpty()) {
+                throw new Exception("No valid records found in import payload. Check XML markup for not-well-formed errors, elements not matching import or document-specific schema, etc.");
+            }
             dump.append("<importedRecords>");
             for (Map.Entry<DocumentRef, DocumentRef> entry : documentRefs.entrySet()) {
                 keyDocRef = (DocumentRef) entry.getKey();