use of org.commonjava.indy.model.core.ArtifactStore.METADATA_CHANGELOG in project indy by Commonjava.
the class DeprecatedStoreAdminHandler method delete.
@ApiOperation("Delete an artifact store")
@ApiResponses({ @ApiResponse(code = 204, response = ArtifactStore.class, message = "The store was deleted (or didn't exist in the first place)") })
@Path("/{name}")
@DELETE
public Response delete(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam(required = true) @PathParam("name") final String name, @Context final HttpServletRequest request, @Context final SecurityContext securityContext) {
String altPath = Paths.get(MavenPackageTypeDescriptor.MAVEN_ADMIN_REST_BASE_PATH, type, name).toString();
Consumer<Response.ResponseBuilder> modifier = (rb) -> markDeprecated(rb, altPath);
final StoreType st = StoreType.get(type);
final StoreKey key = new StoreKey(st, name);
logger.info("Deleting: {}", key);
Response response;
try {
String summary = null;
try {
summary = IOUtils.toString(request.getInputStream());
} catch (final IOException e) {
// no problem, try to get the summary from a header instead.
logger.info("store-deletion change summary not in request body, checking headers.");
}
if (isEmpty(summary)) {
summary = request.getHeader(METADATA_CHANGELOG);
}
if (isEmpty(summary)) {
summary = "Changelog not provided";
}
String user = securityManager.getUser(securityContext, request);
adminController.delete(key, user, summary);
response = markDeprecated(noContent(), altPath).build();
} catch (final IndyWorkflowException e) {
logger.error(e.getMessage(), e);
response = formatResponse(e, modifier);
}
return response;
}
Aggregations