Package org.hl7.fhir.utilities.npm
Class FilesystemPackageCacheManager
java.lang.Object
org.hl7.fhir.utilities.npm.BasePackageCacheManager
org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager
- All Implemented Interfaces:
IPackageCacheManager
public class FilesystemPackageCacheManager
extends BasePackageCacheManager
implements IPackageCacheManager
This is a package cache manager implementation that uses a local disk cache
API:
constructor getPackageUrl getPackageId findPackageCache addPackageToCache
- Author:
- Grahame Grieve
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfacestatic interfaceNested classes/interfaces inherited from class org.hl7.fhir.utilities.npm.BasePackageCacheManager
BasePackageCacheManager.InputStreamWithSrc -
Field Summary
FieldsFields inherited from class org.hl7.fhir.utilities.npm.BasePackageCacheManager
myPackageServers -
Method Summary
Modifier and TypeMethodDescriptionaddPackageToCache(String id, String version, InputStream packageTgzInputStream, String sourceDesc) Add an already fetched package to the cacheprotected voidvoidclear()Clear the cachefindCanonicalInLocalCache(String canonicalUrl) getLatestVersion(String id, boolean milestonesOnly) getLatestVersion(String id, String versionFilter) getLatestVersionFromCache(String id, String versionFilter) getPackageId(String canonicalUrl) getPackageUrl(String packageId) booleanvoidloadFromFolder(String packagesFolder) do not use this in minimal memory modeloadFromPackageServer(String id, String version) Try to load a package from all registered package servers, and returnnullif it can not be found at any of them.loadPackage(String id, String version) Load the package specified by the id and version specified by the parameters.loadPackageFromCacheOnly(String id, String version) Load the identified package from the cache - if it existsbooleanpackageExists(String id, String ver) booleanpackageInstalled(String id, String version) protected voidCheck if the cache folder exists and is valid.voidremovePackage(String id, String version) Remove a particular package from the cachestatic voidsetPackageProvider(FilesystemPackageCacheManager.IPackageProvider packageProvider) voidsetSuppressErrors(boolean suppressErrors) Methods inherited from class org.hl7.fhir.utilities.npm.BasePackageCacheManager
addPackageServer, getPackageServers, loadPackage, loadPackageFromCacheOnly, setClientFactory, stripAliasMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hl7.fhir.utilities.npm.IPackageCacheManager
loadPackage
-
Field Details
-
PACKAGE_REGEX
- See Also:
-
PACKAGE_VERSION_REGEX
- See Also:
-
PACKAGE_VERSION_REGEX_OPT
- See Also:
-
-
Method Details
-
prepareCacheFolder
Check if the cache folder exists and is valid.If it doesn't exist, create it.
If it does exist and isn't valid, delete it and create a new one.
If it does exist and is valid, just do some cleanup (delete temp download directories, etc.)
- Throws:
IOException- if the cache folder can't be created
-
cleanUpCorruptPackages
- Throws:
IOException
-
getFolder
-
loadFromPackageServer
protected BasePackageCacheManager.InputStreamWithSrc loadFromPackageServer(String id, String version) Description copied from class:BasePackageCacheManagerTry to load a package from all registered package servers, and returnnullif it can not be found at any of them.- Overrides:
loadFromPackageServerin classBasePackageCacheManager
-
getLatestVersion
- Throws:
IOException
-
getLatestVersion
- Throws:
IOException
-
getLatestVersionFromCache
- Throws:
IOException
-
getLatestVersionFromCache
- Throws:
IOException
-
clear
Clear the cache- Throws:
IOException- If the cache cannot be cleared
-
removePackage
Remove a particular package from the cache- Parameters:
id- The id of the package to removeversion- The literal version of the package to remove. Values such as 'current' and 'dev' are not allowed.- Throws:
IOException- If the package cannot be removed
-
loadPackageFromCacheOnly
Load the identified package from the cache - if it exists This is for special purpose only (testing, control over speed of loading). Generally, use the loadPackage method- Specified by:
loadPackageFromCacheOnlyin classBasePackageCacheManager- Parameters:
id- The id of the package to loadversion- The version of the package to load. Values such as 'current' and 'dev' are allowed.- Returns:
- The package, or null if it is not found
- Throws:
IOException- If the package cannot be loaded
-
addPackageToCache
public NpmPackage addPackageToCache(String id, String version, InputStream packageTgzInputStream, String sourceDesc) throws IOException Add an already fetched package to the cache- Specified by:
addPackageToCachein interfaceIPackageCacheManager- Throws:
IOException
-
getPackageUrl
- Specified by:
getPackageUrlin interfaceIPackageCacheManager- Overrides:
getPackageUrlin classBasePackageCacheManager- Throws:
IOException
-
loadFromFolder
do not use this in minimal memory mode- Parameters:
packagesFolder-- Throws:
IOException
-
loadPackage
Description copied from interface:IPackageCacheManagerLoad the package specified by the id and version specified by the parameters. Depending on the implementation logic, this may be from the package cache, or resolved from another service.- Specified by:
loadPackagein interfaceIPackageCacheManager- Parameters:
id- The package idversion- The package version. If this is null, the implementation logic will attempt to resolve an appropriate version based on the package id.- Returns:
- the NPM Package
- Throws:
FHIRExceptionIOException
-
getPackageId
- Specified by:
getPackageIdin interfaceIPackageCacheManager- Overrides:
getPackageIdin classBasePackageCacheManager- Throws:
IOException
-
findCanonicalInLocalCache
-
listPackages
-
packageExists
- Throws:
IOException
-
packageInstalled
-
isSuppressErrors
-
setSuppressErrors
-
getPackageProvider
-
setPackageProvider
public static void setPackageProvider(FilesystemPackageCacheManager.IPackageProvider packageProvider)
-