use of org.commonjava.maven.galley.model.SpecialPathInfo in project indy by Commonjava.
the class DefaultScheduleManager method setProxyTimeouts.
public 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, key.getPackageType());
if (!repo.isPassthrough()) {
if ((info != null && info.isMetadata()) && repo.getMetadataTimeoutSeconds() >= 0) {
if (repo.getMetadataTimeoutSeconds() == 0) {
logger.debug("Using default metadata timeout for: {}", resource);
timeout = config.getRemoteMetadataTimeoutSeconds();
} else {
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 ) );
removeCache(new ScheduleKey(key, CONTENT_JOB_TYPE, path));
scheduleContentExpiration(key, path, timeout);
}
}
use of org.commonjava.maven.galley.model.SpecialPathInfo in project indy by Commonjava.
the class DefaultDownloadManager method recurseListing.
private void recurseListing(final Transfer transfer, final List<Transfer> result) throws IndyWorkflowException {
if (transfer.isDirectory()) {
try {
final String[] children = transfer.list();
for (final String child : children) {
final Transfer childTransfer = transfer.getChild(child);
recurseListing(childTransfer, result);
}
} catch (final IOException e) {
throw new IndyWorkflowException("Failed to list children of: %s. Reason: %s", e, transfer, e.getMessage());
}
} else if (transfer.exists()) {
SpecialPathInfo spi = specialPathManager.getSpecialPathInfo(transfer.getPath());
if (spi == null || spi.isListable()) {
result.add(transfer);
}
}
}
use of org.commonjava.maven.galley.model.SpecialPathInfo in project indy by Commonjava.
the class DefaultContentManager method delete.
@Override
@Measure
public boolean delete(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
if (Boolean.TRUE.equals(eventMetadata.get(CHECK_CACHE_ONLY)) && hosted == store.getKey().getType()) {
SpecialPathInfo info = specialPathManager.getSpecialPathInfo(path, store.getPackageType());
if (info != null && info.isMetadata()) {
// Set ignore readonly for metadata so that we can delete stale metadata from readonly hosted repo
eventMetadata.set(IGNORE_READONLY, Boolean.TRUE);
} else {
logger.info("Can not delete from hosted {}, path: {}, info: {}", store.getKey(), path, info);
return false;
}
}
logger.info("Delete from {}, path: {}, eventMetadata: {}", store.getKey(), path, eventMetadata);
boolean result = false;
if (group == store.getKey().getType()) {
if (Boolean.TRUE.equals(eventMetadata.get(CASCADE))) {
List<ArtifactStore> members = getOrderedConcreteStoresAndFilter((Group) store, path);
for (final ArtifactStore member : members) {
if (downloadManager.delete(member, path, eventMetadata)) {
contentGeneratorManager.handleContentDeletion(member, path, eventMetadata);
}
}
}
contentGeneratorManager.handleContentDeletion(store, path, eventMetadata);
result = true;
} else {
if (downloadManager.delete(store, path, eventMetadata)) {
result = true;
contentGeneratorManager.handleContentDeletion(store, path, eventMetadata);
}
}
return result;
}
use of org.commonjava.maven.galley.model.SpecialPathInfo in project indy by Commonjava.
the class DefaultContentManager method getTransfer.
@Override
public Transfer getTransfer(final ArtifactStore store, final String path, final TransferOperation op) throws IndyWorkflowException {
logger.trace("Getting transfer for: {}/{} (op: {})", store.getKey(), path, op);
if (group == store.getKey().getType()) {
KeyedLocation location = LocationUtils.toLocation(store);
SpecialPathInfo spInfo = specialPathManager.getSpecialPathInfo(location, path, store.getPackageType());
if (spInfo == null || !spInfo.isMergable()) {
List<ArtifactStore> members = getOrderedConcreteStoresAndFilter((Group) store, path);
logger.trace("Trying to retrieve suitable transfer for: {} in group: {}", path, store.getName());
logger.trace("Members in group {}: {}", store.getName(), members);
return getTransfer(members, path, op);
} else {
logger.trace("Detected mergable special path: {}/{}.", store.getKey(), path);
}
}
logger.trace("Retrieving storage reference (Transfer) directly for: {}/{}", store.getKey(), path);
return downloadManager.getStorageReference(store, path, op);
}
use of org.commonjava.maven.galley.model.SpecialPathInfo in project indy by Commonjava.
the class DefaultGalleyStorageProvider method setup.
@PostConstruct
public void setup() {
SpecialPathInfo infoSpi = SpecialPathInfo.from(new FilePatternMatcher(".+\\.info")).setDecoratable(false).setDeletable(false).setListable(false).setPublishable(false).setRetrievable(false).setStorable(false).build();
specialPathManager.registerSpecialPathInfo(infoSpi);
if (specialPathSetProducers != null) {
specialPathSetProducers.forEach(producer -> {
logger.trace("Adding special paths from: {}", producer.getClass().getName());
specialPathManager.registerSpecialPathSet(producer.getSpecialPathSet());
});
}
setupTransferDecoratorPipeline();
setupCacheProviderFactory();
// TODO: Tie this into a config file!
transportManagerConfig = new TransportManagerConfig();
}
Aggregations