Search in sources :

Example 1 with ChangeSummaryDTO

use of org.commonjava.indy.revisions.jaxrs.dto.ChangeSummaryDTO in project indy by Commonjava.

the class RevisionsAdminResource method doGet.

@ApiOperation("Retrieve the changelog for the Indy data directory content with the specified path, start-index, and number of results")
@ApiResponses({ @ApiResponse(code = 200, message = "JSON containing changelog entries", response = ChangeSummaryDTO.class), @ApiResponse(code = 400, message = "In case the revisions add-on is disabled") })
@Path("/data/changelog/{path: .+}")
@GET
@Produces(ApplicationContent.application_json)
public Response doGet(@PathParam("path") final String path, @QueryParam("start") final int start, @QueryParam("count") final int count) {
    if (!config.isEnabled()) {
        return responseHelper.formatResponse(ApplicationStatus.BAD_REQUEST, "Revisions add-on is disabled");
    }
    Response response;
    try {
        final List<ChangeSummary> listing = revisionsManager.getDataChangeLog(path, start, count);
        response = responseHelper.formatOkResponseWithJsonEntity(new ChangeSummaryDTO(listing));
    } catch (final GitSubsystemException e) {
        logger.error("Failed to read git changelog from data dir: " + e.getMessage(), e);
        response = responseHelper.formatResponse(e, "Failed to read git changelog from data dir.");
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) ChangeSummaryDTO(org.commonjava.indy.revisions.jaxrs.dto.ChangeSummaryDTO) GitSubsystemException(org.commonjava.indy.subsys.git.GitSubsystemException) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) 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 2 with ChangeSummaryDTO

use of org.commonjava.indy.revisions.jaxrs.dto.ChangeSummaryDTO in project indy by Commonjava.

the class ChangelogResource method getStoreChangelog.

@ApiOperation("Retrieve the changelog for the Indy group/repository definition with the start-index and number of results")
@ApiResponses({ @ApiResponse(code = 200, message = "JSON containing changelog entries", response = ChangeSummaryDTO.class), @ApiResponse(code = 400, message = "Requested group/repository type is not one of: {remote, hosted, group}") })
@Path("/store/{type}/{name}")
public Response getStoreChangelog(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String t, @PathParam("name") final String storeName, @QueryParam("start") int start, @QueryParam("count") int count) {
    final StoreType storeType = StoreType.get(t);
    if (storeType == null) {
        return Response.status(Status.BAD_REQUEST).entity("Invalid store type: '" + t + "'").build();
    }
    final StoreKey key = new StoreKey(storeType, storeName);
    if (start < 0) {
        start = 0;
    }
    if (count < 1) {
        count = DEFAULT_CHANGELOG_COUNT;
    }
    Response response;
    try {
        final List<ChangeSummary> dataChangeLog = revisions.getDataChangeLog(key, start, count);
        response = responseHelper.formatOkResponseWithJsonEntity(new ChangeSummaryDTO(dataChangeLog));
        logger.info("\n\n\n\n\n\n{} Sent changelog for: {}\n\n{}\n\n\n\n\n\n\n", new Date(), key, dataChangeLog);
    } catch (final GitSubsystemException e) {
        final String message = String.format("Failed to lookup changelog for: %s. Reason: %s", key, e.getMessage());
        logger.error(message, e);
        response = responseHelper.formatResponse(e);
    }
    return response;
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) ChangeSummaryDTO(org.commonjava.indy.revisions.jaxrs.dto.ChangeSummaryDTO) GitSubsystemException(org.commonjava.indy.subsys.git.GitSubsystemException) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) StoreKey(org.commonjava.indy.model.core.StoreKey) Date(java.util.Date) Path(javax.ws.rs.Path) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponse (io.swagger.annotations.ApiResponse)2 ApiResponses (io.swagger.annotations.ApiResponses)2 Path (javax.ws.rs.Path)2 Response (javax.ws.rs.core.Response)2 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)2 ChangeSummaryDTO (org.commonjava.indy.revisions.jaxrs.dto.ChangeSummaryDTO)2 GitSubsystemException (org.commonjava.indy.subsys.git.GitSubsystemException)2 Date (java.util.Date)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1 StoreType (org.commonjava.indy.model.core.StoreType)1