use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class AbstractSkimFunctionalTest method setupTestStores.
@Before
public void setupTestStores() throws Exception {
final String changelog = "Create test structures";
final String url = server.formatUrl(TEST_REPO);
final RemoteRepository testRepo = client.stores().create(new RemoteRepository(TEST_REPO, url), changelog, RemoteRepository.class);
Group g;
if (client.stores().exists(group, PUBLIC)) {
System.out.println("Loading pre-existing public group.");
g = client.stores().load(group, PUBLIC, Group.class);
} else {
System.out.println("Creating new group 'public'");
g = client.stores().create(new Group(PUBLIC), changelog, Group.class);
}
g.setConstituents(Collections.singletonList(testRepo.getKey()));
client.stores().update(g, changelog);
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class AutoProxDataManagerDecorator method getRemoteRepository.
private RemoteRepository getRemoteRepository(final StoreKey key, final StoreKey impliedBy) throws IndyDataException {
logger.debug("DECORATED (getRemoteRepository: {})", key);
RemoteRepository repo = (RemoteRepository) dataManager.getArtifactStore(key);
if (!catalog.isEnabled()) {
logger.debug("AutoProx decorator disabled; returning: {}", repo);
return repo;
}
logger.debug("AutoProx decorator active");
if (repo == null) {
logger.info("AutoProx: creating repository for: {}", key);
try {
repo = catalog.createRemoteRepository(key);
if (repo != null) {
if (!checkValidity(key)) {
return null;
}
final EventMetadata eventMetadata = new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, AutoProxConstants.STORE_ORIGIN).set(AutoProxConstants.ORIGINATING_STORE, impliedBy == null ? repo.getKey() : impliedBy);
dataManager.storeArtifactStore(repo, new ChangeSummary(ChangeSummary.SYSTEM_USER, "AUTOPROX: Creating remote repository for: '" + key + "'"), false, true, eventMetadata);
}
} catch (final AutoProxRuleException e) {
throw new IndyDataException("[AUTOPROX] Failed to create new remote repository from factory matching: '%s'. Reason: %s", e, key, e.getMessage());
}
}
return repo;
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class AutoProxDataManagerDecoratorTest method repositoryNotAutoCreatedWhenTargetIsInvalid.
@Test
public void repositoryNotAutoCreatedWhenTargetIsInvalid() throws Exception {
simpleCatalog();
final String testUrl = http.formatUrl("target", "test");
http.expect(testUrl, 404, "");
catalog.setEnabled(false);
assertThat(storeQuery.getRemoteRepository("test"), nullValue());
catalog.setEnabled(true);
final RemoteRepository repo = storeQuery.getRemoteRepository("test");
assertThat(repo, nullValue());
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class AutoProxDataManagerDecoratorTest method repositoryAutoCreated.
@Test
public void repositoryAutoCreated() throws Exception {
simpleCatalog();
final String testUrl = http.formatUrl("target", "test");
System.out.println("Registering expectation of GET/HEAD to: " + testUrl + "/ with 200 response code.");
http.expect(testUrl + "/", 200, "");
catalog.setEnabled(false);
assertThat(storeQuery.getRemoteRepository("test"), nullValue());
catalog.setEnabled(true);
final RemoteRepository repo = storeQuery.getRemoteRepository("test");
assertThat(repo, notNullValue());
assertThat(repo.getName(), equalTo("test"));
assertThat(repo.getUrl(), equalTo(testUrl));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class AutoProxDataManagerDecoratorTest method repositoryCreatedFromScannedDataDirRules.
@Test
public void repositoryCreatedFromScannedDataDirRules() throws Exception {
final URL u = Thread.currentThread().getContextClassLoader().getResource("data/autoprox/simple-factory.groovy");
final File f = new File(u.getPath());
final File scriptFile = new File(autoproxDataDir, f.getName());
FileUtils.copyFile(f, scriptFile);
System.out.println("Parsing rules for: " + name.getMethodName());
catalog.parseRules();
final String testUrl = http.formatUrl("target", "test");
logger.info("\n\nSETTING UP / VERIFYING REMOTE SERVER EXPECTATIONS");
http.expect(testUrl + "/", 200, "");
logger.info("DONE: SETTING UP / VERIFYING REMOTE SERVER EXPECTATIONS\n\n");
catalog.setEnabled(false);
assertThat(storeQuery.getRemoteRepository("test"), nullValue());
catalog.setEnabled(true);
final RemoteRepository repo = storeQuery.getRemoteRepository("test");
assertThat(repo, notNullValue());
assertThat(repo.getName(), equalTo("test"));
assertThat(repo.getUrl(), equalTo(testUrl));
}
Aggregations