@DELETE
@Path("/{" + PARAM_MCRID + "}")
@Operation(summary = "Deletes MCRObject {" + PARAM_MCRID + "}",
tags = MCRRestUtils.TAG_MYCORE_OBJECT,
responses = {
@ApiResponse(responseCode = "204", description = "MCRObject successfully deleted"),
@ApiResponse(responseCode = "409",
description = "MCRObject could not be deleted as it is referenced.",
content = @Content(schema = @Schema(
description = "Map<String, <Collection<String>> of source (key) to targets (value)",
implementation = Map.class))),
})
@MCRRequireTransaction
public Response deleteObject(@PathParam(PARAM_MCRID) MCRObjectID id) {
if (!MCRMetadataManager.exists(id)) {
throw new NotFoundException();
}
try {
MCRMetadataManager.deleteMCRObject(id);
} catch (MCRActiveLinkException e) {
Map<String, Collection<String>> activeLinks = e.getActiveLinks();
return Response.status(Response.Status.CONFLICT).entity(activeLinks).build();
} catch (MCRAccessException e) {
throw new ForbiddenException();
}
return Response.noContent().build();
}