use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class ContentIndexManager method clearIndexedPathFrom.
/**
* <b>NOT Recursive</b>. This assumes you've recursed the group membership structure beforehand, using
* {@link StoreDataManager#getGroupsAffectedBy(Collection)} to find the set of {@link Group} instances for which
* the path should be cleared.
*/
public void clearIndexedPathFrom(String path, Set<Group> groups, Consumer<IndexedStorePath> pathConsumer) {
if (groups == null || groups.isEmpty()) {
return;
}
Logger logger = LoggerFactory.getLogger(getClass());
// logger.debug( "Clearing path: '{}' from content index and storage of: {}", path, groups );
groups.forEach((group) -> {
logger.debug("Clearing path: '{}' from content index and storage of: {}", path, group.getName());
// if we remove an indexed path, it SHOULD mean there was content. If not, we should delete the NFC entry.
if (!removeIndexedStorePath(path, group.getKey(), pathConsumer)) {
ConcreteResource resource = new ConcreteResource(LocationUtils.toLocation(group), path);
nfc.clearMissing(resource);
}
});
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class IndexingContentManagerDecorator method store.
// @Override
// public Transfer store( final List<? extends ArtifactStore> stores, final String path, final InputStream stream, final TransferOperation op )
// throws IndyWorkflowException
// {
// return store( stores, path, stream, op, new EventMetadata() );
// }
@Override
public Transfer store(final List<? extends ArtifactStore> stores, final StoreKey topKey, final String path, final InputStream stream, final TransferOperation op, final EventMetadata eventMetadata) throws IndyWorkflowException {
Transfer transfer = delegate.store(stores, topKey, path, stream, op, eventMetadata);
if (transfer != null) {
indexManager.indexTransferIn(transfer, topKey);
try {
ArtifactStore topStore = storeDataManager.getArtifactStore(topKey);
nfc.clearMissing(new ConcreteResource(LocationUtils.toLocation(topStore), path));
} catch (IndyDataException e) {
Logger logger = LoggerFactory.getLogger(getClass());
logger.error(String.format("Failed to retrieve top store: %s for NFC management. Reason: %s", topKey, e.getMessage()), e);
}
}
return transfer;
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class IndexingContentManagerDecorator method retrieve.
@Override
public Transfer retrieve(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
Logger logger = LoggerFactory.getLogger(getClass());
logger.trace("Looking for indexed path: {} in: {}", path, store.getKey());
Transfer transfer = getIndexedTransfer(store.getKey(), null, path, TransferOperation.DOWNLOAD);
if (transfer != null) {
logger.debug("Found indexed transfer: {}. Returning.", transfer);
return transfer;
}
StoreType type = store.getKey().getType();
if (StoreType.group == type) {
ConcreteResource resource = new ConcreteResource(LocationUtils.toLocation(store), path);
if (nfc.isMissing(resource)) {
logger.debug("{} is marked as missing. Returning null.", resource);
return null;
}
logger.debug("No group index hits. Devolving to member store indexes.");
KeyedLocation location = LocationUtils.toLocation(store);
SpecialPathInfo specialPathInfo = specialPathManager.getSpecialPathInfo(location, path, store.getPackageType());
if (specialPathInfo == null || !specialPathInfo.isMergable()) {
transfer = getIndexedMemberTransfer((Group) store, path, TransferOperation.DOWNLOAD, (member) -> {
try {
return delegate.retrieve(member, path);
} catch (IndyWorkflowException e) {
logger.error(String.format("Failed to retrieve() for member path: %s:%s. Reason: %s", member.getKey(), path, e.getMessage()), e);
}
return null;
});
if (transfer != null) {
nfc.clearMissing(resource);
return transfer;
}
logger.debug("No index hits. Delegating to main content manager for: {} in: {}", path, store);
} else {
logger.debug("Merged content. Delegating to main content manager for: {} in: {}", path, store);
transfer = delegate.retrieve(store, path, eventMetadata);
if (transfer == null) {
nfc.addMissing(resource);
}
return transfer;
}
}
transfer = delegate.retrieve(store, path, eventMetadata);
if (transfer != null) {
logger.debug("Got transfer from delegate: {} (will index)", transfer);
indexManager.indexTransferIn(transfer, store.getKey());
}
logger.debug("Returning transfer: {}", transfer);
return transfer;
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class MavenMetadataGeneratorTest method generateFileContent_VersionsMetadataWith2Versions.
@Test
public void generateFileContent_VersionsMetadataWith2Versions() throws Exception {
final StoreResource resource = setupVersionsStructureWith2Versions();
final ConcreteResource metadataFile = resource.getChild("maven-metadata.xml");
final Transfer transfer = generator.generateFileContent(stores.getArtifactStore(resource.getStoreKey()), metadataFile.getPath(), new EventMetadata());
assertThat(transfer, notNullValue());
final MavenMetadataView metadata = metadataReader.readMetadata(new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT"), Collections.singletonList(transfer), new EventMetadata());
assertThat(metadata, notNullValue());
final VersioningView versioning = metadata.getVersioning();
final List<SingleVersion> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.get(0).renderStandard(), equalTo("1.0"));
assertThat(versions.get(1).renderStandard(), equalTo("1.1"));
assertThat(versioning.getReleaseVersion().renderStandard(), equalTo("1.1"));
assertThat(versioning.getLatestVersion().renderStandard(), equalTo("1.1"));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class MavenMetadataGeneratorTest method setupVersionsStructureWith2Versions.
private StoreResource setupVersionsStructureWith2Versions() throws Exception {
final RemoteRepository store = new RemoteRepository(MAVEN_PKG_KEY, "testrepo", "http://foo.bar");
stores.storeArtifactStore(store, summary, false, true, new EventMetadata());
final String path = "org/group/artifact";
final KeyedLocation location = LocationUtils.toLocation(store);
final StoreResource resource = new StoreResource(location, path);
fixture.getTransport().registerListing(resource, new TestListing(new ListingResult(resource, new String[] { "1.0/", "1.1/" })));
ConcreteResource versionDir = (resource.getChild("1.0/"));
fixture.getTransport().registerListing(versionDir, new TestListing(new ListingResult(versionDir, new String[] { "artifact-1.0.jar", "artifact-1.0.pom" })));
versionDir = (resource.getChild("1.1/"));
fixture.getTransport().registerListing(versionDir, new TestListing(new ListingResult(versionDir, new String[] { "artifact-1.1.jar", "artifact-1.1.pom" })));
return resource;
}
Aggregations