use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AbstractFoloUrlsTest method before.
@Before
public void before() throws Exception {
content = client.module(IndyFoloContentClientModule.class);
admin = client.module(IndyFoloAdminClientModule.class);
if (!createStandardTestStructures()) {
return;
}
final String changelog = "Create test structures";
final HostedRepository hosted = this.client.stores().create(new HostedRepository(STORE), changelog, HostedRepository.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(hosted.getKey()));
client.stores().update(g, changelog);
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AbstractFoloContentManagementTest method before.
@Before
public void before() throws Exception {
final String changelog = "Setup: " + name.getMethodName();
final HostedRepository hosted = this.client.stores().create(new HostedRepository(STORE), changelog, HostedRepository.class);
RemoteRepository central = null;
if (client.stores().exists(remote, CENTRAL)) {
client.stores().delete(remote, CENTRAL, "removing existing remote:central definition");
}
central = client.stores().create(new RemoteRepository(CENTRAL, centralServer.getBaseUri()), changelog, RemoteRepository.class);
Group g;
if (client.stores().exists(group, PUBLIC)) {
g = client.stores().load(group, PUBLIC, Group.class);
} else {
g = client.stores().create(new Group(PUBLIC), changelog, Group.class);
}
g.setConstituents(Arrays.asList(hosted.getKey(), central.getKey()));
client.stores().update(g, changelog);
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AbstractTrackingReportTest method before.
@Before
public void before() throws Exception {
if (!createStandardStores()) {
return;
}
final String changelog = "Setup " + name.getMethodName();
final HostedRepository hosted = this.client.stores().create(new HostedRepository(STORE), changelog, HostedRepository.class);
RemoteRepository central = null;
if (!client.stores().exists(remote, CENTRAL)) {
central = client.stores().create(new RemoteRepository(CENTRAL, "http://repo.maven.apache.org/maven2/"), changelog, RemoteRepository.class);
} else {
central = client.stores().load(remote, CENTRAL, RemoteRepository.class);
}
Group g;
if (client.stores().exists(group, PUBLIC)) {
g = client.stores().load(group, PUBLIC, Group.class);
} else {
g = client.stores().create(new Group(PUBLIC), changelog, Group.class);
}
g.setConstituents(Arrays.asList(hosted.getKey(), central.getKey()));
client.stores().update(g, changelog);
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AutoProxCatalogManager method createHostedRepository.
public HostedRepository createHostedRepository(final StoreKey key) throws AutoProxRuleException {
if (!checkEnabled()) {
throw new AutoProxRuleException("AutoProx is disabled");
}
final AutoProxRule rule = getRuleMatching(key);
try {
if (rule != null) {
HostedRepository repo = rule.createHostedRepository(key);
repo.setMetadata(ArtifactStore.METADATA_ORIGIN, AUTOPROX_ORIGIN);
return repo;
}
return null;
} catch (final Exception e) {
throw new AutoProxRuleException("Failed to create remote repository for: %s. Reason: %s", e, key, e.getMessage());
}
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AutoProxDataManagerDecorator method getHostedRepository.
private HostedRepository getHostedRepository(final StoreKey key, final StoreKey impliedBy) throws IndyDataException {
HostedRepository repo = (HostedRepository) 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.createHostedRepository(key);
} catch (final AutoProxRuleException e) {
throw new IndyDataException("[AUTOPROX] Failed to create new hosted repository from factory matching: '%s'. Reason: %s", e, key, e.getMessage());
}
if (repo != null) {
final ChangeSummary changeSummary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "AUTOPROX: Creating hosted repository for: '" + key + "'");
final EventMetadata eventMetadata = new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, AutoProxConstants.STORE_ORIGIN).set(AutoProxConstants.ORIGINATING_STORE, impliedBy == null ? repo.getKey() : impliedBy);
dataManager.storeArtifactStore(repo, changeSummary, false, true, eventMetadata);
}
}
return repo;
}
Aggregations