From 5b46e9655a004ddfc340a74e7f11cd7a85e9b924 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Wed, 13 Jul 2016 07:59:08 -0400 Subject: [PATCH] Fix compile errors --- .../uhn/fhir/parser/JsonParserDstu3Test.java | 2 +- .../main/java/ca/uhn/fhir/to/Controller.java | 61 +++++++++++-------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/JsonParserDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/JsonParserDstu3Test.java index 4957da3c977..0b377bbbb6f 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/JsonParserDstu3Test.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/JsonParserDstu3Test.java @@ -1486,7 +1486,7 @@ public class JsonParserDstu3Test { } - @Test + @Test(expected=DataFormatException.class) public void testParseWithTrailingContent() throws Exception { //@formatter:off String bundle = "{\n" + diff --git a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java index dfc7a8b18d3..d3d5002213f 100644 --- a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java +++ b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java @@ -382,8 +382,10 @@ public class Controller extends BaseController { StringWriter clientCodeJsonStringWriter = new StringWriter(); JsonWriter clientCodeJsonWriter = new JsonWriter(clientCodeJsonStringWriter); clientCodeJsonWriter.beginObject(); - clientCodeJsonWriter.name("action");clientCodeJsonWriter.value("search"); - clientCodeJsonWriter.name("base");clientCodeJsonWriter.value((String) theModel.get("base")); + clientCodeJsonWriter.name("action"); + clientCodeJsonWriter.value("search"); + clientCodeJsonWriter.name("base"); + clientCodeJsonWriter.value((String) theModel.get("base")); CaptureInterceptor interceptor = new CaptureInterceptor(); GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor); @@ -397,22 +399,28 @@ public class Controller extends BaseController { theModel.put("errorMsg", e.toString()); return "resource"; } - clientCodeJsonWriter.name("resource");clientCodeJsonWriter.value(theReq.getParameter("resource")); + clientCodeJsonWriter.name("resource"); + clientCodeJsonWriter.value(theReq.getParameter("resource")); } else { query = search.forAllResources(); - clientCodeJsonWriter.name("resource");clientCodeJsonWriter.nullValue(); + clientCodeJsonWriter.name("resource"); + clientCodeJsonWriter.nullValue(); } if (client.getPrettyPrint() != null) { - clientCodeJsonWriter.name("pretty");clientCodeJsonWriter.value( client.getPrettyPrint().toString()); + clientCodeJsonWriter.name("pretty"); + clientCodeJsonWriter.value(client.getPrettyPrint().toString()); } else { - clientCodeJsonWriter.name("pretty");clientCodeJsonWriter.nullValue(); + clientCodeJsonWriter.name("pretty"); + clientCodeJsonWriter.nullValue(); } if (client.getEncoding() != null) { - clientCodeJsonWriter.name("format");clientCodeJsonWriter.value(client.getEncoding().getRequestContentType()); + clientCodeJsonWriter.name("format"); + clientCodeJsonWriter.value(client.getEncoding().getRequestContentType()); } else { - clientCodeJsonWriter.name("format");clientCodeJsonWriter.nullValue(); + clientCodeJsonWriter.name("format"); + clientCodeJsonWriter.nullValue(); } String outcomeDescription = "Search for Resources"; @@ -465,9 +473,11 @@ public class Controller extends BaseController { } int limitInt = Integer.parseInt(limit); query.limitTo(limitInt); - clientCodeJsonWriter.name("limit");clientCodeJsonWriter.value(limit); + clientCodeJsonWriter.name("limit"); + clientCodeJsonWriter.value(limit); } else { - clientCodeJsonWriter.name("limit");clientCodeJsonWriter.nullValue(); + clientCodeJsonWriter.name("limit"); + clientCodeJsonWriter.nullValue(); } String[] sort = theReq.getParameterValues("sort_by"); @@ -490,7 +500,7 @@ public class Controller extends BaseController { if (client.getFhirContext().getVersion().getVersion() != FhirVersionEnum.DSTU1) { query.returnBundle(client.getFhirContext().getResourceDefinition("Bundle").getImplementingClass()); } - + long start = System.currentTimeMillis(); ResultType returnsResource; try { @@ -683,7 +693,7 @@ public class Controller extends BaseController { long start = System.currentTimeMillis(); try { ourLog.info(logPrefix(theModel) + "Retrieving history for type {} ID {} since {}", new Object[] { type, id, since }); - + IHistory hist0 = client.history(); IHistoryUntyped hist1; if (isNotBlank(id)) { @@ -693,21 +703,21 @@ public class Controller extends BaseController { } else { hist1 = hist0.onServer(); } - + IHistoryTyped hist2; if (client.getFhirContext().getVersion().getVersion() == FhirVersionEnum.DSTU1) { hist2 = hist1.andReturnDstu1Bundle(); } else { hist2 = hist1.andReturnBundle(client.getFhirContext().getResourceDefinition("Bundle").getImplementingClass(IBaseBundle.class)); } - + if (since != null) { hist2.since(since); } if (limit != null) { hist2.count(limit); } - + hist2.execute(); } catch (Exception e) { returnsResource = handleClientException(client, e, theModel); @@ -718,8 +728,7 @@ public class Controller extends BaseController { } - private boolean extractSearchParamsDstu1(IBaseResource theConformance, String resourceName, TreeSet includes, TreeSet sortParams, List queries, boolean haveSearchParams, - List> queryIncludes) { + private boolean extractSearchParamsDstu1(IBaseResource theConformance, String resourceName, TreeSet includes, TreeSet sortParams, List queries, boolean haveSearchParams, List> queryIncludes) { Conformance conformance = (Conformance) theConformance; for (Rest nextRest : conformance.getRest()) { for (RestResource nextRes : nextRest.getResource()) { @@ -767,8 +776,7 @@ public class Controller extends BaseController { return haveSearchParams; } - private boolean extractSearchParamsDstu2(IBaseResource theConformance, String resourceName, TreeSet includes, TreeSet theRevIncludes, TreeSet sortParams, List queries, boolean haveSearchParams, - List> queryIncludes) { + private boolean extractSearchParamsDstu2(IBaseResource theConformance, String resourceName, TreeSet includes, TreeSet theRevIncludes, TreeSet sortParams, List queries, boolean haveSearchParams, List> queryIncludes) { ca.uhn.fhir.model.dstu2.resource.Conformance conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) theConformance; for (ca.uhn.fhir.model.dstu2.resource.Conformance.Rest nextRest : conformance.getRest()) { for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource nextRes : nextRest.getResource()) { @@ -804,8 +812,7 @@ public class Controller extends BaseController { return haveSearchParams; } - private boolean extractSearchParamsDstu3(IBaseResource theConformance, String resourceName, TreeSet includes, TreeSet theRevIncludes, TreeSet sortParams, List queries, boolean haveSearchParams, - List> queryIncludes) { + private boolean extractSearchParamsDstu3(IBaseResource theConformance, String resourceName, TreeSet includes, TreeSet theRevIncludes, TreeSet sortParams, List queries, boolean haveSearchParams, List> queryIncludes) { org.hl7.fhir.dstu3.model.Conformance conformance = (org.hl7.fhir.dstu3.model.Conformance) theConformance; for (ConformanceRestComponent nextRest : conformance.getRest()) { for (ConformanceRestResourceComponent nextRes : nextRest.getResource()) { @@ -926,10 +933,14 @@ public class Controller extends BaseController { for (String nextValue : values) { theClientCodeJsonWriter.beginObject(); - theClientCodeJsonWriter.name("type");theClientCodeJsonWriter.value(nextType); - theClientCodeJsonWriter.name("name");theClientCodeJsonWriter.value(nextName); - theClientCodeJsonWriter.name("qualifier");theClientCodeJsonWriter.value(nextQualifier); - theClientCodeJsonWriter.name("value");theClientCodeJsonWriter.value(nextValue); + theClientCodeJsonWriter.name("type"); + theClientCodeJsonWriter.value(nextType); + theClientCodeJsonWriter.name("name"); + theClientCodeJsonWriter.value(nextName); + theClientCodeJsonWriter.name("qualifier"); + theClientCodeJsonWriter.value(nextQualifier); + theClientCodeJsonWriter.name("value"); + theClientCodeJsonWriter.value(nextValue); theClientCodeJsonWriter.endObject(); if (addToWhere) { theQuery.where(new StringClientParam(nextName + nextQualifier).matches().value(nextValue));