Search in sources :

Example 1 with Pagination

use of org.commonjava.indy.core.model.Pagination in project indy by Commonjava.

the class NfcResource method deprecatedGetStore.

@Path("/{type: (hosted|group|remote)}/{name}")
@ApiOperation("[Deprecated] Retrieve all not-found cache entries currently tracked for a given store")
@ApiResponses({ @ApiResponse(code = 200, response = NotFoundCacheDTO.class, message = "The not-found cache for the specified artifact store") })
@GET
@Produces(ApplicationContent.application_json)
public Response deprecatedGetStore(@ApiParam(allowableValues = "hosted,group,remote", name = "type", required = true, value = "The type of store") @PathParam("type") final String t, @ApiParam(name = "name", value = "The name of the store") @PathParam("name") final String name, @ApiParam(name = "pageIndex", value = "page index") @QueryParam("pageIndex") final Integer pageIndex, @ApiParam(name = "pageSize", value = "page size") @QueryParam("pageSize") final Integer pageSize) {
    Response response;
    final StoreType type = StoreType.get(t);
    String altPath = Paths.get("/api/nfc", MAVEN_PKG_KEY, type.singularEndpointName(), name).toString();
    final StoreKey key = new StoreKey(type, name);
    try {
        NotFoundCacheDTO dto;
        Page page = new Page(pageIndex, pageSize);
        if (page != null && page.allowPaging()) {
            Pagination<NotFoundCacheDTO> nfcPagination = controller.getMissing(key, page);
            dto = nfcPagination.getCurrData();
        } else {
            dto = controller.getMissing(key);
        }
        response = responseHelper.formatOkResponseWithJsonEntity(dto, rb -> responseHelper.markDeprecated(rb, altPath));
    } catch (final IndyWorkflowException e) {
        response = responseHelper.formatResponse(e, (rb) -> responseHelper.markDeprecated(rb, altPath));
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) StoreType(org.commonjava.indy.model.core.StoreType) PathParam(javax.ws.rs.PathParam) REST(org.commonjava.indy.bind.jaxrs.util.REST) NfcController(org.commonjava.indy.core.ctl.NfcController) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Pagination(org.commonjava.indy.core.model.Pagination) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) QueryParam(javax.ws.rs.QueryParam) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Api(io.swagger.annotations.Api) StoreKey(org.commonjava.indy.model.core.StoreKey) MAVEN_PKG_KEY(org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY) DELETE(javax.ws.rs.DELETE) NotFoundCacheDTO(org.commonjava.indy.model.core.dto.NotFoundCacheDTO) Logger(org.slf4j.Logger) ResponseHelper(org.commonjava.indy.bind.jaxrs.util.ResponseHelper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StoreType(org.commonjava.indy.model.core.StoreType) IndyResources(org.commonjava.indy.bind.jaxrs.IndyResources) NotFoundCacheInfoDTO(org.commonjava.indy.model.core.dto.NotFoundCacheInfoDTO) ApplicationContent(org.commonjava.indy.util.ApplicationContent) Response(javax.ws.rs.core.Response) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) Paths(java.nio.file.Paths) ApiResponse(io.swagger.annotations.ApiResponse) Page(org.commonjava.indy.core.model.Page) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Page(org.commonjava.indy.core.model.Page) StoreKey(org.commonjava.indy.model.core.StoreKey) NotFoundCacheDTO(org.commonjava.indy.model.core.dto.NotFoundCacheDTO) 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)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 ApiResponse (io.swagger.annotations.ApiResponse)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Paths (java.nio.file.Paths)1 Inject (javax.inject.Inject)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 PathParam (javax.ws.rs.PathParam)1 Produces (javax.ws.rs.Produces)1 QueryParam (javax.ws.rs.QueryParam)1 Response (javax.ws.rs.core.Response)1 StringUtils.isBlank (org.apache.commons.lang3.StringUtils.isBlank)1 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)1 IndyResources (org.commonjava.indy.bind.jaxrs.IndyResources)1 REST (org.commonjava.indy.bind.jaxrs.util.REST)1 ResponseHelper (org.commonjava.indy.bind.jaxrs.util.ResponseHelper)1