use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class RevisionsManagerTest method commitTwoDifferentFilesAndRetrieveChangelogForOneOfThem.
@Test
public void commitTwoDifferentFilesAndRetrieveChangelogForOneOfThem() throws Exception {
lcEvents.fireStarted();
final DataFile f1 = dfManager.getDataFile("test/foo.txt");
f1.writeString("this is a test", "UTF-8", new ChangeSummary("test-user", "test for first file."));
final DataFile f2 = dfManager.getDataFile("test/bar.txt");
f2.writeString("this is a test", "UTF-8", new ChangeSummary("test-user", "test for second file."));
f2.writeString("this is another test", "UTF-8", new ChangeSummary("test-user", "test (2) for second file."));
final List<DataFileEvent> events = listener.waitForEvents(3);
System.out.println("Got events:\n " + join(events, "\n "));
final List<ChangeSummary> changeLog = revManager.getDataChangeLog(f2.getPath(), 0, -1);
assertThat(changeLog, notNullValue());
assertThat(changeLog.size(), equalTo(2));
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class RevisionsManagerTest method commitOneFileTwice_ChangedBeforeServerStart_FirstChangelogAppearsOnServerStart.
@Test
public void commitOneFileTwice_ChangedBeforeServerStart_FirstChangelogAppearsOnServerStart() throws Exception {
revManager.setup();
final DataFile f1 = dfManager.getDataFile("test/foo.txt");
f1.writeString("this is a test", "UTF-8", new ChangeSummary("test-user", "test for first write of file."));
List<DataFileEvent> events = listener.waitForEvents(1);
System.out.println("Got events:\n " + join(events, "\n "));
f1.writeString("this is another test", "UTF-8", new ChangeSummary("test-user", "test for second write of file."));
events = listener.waitForEvents(1);
System.out.println("Got events:\n " + join(events, "\n "));
List<ChangeSummary> changeLog = revManager.getDataChangeLog(f1.getPath(), 0, -1);
assertThat(changeLog, notNullValue());
assertThat(changeLog.size(), equalTo(0));
lcEvents.fireStarted();
changeLog = revManager.getDataChangeLog(f1.getPath(), 0, -1);
assertThat(changeLog, notNullValue());
assertThat(changeLog.size(), equalTo(1));
assertThat(changeLog.get(0).getSummary().contains(RevisionsManager.CATCHUP_CHANGELOG), equalTo(true));
}
use of org.commonjava.indy.audit.ChangeSummary 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")
@ApiResponse(code = 200, message = "JSON containing changelog entries", response = ChangeSummaryDTO.class)
@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) {
Response response;
try {
final List<ChangeSummary> listing = revisionsManager.getDataChangeLog(path, start, count);
response = formatOkResponseWithJsonEntity(new ChangeSummaryDTO(listing), objectMapper);
} catch (final GitSubsystemException e) {
logger.error("Failed to read git changelog from data dir: " + e.getMessage(), e);
response = formatResponse(e, "Failed to read git changelog from data dir.");
}
return response;
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class SetBackSettingsManager method deleteStoreSettings.
public boolean deleteStoreSettings(final ArtifactStore store) throws SetBackDataException {
if (!config.isEnabled()) {
throw new SetBackDataException("SetBack is disabled!");
}
final StoreKey key = store.getKey();
if (StoreType.hosted == key.getType()) {
return false;
}
final DataFile settingsXml = getSettingsXml(key);
if (settingsXml.exists()) {
try {
settingsXml.delete(new ChangeSummary(ChangeSummary.SYSTEM_USER, "SETBACK: Deleting generated SetBack settings.xml for: " + store));
} catch (final IOException e) {
throw new SetBackDataException("Failed to delete SetBack settings.xml for: %s.\n at: %s\n Reason: %s", e, store, settingsXml, e.getMessage());
}
return true;
}
return false;
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class SetBackSettingsManager method updateSettings.
private DataFile updateSettings(final ArtifactStore store, final List<ArtifactStore> allStores, final List<RemoteRepository> remotes) throws SetBackDataException {
if (!config.isEnabled()) {
throw new SetBackDataException("SetBack is disabled!");
}
final StoreKey key = store.getKey();
final DataFile settingsXml = getSettingsXml(key);
final Map<String, Object> params = new HashMap<String, Object>();
params.put("key", key);
params.put("store", store);
params.put("remotes", remotes);
params.put("allStores", allStores);
String rendered;
try {
rendered = templates.render(ApplicationContent.application_xml, TEMPLATE, params);
} catch (final IndyGroovyException e) {
throw new SetBackDataException("Failed to render template: %s for store: %s. Reason: %s", e, TEMPLATE, key, e.getMessage());
}
try {
settingsXml.getParent().mkdirs();
settingsXml.writeString(rendered, "UTF-8", new ChangeSummary(ChangeSummary.SYSTEM_USER, "SETBACK: Updating generated SetBack settings.xml for: " + key));
} catch (final IOException e) {
throw new SetBackDataException("Failed to write SetBack settings.xml for: %s\n to: %s\n Reason: %s", e, key, settingsXml, e.getMessage());
}
return settingsXml;
}
Aggregations