diff --git a/src/main/java/eu/openaire/urls_worker/controllers/FullTextsController.java b/src/main/java/eu/openaire/urls_worker/controllers/FullTextsController.java index ae16568..3ce1bbb 100644 --- a/src/main/java/eu/openaire/urls_worker/controllers/FullTextsController.java +++ b/src/main/java/eu/openaire/urls_worker/controllers/FullTextsController.java @@ -42,7 +42,7 @@ public class FullTextsController { if ( (fileNamesListNum == 1) && (fileNamesWithExtensions.get(0).length() == 0) ) { // In case the last "/" in the url was given, then this list will not be empty, but have one empty item instead. // In case the url does not end in "/", then Spring will automatically return an "HTTP-BadRequest". String errorMsg = "An empty \"fileNamesWithExtensions\" list was given from assignments_" + assignmentsCounter + ", for batch_" + zipBatchCounter; - logger.warn(errorMsg); + logger.error(errorMsg); return ResponseEntity.badRequest().body(errorMsg); } @@ -56,7 +56,12 @@ public class FullTextsController { return ResponseEntity.badRequest().body(errorMsg); } - if ( zipBatchCounter > totalZipBatches ) { + if ( totalZipBatches == 0 ) { + String errorMsg = "The given \"totalZipBatches\" (" + totalZipBatches + ") was < 0 >!"; + logger.error(errorMsg); + return ResponseEntity.badRequest().body(errorMsg); + } + else if ( zipBatchCounter > totalZipBatches ) { String errorMsg = "The given \"zipBatchCounter\" (" + zipBatchCounter + ") is greater than the \"totalZipBatches\" (" + totalZipBatches + ")!"; logger.error(errorMsg); return ResponseEntity.badRequest().body(errorMsg); @@ -72,7 +77,7 @@ public class FullTextsController { // If this is the last batch for this assignments-count, then make sure it is deleted in the next scheduled delete-operation. if ( zipBatchCounter == totalZipBatches ) { assignmentsNumsHandledAndLocallyDeleted.put(assignmentsCounter, false); - logger.debug("Will return the last batch (" + zipBatchCounter + ") of Assignments_" + assignmentsCounter + " to the Controller and these assignments will be deleted later."); + logger.debug("Will return the " + ((totalZipBatches > 1) ? "last" : "only") + " batch (" + zipBatchCounter + ") of Assignments_" + assignmentsCounter + " to the Controller and these assignments will be deleted later."); } String zipName = zipFile.getName(); diff --git a/src/main/java/eu/openaire/urls_worker/plugins/PublicationsRetrieverPlugin.java b/src/main/java/eu/openaire/urls_worker/plugins/PublicationsRetrieverPlugin.java index ef236c2..8bdfc4e 100644 --- a/src/main/java/eu/openaire/urls_worker/plugins/PublicationsRetrieverPlugin.java +++ b/src/main/java/eu/openaire/urls_worker/plugins/PublicationsRetrieverPlugin.java @@ -161,9 +161,9 @@ public class PublicationsRetrieverPlugin { ConnSupportUtils.domainsWithConnectionData.clear(); // This data is not useful for the next batch, since plenty of time will have passed before needing to check the "lastConnectedTime" for each domain, in order to apply the "politenessDelay". - logger.debug("The number of cookies is: " + cookieStore.getCookies().size()); + //logger.debug("The number of cookies is: " + cookieStore.getCookies().size()); // debug! boolean cookiesDeleted = cookieStore.removeAll(); - logger.debug(cookiesDeleted ? "The cookies where removed!" : "No cookies where removed!"); + //logger.debug(cookiesDeleted ? "The cookies where removed!" : "No cookies where removed!"); // DEBUG! } @@ -174,14 +174,15 @@ public class PublicationsRetrieverPlugin { { // Index the UrlIds with the DatasourceIds for quick-search later. HashMap urlIdsWithDatasourceIds = new HashMap<>(assignments.size()); - for ( Assignment assignment : assignments ) { + for ( Assignment assignment : assignments ) urlIdsWithDatasourceIds.put(assignment.getId(), assignment.getDatasource().getId()); - } Timestamp timestamp = new Timestamp(System.currentTimeMillis()); // Store it here, in order to have the same for all current records. for ( DataToBeLogged data : FileUtils.dataToBeLoggedList ) { + // TODO - Consider adding multi-thread execution for the following code. + UrlReport.StatusType status = null; String fileLocation = null, comment = data.getComment(), mimeType = null, hash = data.getHash(); Long size = data.getSize(); @@ -275,4 +276,5 @@ public class PublicationsRetrieverPlugin { return false; } } + } diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 23d6069..c596b83 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,3 +1,4 @@ + diff --git a/src/test/java/eu/openaire/urls_worker/UrlsWorkerApplicationTests.java b/src/test/java/eu/openaire/urls_worker/UrlsWorkerApplicationTests.java index 880b7bc..2e2a3a3 100644 --- a/src/test/java/eu/openaire/urls_worker/UrlsWorkerApplicationTests.java +++ b/src/test/java/eu/openaire/urls_worker/UrlsWorkerApplicationTests.java @@ -6,8 +6,9 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class UrlsWorkerApplicationTests { - @Test - void contextLoads() { + //@Test // TODO - Enable when the test is ready. + void test1() { + // TODO - Write a test. } }