From 2e434650ea6d8bed80ff4ee9eadfa0b9049cabe8 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Tue, 5 Jan 2016 17:02:37 -0500 Subject: [PATCH] Fixed to testpage overlay for DSTU2.1 --- .../ResponseHighlighterInterceptor.java | 101 +++++++++++++----- .../validation/FhirInstanceValidatorTest.java | 5 - .../java/ca/uhn/fhir/to/BaseController.java | 2 +- .../WEB-INF/templates/tmpl-navbar-left.html | 3 +- 4 files changed, 77 insertions(+), 34 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/ResponseHighlighterInterceptor.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/ResponseHighlighterInterceptor.java index 864aa0c4d13..a4b878331c5 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/ResponseHighlighterInterceptor.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/ResponseHighlighterInterceptor.java @@ -54,6 +54,22 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter { public static final String PARAM_RAW_TRUE = "true"; public static final String PARAM_RAW = "_raw"; +// private boolean myEncodeHeaders = false; +// +// /** +// * Should headers be included in the HTML response? +// */ +// public boolean isEncodeHeaders() { +// return myEncodeHeaders; +// } +// +// /** +// * Should headers be included in the HTML response? +// */ +// public void setEncodeHeaders(boolean theEncodeHeaders) { +// myEncodeHeaders = theEncodeHeaders; +// } + private String format(String theResultBody, EncodingEnum theEncodingEnum) { String str = StringEscapeUtils.escapeHtml4(theResultBody); if (str == null || theEncodingEnum == null) { @@ -242,33 +258,66 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter { } rawB.append(PARAM_RAW).append('=').append(PARAM_RAW_TRUE); + StringBuilder b = new StringBuilder(); + b.append("\n"); + b.append(" \n"); + b.append(" \n"); + b.append(" \n"); + b.append(" \n"); + b.append("\n"); + b.append(" "); + b.append("This result is being rendered in HTML for easy viewing. Click here to disable this.

"); +// if (isEncodeHeaders()) { +// b.append("

Request Headers

"); +// b.append("
"); +// for (int next : theRequestDetails.get) +// b.append("
"); +// b.append("

Response Headers

"); +// b.append("
"); +// b.append("
"); +// b.append("

Response Body

"); +// } + b.append("
");
+		b.append(format(encoded, encoding));
+		b.append("
"); + b.append(" "); + b.append(""); //@formatter:off - String out = "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - " " + - "This result is being rendered in HTML for easy viewing. Click here to disable this.

" + - "
" + 
-		format(encoded, encoding) + 
-		"
" + - " " + - ""; + String out = b.toString(); //@formatter:on try { diff --git a/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/validation/FhirInstanceValidatorTest.java b/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/validation/FhirInstanceValidatorTest.java index 8745bdfa260..cba13f0e80a 100644 --- a/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/validation/FhirInstanceValidatorTest.java +++ b/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/validation/FhirInstanceValidatorTest.java @@ -9,19 +9,14 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -<<<<<<< HEAD import java.util.Set; -||||||| merged common ancestors -======= import java.util.zip.GZIPInputStream; ->>>>>>> 7005cd52d907eb7dbbfea6d181ad3f4c8870c03f import org.apache.commons.io.IOUtils; import org.hl7.fhir.dstu21.hapi.validation.DefaultProfileValidationSupport; diff --git a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/BaseController.java b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/BaseController.java index 7deac0a9743..ada85b3920d 100644 --- a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/BaseController.java +++ b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/BaseController.java @@ -433,7 +433,7 @@ public class BaseController { org.hl7.fhir.dstu21.model.Conformance conformance; try { - conformance = (org.hl7.fhir.dstu21.model.Conformance) client.conformance(); + conformance = client.fetchConformance().ofType(org.hl7.fhir.dstu21.model.Conformance.class).execute(); } catch (Exception e) { ourLog.warn("Failed to load conformance statement", e); theModel.put("errorMsg", "Failed to load conformance statement, error was: " + e.toString()); diff --git a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-navbar-left.html b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-navbar-left.html index 958135a08f5..4e1a309fa7d 100644 --- a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-navbar-left.html +++ b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-navbar-left.html @@ -120,8 +120,7 @@

Resources