Skip to content

Commit

Permalink
Fix refactor misses
Browse files Browse the repository at this point in the history
  • Loading branch information
dotasek committed Nov 11, 2024
1 parent cac080b commit 4ee4a89
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void processArchetype(String id) throws Exception {

private Document loadXml(String address) throws Exception {

HTTPResult res = ManagedWebAccess.get(address, "application/xml");
HTTPResult res = ManagedWebAccess.get("web", address, "application/xml");
res.checkThrowException();
InputStream xml = new ByteArrayInputStream(res.getContent());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.hl7.fhir.r4.test;

import org.hl7.fhir.r4.model.CapabilityStatement;
import org.hl7.fhir.r4.utils.client.FHIRToolingClient;
import org.junit.jupiter.api.Test;

import java.net.URISyntaxException;

public class VSACClientTest {
@Test
public void testVSAC() throws URISyntaxException {
FHIRToolingClient fhirToolingClient = new FHIRToolingClient("https://cts.nlm.nih.gov/fhir", "fhir/vsac");
fhirToolingClient.setTimeoutNormal(30000);
fhirToolingClient.setTimeoutExpand(30000);
CapabilityStatement cs = fhirToolingClient.getCapabilitiesStatement();
System.out.println(cs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.http.HTTPRequest;
import org.hl7.fhir.utilities.http.HTTPResult;
import org.hl7.fhir.utilities.http.ManagedWebAccess;
import org.hl7.fhir.utilities.json.JsonException;
import org.hl7.fhir.utilities.json.model.JsonArray;
import org.hl7.fhir.utilities.json.model.JsonElement;
Expand Down Expand Up @@ -428,6 +431,20 @@ private static String decompress(byte[] compressed) throws Exception {
private String getVCIIssuer(List<ValidationMessage> errors, String issuer) {
try {
JsonObject vci = org.hl7.fhir.utilities.json.parser.JsonParser.parseObjectFromUrl("https://raw.githubusercontent.com/the-commons-project/vci-directory/main/vci-issuers.json");

/* HTTPResult httpResult = ManagedWebAccess.httpCall(
new HTTPRequest().withMethod(HTTPVerb.GET).withUrl(new URL("https://raw.githubusercontent.com/the-commons-project/vci-directory/main/vci-issuers.json"))
new URL("https://raw.githubusercontent.com/the-commons-project/vci-directory/main/vci-issuers.json")
HTTPRequest.HttpMethod.GET,
null,
null,
null
)
)
*/

//JsonObject vci = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject();
for (JsonObject j : vci.getJsonObjects("participating_issuers")) {
if (issuer.equals(j.asString("iss"))) {
return j.asString("name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private ValidatedFragment addNamedElement(List<ValidatedFragment> res, String na


private HTTPResult fetchFile(String url, String ct) throws IOException {
HTTPResult res = ManagedWebAccess.get(url, ct);
HTTPResult res = ManagedWebAccess.get("web", url, ct);
res.checkThrowException();
return res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@

import java.io.File;

/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/



Expand Down Expand Up @@ -724,13 +724,13 @@ public static byte[] writeBytes(JsonObject json, boolean pretty) {
}

public static JsonObject fetchJson(String source) throws IOException {
HTTPResult res = ManagedWebAccess.get(source+"?nocache=" + System.currentTimeMillis(), "application/json, application/fhir+json");
HTTPResult res = ManagedWebAccess.get("web", source+"?nocache=" + System.currentTimeMillis(), "application/json, application/fhir+json");
res.checkThrowException();
return parseJson(res.getContent());
}

public static JsonArray fetchJsonArray(String source) throws IOException {
HTTPResult res = ManagedWebAccess.get(source+"?nocache=" + System.currentTimeMillis(), "application/json, application/fhir+json");
HTTPResult res = ManagedWebAccess.get("web",source+"?nocache=" + System.currentTimeMillis(), "application/json, application/fhir+json");
res.checkThrowException();
return parseJsonArray(res.getContent());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ private void write(StringBuilder b, JsonElement e, boolean pretty, int indent) {

private static byte[] fetch(String source) throws IOException {
String murl = source.contains("?") ? source+"&nocache=" + System.currentTimeMillis() : source+"?nocache=" + System.currentTimeMillis();
HTTPResult res = ManagedWebAccess.get(murl, "application/json, application/fhir+json");
HTTPResult res = ManagedWebAccess.get("web", murl, "application/json, application/fhir+json");
res.checkThrowException();
return res.getContent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,11 @@ private byte[] fetchFromUrlSpecific(String source, String contentType, boolean o
try {
try {
// try with cache-busting option and then try withhout in case the server doesn't support that
HTTPResult res = ManagedWebAccess.get(source + "?nocache=" + System.currentTimeMillis(), contentType);
HTTPResult res = ManagedWebAccess.get("web",source + "?nocache=" + System.currentTimeMillis(), contentType);
res.checkThrowException();
return res.getContent();
} catch (Exception e) {
HTTPResult res = ManagedWebAccess.get(source, contentType);
HTTPResult res = ManagedWebAccess.get("web", source, contentType);
res.checkThrowException();
return res.getContent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void checkSelfLink(ValidationNode vn, Element bundle, Map<String, String

private Element makeRequest(ValidationNode vn, String url) {
try {
HTTPResult result = ManagedWebAccess.get(url, "application/fhir+json");
HTTPResult result = ManagedWebAccess.get("web", url, "application/fhir+json");
if (result.getCode() >= 300) {
vn.getIssues().add(new ValidationMessage(Source.IPAValidator, IssueType.EXCEPTION, "http.request",
"HTTP Return code is "+result.getCode()+" "+result.getMessage(),
Expand Down

0 comments on commit 4ee4a89

Please sign in to comment.