Search in sources :

Example 61 with ApiResponse

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;
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponse(io.swagger.annotations.ApiResponse)

Example 62 with ApiResponse

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;
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) Group(org.commonjava.indy.model.core.Group) StoreKey(org.commonjava.indy.model.core.StoreKey) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) IOException(java.io.IOException) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponse(io.swagger.annotations.ApiResponse)

Example 63 with ApiResponse

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);
}
Also used : PathParam(javax.ws.rs.PathParam) IndyDeployment(org.commonjava.indy.bind.jaxrs.IndyDeployment) REST(org.commonjava.indy.bind.jaxrs.util.REST) CHECK_CACHE_ONLY(org.commonjava.indy.IndyContentConstants.CHECK_CACHE_ONLY) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) Supplier(java.util.function.Supplier) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) HttpServletRequest(javax.servlet.http.HttpServletRequest) MavenPackageTypeDescriptor(org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor) QueryParam(javax.ws.rs.QueryParam) Api(io.swagger.annotations.Api) URI(java.net.URI) STORE_HTTP_HEADERS(org.commonjava.maven.galley.spi.cache.CacheProvider.STORE_HTTP_HEADERS) DELETE(javax.ws.rs.DELETE) Context(javax.ws.rs.core.Context) ResponseHelper(org.commonjava.indy.bind.jaxrs.util.ResponseHelper) RequestUtils(org.commonjava.indy.core.bind.jaxrs.util.RequestUtils) IndyResources(org.commonjava.indy.bind.jaxrs.IndyResources) StreamingOutput(javax.ws.rs.core.StreamingOutput) Consumer(java.util.function.Consumer) Response(javax.ws.rs.core.Response) Paths(java.nio.file.Paths) ApiResponse(io.swagger.annotations.ApiResponse) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) ApplicationScoped(javax.enterprise.context.ApplicationScoped) PUT(javax.ws.rs.PUT) UriInfo(javax.ws.rs.core.UriInfo) HEAD(javax.ws.rs.HEAD) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Path(javax.ws.rs.Path) HEAD(javax.ws.rs.HEAD) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 64 with ApiResponse

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);
}
Also used : PathParam(javax.ws.rs.PathParam) IndyDeployment(org.commonjava.indy.bind.jaxrs.IndyDeployment) REST(org.commonjava.indy.bind.jaxrs.util.REST) CHECK_CACHE_ONLY(org.commonjava.indy.IndyContentConstants.CHECK_CACHE_ONLY) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) Supplier(java.util.function.Supplier) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) HttpServletRequest(javax.servlet.http.HttpServletRequest) MavenPackageTypeDescriptor(org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor) QueryParam(javax.ws.rs.QueryParam) Api(io.swagger.annotations.Api) URI(java.net.URI) STORE_HTTP_HEADERS(org.commonjava.maven.galley.spi.cache.CacheProvider.STORE_HTTP_HEADERS) DELETE(javax.ws.rs.DELETE) Context(javax.ws.rs.core.Context) ResponseHelper(org.commonjava.indy.bind.jaxrs.util.ResponseHelper) RequestUtils(org.commonjava.indy.core.bind.jaxrs.util.RequestUtils) IndyResources(org.commonjava.indy.bind.jaxrs.IndyResources) StreamingOutput(javax.ws.rs.core.StreamingOutput) Consumer(java.util.function.Consumer) Response(javax.ws.rs.core.Response) Paths(java.nio.file.Paths) ApiResponse(io.swagger.annotations.ApiResponse) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) ApplicationScoped(javax.enterprise.context.ApplicationScoped) PUT(javax.ws.rs.PUT) UriInfo(javax.ws.rs.core.UriInfo) HEAD(javax.ws.rs.HEAD) URI(java.net.URI) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Path(javax.ws.rs.Path) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) PUT(javax.ws.rs.PUT)

Example 65 with ApiResponse

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());
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) TrackedContentEntryDTO(org.commonjava.indy.folo.dto.TrackedContentEntryDTO) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) HashSet(java.util.HashSet) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) ApiResponse(io.swagger.annotations.ApiResponse)

Aggregations

ApiResponse (io.swagger.annotations.ApiResponse)156 ApiOperation (io.swagger.annotations.ApiOperation)130 Path (javax.ws.rs.Path)124 Response (javax.ws.rs.core.Response)120 ApiResponses (io.swagger.annotations.ApiResponses)116 GET (javax.ws.rs.GET)93 Produces (javax.ws.rs.Produces)83 Api (io.swagger.annotations.Api)64 Consumes (javax.ws.rs.Consumes)60 POST (javax.ws.rs.POST)58 PathParam (javax.ws.rs.PathParam)58 DELETE (javax.ws.rs.DELETE)55 QueryParam (javax.ws.rs.QueryParam)46 List (java.util.List)45 Inject (javax.inject.Inject)45 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)45 ApiParam (io.swagger.annotations.ApiParam)44 Collectors (java.util.stream.Collectors)42 Logger (org.slf4j.Logger)42 LoggerFactory (org.slf4j.LoggerFactory)42