Package org.hl7.fhir.utilities.npm
Class NpmPackage
java.lang.Object
org.hl7.fhir.utilities.npm.NpmPackage
info and loader for a package
Packages may exist on disk in the cache, or purely in memory when they are loaded on the fly
Packages are contained in subfolders (see the package spec). The FHIR resources will be in "package"
- Author:
- Grahame Grieve
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassstatic interfaceclassstatic classclassclass -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanvoidcheckIndexed(String path) voidclearFolder(String folderName) date()voiddeleteFolder(String folderName) static NpmPackageempty()Factory method that starts a new empty package using the given PackageGenerator to create the manifeststatic NpmPackageempty(PackageGenerator thePackageGenerator) Factory method that starts a new empty package using the given PackageGenerator to create the manifeststatic NpmPackageextractFromTgz(InputStream tgz, String desc, String tempDir, boolean minimal) convenience method for getting the package fhir versionstatic NpmPackagefromFolder(String path) Factory method that parses a package from an extracted folderstatic NpmPackagefromFolder(String path, boolean checkIndexed) static NpmPackagefromFolder(String folder, PackageGenerator.PackageType defType, String... exemptions) static NpmPackagefromFolderMinimal(String path) Factory method that parses a package from an extracted folderstatic NpmPackagefromFolderMinimal(String path, boolean checkIndexed) static NpmPackagefromPackage(InputStream tgz) static NpmPackagefromPackage(InputStream tgz, String desc) static NpmPackagefromPackage(InputStream tgz, String desc, boolean progress) static NpmPackagestatic NpmPackagefromZip(InputStream stream, boolean dropRootFolder, String desc) special case when playing around inside the packagegetNpm()Handle to the package json filegetPath()getProvider(String folder, String file) get a stream that contains the contents of one of the files in a folderintgetSize()getTypes()Keys are resource type names, values are filenamesbooleanhasCanonical(String url) booleanhomepage()id()convenience method for getting the package id (which in NPM language is the same as the name)voidindexFolder(String path, NpmPackage.NpmPackageFolder folder) Create a package .index.json file for a package folder.booleanbooleanisCore()booleanbooleanstatic booleanstatic booleanbooleanbooleanbooleanisTx()booleanisType(PackageGenerator.PackageType template) static booleanisValidName(String pid) static booleanisValidVersion(String ver) booleanisWarned()license()Accessing the contents of the package - get a list of files in a subfolder of the packagelistAllResources(Collection<String> types) listIndexedResources(String... types) listIndexedResources(Set<String> types) listResources(String... types) listResources(Set<String> types) listResourcesinFolder(String folder, String... types) listResourcesInFolder(String folderName, Set<String> types) get a stream that contains the contents of one of the files in the base packageget a stream that contains the contents of one of the files in a foldervoidvoidloadByCanonical(String canonical) get a stream that contains the contents of a resource in the base folder, by it's canonical URLloadByCanonical(String folder, String canonical) get a stream that contains the contents of a resource in the nominated folder, by it's canonical URLloadByCanonicalVersion(String canonical, String version) get a stream that contains the contents of a resource in the base folder, by it's canonical URLloadByCanonicalVersion(String folder, String canonical, String version) get a stream that contains the contents of a resource in the nominated folder, by it's canonical URLloadExampleResource(String type, String id) voidvoidloadResource(String file) use the name from listResources()loadResource(String type, String id) name()convenience method for getting the package namevoidreadStream(InputStream tgz, String desc, boolean progress) voidvoidsave(OutputStream stream) static voidsetLoadCustomResources(boolean loadCustomResources) voidsetNpm(JsonObject npm) should only use this when npm == nullvoidsetSize(int size) voidsetWarned(boolean warned) summary()title()toString()type()voidvoidvoidvoidunPackWithAppend(String dir, List<String> files) url()version()convenience method for getting the package versionvid()
-
Method Details
-
isValidName
-
isValidVersion
-
fromFolder
Factory method that parses a package from an extracted folder- Throws:
IOException
-
fromFolder
- Throws:
IOException
-
fromFolderMinimal
Factory method that parses a package from an extracted folder- Throws:
IOException
-
fromFolderMinimal
- Throws:
IOException
-
empty
Factory method that starts a new empty package using the given PackageGenerator to create the manifest -
empty
Factory method that starts a new empty package using the given PackageGenerator to create the manifest -
getUserData
-
loadFiles
- Throws:
IOException
-
isInternalExemptFile
-
fromFolder
public static NpmPackage fromFolder(String folder, PackageGenerator.PackageType defType, String... exemptions) throws IOException - Throws:
IOException
-
fromPackage
- Throws:
IOException
-
fromPackage
- Throws:
IOException
-
fromPackage
public static NpmPackage fromPackage(InputStream tgz, String desc, boolean progress) throws IOException - Throws:
IOException
-
extractFromTgz
public static NpmPackage extractFromTgz(InputStream tgz, String desc, String tempDir, boolean minimal) throws IOException - Throws:
IOException
-
readStream
- Throws:
IOException
-
loadFile
- Throws:
IOException
-
isIndexed
- Throws:
IOException
-
checkIndexed
- Throws:
IOException
-
indexFolder
public void indexFolder(String path, NpmPackage.NpmPackageFolder folder) throws FileNotFoundException, IOException Create a package .index.json file for a package folder.See the FHIR specification for details on .index.json format and usage.
- Parameters:
path-folder-- Throws:
FileNotFoundExceptionIOException
-
fromZip
public static NpmPackage fromZip(InputStream stream, boolean dropRootFolder, String desc) throws IOException - Throws:
IOException
-
list
Accessing the contents of the package - get a list of files in a subfolder of the package- Parameters:
folder-- Returns:
- Throws:
IOException
-
listResources
- Throws:
IOException
-
listResourcesinFolder
- Throws:
IOException
-
listResources
- Throws:
IOException
-
listResourcesInFolder
- Throws:
IOException
-
listAllResources
public List<NpmPackage.PackagedResourceFile> listAllResources(Collection<String> types) throws IOException - Throws:
IOException
-
listAllResources
- Throws:
IOException
-
listIndexedResources
public List<NpmPackage.PackageResourceInformation> listIndexedResources(String... types) throws IOException - Throws:
IOException
-
listIndexedResources
public List<NpmPackage.PackageResourceInformation> listIndexedResources(Set<String> types) throws IOException - Throws:
IOException
-
loadResource
use the name from listResources()- Parameters:
file-- Returns:
- Throws:
IOException
-
loadByCanonical
get a stream that contains the contents of a resource in the base folder, by it's canonical URL- Parameters:
canonical- - the canonical URL of the resource (exact match only)- Returns:
- null if it is not found
- Throws:
IOException
-
loadByCanonical
get a stream that contains the contents of a resource in the nominated folder, by it's canonical URL- Parameters:
folder- - one of the folders in the package (main folder is "package")canonical- - the canonical URL of the resource (exact match only)- Returns:
- null if it is not found
- Throws:
IOException
-
loadByCanonicalVersion
get a stream that contains the contents of a resource in the base folder, by it's canonical URL- Parameters:
canonical- - the canonical URL of the resource (exact match only)version- - the specified version (or null if the most recent)- Returns:
- null if it is not found
- Throws:
IOException
-
loadByCanonicalVersion
public InputStream loadByCanonicalVersion(String folder, String canonical, String version) throws IOException get a stream that contains the contents of a resource in the nominated folder, by it's canonical URL- Parameters:
folder- - one of the folders in the package (main folder is "package")canonical- - the canonical URL of the resource (exact match only)version- - the specified version (or null if the most recent)- Returns:
- null if it is not found
- Throws:
IOException
-
load
get a stream that contains the contents of one of the files in the base package- Parameters:
file-- Returns:
- Throws:
IOException
-
load
get a stream that contains the contents of one of the files in a folder- Parameters:
folder-file-- Returns:
- Throws:
IOException
-
getProvider
get a stream that contains the contents of one of the files in a folder- Parameters:
folder-file-- Returns:
- Throws:
IOException
-
hasFile
- Throws:
IOException
-
getNpm
Handle to the package json file- Returns:
-
setNpm
should only use this when npm == null- Parameters:
npm-
-
name
convenience method for getting the package name- Returns:
-
id
convenience method for getting the package id (which in NPM language is the same as the name)- Returns:
-
date
-
canonical
-
version
convenience method for getting the package version- Returns:
-
fhirVersion
convenience method for getting the package fhir version- Returns:
-
summary
-
isType
-
type
-
description
-
getPath
-
dependencies
-
homepage
-
url
-
title
-
toolsVersion
-
license
-
getWebLocation
-
loadResource
- Throws:
IOException
-
loadExampleResource
- Throws:
IOException
-
getFolders
special case when playing around inside the package -
save
- Throws:
IOException
-
save
- Throws:
IOException
-
getTypes
Keys are resource type names, values are filenames -
fhirVersionList
-
dependencySummary
-
unPack
- Throws:
IOException
-
unPackWithAppend
- Throws:
IOException
-
unPack
- Throws:
IOException
-
unPack
- Throws:
IOException
-
clearFolder
-
deleteFolder
-
addFile
-
loadAllFiles
- Throws:
IOException
-
loadAllFiles
- Throws:
IOException
-
isChangedByLoader
-
isCore
-
isCoreExamples
-
isTx
-
hasCanonical
- Throws:
IOException
-
canLazyLoad
- Throws:
IOException
-
isNotForPublication
-
load
- Throws:
IOException
-
dateAsDate
-
fromUrl
- Throws:
IOException
-
toString
-
getFilePath
- Throws:
IOException
-
isMinimalMemory
-
getSize
-
setSize
-
isWarned
-
setWarned
-
vid
-
isLoadCustomResources
-
setLoadCustomResources
-
dateAsLocalDate
-