diff --git a/modules/admin-ui/src/main/java/org/opencastproject/adminui/endpoint/SeriesEndpoint.java b/modules/admin-ui/src/main/java/org/opencastproject/adminui/endpoint/SeriesEndpoint.java index ac44a2dae26..0ac3808f285 100644 --- a/modules/admin-ui/src/main/java/org/opencastproject/adminui/endpoint/SeriesEndpoint.java +++ b/modules/admin-ui/src/main/java/org/opencastproject/adminui/endpoint/SeriesEndpoint.java @@ -1197,7 +1197,61 @@ public Response updateSeriesTobiraPath( tobira.createRealmLineage(paths); tobira.addSeriesMountPoint(mountParams); - if (currentPath != null) { + if (currentPath != null && !currentPath.trim().isEmpty()) { + var unmountParams = new JSONObject(); + unmountParams.put("seriesId", seriesId); + unmountParams.put("currentPath", currentPath); + tobira.removeSeriesMountPoint(unmountParams); + } + + return ok(); + } catch (Exception e) { + return Response.status(Status.INTERNAL_SERVER_ERROR) + .entity("Internal server error: " + e.getMessage()) + .build(); + } + } + + @DELETE + @Path("{seriesId}/tobira/{currentPath}") + @RestQuery( + name = "removeSeriesTobiraPath", + description = "Removes the path of the given series in a connected Tobira instance", + returnDescription = "Status code", + pathParameters = { + @RestParameter( + name = "seriesId", + isRequired = true, + description = "The series id", + type = STRING), + @RestParameter( + name = "currentPath", + isRequired = true, + description = "URL encoded path where the series is currently mounted.", + type = STRING) }, + responses = { + @RestResponse( + responseCode = SC_OK, + description = "The path of the series has successfully been removed in Tobira."), + @RestResponse( + responseCode = SC_NOT_FOUND, + description = "Tobira doesn't know about the given series"), + @RestResponse( + responseCode = SC_SERVICE_UNAVAILABLE, + description = "Tobira is not configured (correctly)") }) + public Response removeSeriesTobiraPath( + @PathParam("seriesId") String seriesId, + @PathParam("currentPath") String currentPath + ) throws IOException, InterruptedException { + var tobira = getTobira(); + if (!tobira.ready()) { + return Response.status(Status.SERVICE_UNAVAILABLE) + .entity("Tobira is not configured (correctly)") + .build(); + } + + try { + if (currentPath != null && !currentPath.trim().isEmpty()) { var unmountParams = new JSONObject(); unmountParams.put("seriesId", seriesId); unmountParams.put("currentPath", currentPath);