From d2a9ea6311f85246376637dd5a79a1b56a6c853f Mon Sep 17 00:00:00 2001 From: Marcos Lopez Gonzalez Date: Fri, 29 Sep 2023 11:48:09 +0200 Subject: [PATCH] #315 added logs + checking SUSPENDED state too --- .../download/resource/DownloadResource.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/occurrence-download-service/src/main/java/org/gbif/occurrence/download/resource/DownloadResource.java b/occurrence-download-service/src/main/java/org/gbif/occurrence/download/resource/DownloadResource.java index 735f1eb3c..3acc66e6b 100644 --- a/occurrence-download-service/src/main/java/org/gbif/occurrence/download/resource/DownloadResource.java +++ b/occurrence-download-service/src/main/java/org/gbif/occurrence/download/resource/DownloadResource.java @@ -97,6 +97,7 @@ import static org.gbif.api.model.occurrence.Download.Status.PREPARING; import static org.gbif.api.model.occurrence.Download.Status.RUNNING; import static org.gbif.api.model.occurrence.Download.Status.SUCCEEDED; +import static org.gbif.api.model.occurrence.Download.Status.SUSPENDED; import static org.gbif.occurrence.download.service.DownloadSecurityUtil.assertLoginMatches; import static org.gbif.occurrence.download.service.DownloadSecurityUtil.assertMonthlyDownloadBypass; import static org.gbif.occurrence.download.service.DownloadSecurityUtil.assertUserAuthenticated; @@ -361,7 +362,7 @@ private String createDownload( occurrenceDownloadService.listByUser( "download.gbif.org", new PagingRequest(0, 50), - EnumSet.of(PREPARING, RUNNING, SUCCEEDED), + EnumSet.of(PREPARING, RUNNING, SUCCEEDED, SUSPENDED), LocalDateTime.now().minus(35, ChronoUnit.DAYS), false); String existingMonthlyDownload = @@ -376,7 +377,7 @@ private String createDownload( occurrenceDownloadService.listByUser( userAuthenticated.getName(), new PagingRequest(0, 50), - EnumSet.of(PREPARING, RUNNING, SUCCEEDED), + EnumSet.of(PREPARING, RUNNING, SUCCEEDED, SUSPENDED), LocalDateTime.now().minus(4, ChronoUnit.HOURS), false); String existingUserDownload = matchExistingDownload(userDownloads, predicateDownloadRequest); @@ -472,12 +473,28 @@ private String matchExistingDownload( existingDownload.getKey(), existingPredicateDownload.getCreator()); return existingDownload.getKey(); + } else { + LOG.info( + "Download {} didn't match with new download with creator {}, format {}, type {} and predicate {}", + existingDownload.getKey(), + newDownload.getCreator(), + newDownload.getFormat(), + newDownload.getType(), + newDownload.getPredicate()); } } else { LOG.warn("Unexpected download type {}", existingDownload.getClass()); } } + LOG.info( + "{} downloads found but none of them matched for user {}, format {}, type {} and predicate {}", + existingDownloads.getCount(), + newDownload.getCreator(), + newDownload.getFormat(), + newDownload.getType(), + newDownload.getPredicate()); + return null; }