use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class MaintenanceHandler method deleteAll.
@ApiOperation("Delete the specified path globally (from any repository that contains it).")
@ApiResponse(code = 200, message = "Global deletion complete for path.")
@Path("/content/all{path: (/.+)?}")
@DELETE
public Response deleteAll(@ApiParam("The path to delete globally") @PathParam("path") final String path) {
Response response;
try {
contentController.deleteAll(path);
response = Response.ok().build();
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to delete: %s in: ALL. Reason: %s", e.getMessage()), e);
response = responseHelper.formatResponse(e);
}
return response;
}
use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class MaintenanceHandler method affectedBy.
@ApiOperation("Get groups affected by specified repo.")
@ApiResponse(code = 200, message = "Complete.")
@Produces("application/json")
@Path("/store/affected/{key}")
@GET
public Response affectedBy(@ApiParam("The store key") @PathParam("key") final String key) {
Response response;
try {
Set<StoreKey> storeKeys = new HashSet<>();
storeKeys.add(StoreKey.fromString(key));
Set<Group> groups = storeDataManager.affectedBy(storeKeys);
response = Response.ok(mapper.writeValueAsString(groups)).build();
} catch (final Exception e) {
logger.error(String.format("Failed to export: %s. Reason: %s", key, e.getMessage()), e);
response = responseHelper.formatResponse(e);
}
return response;
}
use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class DeprecatedContentAccessResource method doHead.
@ApiOperation("Store file/artifact content under the given artifact store (type/name) and path.")
@ApiResponses({ @ApiResponse(code = 404, message = "Content is not available"), @ApiResponse(code = 200, message = "Header metadata for content (or rendered listing when path ends with '/index.html' or '/'") })
@HEAD
@Path("/{path: (.*)}")
public Response doHead(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam(required = true) @PathParam("name") final String name, @PathParam("path") final String path, @QueryParam(CHECK_CACHE_ONLY) final Boolean cacheOnly, @Context final UriInfo uriInfo, @Context final HttpServletRequest request) {
String packageType = MavenPackageTypeDescriptor.MAVEN_PKG_KEY;
final String baseUri = uriInfo.getBaseUriBuilder().path(IndyDeployment.API_PREFIX).build().toString();
final Consumer<Response.ResponseBuilder> deprecated = builder -> {
String alt = Paths.get("/api/maven", type, name, path).toString();
responseHelper.markDeprecated(builder, alt);
};
return handler.doHead(packageType, type, name, path, cacheOnly, baseUri, request, new EventMetadata(), deprecated);
}
use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class DeprecatedContentAccessResource method doCreate.
@ApiOperation("Store file/artifact content under the given artifact store (type/name) and path.")
@ApiResponses({ @ApiResponse(code = 201, message = "Content was stored successfully"), @ApiResponse(code = 400, message = "No appropriate storage location was found in the specified store (this store, or a member if a group is specified).") })
@PUT
@Path("/{path: (.+)?}")
public Response doCreate(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam(required = true) @PathParam("name") final String name, @PathParam("path") final String path, @Context final UriInfo uriInfo, @Context final HttpServletRequest request) {
String packageType = MavenPackageTypeDescriptor.MAVEN_PKG_KEY;
final Supplier<URI> uriSupplier = () -> uriInfo.getBaseUriBuilder().path(getClass()).path(path).build(packageType, type, name);
final Consumer<Response.ResponseBuilder> deprecated = builder -> {
String alt = Paths.get("/api/maven", type, name, path).toString();
responseHelper.markDeprecated(builder, alt);
};
final EventMetadata metadata = new EventMetadata().set(STORE_HTTP_HEADERS, RequestUtils.extractRequestHeadersToMap(request));
return handler.doCreate(packageType, type, name, path, request, metadata, uriSupplier, deprecated);
}
use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class FoloAdminResource method doDelete.
@ApiOperation("Batch delete files uploaded through FOLO trackingID under the given storeKey.")
@ApiResponse(code = 200, message = "Batch delete operation finished.")
@ApiImplicitParam(name = "body", paramType = "body", value = "JSON object, specifying trackingID and storeKey, with other configuration options", required = true, dataType = "org.commonjava.indy.model.core.BatchDeleteRequest")
@Path("/batch/delete")
@POST
@Produces(application_json)
public Response doDelete(@Context final UriInfo uriInfo, final BatchDeleteRequest request) {
String trackingID = request.getTrackingID();
if (trackingID == null || request.getStoreKey() == null) {
Response.ResponseBuilder builder = Response.status(400);
return builder.build();
}
if (request.getPaths() == null || request.getPaths().isEmpty()) {
final String baseUrl = uriInfo.getBaseUriBuilder().path("api").build().toString();
try {
final TrackedContentDTO record = controller.getRecord(trackingID, baseUrl);
if (record == null || record.getUploads().isEmpty()) {
Response.ResponseBuilder builder = Response.status(400);
return builder.build();
}
Set<String> paths = new HashSet<>();
for (TrackedContentEntryDTO entry : record.getUploads()) {
if (!paths.contains(entry.getPath())) {
paths.add(entry.getPath());
}
}
request.setPaths(paths);
} catch (IndyWorkflowException e) {
responseHelper.throwError(e);
}
}
return handler.doDelete(request, new EventMetadata());
}
Aggregations