use of org.commonjava.indy.model.core.StoreKey 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;
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class SetBackSettingsManagerTest method settingsForGroup_SingleMemberRemote.
@Test
public void settingsForGroup_SingleMemberRemote() throws Exception {
final RemoteRepository remote = new RemoteRepository(MAVEN_PKG_KEY, "test", "http://foo.bar/");
remote.setDescription("Test Repository");
store(remote);
final StoreKey remoteKey = remote.getKey();
final Group group = new Group(MAVEN_PKG_KEY, "test-group", remoteKey);
store(group);
assertThat(readSettings(group.getKey(), false), equalTo(null));
final List<String> lines = generateSettings(group.getKey());
assertThat("No repository with id: " + remote.getName() + " found in settings.xml for remote!", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class SetBackSettingsManagerTest method settingsForSingleRemoteRepository_NoGroups.
@Test
public void settingsForSingleRemoteRepository_NoGroups() throws Exception {
final RemoteRepository remote = new RemoteRepository(MAVEN_PKG_KEY, "test", "http://foo.bar/");
remote.setDescription("Test Repository");
store(remote);
final StoreKey key = remote.getKey();
final List<String> lines = generateSettings(key);
assertThat("No repository with id: " + remote.getName() + " found in settings.xml", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class SetBackSettingsManagerTest method settingsForSingleRemoteRepository_GenerateDeleteAndProveNonExistent.
@Test
public void settingsForSingleRemoteRepository_GenerateDeleteAndProveNonExistent() throws Exception {
final RemoteRepository remote = new RemoteRepository(MAVEN_PKG_KEY, "test", "http://foo.bar/");
remote.setDescription("Test Repository");
store(remote);
final StoreKey key = remote.getKey();
final List<String> lines = generateSettings(key);
assertThat("No repository with id: " + remote.getName() + " found in settings.xml", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
final ArtifactStore store = storeManager.getArtifactStore(key);
manager.deleteStoreSettings(store);
assertThat("Settings.xml for: " + key + " should have been deleted!", manager.getSetBackSettings(key), nullValue());
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class SetBackSettingsManagerTest method settingsForSingleRemoteRepository_GenerateSpawnsGroupGeneration.
@Test
public void settingsForSingleRemoteRepository_GenerateSpawnsGroupGeneration() throws Exception {
final RemoteRepository remote = new RemoteRepository(MAVEN_PKG_KEY, "test", "http://foo.bar/");
remote.setDescription("Test Repository");
store(remote);
final StoreKey key = remote.getKey();
final Group group = new Group(MAVEN_PKG_KEY, "test-group", key);
store(group);
assertThat(readSettings(group.getKey(), false), equalTo(null));
List<String> lines = generateSettings(key);
assertThat("No repository with id: " + remote.getName() + " found in settings.xml for remote!", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
lines = readSettings(group.getKey(), true);
assertThat("No repository with id: " + remote.getName() + " found in settings.xml for group!", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
}
Aggregations