use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class KojiContentManagerDecorator method getTransfer.
@Override
public Transfer getTransfer(final ArtifactStore store, final String path, final TransferOperation operation) throws IndyWorkflowException {
Logger logger = LoggerFactory.getLogger(getClass());
logger.debug("KOJI: Delegating initial getTransfer() attempt for: {}/{}", store.getKey(), path);
Transfer result = delegate.getTransfer(store, path, operation);
if (result == null && kojiUtils.isVersionSignatureAllowedWithPath(path) && TransferOperation.DOWNLOAD == operation && StoreType.group == store.getKey().getType()) {
logger.info("KOJI: Checking for Koji build matching: {}", path);
Group group = (Group) store;
RemoteRepository kojiProxy = findKojiBuildAnd(store, path, new EventMetadata(), null, this::createRemoteRepository);
if (kojiProxy != null) {
adjustTargetGroup(kojiProxy, group);
EventMetadata eventMetadata = new EventMetadata().set(ContentManager.ENTRY_POINT_STORE, store.getKey());
result = delegate.retrieve(kojiProxy, path, eventMetadata);
}
if (result != null && result.exists()) {
nfc.clearMissing(new ConcreteResource(LocationUtils.toLocation(store), path));
}
}
// Finally, pass the Transfer back.
return result;
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class ReuseExistingRepoIntoConfiguredGroupTest method skimPomForExistingRepoAndAddItInGroup.
@Test
public void skimPomForExistingRepoAndAddItInGroup() throws Exception {
RemoteRepository repo = new RemoteRepository(REPO, server.formatUrl(REPO));
repo.setAllowReleases(Boolean.TRUE);
repo.setAllowSnapshots(Boolean.FALSE);
repo = client.stores().create(repo, "Pre stored remote repo", RemoteRepository.class);
final StoreKey remoteRepoKey = repo.getKey();
final PomRef ref = loadPom("one-repo", Collections.singletonMap("one-repo.url", server.formatUrl(REPO)));
server.expect("HEAD", server.formatUrl(REPO, "/"), 200, (String) null);
server.expect(server.formatUrl(TEST_REPO, ref.path), 200, ref.pom);
final StoreKey pubGroupKey = new StoreKey(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, StoreType.group, PUBLIC);
Group g = client.stores().load(pubGroupKey, Group.class);
assertThat("Group membership should not contain implied before getting pom.", g.getConstituents().contains(remoteRepoKey), equalTo(false));
logger.debug("Start fetching pom!");
final InputStream stream = client.content().get(pubGroupKey, ref.path);
final String downloaded = IOUtils.toString(stream);
IOUtils.closeQuietly(stream);
System.out.println("Waiting 5s for events to run.");
Thread.sleep(5000);
g = client.stores().load(pubGroupKey, Group.class);
assertThat("Group membership does not contain implied repository", g.getConstituents().contains(remoteRepoKey), equalTo(true));
repo = client.stores().load(new StoreKey(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, StoreType.remote, TEST_REPO), RemoteRepository.class);
String metadata = repo.getMetadata(ImpliedRepoMetadataManager.IMPLIED_STORES);
assertThat("Reference to repositories implied by POMs in this repo is missing from metadata.", metadata.contains("remote:" + REPO), equalTo(true));
repo = client.stores().load(remoteRepoKey, RemoteRepository.class);
metadata = repo.getMetadata(ImpliedRepoMetadataManager.IMPLIED_BY_STORES);
assertThat("Backref to repo with pom that implies this repo is missing from metadata.", metadata.contains("remote:" + TEST_REPO), equalTo(true));
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class ImpliedReposQueryDelegate method getGroupsContaining.
@Override
public Set<Group> getGroupsContaining(StoreKey key) throws IndyDataException {
ArtifactStore store = dataManager.getArtifactStore(key);
if (store != null) {
boolean storeIsImplied = IMPLIED_REPO_ORIGIN.equals(store.getMetadata(METADATA_ORIGIN));
Set<Group> delegateGroups = delegate().getGroupsContaining(key);
if (!storeIsImplied || delegateGroups == null || delegateGroups.isEmpty()) {
return delegateGroups;
}
return delegateGroups.stream().filter((group) -> config.isEnabledForGroup(group.getName())).collect(Collectors.toSet());
}
return delegate().getGroupsContaining(key);
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class KojiRemoteContenIndexingRescanManager method indexPostRescan.
public void indexPostRescan(@Observes final ArtifactStorePostRescanEvent e) throws IndyWorkflowException {
Collection<ArtifactStore> repos = e.getStores();
for (ArtifactStore repo : repos) {
if (repo.getType() == StoreType.remote && repo.getName().startsWith(KOJI_ORIGIN)) {
LOGGER.trace("Rebuild content index for koji remote: {}", repo.getKey());
final RemoteRepository kojiRemote = (RemoteRepository) repo;
try {
Set<Group> affected = storeDataManager.query().getGroupsAffectedBy(kojiRemote.getKey());
Set<StoreKey> affetctedGroupKeys = affected.stream().map(g -> g.getKey()).collect(Collectors.toSet());
StoreKey[] gKeys = affetctedGroupKeys.toArray(new StoreKey[affetctedGroupKeys.size()]);
kojiRemote.getPathMaskPatterns().forEach(path -> contentIndexManager.indexPathInStores(path, kojiRemote.getKey(), gKeys));
} catch (IndyDataException ex) {
LOGGER.error(String.format("Can not get the affected groups for hosted repo %s due to %s", kojiRemote.getKey(), ex.getMessage()), ex);
}
}
}
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class AbstractMaintFunctionalTest method setupTestStores.
@Before
public void setupTestStores() throws Exception {
setupChangelog = "Create test structures";
final StoreKey groupKey = new StoreKey(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, group, PUBLIC);
if (client.stores().exists(groupKey)) {
System.out.println("Loading pre-existing public group.");
pubGroup = client.stores().load(groupKey, Group.class);
} else {
System.out.println("Creating new group 'public'");
pubGroup = client.stores().create(new Group(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, PUBLIC), setupChangelog, Group.class);
}
}
Aggregations