Package org.apache.ivy.core.cache
Class DefaultRepositoryCacheManager
- java.lang.Object
-
- org.apache.ivy.core.cache.DefaultRepositoryCacheManager
-
- All Implemented Interfaces:
RepositoryCacheManager,IvySettingsAware
public class DefaultRepositoryCacheManager extends java.lang.Object implements RepositoryCacheManager, IvySettingsAware
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classDefaultRepositoryCacheManager.BackupResourceDownloaderResource downloader which makes a copy of the previously existing file before overriding it.private static classDefaultRepositoryCacheManager.ConfiguredTTLprivate classDefaultRepositoryCacheManager.MyModuleDescriptorProvider
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternARTIFACT_KEY_PATTERNprivate java.lang.StringartifactPatternprivate java.io.Filebasedirprivate java.lang.StringchangingMatcherNameprivate java.lang.StringchangingPatternprivate java.lang.Booleancheckmodifiedprivate java.util.List<DefaultRepositoryCacheManager.ConfiguredTTL>configuredTTLsprivate java.lang.StringdataFilePatternprivate static java.lang.StringDEFAULT_ARTIFACT_PATTERNprivate static java.lang.StringDEFAULT_DATA_FILE_PATTERNprivate static java.lang.StringDEFAULT_IVY_PATTERNprivate static intDEFAULT_MEMORY_CACHE_SIZEprivate java.lang.LongdefaultTTLprivate static java.util.regex.PatternDURATION_PATTERNprivate java.lang.StringivyPatternprivate LockStrategylockStrategyprivate java.lang.StringlockStrategyNameprivate ModuleDescriptorMemoryCachememoryModuleDescrCacheprivate static intMILLIS_IN_DAYprivate static intMILLIS_IN_HOURprivate static intMILLIS_IN_MINUTESprivate static intMILLIS_IN_SECONDSprivate java.lang.Stringnameprivate PackagingManagerpackagingManagerprivate IvySettingssettingsprivate static java.security.MessageDigestSHA_DIGESTprivate ModuleRules<java.lang.Long>ttlRulesprivate java.lang.BooleanuseOrigin
-
Constructor Summary
Constructors Constructor Description DefaultRepositoryCacheManager()DefaultRepositoryCacheManager(java.lang.String name, IvySettings settings, java.io.File basedir)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddConfiguredTtl(java.util.Map<java.lang.String,java.lang.String> attributes)voidaddTTL(java.util.Map<java.lang.String,java.lang.String> attributes, PatternMatcher matcher, long duration)ResolvedModuleRevisioncacheModuleDescriptor(DependencyResolver resolver, ResolvedResource mdRef, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options)Caches an original module descriptor.private booleancheckCacheUptodate(java.io.File archiveFile, Resource resource, ArtifactOrigin savedOrigin, ArtifactOrigin origin, long ttl)Check that a cached file can be considered up to date and thus not downloadedvoidclean()Cleans the whole cache.private java.lang.StringcomputeResourceNameHash(Resource resource)Compute a SHA1 of the resource name, encoded in base64, so we can use it as a file name.private ResolvedModuleRevisiondoFindModuleInCache(ModuleRevisionId mrid, CacheMetadataOptions options, java.lang.String expectedResolver)ArtifactDownloadReportdownload(Artifact artifact, ArtifactResourceResolver resourceResolver, ResourceDownloader resourceDownloader, CacheDownloadOptions options)Downloads an artifact to this cache.ArtifactDownloadReportdownloadRepositoryResource(Resource resource, java.lang.String name, java.lang.String type, java.lang.String extension, CacheResourceOptions options, Repository repository)Download some repository resource and put it in the cache.voiddumpSettings()ResolvedModuleRevisionfindModuleInCache(DependencyDescriptor dd, ModuleRevisionId requestedRevisionId, CacheMetadataOptions options, java.lang.String expectedResolver)Search a module descriptor in cache for a mridjava.io.FilegetArchiveFileInCache(Artifact artifact)Returns a File object pointing to where the artifact can be found on the local file system.java.io.FilegetArchiveFileInCache(Artifact artifact, ArtifactOrigin origin)Returns a File object pointing to where the artifact can be found on the local file system.private java.io.FilegetArchiveFileInCache(Artifact artifact, ArtifactOrigin origin, boolean useOrigin)Returns a File object pointing to where the artifact can be found on the local file system, using or not the original location depending on the availability of origin information provided as parameter and the setting of useOrigin.java.lang.StringgetArchivePathInCache(Artifact artifact)java.lang.StringgetArchivePathInCache(Artifact artifact, ArtifactOrigin origin)java.lang.StringgetArtifactPattern()java.io.FilegetBasedir()private PropertiesFilegetCachedDataFile(java.lang.String resolverName, ModuleRevisionId mRevId)A resolver-specific ivydata file, only used for caching dynamic revisions, e.g.private PropertiesFilegetCachedDataFile(ModuleDescriptor md)private PropertiesFilegetCachedDataFile(ModuleRevisionId mRevId)private MatchergetChangingMatcher(CacheMetadataOptions options)java.lang.StringgetChangingMatcherName()java.lang.StringgetChangingPattern()java.lang.StringgetDataFilePattern()private ArtifactgetDefaultMetadataArtifact(ModuleRevisionId mrid)private ArtifactOrigingetDefaultMetadataArtifactOrigin(ModuleRevisionId mrid)longgetDefaultTTL()private java.lang.StringgetExistsKey(Artifact artifact)Returns the key used to identify the existence of the remote artifact.private intgetGroupIntValue(java.util.regex.Matcher m, int groupNumber)private java.lang.StringgetIsLocalKey(Artifact artifact)Returns the key used to identify if the artifact is local.java.io.FilegetIvyFileInCache(ModuleRevisionId mrid)java.lang.StringgetIvyPattern()private java.lang.StringgetLastCheckedKey(Artifact artifact)Returns the key used to identify the last time the artifact was checked to be up to date.private java.lang.StringgetLocationKey(Artifact artifact)Returns the key used to identify the location of the artifact.LockStrategygetLockStrategy()private ModuleDescriptorgetMdFromCache(ModuleDescriptorParser mdParser, CacheMetadataOptions options, java.io.File ivyFile)ModuleDescriptorMemoryCachegetMemoryCache()protected ModuleDescriptorParsergetModuleDescriptorParser(java.io.File moduleDescriptorFile)Choose write module descriptor parser for a given moduleDescriptorjava.lang.StringgetName()Returns the name of the repository cache manager.private java.lang.StringgetOriginalKey(Artifact artifact)Returns the key used to identify the original artifact.ArtifactgetOriginalMetadataArtifact(Artifact moduleArtifact)private java.lang.StringgetPrefixKey(Artifact artifact)Creates the unique prefix key that will reference the artifact within the properties.java.io.FilegetRepositoryCacheRoot()private java.lang.StringgetResolvedRevision(java.lang.String expectedResolver, ModuleRevisionId mrid, CacheMetadataOptions options)Called by doFindModuleInCache to lookup the dynamicmridin the ivycache's ivydata file.ArtifactOrigingetSavedArtifactOrigin(Artifact artifact)Returns the artifact origin of the given artifact as saved in this cache.private java.lang.StringgetSavedArtResolverName(ModuleDescriptor md)private java.lang.StringgetSavedResolverName(ModuleDescriptor md)IvySettingsgetSettings()private ModuleDescriptorgetStaledMd(ModuleDescriptorParser mdParser, CacheMetadataOptions options, java.io.File ivyFile, ParserSettings parserSettings)longgetTTL(ModuleRevisionId mrid)private booleanisChanging(DependencyDescriptor dd, ModuleRevisionId requestedRevisionId, CacheMetadataOptions options)booleanisCheckmodified()True if this cache should check lastmodified date to know if ivy files are up to date.private booleanisCheckmodified(DependencyDescriptor dd, ModuleRevisionId requestedRevisionId, CacheMetadataOptions options)private booleanisOriginalMetadataArtifact(Artifact artifact)booleanisUseOrigin()True if this cache should use artifacts original location when possible, false if they should be copied to cache.private booleanlockMetadataArtifact(ModuleRevisionId mrid)voidoriginalToCachedModuleDescriptor(DependencyResolver resolver, ResolvedResource originalMetadataRef, Artifact requestedMetadataArtifact, ResolvedModuleRevision rmr, ModuleDescriptorWriter writer)Stores a standardized version of an original module descriptor in the cache for later use.private longparseDuration(java.lang.String duration)private voidremoveSavedArtifactOrigin(Artifact artifact)(package private) voidsaveArtifactOrigin(Artifact artifact, ArtifactOrigin origin)voidsaveResolvedRevision(java.lang.String resolverName, ModuleRevisionId mrid, java.lang.String revision)Caches a dynamic revision constraint resolution for a specific resolver.voidsaveResolvedRevision(ModuleRevisionId mrid, java.lang.String revision)Deprecated.private voidsaveResolver(ModuleDescriptor md, java.lang.String name)Saves the information of which resolver was used to resolve a md, so that this info can be retrieve later (even after a jvm restart) by getSavedResolverName(ModuleDescriptor md)voidsaveResolvers(ModuleDescriptor md, java.lang.String metadataResolverName, java.lang.String artifactResolverName)Saves the information of which resolver was used to resolve a md, so that this info can be retrieve later (even after a jvm restart) by getSavedArtResolverName(ModuleDescriptor md)voidsetArtifactPattern(java.lang.String artifactPattern)voidsetBasedir(java.io.File cache)voidsetChangingMatcher(java.lang.String changingMatcherName)voidsetChangingPattern(java.lang.String changingPattern)voidsetCheckmodified(boolean check)voidsetDataFilePattern(java.lang.String dataFilePattern)voidsetDefaultTTL(long defaultTTL)voidsetDefaultTTL(java.lang.String defaultTTL)voidsetIvyPattern(java.lang.String ivyPattern)voidsetLockStrategy(java.lang.String lockStrategyName)voidsetLockStrategy(LockStrategy lockStrategy)voidsetMemorySize(int size)voidsetName(java.lang.String name)voidsetSettings(IvySettings settings)voidsetUseOrigin(boolean b)java.lang.StringtoString()private voidunlockMetadataArtifact(ModuleRevisionId mrid)private voidunpackArtifact(Artifact artifact, ArtifactDownloadReport adr, CacheDownloadOptions options)
-
-
-
Field Detail
-
DEFAULT_ARTIFACT_PATTERN
private static final java.lang.String DEFAULT_ARTIFACT_PATTERN
- See Also:
- Constant Field Values
-
DEFAULT_DATA_FILE_PATTERN
private static final java.lang.String DEFAULT_DATA_FILE_PATTERN
- See Also:
- Constant Field Values
-
DEFAULT_IVY_PATTERN
private static final java.lang.String DEFAULT_IVY_PATTERN
- See Also:
- Constant Field Values
-
DEFAULT_MEMORY_CACHE_SIZE
private static final int DEFAULT_MEMORY_CACHE_SIZE
- See Also:
- Constant Field Values
-
SHA_DIGEST
private static java.security.MessageDigest SHA_DIGEST
-
settings
private IvySettings settings
-
basedir
private java.io.File basedir
-
lockStrategy
private LockStrategy lockStrategy
-
name
private java.lang.String name
-
ivyPattern
private java.lang.String ivyPattern
-
dataFilePattern
private java.lang.String dataFilePattern
-
artifactPattern
private java.lang.String artifactPattern
-
lockStrategyName
private java.lang.String lockStrategyName
-
changingPattern
private java.lang.String changingPattern
-
changingMatcherName
private java.lang.String changingMatcherName
-
checkmodified
private java.lang.Boolean checkmodified
-
useOrigin
private java.lang.Boolean useOrigin
-
ttlRules
private ModuleRules<java.lang.Long> ttlRules
-
defaultTTL
private java.lang.Long defaultTTL
-
memoryModuleDescrCache
private ModuleDescriptorMemoryCache memoryModuleDescrCache
-
packagingManager
private PackagingManager packagingManager
-
configuredTTLs
private final java.util.List<DefaultRepositoryCacheManager.ConfiguredTTL> configuredTTLs
-
DURATION_PATTERN
private static final java.util.regex.Pattern DURATION_PATTERN
-
MILLIS_IN_SECONDS
private static final int MILLIS_IN_SECONDS
- See Also:
- Constant Field Values
-
MILLIS_IN_MINUTES
private static final int MILLIS_IN_MINUTES
- See Also:
- Constant Field Values
-
MILLIS_IN_HOUR
private static final int MILLIS_IN_HOUR
- See Also:
- Constant Field Values
-
MILLIS_IN_DAY
private static final int MILLIS_IN_DAY
- See Also:
- Constant Field Values
-
ARTIFACT_KEY_PATTERN
private static final java.util.regex.Pattern ARTIFACT_KEY_PATTERN
-
-
Constructor Detail
-
DefaultRepositoryCacheManager
public DefaultRepositoryCacheManager()
-
DefaultRepositoryCacheManager
public DefaultRepositoryCacheManager(java.lang.String name, IvySettings settings, java.io.File basedir)
-
-
Method Detail
-
getSettings
public IvySettings getSettings()
-
setSettings
public void setSettings(IvySettings settings)
- Specified by:
setSettingsin interfaceIvySettingsAware
-
getIvyFileInCache
public java.io.File getIvyFileInCache(ModuleRevisionId mrid)
-
getIvyPattern
public java.lang.String getIvyPattern()
-
getArtifactPattern
public java.lang.String getArtifactPattern()
-
setArtifactPattern
public void setArtifactPattern(java.lang.String artifactPattern)
-
getBasedir
public java.io.File getBasedir()
-
setBasedir
public void setBasedir(java.io.File cache)
-
getDefaultTTL
public long getDefaultTTL()
-
setDefaultTTL
public void setDefaultTTL(long defaultTTL)
-
setDefaultTTL
public void setDefaultTTL(java.lang.String defaultTTL)
-
getDataFilePattern
public java.lang.String getDataFilePattern()
-
setDataFilePattern
public void setDataFilePattern(java.lang.String dataFilePattern)
-
setIvyPattern
public void setIvyPattern(java.lang.String ivyPattern)
-
getName
public java.lang.String getName()
Description copied from interface:RepositoryCacheManagerReturns the name of the repository cache manager.- Specified by:
getNamein interfaceRepositoryCacheManager- Returns:
- the name of the repository cache manager.
-
setName
public void setName(java.lang.String name)
-
getChangingMatcherName
public java.lang.String getChangingMatcherName()
-
setChangingMatcher
public void setChangingMatcher(java.lang.String changingMatcherName)
-
getChangingPattern
public java.lang.String getChangingPattern()
-
setChangingPattern
public void setChangingPattern(java.lang.String changingPattern)
-
addTTL
public void addTTL(java.util.Map<java.lang.String,java.lang.String> attributes, PatternMatcher matcher, long duration)
-
addConfiguredTtl
public void addConfiguredTtl(java.util.Map<java.lang.String,java.lang.String> attributes)
-
setMemorySize
public void setMemorySize(int size)
-
getMemoryCache
public ModuleDescriptorMemoryCache getMemoryCache()
-
parseDuration
private long parseDuration(java.lang.String duration)
-
getGroupIntValue
private int getGroupIntValue(java.util.regex.Matcher m, int groupNumber)
-
isCheckmodified
public boolean isCheckmodified()
True if this cache should check lastmodified date to know if ivy files are up to date.- Returns:
- boolean
-
setCheckmodified
public void setCheckmodified(boolean check)
-
isUseOrigin
public boolean isUseOrigin()
True if this cache should use artifacts original location when possible, false if they should be copied to cache.- Returns:
- boolean
-
setUseOrigin
public void setUseOrigin(boolean b)
-
getArchiveFileInCache
public java.io.File getArchiveFileInCache(Artifact artifact)
Returns a File object pointing to where the artifact can be found on the local file system. This is usually in the cache, but it can be directly in the repository if it is local and if the resolve has been done with useOrigin = true- Parameters:
artifact- Artifact- Returns:
- File
-
getArchiveFileInCache
public java.io.File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin)
Returns a File object pointing to where the artifact can be found on the local file system. This is usually in the cache, but it can be directly in the repository if it is local and if the resolve has been done with useOrigin = true- Parameters:
artifact- Artifactorigin- ArtifactOrigin- Returns:
- File
-
getArchiveFileInCache
private java.io.File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin, boolean useOrigin)
Returns a File object pointing to where the artifact can be found on the local file system, using or not the original location depending on the availability of origin information provided as parameter and the setting of useOrigin. If useOrigin is false, this method will always return the file in the cache.- Parameters:
artifact- Artifactorigin- ArtifactOriginuseOrigin- boolean- Returns:
- File
-
getArchivePathInCache
public java.lang.String getArchivePathInCache(Artifact artifact)
-
getArchivePathInCache
public java.lang.String getArchivePathInCache(Artifact artifact, ArtifactOrigin origin)
-
saveResolver
private void saveResolver(ModuleDescriptor md, java.lang.String name)
Saves the information of which resolver was used to resolve a md, so that this info can be retrieve later (even after a jvm restart) by getSavedResolverName(ModuleDescriptor md)- Parameters:
md- the module descriptor resolvedname- resolver name
-
saveResolvers
public void saveResolvers(ModuleDescriptor md, java.lang.String metadataResolverName, java.lang.String artifactResolverName)
Saves the information of which resolver was used to resolve a md, so that this info can be retrieve later (even after a jvm restart) by getSavedArtResolverName(ModuleDescriptor md)- Specified by:
saveResolversin interfaceRepositoryCacheManager- Parameters:
md- the module descriptor resolvedmetadataResolverName- metadata resolver nameartifactResolverName- artifact resolver name
-
getSavedResolverName
private java.lang.String getSavedResolverName(ModuleDescriptor md)
-
getSavedArtResolverName
private java.lang.String getSavedArtResolverName(ModuleDescriptor md)
-
saveArtifactOrigin
void saveArtifactOrigin(Artifact artifact, ArtifactOrigin origin)
-
removeSavedArtifactOrigin
private void removeSavedArtifactOrigin(Artifact artifact)
-
getSavedArtifactOrigin
public ArtifactOrigin getSavedArtifactOrigin(Artifact artifact)
Description copied from interface:RepositoryCacheManagerReturns the artifact origin of the given artifact as saved in this cache.If the origin is unknown, the returned ArtifactOrigin instance will return true when
ArtifactOrigin.isUnknown(ArtifactOrigin)is called.- Specified by:
getSavedArtifactOriginin interfaceRepositoryCacheManager- Parameters:
artifact- the artifact for which the saved artifact origin should be returned.- Returns:
- the artifact origin of the given artifact as saved in this cache
-
getPrefixKey
private java.lang.String getPrefixKey(Artifact artifact)
Creates the unique prefix key that will reference the artifact within the properties.- Parameters:
artifact- the artifact to create the unique key from. Cannot be null.- Returns:
- the unique prefix key as a string.
-
getLocationKey
private java.lang.String getLocationKey(Artifact artifact)
Returns the key used to identify the location of the artifact.- Parameters:
artifact- the artifact to generate the key from. Cannot be null.- Returns:
- the key to be used to reference the artifact location.
-
getIsLocalKey
private java.lang.String getIsLocalKey(Artifact artifact)
Returns the key used to identify if the artifact is local.- Parameters:
artifact- the artifact to generate the key from. Cannot be null.- Returns:
- the key to be used to reference the artifact locality.
-
getLastCheckedKey
private java.lang.String getLastCheckedKey(Artifact artifact)
Returns the key used to identify the last time the artifact was checked to be up to date.- Parameters:
artifact- the artifact to generate the key from. Cannot be null.- Returns:
- the key to be used to reference the artifact's last check date.
-
getExistsKey
private java.lang.String getExistsKey(Artifact artifact)
Returns the key used to identify the existence of the remote artifact.- Parameters:
artifact- the artifact to generate the key from. Cannot be null.- Returns:
- the key to be used to reference the existence of the artifact.
-
getOriginalKey
private java.lang.String getOriginalKey(Artifact artifact)
Returns the key used to identify the original artifact.- Parameters:
artifact- the artifact to generate the key from. Cannot be null.- Returns:
- the key to be used to reference the original artifact.
-
getCachedDataFile
private PropertiesFile getCachedDataFile(ModuleDescriptor md)
-
getCachedDataFile
private PropertiesFile getCachedDataFile(ModuleRevisionId mRevId)
-
getCachedDataFile
private PropertiesFile getCachedDataFile(java.lang.String resolverName, ModuleRevisionId mRevId)
A resolver-specific ivydata file, only used for caching dynamic revisions, e.g. integration-repo.
-
findModuleInCache
public ResolvedModuleRevision findModuleInCache(DependencyDescriptor dd, ModuleRevisionId requestedRevisionId, CacheMetadataOptions options, java.lang.String expectedResolver)
Description copied from interface:RepositoryCacheManagerSearch a module descriptor in cache for a mrid- Specified by:
findModuleInCachein interfaceRepositoryCacheManager- Parameters:
dd- the dependency descriptor identifying the module to searchrequestedRevisionId- the requested dependency module revision id identifying the module to searchoptions- options on how caching should be handledexpectedResolver- the resolver with which the md in cache must have been resolved to be returned, null if this doesn't matter- Returns:
- the ResolvedModuleRevision corresponding to the module found, null if none correct has been found in cache
-
doFindModuleInCache
private ResolvedModuleRevision doFindModuleInCache(ModuleRevisionId mrid, CacheMetadataOptions options, java.lang.String expectedResolver)
-
getModuleDescriptorParser
protected ModuleDescriptorParser getModuleDescriptorParser(java.io.File moduleDescriptorFile)
Choose write module descriptor parser for a given moduleDescriptor- Parameters:
moduleDescriptorFile- a given module descriptor- Returns:
- ModuleDescriptorParser
-
getMdFromCache
private ModuleDescriptor getMdFromCache(ModuleDescriptorParser mdParser, CacheMetadataOptions options, java.io.File ivyFile) throws java.text.ParseException, java.io.IOException
- Throws:
java.text.ParseExceptionjava.io.IOException
-
getStaledMd
private ModuleDescriptor getStaledMd(ModuleDescriptorParser mdParser, CacheMetadataOptions options, java.io.File ivyFile, ParserSettings parserSettings) throws java.text.ParseException, java.io.IOException
- Throws:
java.text.ParseExceptionjava.io.IOException
-
getResolvedRevision
private java.lang.String getResolvedRevision(java.lang.String expectedResolver, ModuleRevisionId mrid, CacheMetadataOptions options)Called by doFindModuleInCache to lookup the dynamicmridin the ivycache's ivydata file.
-
saveResolvedRevision
@Deprecated public void saveResolvedRevision(ModuleRevisionId mrid, java.lang.String revision)
Deprecated.Description copied from interface:RepositoryCacheManagerCaches a dynamic revision constraint resolution.- Specified by:
saveResolvedRevisionin interfaceRepositoryCacheManager- Parameters:
mrid- the dynamic module revision idrevision- the resolved revision
-
saveResolvedRevision
public void saveResolvedRevision(java.lang.String resolverName, ModuleRevisionId mrid, java.lang.String revision)Description copied from interface:RepositoryCacheManagerCaches a dynamic revision constraint resolution for a specific resolver.- Specified by:
saveResolvedRevisionin interfaceRepositoryCacheManager- Parameters:
resolverName- the resolver in which this dynamic revision was resolvedmrid- the dynamic module revision idrevision- the resolved revision
-
getTTL
public long getTTL(ModuleRevisionId mrid)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getRepositoryCacheRoot
public java.io.File getRepositoryCacheRoot()
-
getLockStrategy
public LockStrategy getLockStrategy()
-
setLockStrategy
public void setLockStrategy(LockStrategy lockStrategy)
-
setLockStrategy
public void setLockStrategy(java.lang.String lockStrategyName)
-
download
public ArtifactDownloadReport download(Artifact artifact, ArtifactResourceResolver resourceResolver, ResourceDownloader resourceDownloader, CacheDownloadOptions options)
Description copied from interface:RepositoryCacheManagerDownloads an artifact to this cache.- Specified by:
downloadin interfaceRepositoryCacheManager- Parameters:
artifact- the artifact to downloadresourceResolver- a resource resolver to use if the artifact needs to be resolved to a Resource for downloadingresourceDownloader- a resource downloader to use if actual download of the resource is neededoptions- a set of options to adjust the download- Returns:
- a report indicating how the download was performed
-
unpackArtifact
private void unpackArtifact(Artifact artifact, ArtifactDownloadReport adr, CacheDownloadOptions options)
-
downloadRepositoryResource
public ArtifactDownloadReport downloadRepositoryResource(Resource resource, java.lang.String name, java.lang.String type, java.lang.String extension, CacheResourceOptions options, Repository repository)
Description copied from interface:RepositoryCacheManagerDownload some repository resource and put it in the cache.If the cached version is considered enough up to date, no downloading is done.
- Specified by:
downloadRepositoryResourcein interfaceRepositoryCacheManager- Parameters:
resource- the resource of the file to put in cachename- the descriptive name of the resource (helps while manually looking into the cache files)type- the type of the resource (helps while manually looking into the cache files)extension- the extension of the resource (helps while manually looking into the cache files)options- a set of options to adjust the downloadrepository- the repository which resolve the content of the resource- Returns:
- a report indicating how the download was performed
-
computeResourceNameHash
private java.lang.String computeResourceNameHash(Resource resource)
Compute a SHA1 of the resource name, encoded in base64, so we can use it as a file name.- Parameters:
resource- the resource which name will be hashed- Returns:
- the hash
-
checkCacheUptodate
private boolean checkCacheUptodate(java.io.File archiveFile, Resource resource, ArtifactOrigin savedOrigin, ArtifactOrigin origin, long ttl)Check that a cached file can be considered up to date and thus not downloaded- Parameters:
archiveFile- the file in the cacheresource- the remote resource to checksavedOrigin- the saved origin which contains that last checked dateorigin- the origin in which to store the new last checked datettl- the time to live to consider the cache up to date- Returns:
trueif the cache is considered up to date
-
originalToCachedModuleDescriptor
public void originalToCachedModuleDescriptor(DependencyResolver resolver, ResolvedResource originalMetadataRef, Artifact requestedMetadataArtifact, ResolvedModuleRevision rmr, ModuleDescriptorWriter writer)
Description copied from interface:RepositoryCacheManagerStores a standardized version of an original module descriptor in the cache for later use.- Specified by:
originalToCachedModuleDescriptorin interfaceRepositoryCacheManager- Parameters:
resolver- the dependency resolver from which the cache request comes fromoriginalMetadataRef- a resolved resource pointing to the remote original module descriptorrequestedMetadataArtifact- the module descriptor artifact as requested originallyrmr- theResolvedModuleRevisionrepresenting the local cached module descriptorwriter- aModuleDescriptorWriterable to write the module descriptor to a stream.
-
cacheModuleDescriptor
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, ResolvedResource mdRef, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws java.text.ParseException
Description copied from interface:RepositoryCacheManagerCaches an original module descriptor.After this call, the original module descriptor file (with no modification nor conversion) should be available as a local file.
- Specified by:
cacheModuleDescriptorin interfaceRepositoryCacheManager- Parameters:
resolver- the dependency resolver from which the cache request comes frommdRef- a resolved resource pointing to the remote original module descriptordd- the dependency descriptor for which the module descriptor should be cachedmoduleArtifact- the module descriptor artifact as requested originallydownloader- a ResourceDownloader able to download the original module descriptor resource if required by this cache implementationoptions- options to apply to cache this module descriptor- Returns:
- a
ResolvedModuleRevisionrepresenting the local cached module descriptor, or null if it failed - Throws:
java.text.ParseException- if an exception occurred while parsing the module descriptor
-
lockMetadataArtifact
private boolean lockMetadataArtifact(ModuleRevisionId mrid)
-
unlockMetadataArtifact
private void unlockMetadataArtifact(ModuleRevisionId mrid)
-
getDefaultMetadataArtifactOrigin
private ArtifactOrigin getDefaultMetadataArtifactOrigin(ModuleRevisionId mrid)
-
getDefaultMetadataArtifact
private Artifact getDefaultMetadataArtifact(ModuleRevisionId mrid)
-
isOriginalMetadataArtifact
private boolean isOriginalMetadataArtifact(Artifact artifact)
-
isChanging
private boolean isChanging(DependencyDescriptor dd, ModuleRevisionId requestedRevisionId, CacheMetadataOptions options)
-
getChangingMatcher
private Matcher getChangingMatcher(CacheMetadataOptions options)
-
isCheckmodified
private boolean isCheckmodified(DependencyDescriptor dd, ModuleRevisionId requestedRevisionId, CacheMetadataOptions options)
-
clean
public void clean()
Description copied from interface:RepositoryCacheManagerCleans the whole cache.- Specified by:
cleanin interfaceRepositoryCacheManager
-
dumpSettings
public void dumpSettings()
-
-