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;
}
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);
}
}
}
Aggregations