use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class MavenMetadataMergerTest method mergeOneTransferWithProviderError.
@Test
public void mergeOneTransferWithProviderError() throws Exception {
String path = "org/foo/bar/maven-metadata.xml";
HostedRepository h1 = new HostedRepository("test-hosted-1");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "simple-1.xml");
Group g = new Group("test-group", h1.getKey());
List<Transfer> sources = Arrays.asList(t1);
TestMavenMetadataProvider testProvider = new TestMavenMetadataProvider(new IndyWorkflowException("Failed to get provider content"));
byte[] output = new MavenMetadataMerger(Collections.singletonList(testProvider)).merge(sources, g, path);
Metadata merged = new MetadataXpp3Reader().read(new ByteArrayInputStream(output));
assertThat(merged.getGroupId(), equalTo("org.foo"));
assertThat(merged.getArtifactId(), equalTo("bar"));
Versioning versioning = merged.getVersioning();
assertThat(versioning, notNullValue());
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(1));
assertThat(versioning.getRelease(), equalTo("1.0"));
assertThat(versioning.getLatest(), equalTo("1.0"));
int idx = 0;
assertThat(versions.get(idx), equalTo("1.0"));
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class AutoProxDataManagerDecorator method getGroup.
private Group getGroup(final StoreKey key, final StoreKey impliedBy) throws IndyDataException {
logger.debug("DECORATED (getGroup: {})", key);
Group g = (Group) dataManager.getArtifactStore(key);
if (!catalog.isEnabled()) {
logger.debug("AutoProx decorator disabled; returning: {}", g);
return g;
}
logger.debug("AutoProx decorator active");
if (g == null) {
logger.debug("AutoProx: creating repository for: {}", key);
if (!checkValidity(key)) {
return null;
}
try {
g = catalog.createGroup(key);
} catch (final AutoProxRuleException e) {
throw new IndyDataException("[AUTOPROX] Failed to create new group from factory matching: '%s'. Reason: %s", e, key, e.getMessage());
}
if (g != null) {
logger.info("Validating group: {}", g);
for (final StoreKey memberKey : new ArrayList<>(g.getConstituents())) {
final ArtifactStore store = getArtifactStore(memberKey, impliedBy == null ? g.getKey() : impliedBy);
if (store == null) {
g.removeConstituent(memberKey);
}
}
if (g.getConstituents().isEmpty()) {
return null;
}
final EventMetadata eventMetadata = new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, AutoProxConstants.STORE_ORIGIN).set(AutoProxConstants.ORIGINATING_STORE, impliedBy == null ? g.getKey() : impliedBy);
dataManager.storeArtifactStore(g, new ChangeSummary(ChangeSummary.SYSTEM_USER, "AUTOPROX: Creating group for: '" + key + "'"), false, true, eventMetadata);
}
}
return g;
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class TestAutoProxFactory method createGroup.
@Override
public Group createGroup(final StoreKey key) {
final List<StoreKey> constituents = new ArrayList<StoreKey>();
constituents.add(new StoreKey(key.getPackageType(), StoreType.hosted, key.getName()));
constituents.add(new StoreKey(key.getPackageType(), StoreType.remote, key.getName()));
constituents.add(new StoreKey(key.getPackageType(), StoreType.remote, "first"));
constituents.add(new StoreKey(key.getPackageType(), StoreType.remote, "second"));
return new Group(key.getPackageType(), key.getName(), constituents);
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class AutoProxCatalogManager method createGroup.
public Group createGroup(final StoreKey key) throws AutoProxRuleException {
if (!checkEnabled()) {
throw new AutoProxRuleException("AutoProx is disabled");
}
final AutoProxRule rule = getRuleMatching(key);
try {
if (rule != null) {
Group group = rule.createGroup(key);
group.setMetadata(ArtifactStore.METADATA_ORIGIN, AUTOPROX_ORIGIN);
return group;
}
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.Group in project indy by Commonjava.
the class AutoProxDataManagerDecoratorTest method groupNotAutoCreatedWhenTargetIsInvalid.
@Test
public void groupNotAutoCreatedWhenTargetIsInvalid() throws Exception {
simpleCatalog();
final String testUrl = http.formatUrl("target", "test");
http.expect(testUrl, 404, "");
catalog.setEnabled(false);
assertThat(storeQuery.getGroup("test"), nullValue());
catalog.setEnabled(true);
final Group group = storeQuery.getGroup("test");
assertThat(group, nullValue());
}
Aggregations