Search in sources :

Example 56 with ApiResponse

use of io.swagger.annotations.ApiResponse in project indy by Commonjava.

the class NfcResource method getStoreInfo.

@Path("/{packageType}/{type: (hosted|group|remote)}/{name}/info")
@ApiOperation("Get not-found cache information, e.g., size, etc")
@ApiResponses({ @ApiResponse(code = 200, response = NotFoundCacheInfoDTO.class, message = "The info of not-found cache") })
@GET
@Produces(ApplicationContent.application_json)
public Response getStoreInfo(@ApiParam(name = "packageType", required = true, value = "type of package (eg. maven, npm, generic-http)") @PathParam("packageType") final String packageType, @ApiParam(allowableValues = "hosted,group,remote", name = "type", required = true, value = "type of store") @PathParam("type") final String t, @ApiParam(name = "name", value = "name of the store") @PathParam("name") final String name) {
    Response response;
    final StoreType type = StoreType.get(t);
    final StoreKey key = new StoreKey(packageType, type, name);
    try {
        NotFoundCacheInfoDTO dto = controller.getInfo(key);
        response = responseHelper.formatOkResponseWithJsonEntity(dto);
    } catch (final IndyWorkflowException e) {
        response = responseHelper.formatResponse(e);
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) StoreType(org.commonjava.indy.model.core.StoreType) NotFoundCacheInfoDTO(org.commonjava.indy.model.core.dto.NotFoundCacheInfoDTO) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) StoreKey(org.commonjava.indy.model.core.StoreKey) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 57 with ApiResponse

use of io.swagger.annotations.ApiResponse in project indy by Commonjava.

the class MaintenanceHandler method exportInfinispanCache.

@ApiOperation("Export the specified Infinispan cache.")
@ApiResponse(code = 200, message = "Export complete.")
@Produces("application/json")
@Path("/infinispan/cache/{name}{key: (/.+)?}")
@GET
public Response exportInfinispanCache(@ApiParam("The name of cache to export") @PathParam("name") final String name, @ApiParam("The cache key") @PathParam("key") final String key) {
    Response response;
    try {
        String json = ispnCacheController.export(name, key);
        response = Response.ok(json).build();
    } catch (final Exception e) {
        logger.error(String.format("Failed to export: %s. Reason: %s", name, 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) IOException(java.io.IOException) 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 58 with ApiResponse

use of io.swagger.annotations.ApiResponse in project indy by Commonjava.

the class MaintenanceHandler method rescan.

@ApiOperation("Rescan all content in the specified repository to re-initialize metadata, capture missing index keys, etc.")
@ApiResponse(code = 200, message = "Rescan was started successfully. (NOTE: There currently is no way to determine when rescanning is complete.)")
@Path("/rescan/{packageType}/{type: (hosted|group|remote)}/{name}")
@GET
public Response rescan(@ApiParam(value = "The package type (eg. maven, npm, generic-http)", required = true) @PathParam("packageType") final String packageType, @ApiParam(value = "The type of store / repository", allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam("The name of the store / repository") @PathParam("name") final String name) {
    final StoreKey key = new StoreKey(packageType, StoreType.get(type), name);
    Response response;
    try {
        contentController.rescan(key);
        response = Response.ok().build();
    } catch (final IndyWorkflowException e) {
        logger.error(String.format("Failed to rescan: %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) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) StoreKey(org.commonjava.indy.model.core.StoreKey) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponse(io.swagger.annotations.ApiResponse)

Example 59 with ApiResponse

use of io.swagger.annotations.ApiResponse in project indy by Commonjava.

the class MaintenanceHandler method getTombstoneStores.

@ApiOperation("Get tombstone stores that have no content and not in any group.")
@ApiResponse(code = 200, message = "Complete.")
@Produces(application_json)
@Path("/stores/tombstone/{packageType}/hosted")
@GET
public Response getTombstoneStores(@ApiParam("The packageType") @PathParam("packageType") final String packageType) {
    Response response;
    try {
        Set<StoreKey> tombstoneStores = maintenanceController.getTombstoneStores(packageType);
        response = Response.ok(mapper.writeValueAsString(tombstoneStores)).build();
    } catch (final Exception e) {
        logger.error(String.format("Failed to get tombstone stores. Reason: %s", e.getMessage()), e);
        response = responseHelper.formatResponse(e);
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) StoreKey(org.commonjava.indy.model.core.StoreKey) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) IOException(java.io.IOException) 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 60 with ApiResponse

use of io.swagger.annotations.ApiResponse in project indy by Commonjava.

the class MaintenanceHandler method deprecatedRescan.

@ApiOperation("[Deprecated] Rescan all content in the specified repository to re-initialize metadata, capture missing index keys, etc.")
@ApiResponse(code = 200, message = "Rescan was started successfully. (NOTE: There currently is no way to determine when rescanning is complete.)")
@Path("/rescan/{type: (hosted|group|remote)}/{name}")
@GET
@Deprecated
public Response deprecatedRescan(@ApiParam(value = "The type of store / repository", allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam("The name of the store / repository") @PathParam("name") final String name) {
    final StoreType storeType = StoreType.get(type);
    String altPath = Paths.get("/api/admin/maint", MAVEN_PKG_KEY, type, name).toString();
    final StoreKey key = new StoreKey(storeType, name);
    Response response;
    try {
        contentController.rescan(key);
        response = responseHelper.markDeprecated(Response.ok(), altPath).build();
    } catch (final IndyWorkflowException e) {
        logger.error(String.format("Failed to rescan: %s. Reason: %s", key, e.getMessage()), e);
        response = responseHelper.formatResponse(e, rb -> responseHelper.markDeprecated(rb, altPath));
    }
    return response;
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) StoreKey(org.commonjava.indy.model.core.StoreKey) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) 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