Package org.hl7.fhir.utilities.npm
Class BasePackageCacheManager
- java.lang.Object
-
- org.hl7.fhir.utilities.npm.BasePackageCacheManager
-
- All Implemented Interfaces:
IPackageCacheManager
- Direct Known Subclasses:
FilesystemPackageCacheManager
public abstract class BasePackageCacheManager extends Object implements IPackageCacheManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBasePackageCacheManager.InputStreamWithSrc
-
Field Summary
Fields Modifier and Type Field Description protected List<PackageServer>myPackageServersprotected booleansilent
-
Constructor Summary
Constructors Modifier Constructor Description BasePackageCacheManager()ConstructorprotectedBasePackageCacheManager(List<PackageServer> thePackageServers)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddPackageServer(PackageServer thePackageServer)Add a package server that can be used to fetch remote packagesStringgetPackageId(String canonicalUrl)List<PackageServer>getPackageServers()StringgetPackageUrl(String packageId)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 idAndVer)Load the package specified by the id and version specified in the idAndVer parameter.NpmPackageloadPackageFromCacheOnly(String id)Load the latest version of the identified package from the cache - it it existsabstract NpmPackageloadPackageFromCacheOnly(String id, String version)voidsetClientFactory(Function<PackageServer,PackageClient> theClientFactory)Provide a new client factory implementationvoidsetSilent(boolean silent)-
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
addPackageToCache, loadPackage
-
-
-
-
Field Detail
-
myPackageServers
protected final List<PackageServer> myPackageServers
-
silent
protected boolean silent
-
-
Constructor Detail
-
BasePackageCacheManager
public BasePackageCacheManager()
Constructor
-
BasePackageCacheManager
protected BasePackageCacheManager(@Nonnull List<PackageServer> thePackageServers)
-
-
Method Detail
-
setClientFactory
public void setClientFactory(Function<PackageServer,PackageClient> theClientFactory)
Provide a new client factory implementation
-
getPackageServers
public List<PackageServer> getPackageServers()
-
addPackageServer
public void addPackageServer(@Nonnull PackageServer thePackageServer)
Add a package server that can be used to fetch remote packages
-
loadPackageFromCacheOnly
public NpmPackage loadPackageFromCacheOnly(String id) throws IOException
Load the latest version of the identified package from the cache - it it exists- Throws:
IOException
-
loadFromPackageServer
@Nullable protected BasePackageCacheManager.InputStreamWithSrc loadFromPackageServer(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.
-
loadPackageFromCacheOnly
public abstract NpmPackage loadPackageFromCacheOnly(String id, @Nullable String version) throws IOException
- Throws:
IOException
-
getPackageUrl
public String getPackageUrl(String packageId) throws IOException
- Specified by:
getPackageUrlin interfaceIPackageCacheManager- Throws:
IOException
-
getPackageId
public String getPackageId(String canonicalUrl) throws IOException
- Specified by:
getPackageIdin interfaceIPackageCacheManager- Throws:
IOException
-
loadPackage
public NpmPackage loadPackage(String idAndVer) throws FHIRException, IOException
Description copied from interface:IPackageCacheManagerLoad the package specified by the id and version specified in the idAndVer parameter. Depending on the implementation logic, this may be from the package cache, or resolved from another service.- Specified by:
loadPackagein interfaceIPackageCacheManager- Parameters:
idAndVer- - use id#ver- Returns:
- the NPM Package or
- Throws:
FHIRExceptionIOException
-
setSilent
public void setSilent(boolean silent)
-
-