Rename to ResourceOperationMessage

This commit is contained in:
Tadgh 2020-09-15 18:57:55 -04:00
parent 3ca1a42d37
commit 74bba9dbcc
8 changed files with 78 additions and 79 deletions

View File

@ -1620,7 +1620,7 @@ public enum Pointcut {
* <p>
* Hooks may accept the following parameters:
* <ul>
* <li>ca.uhn.fhir.rest.server.messaging.ConcreteResourceModifiedMessage- This parameter should not be modified as processing is complete when this hook is invoked.</li>
* <li>ca.uhn.fhir.rest.server.messaging.ResourceOperationMessage - This parameter should not be modified as processing is complete when this hook is invoked.</li>
* <li>ca.uhn.fhir.empi.model.TransactionLogMessages - This parameter is for informational messages provided by the EMPI module during EMPI procesing. .</li>
* </ul>
* </p>
@ -1628,7 +1628,7 @@ public enum Pointcut {
* Hooks should return <code>void</code>.
* </p>
*/
EMPI_AFTER_PERSISTED_RESOURCE_CHECKED(void.class, "ca.uhn.fhir.rest.server.messaging.ConcreteResourceModifiedMessage", "ca.uhn.fhir.rest.server.TransactionLogMessages"),
EMPI_AFTER_PERSISTED_RESOURCE_CHECKED(void.class, "ca.uhn.fhir.rest.server.messaging.ResourceOperationMessage", "ca.uhn.fhir.rest.server.TransactionLogMessages"),
/**
* <b>Performance Tracing Hook:</b>

View File

@ -33,7 +33,7 @@ import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.rest.server.TransactionLogMessages;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.messaging.ConcreteResourceModifiedMessage;
import ca.uhn.fhir.rest.server.messaging.ResourceOperationMessage;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@ -96,12 +96,11 @@ public class EmpiMessageHandler implements MessageHandler {
} finally {
// Interceptor call: EMPI_AFTER_PERSISTED_RESOURCE_CHECKED
ConcreteResourceModifiedMessage outgoingMsg = new ConcreteResourceModifiedMessage(myFhirContext, theMsg.getPayload(myFhirContext), theMsg.getOperationType());
ResourceOperationMessage outgoingMsg = new ResourceOperationMessage(myFhirContext, theMsg.getPayload(myFhirContext), theMsg.getOperationType());
outgoingMsg.setTransactionId(theMsg.getTransactionId());
HookParams params = new HookParams()
//Janky upcast.
.add(ConcreteResourceModifiedMessage.class,outgoingMsg)
.add(ResourceOperationMessage.class, outgoingMsg)
.add(TransactionLogMessages.class, empiContext.getTransactionLogMessages());
myInterceptorBroadcaster.callHooks(Pointcut.EMPI_AFTER_PERSISTED_RESOURCE_CHECKED, params);
}

View File

@ -113,7 +113,7 @@ public abstract class BaseResourceMessage implements IResourceMessage, IModelJso
}
/**
* Adds a transcation ID to this message. This ID can be used for many purposes. For example, performing tracing
* Adds a transaction ID to this message. This ID can be used for many purposes. For example, performing tracing
* across asynchronous hooks, tying data together, or downstream logging purposes.
*
* One current internal implementation uses this field to tie back EMPI processing results (which are asynchronous)

View File

@ -1,18 +0,0 @@
package ca.uhn.fhir.rest.server.messaging;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import org.hl7.fhir.instance.model.api.IBaseResource;
public class ConcreteResourceModifiedMessage extends BaseResourceModifiedMessage {
public ConcreteResourceModifiedMessage() {
}
public ConcreteResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
super(theFhirContext, theResource, theOperationType);
}
public ConcreteResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
super(theFhirContext, theNewResource, theOperationType, theRequest);
}
}

View File

@ -0,0 +1,18 @@
package ca.uhn.fhir.rest.server.messaging;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import org.hl7.fhir.instance.model.api.IBaseResource;
public class ResourceOperationMessage extends BaseResourceModifiedMessage {
public ResourceOperationMessage() {
}
public ResourceOperationMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
super(theFhirContext, theResource, theOperationType);
}
public ResourceOperationMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
super(theFhirContext, theNewResource, theOperationType, theRequest);
}
}

View File

@ -1,49 +0,0 @@
package ca.uhn.fhir.rest.server.messaging.json;
import ca.uhn.fhir.rest.server.messaging.ConcreteResourceModifiedMessage;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
public class ConcreteResourceModifiedJsonMessage extends BaseJsonMessage<ConcreteResourceModifiedMessage> {
@JsonProperty("payload")
private ConcreteResourceModifiedMessage myPayload;
/**
* Constructor
*/
public ConcreteResourceModifiedJsonMessage() {
super();
}
/**
* Constructor
*/
public ConcreteResourceModifiedJsonMessage(ConcreteResourceModifiedMessage thePayload) {
myPayload = thePayload;
setDefaultRetryHeaders();
}
public ConcreteResourceModifiedJsonMessage(HapiMessageHeaders theRetryMessageHeaders, ConcreteResourceModifiedMessage thePayload) {
myPayload = thePayload;
setHeaders(theRetryMessageHeaders);
}
@Override
public ConcreteResourceModifiedMessage getPayload() {
return myPayload;
}
public void setPayload(ConcreteResourceModifiedMessage thePayload) {
myPayload = thePayload;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("myPayload", myPayload)
.toString();
}
}

View File

@ -0,0 +1,49 @@
package ca.uhn.fhir.rest.server.messaging.json;
import ca.uhn.fhir.rest.server.messaging.ResourceOperationMessage;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
public class ResourceOperationJsonMessage extends BaseJsonMessage<ResourceOperationMessage> {
@JsonProperty("payload")
private ResourceOperationMessage myPayload;
/**
* Constructor
*/
public ResourceOperationJsonMessage() {
super();
}
/**
* Constructor
*/
public ResourceOperationJsonMessage(ResourceOperationMessage thePayload) {
myPayload = thePayload;
setDefaultRetryHeaders();
}
public ResourceOperationJsonMessage(HapiMessageHeaders theRetryMessageHeaders, ResourceOperationMessage thePayload) {
myPayload = thePayload;
setHeaders(theRetryMessageHeaders);
}
@Override
public ResourceOperationMessage getPayload() {
return myPayload;
}
public void setPayload(ResourceOperationMessage thePayload) {
myPayload = thePayload;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("myPayload", myPayload)
.toString();
}
}

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.rest.server.messaging;
import ca.uhn.fhir.rest.server.messaging.json.ConcreteResourceModifiedJsonMessage;
import ca.uhn.fhir.rest.server.messaging.json.ResourceOperationJsonMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
@ -12,15 +12,15 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
class ConcreteResourceModifiedMessageTest {
class ResourceOperationMessageTest {
@Test
public void testSerializationAndDeserializationOfResourceModifiedMessage() throws JsonProcessingException {
ConcreteResourceModifiedJsonMessage jsonMessage = new ConcreteResourceModifiedJsonMessage();
jsonMessage.setPayload(new ConcreteResourceModifiedMessage());
ResourceOperationJsonMessage jsonMessage = new ResourceOperationJsonMessage();
jsonMessage.setPayload(new ResourceOperationMessage());
ObjectMapper mapper = new ObjectMapper();
String serialized = mapper.writeValueAsString(jsonMessage);
jsonMessage = mapper.readValue(serialized, ConcreteResourceModifiedJsonMessage.class);
jsonMessage = mapper.readValue(serialized, ResourceOperationJsonMessage.class);
assertThat(jsonMessage.getHapiHeaders().getRetryCount(), is(equalTo(0)));
assertThat(jsonMessage.getHapiHeaders().getFirstFailureDate(), is(equalTo(null)));