This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See https://gitlab.nuiton.org/codelutin/coselmar.git commit 3de017790ba8e3ba84feaede11e12bc90f34adb4 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jun 8 11:42:13 2017 +0200 refs #9206 Fix indexation revert when failure on documents mass import --- .../beans/MassiveDocumentsImportResult.java | 2 +- .../indexation/DocumentsIndexationService.java | 2 +- .../coselmar/services/v1/AdminWebService.java | 1 + .../coselmar/services/v1/DocumentsWebService.java | 23 +++++++++++++--------- 4 files changed, 17 insertions(+), 11 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 3f8f4ab..6bb29ad 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 @@ -18,7 +18,7 @@ public class MassiveDocumentsImportResult { } public boolean isSuccess() { - return missingFiles.isEmpty() && !errorSystem; + return missingFiles != null && missingFiles.isEmpty() && !errorSystem; } public List<String> getMissingFiles() { diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java index f820531..1e49e96 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java @@ -304,7 +304,7 @@ public class DocumentsIndexationService extends CoselmarSimpleServiceSupport { } - protected void cleanIndex() throws IOException { + public void cleanIndex() throws IOException { BooleanQuery query = new BooleanQuery.Builder() .add(new TermQuery(new Term("type", DOCUMENT_TYPE)), BooleanClause.Occur.MUST) //XXX ymartel 20151215 : Clean older DOCUMENT_TYPE value too (less or equals V1.0.1), should be removed after V2.0 diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/AdminWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/AdminWebService.java index 6fd6325..5686aec 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/AdminWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/AdminWebService.java @@ -96,6 +96,7 @@ public class AdminWebService extends CoselmarWebServiceSupport { protected void refreshDocumentsIndex() throws IOException { DocumentsIndexationService documentsIndexationService = getServicesContext().newService(DocumentsIndexationService.class); + documentsIndexationService.cleanIndex(); // get All documents List<Document> documents = getDocumentDao().findAll(); for (Document document : documents) { 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 7ab6011..951f67d 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 @@ -1082,7 +1082,7 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { } } } - if (!importResult.isErrorSystem() && (importResult.getMissingFiles() == null || importResult.getMissingFiles().isEmpty())) { + if (importResult.isSuccess()) { // All is ok ! try { // Ok, let move all files from temp storage to real one ! @@ -1094,21 +1094,26 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { if (log.isErrorEnabled()) { log.error(message, e); } + refreshDocumentsIndex(); throw new CoselmarTechnicalException(message, e); } } else { // Something wrong happened... rollback, and refresh lucene to avoid new data rollback(); - AdminWebService adminWebService = getServicesContext().newService(AdminWebService.class); - try { - adminWebService.refreshDocumentsIndex(); - } catch (IOException e) { - if (log.isErrorEnabled()) { - log.error("Unable to refresh Lucene Documents index. Data should be corrupted", e); - } - } + refreshDocumentsIndex(); } return importResult; } + + protected void refreshDocumentsIndex() { + AdminWebService adminWebService = getServicesContext().newService(AdminWebService.class); + try { + adminWebService.refreshDocumentsIndex(); + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Unable to refresh Lucene Documents index. Data should be corrupted", e); + } + } + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.