Skip to content

Commit

Permalink
#315 added logs + checking SUSPENDED state too
Browse files Browse the repository at this point in the history
  • Loading branch information
marcos-lg committed Sep 29, 2023
1 parent 1911143 commit d2a9ea6
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit d2a9ea6

Please sign in to comment.