Merge pull request #2338 from hapifhir/2325-channel-import-mimetype
ResourceOperation mimetype
This commit is contained in:
commit
ca93cd8246
|
@ -24,6 +24,7 @@ package ca.uhn.fhir.rest.server.messaging;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IModelJson;
|
import ca.uhn.fhir.model.api.IModelJson;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.google.common.net.MediaType;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -43,6 +44,9 @@ public abstract class BaseResourceMessage implements IResourceMessage, IModelJso
|
||||||
@JsonProperty("transactionId")
|
@JsonProperty("transactionId")
|
||||||
private String myTransactionId;
|
private String myTransactionId;
|
||||||
|
|
||||||
|
@JsonProperty("mimeType")
|
||||||
|
private String myMimeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an attribute stored in this message.
|
* Returns an attribute stored in this message.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -145,6 +149,14 @@ public abstract class BaseResourceMessage implements IResourceMessage, IModelJso
|
||||||
myTransactionId = theTransactionId;
|
myTransactionId = theTransactionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMimeType() {
|
||||||
|
return myMimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMimeType(String theMimeType) {
|
||||||
|
myMimeType = theMimeType;
|
||||||
|
}
|
||||||
|
|
||||||
public enum OperationTypeEnum {
|
public enum OperationTypeEnum {
|
||||||
CREATE,
|
CREATE,
|
||||||
UPDATE,
|
UPDATE,
|
||||||
|
|
|
@ -25,6 +25,8 @@ import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
|
||||||
public class ResourceOperationMessage extends BaseResourceModifiedMessage {
|
public class ResourceOperationMessage extends BaseResourceModifiedMessage {
|
||||||
|
|
||||||
|
|
||||||
public ResourceOperationMessage() {
|
public ResourceOperationMessage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,4 +37,12 @@ public class ResourceOperationMessage extends BaseResourceModifiedMessage {
|
||||||
public ResourceOperationMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
|
public ResourceOperationMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
|
||||||
super(theFhirContext, theNewResource, theOperationType, 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ca.uhn.fhir.rest.server.messaging;
|
package ca.uhn.fhir.rest.server.messaging;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
import ca.uhn.fhir.rest.server.messaging.json.ResourceOperationJsonMessage;
|
import ca.uhn.fhir.rest.server.messaging.json.ResourceOperationJsonMessage;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -17,7 +18,9 @@ class ResourceOperationMessageTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSerializationAndDeserializationOfResourceModifiedMessage() throws JsonProcessingException {
|
public void testSerializationAndDeserializationOfResourceModifiedMessage() throws JsonProcessingException {
|
||||||
ResourceOperationJsonMessage jsonMessage = new ResourceOperationJsonMessage();
|
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();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String serialized = mapper.writeValueAsString(jsonMessage);
|
String serialized = mapper.writeValueAsString(jsonMessage);
|
||||||
jsonMessage = mapper.readValue(serialized, ResourceOperationJsonMessage.class);
|
jsonMessage = mapper.readValue(serialized, ResourceOperationJsonMessage.class);
|
||||||
|
|
Loading…
Reference in New Issue