use of org.commonjava.indy.model.core.ArtifactStore in project indy by Commonjava.
the class RelateGenerationManager method generateRelationshipFile.
/**
* Generate relationship file for pom transfer.
* @param transfer
* @param op
* @return transfer pointing to the generated rel file.
*/
public Transfer generateRelationshipFile(Transfer transfer, TransferOperation op) {
final Logger logger = LoggerFactory.getLogger(getClass());
logger.debug("Relate generation for {}", transfer);
if (transfer == null) {
logger.debug("No transfer. No .rel generation performed.");
return null;
}
String txfrPath = transfer.getPath();
if (!txfrPath.endsWith(".pom")) {
logger.debug("This is not a pom transfer.");
return null;
}
ArtifactPathInfo artPathInfo = ArtifactPathInfo.parse(txfrPath);
if (artPathInfo == null) {
logger.debug("Not an artifact download ({}). No .rel generation performed.", txfrPath);
return null;
}
ConcreteResource pomResource = transfer.getResource();
StoreKey storeKey = StoreKey.fromString(transfer.getLocation().getName());
ArtifactStore store;
try {
store = storeManager.getArtifactStore(storeKey);
} catch (final IndyDataException ex) {
logger.error("Error retrieving artifactStore with key " + storeKey, ex);
return null;
}
logger.debug("Generate .rel corresponding to associated POM download: {}/{}", storeKey, pomResource.getPath());
try {
URI source = new URI(pomResource.getLocation().getUri() + REL_SUFFIX);
ProjectVersionRef ref = artPathInfo.getProjectId();
// get all groups that this store is a member of
Set<ArtifactStore> stores = new HashSet<>();
stores.add(store);
stores.addAll(storeManager.query().getGroupsContaining(store.getKey()));
List<? extends Location> supplementalLocations = LocationUtils.toLocations(stores.toArray(new ArtifactStore[0]));
MavenPomView pomView = mavenPomReader.read(ref, transfer, supplementalLocations, ALL_PROFILES);
EProjectDirectRelationships rel = mavenModelProcessor.readRelationships(pomView, source, new ModelProcessorConfig());
Transfer transferRel = transfer.getSiblingMeta(REL_SUFFIX);
writeRelationships(rel, transferRel, op);
return transferRel;
} catch (Exception e) {
logger.error("Error generating .rel file for " + txfrPath + " from store " + store, e);
return null;
}
}
use of org.commonjava.indy.model.core.ArtifactStore in project indy by Commonjava.
the class RepositoryDataManagerTCK method createAndDeleteCentralRepoProxy.
@Test
public void createAndDeleteCentralRepoProxy() throws Exception {
final StoreDataManager manager = getFixtureProvider().getDataManager();
final RemoteRepository repo = new RemoteRepository("central", "http://repo1.maven.apache.org/maven2/");
storeRemoteRepository(repo, false);
manager.deleteArtifactStore(repo.getKey(), summary, new EventMetadata());
final ArtifactStore result = manager.query().packageType(MAVEN_PKG_KEY).storeType(RemoteRepository.class).getByName(repo.getName());
assertThat(result, nullValue());
}
use of org.commonjava.indy.model.core.ArtifactStore in project indy by Commonjava.
the class GroupDataManagerTCK method createGroupAndRetrieveRepositoryConstituents.
@Test
public void createGroupAndRetrieveRepositoryConstituents() throws Exception {
final StoreDataManager manager = getFixtureProvider().getDataManager();
final Group grp = new Group("test", new StoreKey(StoreType.remote, "central"), new StoreKey(StoreType.remote, "repo2"));
store(grp);
final List<ArtifactStore> result = manager.query().packageType(MAVEN_PKG_KEY).getOrderedConcreteStoresInGroup(grp.getName());
assertThat(result, notNullValue());
assertThat(result.size(), equalTo(2));
ArtifactStore repo = result.get(0);
assertThat(repo, notNullValue());
assertThat(repo.getName(), equalTo("central"));
repo = result.get(1);
assertThat(repo, notNullValue());
assertThat(repo.getName(), equalTo("repo2"));
}
use of org.commonjava.indy.model.core.ArtifactStore in project indy by Commonjava.
the class GroupDataManagerTCK method createGroupAndRetrieveReposForThatGroupInOrder.
@Test
public void createGroupAndRetrieveReposForThatGroupInOrder() throws Exception {
final StoreDataManager manager = getFixtureProvider().getDataManager();
final Group grp = new Group("test", new StoreKey(StoreType.remote, "repo2"), new StoreKey(StoreType.remote, "central"));
store(grp);
final List<ArtifactStore> repos = manager.query().packageType(MAVEN_PKG_KEY).getOrderedConcreteStoresInGroup(grp.getName());
assertThat(repos, notNullValue());
assertThat(repos.size(), equalTo(2));
assertThat(repos.get(0).getName(), equalTo("repo2"));
assertThat(repos.get(1).getName(), equalTo("central"));
}
use of org.commonjava.indy.model.core.ArtifactStore in project indy by Commonjava.
the class IndexingContentManagerDecorator method getTransfer.
@Override
public Transfer getTransfer(final StoreKey storeKey, final String path, final TransferOperation op) throws IndyWorkflowException {
Logger logger = LoggerFactory.getLogger(getClass());
Transfer transfer = getIndexedTransfer(storeKey, null, path, TransferOperation.DOWNLOAD);
if (transfer != null) {
logger.debug("Returning indexed transfer: {}", transfer);
return transfer;
}
ArtifactStore store;
try {
store = storeDataManager.getArtifactStore(storeKey);
} catch (IndyDataException e) {
throw new IndyWorkflowException("Failed to lookup ArtifactStore: %s for NFC handling. Reason: %s", e, storeKey, e.getMessage());
}
ConcreteResource resource = new ConcreteResource(LocationUtils.toLocation(store), path);
StoreType type = storeKey.getType();
if (StoreType.group == type) {
Group g = (Group) store;
if (g == null) {
throw new IndyWorkflowException("Cannot find requested group: %s", storeKey);
}
if (nfc.isMissing(resource)) {
logger.debug("NFC / MISSING: {}", resource);
return null;
}
logger.debug("No group index hits. Devolving to member store indexes.");
for (StoreKey key : g.getConstituents()) {
transfer = getIndexedMemberTransfer((Group) store, path, op, (member) -> {
try {
return delegate.getTransfer(member, path, op);
} catch (IndyWorkflowException e) {
logger.error(String.format("Failed to getTransfer() for member path: %s:%s with operation: %s. Reason: %s", member.getKey(), path, op, e.getMessage()), e);
}
return null;
});
if (transfer != null) {
logger.debug("Returning indexed transfer: {} from member: {}", transfer, key);
return transfer;
}
}
}
transfer = delegate.getTransfer(storeKey, path, op);
if (transfer != null) {
logger.debug("Indexing transfer: {}", transfer);
indexManager.indexTransferIn(transfer, storeKey);
}
return transfer;
}
Aggregations