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 cacheAPI:
constructor getPackageUrl getPackageId findPackageCache addPackageToCache
- Author:
- Grahame Grieve
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classFilesystemPackageCacheManager.BuildRecordclassFilesystemPackageCacheManager.BuildRecordSorterclassFilesystemPackageCacheManager.CacheLockstatic interfaceFilesystemPackageCacheManager.CacheLockFunction<T>static interfaceFilesystemPackageCacheManager.INetworkServicesif you don't provide and implementation of this interface, the PackageCacheManager will use the web directly.classFilesystemPackageCacheManager.PackageEntryclassFilesystemPackageCacheManager.VersionHistory-
Nested classes/interfaces inherited from class org.hl7.fhir.utilities.npm.BasePackageCacheManager
BasePackageCacheManager.InputStreamWithSrc
-
-
Field Summary
Fields Modifier and Type Field Description static StringPACKAGE_REGEXstatic StringPACKAGE_VERSION_REGEXstatic StringPACKAGE_VERSION_REGEX_OPT
-
Constructor Summary
Constructors Constructor Description FilesystemPackageCacheManager(boolean userMode, int toolsVersion)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NpmPackageaddPackageToCache(String id, String version, InputStream packageTgzInputStream, String sourceDesc)Add an already fetched package to the cachevoidclear()Clear the cacheStringfindCanonicalInLocalCache(String canonicalUrl)StringgetFolder()StringgetLatestVersion(String id)StringgetPackageId(String canonicalUrl)StringgetPackageUrl(String packageId)voidlistAllIds(Map<String,String> specList)List<String>listPackages()voidloadFromFolder(String packagesFolder)protected BasePackageCacheManager.InputStreamWithSrcloadFromPackageServer(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.NpmPackageloadPackage(String id, String version)NpmPackageloadPackageFromCacheOnly(String id, String version)Load the identified package from the cache - if it existsbooleanpackageExists(String id, String ver)booleanpackageInstalled(String id, String version)voidremovePackage(String id, String ver)Remove a particular package from the cache-
Methods inherited from class org.hl7.fhir.utilities.npm.BasePackageCacheManager
addPackageServer, getPackageServers, loadPackage, loadPackageFromCacheOnly, setClientFactory
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hl7.fhir.utilities.npm.IPackageCacheManager
loadPackage
-
-
-
-
Field Detail
-
PACKAGE_REGEX
public static final String PACKAGE_REGEX
- See Also:
- Constant Field Values
-
PACKAGE_VERSION_REGEX
public static final String PACKAGE_VERSION_REGEX
- See Also:
- Constant Field Values
-
PACKAGE_VERSION_REGEX_OPT
public static final String PACKAGE_VERSION_REGEX_OPT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FilesystemPackageCacheManager
public FilesystemPackageCacheManager(boolean userMode, int toolsVersion) throws IOException
Constructor- Throws:
IOException
-
-
Method Detail
-
loadFromFolder
public void loadFromFolder(String packagesFolder) throws IOException
- Throws:
IOException
-
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
public String getLatestVersion(String id) throws IOException
- Throws:
IOException
-
clear
public void clear() throws IOException
Clear the cache- Throws:
IOException
-
removePackage
public void removePackage(String id, String ver) throws IOException
Remove a particular package from the cache- Parameters:
id-ver-- Throws:
IOException
-
loadPackageFromCacheOnly
public NpmPackage loadPackageFromCacheOnly(String id, String version) throws IOException
Load the identified package from the cache - if it existsThis is for special purpose only (testing, control over speed of loading). Generally, use the loadPackage method
- Specified by:
loadPackageFromCacheOnlyin classBasePackageCacheManager- Parameters:
id-version-- Returns:
- Throws:
IOException
-
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
public String getPackageUrl(String packageId) throws IOException
- Specified by:
getPackageUrlin interfaceIPackageCacheManager- Overrides:
getPackageUrlin classBasePackageCacheManager- Throws:
IOException
-
listAllIds
public void listAllIds(Map<String,String> specList) throws IOException
- Throws:
IOException
-
loadPackage
public NpmPackage loadPackage(String id, String version) throws FHIRException, IOException
- Specified by:
loadPackagein interfaceIPackageCacheManager- Throws:
FHIRExceptionIOException
-
getPackageId
public String getPackageId(String canonicalUrl) throws IOException
- Specified by:
getPackageIdin interfaceIPackageCacheManager- Overrides:
getPackageIdin classBasePackageCacheManager- Throws:
IOException
-
findCanonicalInLocalCache
public String findCanonicalInLocalCache(String canonicalUrl)
-
listPackages
public List<String> listPackages()
-
packageExists
public boolean packageExists(String id, String ver) throws IOException
- Throws:
IOException
-
packageInstalled
public boolean packageInstalled(String id, String version)
-
-