Skip to content

Commit

Permalink
Make static file publish step async
Browse files Browse the repository at this point in the history
  • Loading branch information
dionisislolas committed Jan 30, 2025
1 parent 4a74cb0 commit dfe250a
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public static boolean executePublish(Collection collection, CollectionReader col
boolean success = false;
final String collectionId = collection.getDescription().getId();

Future<Boolean> staticFilesPublishingFuture = null;
if (CMSFeatureFlags.cmsFeatureFlags().isStaticFilesPublishingEnabled()) {
staticFilesPublishingFuture = performStaticFilesPublish(collection);
}

Future<ImageServicePublishingResult> imageFuture = null;
if (CMSFeatureFlags.cmsFeatureFlags().isImagePublishingEnabled()) {
imageFuture = publishImages(collection);
Expand All @@ -139,11 +144,13 @@ public static boolean executePublish(Collection collection, CollectionReader col

if (CMSFeatureFlags.cmsFeatureFlags().isStaticFilesPublishingEnabled()) {
try {
staticFilesServiceSupplier.getService().publishCollection(collection);
success &= true;
if (staticFilesPublishingFuture == null) {
throw new Exception("static files publishing future unexpectedly null on completion of publishing");
}
success &= staticFilesPublishingFuture.get();
} catch (Exception e) {
error().data("collectionId", collectionId).data("publishing", true)
.logException(e, "Exception thrown when performing static file publish()");
.logException(e, "Exception thrown when completing static file publish()");
success = false;
}
}
Expand Down Expand Up @@ -788,6 +795,19 @@ private static Future<ImageServicePublishingResult> publishImages(Collection col
});
}

private static Future<Boolean> performStaticFilesPublish(Collection collection) {
return apiPool.submit(() -> {
try {
staticFilesServiceSupplier.getService().publishCollection(collection);
return true;
} catch (Exception e) {
error().data("collectionId", collection.getDescription().getId()).data("publishing", true)
.logException(e, "Exception thrown when performing static file publish()");
return false;
}
});
}

// Valid CMDDataset uris for published CMD versions of a dataset (edition) -
// /dataset/{datatsetId}/editions/{edition}/versions/{version}/metadata
protected static boolean isValidCMDDatasetURI(String uri) {
Expand Down

0 comments on commit dfe250a

Please sign in to comment.