Search in sources :

Example 6 with GitSubsystemException

use of org.commonjava.indy.subsys.git.GitSubsystemException 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)

Example 7 with GitSubsystemException

use of org.commonjava.indy.subsys.git.GitSubsystemException in project indy by Commonjava.

the class RevisionsManager method onLifecycleEvent.

public void onLifecycleEvent(@Observes final IndyLifecycleEvent event) {
    if (!revisionsConfig.isEnabled()) {
        return;
    }
    if (IndyLifecycleEvent.Type.started == event.getType()) {
        started = true;
        try {
            logger.info("Indy started; committing externally changed files.");
            ChangeSummary summary = new ChangeSummary(SYSTEM_USER, CATCHUP_CHANGELOG_MODIFIED);
            dataFileGit.addExternallyChangedFiles(summary);
            summary = new ChangeSummary(SYSTEM_USER, CATCHUP_CHANGELOG_DELETED);
            dataFileGit.deleteExternallyRemovedFiles(summary);
            dataFileGit.commit();
            if (revisionsConfig.isPushEnabled()) {
                dataFileGit.pushUpdates();
            }
        } catch (final GitSubsystemException e) {
            logger.error("Failed to commit pre-existing uncommitted changes in revisions manager: " + e.getMessage(), e);
        }
    }
}
Also used : GitSubsystemException(org.commonjava.indy.subsys.git.GitSubsystemException) ChangeSummary(org.commonjava.indy.audit.ChangeSummary)

Aggregations

GitSubsystemException (org.commonjava.indy.subsys.git.GitSubsystemException)7 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponse (io.swagger.annotations.ApiResponse)4 ApiResponses (io.swagger.annotations.ApiResponses)4 Path (javax.ws.rs.Path)4 Response (javax.ws.rs.core.Response)4 GET (javax.ws.rs.GET)3 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)3 File (java.io.File)2 ChangeSummaryDTO (org.commonjava.indy.revisions.jaxrs.dto.ChangeSummaryDTO)2 DataFile (org.commonjava.indy.subsys.datafile.DataFile)2 IOException (java.io.IOException)1 Date (java.util.Date)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 PostConstruct (javax.annotation.PostConstruct)1 Produces (javax.ws.rs.Produces)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1 StoreType (org.commonjava.indy.model.core.StoreType)1 GitConfig (org.commonjava.indy.subsys.git.GitConfig)1