Skip to content

Commit

Permalink
better pre-delete checks, emit full template description on notification
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Feb 21, 2024
1 parent bca3ec9 commit 74eebe3
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/main/java/io/cryostat/events/S3TemplateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,25 @@ public Template addTemplate(InputStream stream)
@Blocking
@Override
public void deleteTemplate(String templateName) {
var req =
DeleteObjectRequest.builder()
.bucket(eventTemplatesBucket)
.key(templateName)
.build();
storage.deleteObject(req);
bus.publish(
MessagingServer.class.getName(),
new Notification(
EVENT_TEMPLATE_DELETED, Map.of("template", Map.of("name", templateName))));
try {
var template =
getTemplates().stream()
.filter(t -> t.getName().equals(templateName))
.findFirst()
.orElseThrow();
var req =
DeleteObjectRequest.builder()
.bucket(eventTemplatesBucket)
.key(templateName)
.build();
if (storage.deleteObject(req).sdkHttpResponse().isSuccessful()) {
bus.publish(
MessagingServer.class.getName(),
new Notification(EVENT_TEMPLATE_DELETED, Map.of("template", template)));
}
} catch (FlightRecorderException e) {
logger.error(e);
}
}

private Tagging createTemplateTagging(
Expand Down

0 comments on commit 74eebe3

Please sign in to comment.