use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class IndyPromoteClientModule method promoteByPath.
public PathsPromoteResult promoteByPath(final StoreType srcType, final String srcName, final StoreType targetType, final String targetName, final boolean purgeSource, final String... paths) throws IndyClientException {
final PathsPromoteRequest req = new PathsPromoteRequest(new StoreKey(srcType, srcName), new StoreKey(targetType, targetName), new HashSet<String>(Arrays.asList(paths))).setPurgeSource(purgeSource);
final PathsPromoteResult result = http.postWithResponse(PATHS_PROMOTE_PATH, req, PathsPromoteResult.class, HttpStatus.SC_OK);
return result;
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class IndyPromoteClientModule method promoteToGroup.
public GroupPromoteResult promoteToGroup(final StoreType srcType, final String srcName, final String targetGroup) throws IndyClientException {
final GroupPromoteRequest req = new GroupPromoteRequest(new StoreKey(srcType, srcName), targetGroup);
final GroupPromoteResult result = http.postWithResponse(GROUP_PROMOTE_PATH, req, GroupPromoteResult.class, HttpStatus.SC_OK);
return result;
}
use of org.commonjava.indy.model.core.StoreKey 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.StoreKey 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.StoreKey in project indy by Commonjava.
the class AutoProxDataManagerDecoratorTest method groupAutoCreatedWithDeployPointAndTwoRepos.
@Test
public void groupAutoCreatedWithDeployPointAndTwoRepos() throws Exception {
simpleCatalog();
final String testUrl = http.formatUrl("target", "test");
http.expect(testUrl + "/", 200, "");
http.expect(http.formatUrl("target", "first/"), 200, "");
http.expect(http.formatUrl("target", "second/"), 200, "");
catalog.setEnabled(false);
assertThat(storeQuery.getGroup("test"), nullValue());
catalog.setEnabled(true);
final Group group = storeQuery.getGroup("test");
assertThat(group, notNullValue());
assertThat(group.getName(), equalTo("test"));
final List<StoreKey> constituents = group.getConstituents();
logger.info("Group constituents: {}", constituents);
assertThat(constituents, notNullValue());
assertThat(constituents.size(), equalTo(4));
int idx = 0;
StoreKey key = constituents.get(idx);
assertThat(key.getType(), equalTo(StoreType.hosted));
assertThat(key.getName(), equalTo("test"));
idx++;
key = constituents.get(idx);
assertThat(key.getType(), equalTo(StoreType.remote));
assertThat(key.getName(), equalTo("test"));
idx++;
key = constituents.get(idx);
assertThat(key.getType(), equalTo(StoreType.remote));
assertThat(key.getName(), equalTo("first"));
idx++;
key = constituents.get(idx);
assertThat(key.getType(), equalTo(StoreType.remote));
assertThat(key.getName(), equalTo("second"));
}
Aggregations