Merge pull request #2338 from hapifhir/2325-channel-import-mimetype

ResourceOperation mimetype
This commit is contained in:
Tadgh 2021-02-01 17:56:01 -05:00 committed by GitHub
commit ca93cd8246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View File

@ -24,6 +24,7 @@ package ca.uhn.fhir.rest.server.messaging;
import ca.uhn.fhir.model.api.IModelJson;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.net.MediaType;
import org.apache.commons.lang3.Validate;
import javax.annotation.Nullable;
@ -43,6 +44,9 @@ public abstract class BaseResourceMessage implements IResourceMessage, IModelJso
@JsonProperty("transactionId")
private String myTransactionId;
@JsonProperty("mimeType")
private String myMimeType;
/**
* Returns an attribute stored in this message.
* <p>
@ -145,6 +149,14 @@ public abstract class BaseResourceMessage implements IResourceMessage, IModelJso
myTransactionId = theTransactionId;
}
public String getMimeType() {
return myMimeType;
}
public void setMimeType(String theMimeType) {
myMimeType = theMimeType;
}
public enum OperationTypeEnum {
CREATE,
UPDATE,

View File

@ -25,6 +25,8 @@ import ca.uhn.fhir.rest.api.server.RequestDetails;
import org.hl7.fhir.instance.model.api.IBaseResource;
public class ResourceOperationMessage extends BaseResourceModifiedMessage {
public ResourceOperationMessage() {
}
@ -35,4 +37,12 @@ public class ResourceOperationMessage extends BaseResourceModifiedMessage {
public ResourceOperationMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
super(theFhirContext, theNewResource, theOperationType, theRequest);
}
/**
* If you are using a non-fhir-resource payload, you may set the payload directly here instead of using the constructor.
* @param thePayload the payload of the message.
*/
public void setPayload(String thePayload) {
this.myPayload = thePayload;
}
}

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.messaging;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.server.messaging.json.ResourceOperationJsonMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -17,7 +18,9 @@ class ResourceOperationMessageTest {
@Test
public void testSerializationAndDeserializationOfResourceModifiedMessage() throws JsonProcessingException {
ResourceOperationJsonMessage jsonMessage = new ResourceOperationJsonMessage();
jsonMessage.setPayload(new ResourceOperationMessage());
ResourceOperationMessage payload = new ResourceOperationMessage();
payload.setMimeType(Constants.CT_FHIR_JSON_NEW);
jsonMessage.setPayload(payload);
ObjectMapper mapper = new ObjectMapper();
String serialized = mapper.writeValueAsString(jsonMessage);
jsonMessage = mapper.readValue(serialized, ResourceOperationJsonMessage.class);