use of org.commonjava.indy.spi.pkg.ContentAdvisor in project indy by Commonjava.
the class ScheduleManager method setSnapshotTimeouts.
public synchronized void setSnapshotTimeouts(final StoreKey key, final String path) throws IndySchedulerException {
if (!schedulerConfig.isEnabled()) {
logger.debug("Scheduler disabled.");
return;
}
HostedRepository deploy = null;
try {
final ArtifactStore store = dataManager.getArtifactStore(key);
if (store == null) {
return;
}
if (store instanceof HostedRepository) {
deploy = (HostedRepository) store;
} else if (store instanceof Group) {
final Group group = (Group) store;
deploy = findDeployPoint(group);
}
} catch (final IndyDataException e) {
logger.error(String.format("Failed to retrieve deploy point for: %s. Reason: %s", key, e.getMessage()), e);
}
if (deploy == null) {
return;
}
final ContentAdvisor advisor = StreamSupport.stream(Spliterators.spliteratorUnknownSize(contentAdvisor.iterator(), Spliterator.ORDERED), false).filter(Objects::nonNull).findFirst().orElse(null);
final ContentQuality quality = advisor == null ? null : advisor.getContentQuality(path);
if (quality == null) {
return;
}
if (ContentQuality.SNAPSHOT == quality && deploy.getSnapshotTimeoutSeconds() > 0) {
final int timeout = deploy.getSnapshotTimeoutSeconds();
// // logger.info( "[SNAPSHOT TIMEOUT SET] {}/{}; {}", deploy.getKey(), path, new Date( timeout ) );
// cancel( new StoreKeyMatcher( key, CONTENT_JOB_TYPE ), path );
scheduleContentExpiration(key, path, timeout);
}
}
Aggregations