diff --git a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/narrative/OperationOutcome.html b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/narrative/OperationOutcome.html
index 4041ee58967..a84249a298f 100644
--- a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/narrative/OperationOutcome.html
+++ b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/narrative/OperationOutcome.html
@@ -11,7 +11,7 @@
|
|
- |
+ |
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaResourceProviderDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaResourceProviderDstu2.java
index cbaa640b52f..cb14c240d7b 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaResourceProviderDstu2.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaResourceProviderDstu2.java
@@ -39,6 +39,7 @@ import ca.uhn.fhir.rest.annotation.Validate;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.api.ValidationModeEnum;
import ca.uhn.fhir.rest.server.EncodingEnum;
+import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
public class JpaResourceProviderDstu2 extends BaseJpaResourceProvider {
@@ -112,6 +113,9 @@ public class JpaResourceProviderDstu2 extends BaseJpaResour
})
//@formatter:on
public Parameters metaAdd(@IdParam IdDt theId, @OperationParam(name = "meta") MetaDt theMeta) {
+ if (theMeta == null) {
+ throw new InvalidRequestException("Input contains no parameter with name 'meta'");
+ }
Parameters parameters = new Parameters();
MetaDt metaAddOperation = getDao().metaAddOperation(theId, theMeta);
parameters.addParameter().setName("return").setValue(metaAddOperation);
@@ -124,6 +128,9 @@ public class JpaResourceProviderDstu2 extends BaseJpaResour
})
//@formatter:on
public Parameters metaDelete(@IdParam IdDt theId, @OperationParam(name = "meta") MetaDt theMeta) {
+ if (theMeta == null) {
+ throw new InvalidRequestException("Input contains no parameter with name 'meta'");
+ }
Parameters parameters = new Parameters();
parameters.addParameter().setName("return").setValue(getDao().metaDeleteOperation(theId, theMeta));
return parameters;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java
index 7b76e5c81d1..bf6f6cf8bc0 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java
@@ -747,6 +747,50 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
}
}
+ @Test
+ public void testMetaOperationWithNoMetaParameter() throws Exception {
+ Patient p = new Patient();
+ p.addName().addFamily("testMetaAddInvalid");
+ IIdType id = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
+
+ //@formatter:off
+ String input = "\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "
\n" +
+ " \n" +
+ "";
+ //@formatter:on
+
+ HttpPost post = new HttpPost(ourServerBase + "/Patient/" + id.getIdPart() + "/$meta-add");
+ post.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ CloseableHttpResponse response = ourHttpClient.execute(post);
+ try {
+ String output = IOUtils.toString(response.getEntity().getContent());
+ ourLog.info(output);
+ assertEquals(400, response.getStatusLine().getStatusCode());
+ assertThat(output, containsString("Input contains no parameter with name 'meta'"));
+ } finally {
+ response.close();
+ }
+
+ post = new HttpPost(ourServerBase + "/Patient/" + id.getIdPart() + "/$meta-delete");
+ post.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ response = ourHttpClient.execute(post);
+ try {
+ String output = IOUtils.toString(response.getEntity().getContent());
+ ourLog.info(output);
+ assertEquals(400, response.getStatusLine().getStatusCode());
+ assertThat(output, containsString("Input contains no parameter with name 'meta'"));
+ } finally {
+ response.close();
+ }
+
+ }
+
@Test
public void testMetaOperations() throws Exception {
String methodName = "testMetaOperations";
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTestDstu2.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTestDstu2.java
index 769e279a4f0..02e71f67872 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTestDstu2.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTestDstu2.java
@@ -116,11 +116,11 @@ public class DefaultThymeleafNarrativeGeneratorTestDstu2 {
String parse = "\n" +
" \n" +
" \n" +
- " \n" +
+ " \n" +
" \n" +
" \n" +
" \n" +
- " \n" +
+ " \n" +
" \n" +
"";
//@formatter:on
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ac61959a6b6..03e8ed1806d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -41,6 +41,14 @@
In JSON parsing, finding an object where an array was expected led to an unhelpful
error message. Thanks to Avinash Shanbhag for reporting!
+
+ JPA server gave an unhelpful error message if $meta-add or $meta-delete were called
+ with no meta elements in the input Parameters
+
+
+ Narrative generator did not include OperationOutcome.issue.diagnostics in the
+ generated narrative.
+