rename package cache operations for clarity + upgrade for version release
This commit is contained in:
parent
742dac277a
commit
364ed14c2a
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.1-SNAPSHOT</version>
|
||||
<version>3.7.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -383,7 +383,7 @@ public class ExtensionDefinitionGenerator {
|
|||
private List<StructureDefinition> loadSource() throws IOException, FHIRException {
|
||||
List<StructureDefinition> list = new ArrayList<>();
|
||||
PackageCacheManager pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||
NpmPackage npm = pcm.loadPackageCache("hl7.fhir.core", sourceVersion.toCode());
|
||||
NpmPackage npm = pcm.loadPackage("hl7.fhir.core", sourceVersion.toCode());
|
||||
if (sourceVersion == FHIRVersion._4_0_0)
|
||||
context = SimpleWorkerContext.fromPackage(npm);
|
||||
else if (sourceVersion == FHIRVersion._3_0_1)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.1-SNAPSHOT</version>
|
||||
<version>3.7.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.1-SNAPSHOT</version>
|
||||
<version>3.7.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.1-SNAPSHOT</version>
|
||||
<version>3.7.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.1-SNAPSHOT</version>
|
||||
<version>3.7.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public class TestingUtilities {
|
|||
PackageCacheManager pcm;
|
||||
try {
|
||||
pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||
fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackageCache("hl7.fhir.core", "4.0.0"));
|
||||
fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.core", "4.0.0"));
|
||||
fcontext.setUcumService(new UcumEssenceService(TestingUtilities.resourceNameToFile("ucum", "ucum-essence.xml")));
|
||||
fcontext.setExpansionProfile(new Parameters());
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -26,8 +26,8 @@ public class CDARoundTripTests {
|
|||
public void setUp() throws Exception {
|
||||
context = new SimpleWorkerContext();
|
||||
PackageCacheManager pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||
context.loadFromPackage(pcm.loadPackageCacheLatest("hl7.fhir.core"), null, "StructureDefinition");
|
||||
context.loadFromPackage(pcm.loadPackageCacheLatest("hl7.fhir.cda"), null, "StructureDefinition");
|
||||
context.loadFromPackage(pcm.loadPackage("hl7.fhir.core"), null, "StructureDefinition");
|
||||
context.loadFromPackage(pcm.loadPackage("hl7.fhir.cda"), null, "StructureDefinition");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.1-SNAPSHOT</version>
|
||||
<version>3.7.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ public class PackageCacheManager {
|
|||
boolean del = true;
|
||||
NpmPackage pck;
|
||||
try {
|
||||
pck = resolvePackage(id, ver, "xx");
|
||||
pck = loadPackageFromCacheOnly(id, ver);
|
||||
if (pck.getNpm().has("tools-version")) {
|
||||
del = pck.getNpm().get("tools-version").getAsInt() < minVer;
|
||||
}
|
||||
|
@ -247,7 +247,13 @@ public class PackageCacheManager {
|
|||
return names;
|
||||
}
|
||||
|
||||
public NpmPackage loadPackageCacheLatest(String id) throws IOException {
|
||||
/**
|
||||
* get the latest version of the package from what is in the cache
|
||||
* @param id
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public NpmPackage loadPackageFromCacheOnly(String id) throws IOException {
|
||||
String match = null;
|
||||
List<String> l = sorted(new File(cacheFolder).list());
|
||||
for (int i = l.size()-1; i >= 0; i--) {
|
||||
|
@ -259,7 +265,17 @@ public class PackageCacheManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
public NpmPackage loadPackageCache(String id, String version) throws IOException {
|
||||
/**
|
||||
* Load the identified package from the cache - it it exists
|
||||
*
|
||||
* This is for special purpose only. Generally, use the loadPackage method
|
||||
*
|
||||
* @param id
|
||||
* @param version
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public NpmPackage loadPackageFromCacheOnly(String id, String version) throws IOException {
|
||||
for (NpmPackage p : temporaryPackages) {
|
||||
if (p.name().equals(id) && ("current".equals(version) || "dev".equals(version) || p.version().equals(version)))
|
||||
return p;
|
||||
|
@ -271,7 +287,7 @@ public class PackageCacheManager {
|
|||
}
|
||||
}
|
||||
if ("dev".equals(version))
|
||||
return loadPackageCache(id, "current");
|
||||
return loadPackageFromCacheOnly(id, "current");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
@ -515,13 +531,17 @@ public class PackageCacheManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
public NpmPackage resolvePackage(String id, String v, String currentVersion) throws FHIRException, IOException {
|
||||
NpmPackage p = loadPackageCache(id, v);
|
||||
public NpmPackage loadPackage(String id) throws FHIRException, IOException {
|
||||
throw new Error("Not done yet");
|
||||
}
|
||||
|
||||
public NpmPackage loadPackage(String id, String v) throws FHIRException, IOException {
|
||||
NpmPackage p = loadPackageFromCacheOnly(id, v);
|
||||
if (p != null)
|
||||
return p;
|
||||
|
||||
if ("dev".equals(v)) {
|
||||
p = loadPackageCache(id, "current");
|
||||
p = loadPackageFromCacheOnly(id, "current");
|
||||
if (p != null)
|
||||
return p;
|
||||
v = "current";
|
||||
|
@ -560,13 +580,13 @@ public class PackageCacheManager {
|
|||
return addPackageToCache(id, v, stream);
|
||||
}
|
||||
}
|
||||
// special case: current version
|
||||
if (id.equals("hl7.fhir.core") && v.equals(currentVersion)) {
|
||||
InputStream stream = fetchFromUrlSpecific(Utilities.pathURL("http://build.fhir.org", "package.tgz"), true);
|
||||
if (stream == null)
|
||||
throw new FHIRException("Unable to find the package source for '"+id+"#"+v+"' at "+Utilities.pathURL("http://build.fhir.org", "package.tgz"));
|
||||
return addPackageToCache(id, v, stream);
|
||||
}
|
||||
// // special case: current version
|
||||
// if (id.equals("hl7.fhir.core") && v.equals(currentVersion)) {
|
||||
// InputStream stream = fetchFromUrlSpecific(Utilities.pathURL("http://build.fhir.org", "package.tgz"), true);
|
||||
// if (stream == null)
|
||||
// throw new FHIRException("Unable to find the package source for '"+id+"#"+v+"' at "+Utilities.pathURL("http://build.fhir.org", "package.tgz"));
|
||||
// return addPackageToCache(id, v, stream);
|
||||
// }
|
||||
throw new FHIRException("Unable to resolve version "+v+" for package "+id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.1-SNAPSHOT</version>
|
||||
<version>3.7.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -540,11 +540,11 @@ public class ValidationEngine {
|
|||
}
|
||||
NpmPackage pi = null;
|
||||
if (version == null) {
|
||||
pi = pcm.loadPackageCacheLatest(id);
|
||||
pi = pcm.loadPackageFromCacheOnly(id);
|
||||
if (pi != null)
|
||||
log(" ... Using version "+pi.version());
|
||||
} else
|
||||
pi = pcm.loadPackageCache(id, version);
|
||||
pi = pcm.loadPackageFromCacheOnly(id, version);
|
||||
if (pi == null) {
|
||||
return resolvePackage(id, version);
|
||||
} else
|
||||
|
@ -557,7 +557,7 @@ public class ValidationEngine {
|
|||
} catch (IOException e) {
|
||||
log("Unable to connect to build.fhir.org to check on packages");
|
||||
}
|
||||
NpmPackage pi = pcm.resolvePackage(id, v, Constants.VERSION);
|
||||
NpmPackage pi = pcm.loadPackage(id, v);
|
||||
if (pi != null && v == null)
|
||||
log(" ... Using version "+pi.version());
|
||||
return loadPackage(pi);
|
||||
|
|
Loading…
Reference in New Issue