Package org.hl7.fhir.utilities.cache
Class FilesystemPackageCacheManager
- java.lang.Object
-
- org.hl7.fhir.utilities.cache.BasePackageCacheManager
-
- org.hl7.fhir.utilities.cache.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.cache.BasePackageCacheManager
BasePackageCacheManager.InputStreamWithSrc
-
-
Field Summary
Fields Modifier and Type Field Description static StringPACKAGE_REGEXstatic StringPACKAGE_VERSION_REGEXstatic StringPRIMARY_SERVERstatic StringSECONDARY_SERVER
-
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 cacheStringgetFolder()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 - it it existsvoidremovePackage(String id, String ver)Remove a particular package from the cache-
Methods inherited from class org.hl7.fhir.utilities.cache.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.cache.IPackageCacheManager
loadPackage
-
-
-
-
Field Detail
-
PRIMARY_SERVER
public static final String PRIMARY_SERVER
- See Also:
- Constant Field Values
-
SECONDARY_SERVER
public static final String SECONDARY_SERVER
- See Also:
- Constant Field Values
-
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
-
-
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 - it 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
-
listPackages
public List<String> listPackages()
-
-