Search in sources :

Example 6 with NotFoundCacheDTO

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

the class NfcResource method getAll.

@GET
@ApiOperation("Retrieve all not-found cache entries currently tracked")
@ApiResponses({ @ApiResponse(code = 200, response = NotFoundCacheDTO.class, message = "The full not-found cache") })
@Produces(ApplicationContent.application_json)
public Response getAll(@ApiParam(name = "pageIndex", value = "page index") @QueryParam("pageIndex") final Integer pageIndex, @ApiParam(name = "pageSize", value = "page size") @QueryParam("pageSize") final Integer pageSize) {
    NotFoundCacheDTO dto;
    Page page = new Page(pageIndex, pageSize);
    if (page != null && page.allowPaging()) {
        Pagination<NotFoundCacheDTO> nfcPagination = controller.getAllMissing(page);
        dto = nfcPagination.getCurrData();
    } else {
        dto = controller.getAllMissing();
    }
    return responseHelper.formatOkResponseWithJsonEntity(dto);
}
Also used : Page(org.commonjava.indy.core.model.Page) NotFoundCacheDTO(org.commonjava.indy.model.core.dto.NotFoundCacheDTO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 7 with NotFoundCacheDTO

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

the class NfcController method getNotFoundCacheDTO.

private NotFoundCacheDTO getNotFoundCacheDTO(Map<Location, Set<String>> allMissing) {
    final NotFoundCacheDTO dto = new NotFoundCacheDTO();
    for (final Location loc : allMissing.keySet()) {
        if (loc instanceof KeyedLocation) {
            final List<String> paths = new ArrayList<String>(allMissing.get(loc));
            Collections.sort(paths);
            dto.addSection(((KeyedLocation) loc).getKey(), paths);
        }
    }
    return dto;
}
Also used : KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) ArrayList(java.util.ArrayList) NotFoundCacheDTO(org.commonjava.indy.model.core.dto.NotFoundCacheDTO) KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) LocationUtils.toLocation(org.commonjava.indy.util.LocationUtils.toLocation) Location(org.commonjava.maven.galley.model.Location)

Example 8 with NotFoundCacheDTO

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

the class NfcResource method getStore.

@Path("/{packageType}/{type: (hosted|group|remote)}/{name}")
@ApiOperation("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 getStore(@ApiParam(name = "packageType", required = true, value = "The type of package (eg. maven, npm, generic-http)") @PathParam("packageType") final String packageType, @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) {
    Response response;
    final StoreType type = StoreType.get(t);
    final StoreKey key = new StoreKey(packageType, type, name);
    try {
        final NotFoundCacheDTO dto = controller.getMissing(key);
        response = formatOkResponseWithJsonEntity(dto, serializer);
    } catch (final IndyWorkflowException e) {
        response = formatResponse(e);
    }
    return response;
}
Also used : ResponseUtils.formatResponse(org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) StoreType(org.commonjava.indy.model.core.StoreType) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) 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)

Example 9 with NotFoundCacheDTO

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

the class NfcController method getAllMissing.

public NotFoundCacheDTO getAllMissing() {
    final NotFoundCacheDTO dto = new NotFoundCacheDTO();
    final Map<Location, Set<String>> allMissing = cache.getAllMissing();
    for (final Location loc : allMissing.keySet()) {
        if (loc instanceof KeyedLocation) {
            final List<String> paths = new ArrayList<String>(allMissing.get(loc));
            Collections.sort(paths);
            dto.addSection(((KeyedLocation) loc).getKey(), paths);
        }
    }
    return dto;
}
Also used : Set(java.util.Set) KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) ArrayList(java.util.ArrayList) NotFoundCacheDTO(org.commonjava.indy.model.core.dto.NotFoundCacheDTO) KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) LocationUtils.toLocation(org.commonjava.indy.util.LocationUtils.toLocation) Location(org.commonjava.maven.galley.model.Location)

Example 10 with NotFoundCacheDTO

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

the class NfcResource method getStore.

@Path("/{packageType}/{type: (hosted|group|remote)}/{name}")
@ApiOperation("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 getStore(@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, @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);
    final StoreKey key = new StoreKey(packageType, 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);
    } 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) 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

NotFoundCacheDTO (org.commonjava.indy.model.core.dto.NotFoundCacheDTO)14 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)6 ApiOperation (io.swagger.annotations.ApiOperation)5 ApiResponses (io.swagger.annotations.ApiResponses)5 GET (javax.ws.rs.GET)5 Produces (javax.ws.rs.Produces)5 StoreType (org.commonjava.indy.model.core.StoreType)5 KeyedLocation (org.commonjava.indy.model.galley.KeyedLocation)5 ApiResponse (io.swagger.annotations.ApiResponse)4 ArrayList (java.util.ArrayList)4 Path (javax.ws.rs.Path)4 Response (javax.ws.rs.core.Response)4 IndyNfcClientModule (org.commonjava.indy.client.core.module.IndyNfcClientModule)4 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)4 StoreKey (org.commonjava.indy.model.core.StoreKey)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 Page (org.commonjava.indy.core.model.Page)3 Test (org.junit.Test)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2