This is an automated email from the git hooks/post-receive script. New commit to branch feature/9206-upload-validation-zip-documents in repository coselmar. See https://gitlab.nuiton.org/codelutin/coselmar.git commit 1f29db59dd67a0ccd9b9f1aec9f015b4dd850a8a Author: Yannick Martel <martel@©odelutin.com> Date: Tue Jun 6 14:34:53 2017 +0200 refs #9206 technical error management during zip import --- .../beans/MassiveDocumentsImportResult.java | 14 +++++++++++--- .../coselmar/services/v1/DocumentsWebService.java | 15 ++++++++------- .../src/test/resources/documents_errors.zip | Bin 87789 -> 87789 bytes 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/MassiveDocumentsImportResult.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/MassiveDocumentsImportResult.java index fff4400..20495f4 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/MassiveDocumentsImportResult.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/MassiveDocumentsImportResult.java @@ -1,6 +1,5 @@ package fr.ifremer.coselmar.beans; -import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -11,6 +10,7 @@ public class MassiveDocumentsImportResult { protected List<String> missingFiles; protected boolean errorSystem; + protected ImportSystemErrorType systemErrorType; protected boolean invalidFile; public MassiveDocumentsImportResult() { @@ -33,8 +33,9 @@ public class MassiveDocumentsImportResult { return errorSystem; } - public void setErrorSystem(boolean errorSystem) { - this.errorSystem = errorSystem; + public void setSystemErrorType(ImportSystemErrorType importSystemErrorType) { + this.systemErrorType = importSystemErrorType; + this.errorSystem = true; } public boolean isInvalidFile() { @@ -44,4 +45,11 @@ public class MassiveDocumentsImportResult { public void setInvalidFile(boolean invalidFile) { this.invalidFile = invalidFile; } + + public enum ImportSystemErrorType { + UNABLE_TO_READ_ZIP, + UNABLE_TO_READ_CSV, + UNABLE_TO_READ_ZIP_ENTRY, + ; + } } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java index 6455deb..d54a7a0 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java @@ -975,7 +975,8 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { if (log.isErrorEnabled()) { log.error("error during ZipFile transfer", e); } - throw new CoselmarTechnicalException("Internal error during ZipFile transfer", e); + importResult.setSystemErrorType(MassiveDocumentsImportResult.ImportSystemErrorType.UNABLE_TO_READ_ZIP); + return importResult; } // Get descriptions.csv : it should contains all DocumentBean information @@ -1054,7 +1055,7 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { if (log.isErrorEnabled()) { log.error(message, e); } - importResult.setErrorSystem(true); + importResult.setSystemErrorType(MassiveDocumentsImportResult.ImportSystemErrorType.UNABLE_TO_READ_ZIP_ENTRY); importResult.addMissingFile(fileName); } } @@ -1064,8 +1065,8 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { if (log.isErrorEnabled()) { log.error("Error with CSV file", ire); } - importResult.setErrorSystem(true); - throw new CoselmarTechnicalException("Error with CSV file", ire); + importResult.setSystemErrorType(MassiveDocumentsImportResult.ImportSystemErrorType.UNABLE_TO_READ_CSV); + return importResult; } finally { // Close importer importer.close(); @@ -1086,11 +1087,11 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { commit(); } catch (IOException e) { // Big problem if we can't move files into real folder ! + String message = String.format("Unable to move files from temp folder '%s' to final folder", zipTempPath); if (log.isErrorEnabled()) { - log.error("Unable to move files from temp folder '%s' to final folder", e); + log.error(message, e); } - importResult.setErrorSystem(true); - rollback(); + throw new CoselmarTechnicalException(message, e); } } else { diff --git a/coselmar-rest/src/test/resources/documents_errors.zip b/coselmar-rest/src/test/resources/documents_errors.zip index 836cde6..a6e53df 100644 Binary files a/coselmar-rest/src/test/resources/documents_errors.zip and b/coselmar-rest/src/test/resources/documents_errors.zip differ -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.