the validator front end needs these changes (#450)
This commit is contained in:
parent
0dc44571e6
commit
dfc59882ca
|
@ -107,7 +107,7 @@ public abstract class BasePackageCacheManager implements IPackageCacheManager {
|
|||
|
||||
private String getPackageUrl(String packageId, String server) throws IOException {
|
||||
PackageClient pc = myClientFactory.apply(server);
|
||||
List<PackageClient.PackageInfo> res = pc.search(packageId, null, null, false);
|
||||
List<PackageInfo> res = pc.search(packageId, null, null, false);
|
||||
if (res.size() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -135,12 +135,12 @@ public abstract class BasePackageCacheManager implements IPackageCacheManager {
|
|||
return null;
|
||||
}
|
||||
PackageClient pc = myClientFactory.apply(server);
|
||||
List<PackageClient.PackageInfo> res = pc.search(null, canonical, null, false);
|
||||
List<PackageInfo> res = pc.search(null, canonical, null, false);
|
||||
if (res.size() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
// this is driven by HL7 Australia (http://hl7.org.au/fhir/ is the canonical url for the base package, and the root for all the others)
|
||||
for (PackageClient.PackageInfo pi : res) {
|
||||
for (PackageInfo pi : res) {
|
||||
if (canonical.equals(pi.getCanonical())) {
|
||||
return pi.getId();
|
||||
}
|
||||
|
|
|
@ -53,12 +53,10 @@ import java.io.FileNotFoundException;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.FileLock;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -207,8 +205,8 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
|
||||
private void listSpecs(Map<String, String> specList, String server) throws IOException {
|
||||
CachingPackageClient pc = new CachingPackageClient(server);
|
||||
List<PackageClient.PackageInfo> matches = pc.search(null, null, null, false);
|
||||
for (PackageClient.PackageInfo m : matches) {
|
||||
List<PackageInfo> matches = pc.search(null, null, null, false);
|
||||
for (PackageInfo m : matches) {
|
||||
if (!specList.containsKey(m.getId())) {
|
||||
specList.put(m.getId(), m.getUrl());
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@ import org.hl7.fhir.utilities.VersionUtilities;
|
|||
import org.hl7.fhir.utilities.json.JSONUtil;
|
||||
import org.hl7.fhir.utilities.json.JsonTrackingParser;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -25,51 +23,6 @@ import java.util.Set;
|
|||
|
||||
public class PackageClient {
|
||||
|
||||
public class PackageInfo {
|
||||
private String id;
|
||||
private String version;
|
||||
private String fhirVersion;
|
||||
private String description;
|
||||
private String url;
|
||||
private String canonical;
|
||||
|
||||
public PackageInfo(String id, String version, String fhirVersion, String description, String url, String canonical) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.version = version;
|
||||
this.fhirVersion = fhirVersion;
|
||||
this.description = description;
|
||||
this.url = url;
|
||||
if (url == null && id != null && version != null) {
|
||||
url = Utilities.pathURL(address, id, version);
|
||||
}
|
||||
this.canonical = canonical;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
public String getFhirVersion() {
|
||||
return fhirVersion;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getCanonical() {
|
||||
return canonical;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return id+"#"+(version == null ? "?pc-pi?" : version)+(fhirVersion == null ? "": " ("+canonical+") for FHIR "+fhirVersion)+(url == null ? "" : " @"+url)+(description == null ? "" : " '"+description+"'");
|
||||
}
|
||||
}
|
||||
|
||||
private String address;
|
||||
private String cacheFolder;
|
||||
|
||||
|
@ -124,7 +77,13 @@ public class PackageClient {
|
|||
if (versions != null) {
|
||||
for (String v : sorted(versions.keySet())) {
|
||||
JsonObject obj = versions.getAsJsonObject(v);
|
||||
res.add(new PackageInfo(JSONUtil.str(obj, "name"), JSONUtil.str(obj, "version"), JSONUtil.str(obj, "FhirVersion"), JSONUtil.str(obj, "description"), JSONUtil.str(obj, "url"), JSONUtil.str(obj, "canonical")));
|
||||
res.add(new PackageInfo(JSONUtil.str(obj, "name"),
|
||||
JSONUtil.str(obj, "version"),
|
||||
JSONUtil.str(obj, "FhirVersion"),
|
||||
JSONUtil.str(obj, "description"),
|
||||
JSONUtil.str(obj, "url"),
|
||||
JSONUtil.str(obj, "canonical"),
|
||||
address));
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
|
@ -158,7 +117,13 @@ public class PackageClient {
|
|||
JsonArray json = fetchJsonArray(Utilities.pathURL(address, "catalog?")+params.toString());
|
||||
for (JsonElement e : json) {
|
||||
JsonObject obj = (JsonObject) e;
|
||||
res.add(new PackageInfo(JSONUtil.str(obj, "Name", "name"), JSONUtil.str(obj, "Version", "version"), JSONUtil.str(obj, "FhirVersion", "fhirVersion"), JSONUtil.str(obj, "Description", "description"), JSONUtil.str(obj, "url"), JSONUtil.str(obj, "canonical")));
|
||||
res.add(new PackageInfo(JSONUtil.str(obj, "Name", "name"),
|
||||
JSONUtil.str(obj, "Version", "version"),
|
||||
JSONUtil.str(obj, "FhirVersion", "fhirVersion"),
|
||||
JSONUtil.str(obj, "Description", "description"),
|
||||
JSONUtil.str(obj, "url"),
|
||||
JSONUtil.str(obj, "canonical"),
|
||||
address));
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
|
@ -199,10 +164,10 @@ public class PackageClient {
|
|||
if (list.isEmpty()) {
|
||||
throw new IOException("Package not found: "+id);
|
||||
} else {
|
||||
String v = list.get(0).version;
|
||||
String v = list.get(0).getVersion();
|
||||
for (PackageInfo p : list) {
|
||||
if (VersionUtilities.isThisOrLater(v, p.version)) {
|
||||
v = p.version;
|
||||
if (VersionUtilities.isThisOrLater(v, p.getVersion())) {
|
||||
v = p.getVersion();
|
||||
}
|
||||
}
|
||||
return v;
|
||||
|
@ -216,8 +181,8 @@ public class PackageClient {
|
|||
} else {
|
||||
String v = majMinVersion;
|
||||
for (PackageInfo p : list) {
|
||||
if (VersionUtilities.isMajMinOrLaterPatch(v, p.version)) {
|
||||
v = p.version;
|
||||
if (VersionUtilities.isMajMinOrLaterPatch(v, p.getVersion())) {
|
||||
v = p.getVersion();
|
||||
}
|
||||
}
|
||||
return v;
|
||||
|
@ -259,7 +224,7 @@ public class PackageClient {
|
|||
}
|
||||
}
|
||||
if (version != null) {
|
||||
result.add(new PackageInfo(id, version, fVersion, description, url, pcanonical));
|
||||
result.add(new PackageInfo(id, version, fVersion, description, url, pcanonical, address));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package org.hl7.fhir.utilities.npm;
|
||||
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
public class PackageInfo {
|
||||
private final String id;
|
||||
private final String version;
|
||||
private final String fhirVersion;
|
||||
private final String description;
|
||||
private final String url;
|
||||
private final String canonical;
|
||||
|
||||
public PackageInfo(String id, String version, String fhirVersion, String description, String url, String canonical) {
|
||||
this(id, version, fhirVersion, description, url, canonical, null);
|
||||
}
|
||||
|
||||
public PackageInfo(String id, String version, String fhirVersion, String description, String url, String canonical, String address) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.version = version;
|
||||
this.fhirVersion = fhirVersion;
|
||||
this.description = description;
|
||||
if (url == null && id != null && version != null) {
|
||||
this.url = Utilities.pathURL(address, id, version);
|
||||
} else {
|
||||
this.url = url;
|
||||
}
|
||||
this.canonical = canonical;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getFhirVersion() {
|
||||
return fhirVersion;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getCanonical() {
|
||||
return canonical;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id + "#" + (version == null ? "?pc-pi?" : version) + (fhirVersion == null ? "" : " (" + canonical + ") for FHIR " + fhirVersion) + (url == null ? "" : " @" + url) + (description == null ? "" : " '" + description + "'");
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package org.hl7.fhir.utilities.tests;
|
||||
|
||||
import org.hl7.fhir.utilities.npm.CachingPackageClient;
|
||||
import org.hl7.fhir.utilities.npm.PackageClient.PackageInfo;
|
||||
import org.hl7.fhir.utilities.npm.PackageInfo;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ public class ValidationResponse {
|
|||
@JsonProperty("outcomes")
|
||||
public List<ValidationOutcome> outcomes = new ArrayList<>();
|
||||
|
||||
@JsonProperty("sessionToken")
|
||||
public String sessionToken;
|
||||
@JsonProperty("sessionId")
|
||||
public String sessionId;
|
||||
|
||||
public ValidationResponse() {}
|
||||
|
||||
|
@ -19,9 +19,9 @@ public class ValidationResponse {
|
|||
this(outcomes, null);
|
||||
}
|
||||
|
||||
public ValidationResponse(List<ValidationOutcome> outcomes, String sessionToken) {
|
||||
public ValidationResponse(List<ValidationOutcome> outcomes, String sessionId) {
|
||||
this.outcomes = outcomes;
|
||||
this.sessionToken = sessionToken;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@JsonProperty("outcomes")
|
||||
|
@ -36,13 +36,13 @@ public class ValidationResponse {
|
|||
}
|
||||
|
||||
@JsonProperty("sessionToken")
|
||||
public String getSessionToken() {
|
||||
return sessionToken;
|
||||
public String getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
@JsonProperty("sessionToken")
|
||||
public ValidationResponse setSessionToken(String sessionToken) {
|
||||
this.sessionToken = sessionToken;
|
||||
public ValidationResponse setSessionId(String sessionId) {
|
||||
this.sessionId = sessionId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.hl7.fhir.utilities.VersionUtilities;
|
|||
import org.hl7.fhir.utilities.npm.CachingPackageClient;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.PackageClient.PackageInfo;
|
||||
import org.hl7.fhir.utilities.npm.PackageInfo;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
|
||||
public class PackageValidator {
|
||||
|
|
Loading…
Reference in New Issue