From a1924392819bba5708a6245573d57825c36790ea Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Mon, 11 Mar 2024 12:16:04 -0400 Subject: [PATCH] @source --- src/main/java/io/cryostat/graphql/ActiveRecordings.java | 7 +++---- src/main/java/io/cryostat/recordings/RecordingHelper.java | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/cryostat/graphql/ActiveRecordings.java b/src/main/java/io/cryostat/graphql/ActiveRecordings.java index a952eb508..ee636980f 100644 --- a/src/main/java/io/cryostat/graphql/ActiveRecordings.java +++ b/src/main/java/io/cryostat/graphql/ActiveRecordings.java @@ -45,7 +45,6 @@ import jdk.jfr.RecordingState; import org.eclipse.microprofile.graphql.Description; import org.eclipse.microprofile.graphql.GraphQLApi; -import org.eclipse.microprofile.graphql.Mutation; import org.eclipse.microprofile.graphql.NonNull; import org.eclipse.microprofile.graphql.Source; @@ -121,16 +120,16 @@ public RecordingOptions asOptions() { } } - @Mutation @Description( "Updates the metadata labels for an existing Flight Recorder recording specified by the" + " recording ID.") - public Uni doPutMetadata(Long recordingId, MetadataInput metadataInput) { + public Uni doPutMetadata( + @Source ActiveRecording recording, MetadataInput metadataInput) { return Uni.createFrom() .item( () -> { Map labels = metadataInput.getLabels(); - return recordingHelper.updateRecordingMetadata(recordingId, labels); + return recordingHelper.updateRecordingMetadata(recording.id, labels); }); } diff --git a/src/main/java/io/cryostat/recordings/RecordingHelper.java b/src/main/java/io/cryostat/recordings/RecordingHelper.java index c33676103..16fe0b3c2 100644 --- a/src/main/java/io/cryostat/recordings/RecordingHelper.java +++ b/src/main/java/io/cryostat/recordings/RecordingHelper.java @@ -932,12 +932,14 @@ private Metadata taggingToMetadata(List tagSet) { public ActiveRecording updateRecordingMetadata( Long recordingId, Map newLabels) { ActiveRecording recording = ActiveRecording.findById(recordingId); + if (recording == null) { throw new NotFoundException("Recording not found for ID: " + recordingId); } Metadata updatedMetadata = new Metadata(newLabels); recording.setMetadata(updatedMetadata); + recording.persist(); return recording;