use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class ScheduleManager method setProxyTimeouts.
public synchronized void setProxyTimeouts(final StoreKey key, final String path) throws IndySchedulerException {
if (!schedulerConfig.isEnabled()) {
logger.debug("Scheduler disabled.");
return;
}
RemoteRepository repo = null;
try {
repo = (RemoteRepository) dataManager.getArtifactStore(key);
} catch (final IndyDataException e) {
logger.error(String.format("Failed to retrieve store for: %s. Reason: %s", key, e.getMessage()), e);
}
if (repo == null) {
return;
}
int timeout = config.getPassthroughTimeoutSeconds();
final ConcreteResource resource = new ConcreteResource(LocationUtils.toLocation(repo), path);
final SpecialPathInfo info = specialPathManager.getSpecialPathInfo(resource);
if (!repo.isPassthrough()) {
if ((info != null && info.isMetadata()) && repo.getMetadataTimeoutSeconds() > 0) {
logger.debug("Using metadata timeout for: {}", resource);
timeout = repo.getMetadataTimeoutSeconds();
} else {
if (info == null) {
logger.debug("No special path info for: {}", resource);
} else {
logger.debug("{} is a special path, but not metadata.", resource);
}
timeout = repo.getCacheTimeoutSeconds();
}
}
if (timeout > 0) {
// logger.info( "[PROXY TIMEOUT SET] {}/{}; {}", repo.getKey(), path, new Date( System.currentTimeMillis()
// + timeout ) );
cancel(new StoreKeyMatcher(key, CONTENT_JOB_TYPE), path);
scheduleContentExpiration(key, path, timeout);
}
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class FoloPomDownloadListener method onFileUpload.
public void onFileUpload(@Observes final FileStorageEvent event) {
// check for a TransferOperation of DOWNLOAD
final TransferOperation op = event.getType();
if (op != TransferOperation.DOWNLOAD) {
logger.trace("Not a download transfer operation. No pom existence check performed.");
return;
}
// check if it is a path that doesn't end in with ".pom"
final Transfer transfer = event.getTransfer();
if (transfer == null) {
logger.trace("No transfer. No pom existence check performed.");
return;
}
String txfrPath = transfer.getPath();
if (txfrPath.endsWith(".pom")) {
logger.trace("This is a pom download.");
return;
}
// use ArtifactPathInfo to parse into a GAV, just to verify that it's looking at an artifact download
ArtifactPathInfo artPathInfo = ArtifactPathInfo.parse(txfrPath);
if (artPathInfo == null) {
logger.trace("Not an artifact download ({}). No pom existence check performed.", txfrPath);
return;
}
// verify that the associated .pom file exists
String pomFilename = String.format("%s-%s.pom", artPathInfo.getArtifactId(), artPathInfo.getVersion());
ConcreteResource pomResource = transfer.getResource().getParent().getChild(pomFilename);
if (cacheProvider.exists(pomResource)) {
logger.trace("Pom {} already exists.", cacheProvider.getFilePath(pomResource));
return;
}
// trigger pom download by requesting it from the same repository as the original artifact
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;
}
try {
logger.debug("Downloading POM as automatic response to associated artifact download: {}/{}", storeKey, pomResource.getPath());
contentManager.retrieve(store, pomResource.getPath(), event.getEventMetadata());
} catch (final IndyWorkflowException ex) {
logger.error("Error while retrieving pom artifact " + pomResource.getPath() + " from store " + store, ex);
return;
}
}
use of org.commonjava.maven.galley.model.ConcreteResource 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.info("KOJI: Delegating initial getTransfer() attempt for: {}/{}", store.getKey(), path);
Transfer result = delegate.getTransfer(store, path, operation);
if (result == null && 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.maven.galley.model.ConcreteResource in project galley by Commonjava.
the class ArtifactManagerImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy.
@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy() throws Exception {
final String base = "2-snapshots-1-location/";
final String testResource = base + "two-snapshots.xml";
final String testPomResource = base + "two-snapshots-pom.xml";
final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "artifact", "1.0-SNAPSHOT");
final ConcreteResource metadataResource = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
final ConcreteResource pomResource = new ConcreteResource(LOCATION, fixture.pomPath(ref.selectVersion("1.0-20140604.102909-1").asPomArtifact()));
fixture.getTransport().registerDownload(metadataResource, new TestDownload(ROOT + testResource));
fixture.getTransport().registerDownload(pomResource, new TestDownload(ROOT + testPomResource));
final Transfer retrieved = fixture.getArtifactManager().retrieve(LOCATION, ref.asPomArtifact(), new EventMetadata());
final Document document = fixture.getXml().parse(retrieved, new EventMetadata());
final ProjectVersionRef result = fixture.getXml().getProjectVersionRef(document);
System.out.println(result);
assertThat(result, notNullValue());
assertThat(result.getVersionString(), equalTo("1.0-20140604.102909-1"));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project galley by Commonjava.
the class VersionResolverImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy.
@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy() throws Exception {
final String testResource = "single-snapshot/single-snapshot.xml";
final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT");
final ConcreteResource cr = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
final TestDownload download = new TestDownload(ROOT + testResource);
fixture.getTransport().registerDownload(cr, download);
final ProjectVersionRef result = fixture.getVersionResolver().resolveFirstMatchVariableVersion(ONE_LOCATION, ref, LatestVersionSelectionStrategy.INSTANCE, new EventMetadata());
assertThat(result, notNullValue());
assertThat(result.getVersionString(), equalTo("1.0-20140604.101244-1"));
}
Aggregations