diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/demographics/ConvertAndSendDemographicsUsecase.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/demographics/ConvertAndSendDemographicsUsecase.java index 210d6141d..4b99aecfa 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/demographics/ConvertAndSendDemographicsUsecase.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/demographics/ConvertAndSendDemographicsUsecase.java @@ -2,8 +2,8 @@ import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException; import gov.hhs.cdc.trustedintermediary.etor.orders.OrderSender; +import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleExecutionException; import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleEngine; -import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleException; import gov.hhs.cdc.trustedintermediary.external.hapi.HapiOrder; import javax.inject.Inject; import org.hl7.fhir.r4.model.Bundle; @@ -30,7 +30,7 @@ private ConvertAndSendDemographicsUsecase() {} public void convertAndSend(Demographics demographics) throws UnableToSendMessageException { try { transformationEngine.runRules(demographics); - } catch (TransformationRuleException e) { + } catch (RuleExecutionException e) { throw new UnableToSendMessageException("Error running transformation rules", e); } var order = new HapiOrder((Bundle) demographics.getUnderlyingResource()); diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCase.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCase.java index 65044bc01..a342eb9aa 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCase.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCase.java @@ -5,8 +5,8 @@ import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException; import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadata; import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadataMessageType; +import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleExecutionException; import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleEngine; -import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleException; import gov.hhs.cdc.trustedintermediary.wrappers.Logger; import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata; import javax.inject.Inject; @@ -45,7 +45,7 @@ public void convertAndSend(final Order order, String receivedSubmissionId) try { transformationEngine.runRules(order); - } catch (TransformationRuleException e) { + } catch (RuleExecutionException e) { throw new UnableToSendMessageException("Error running transformation rules", e); } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCase.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCase.java index 90e95c6d6..f8f3dccaa 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCase.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCase.java @@ -5,8 +5,8 @@ import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException; import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadata; import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadataMessageType; +import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleExecutionException; import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleEngine; -import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleException; import gov.hhs.cdc.trustedintermediary.wrappers.Logger; import javax.inject.Inject; @@ -46,7 +46,7 @@ public void convertAndSend(Result result, String receivedSubmissionId) try { transformationEngine.runRules(result); - } catch (TransformationRuleException e) { + } catch (RuleExecutionException e) { throw new UnableToSendMessageException("Error running transformation rules", e); } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/Rule.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/Rule.java index 58453bb64..0a9ab78ff 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/Rule.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/Rule.java @@ -79,7 +79,7 @@ public boolean shouldRun(FhirResource resource) { }); } - public void runRule(FhirResource resource) { + public void runRule(FhirResource resource) throws RuleExecutionException { throw new UnsupportedOperationException("This method must be implemented by subclasses."); } } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/RuleExecutionException.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/RuleExecutionException.java new file mode 100644 index 000000000..4a88f1bb7 --- /dev/null +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/RuleExecutionException.java @@ -0,0 +1,7 @@ +package gov.hhs.cdc.trustedintermediary.etor.ruleengine; + +public class RuleExecutionException extends Exception { + public RuleExecutionException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRule.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRule.java index b98b3134e..808eaa6f5 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRule.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRule.java @@ -2,6 +2,7 @@ import gov.hhs.cdc.trustedintermediary.etor.ruleengine.FhirResource; import gov.hhs.cdc.trustedintermediary.etor.ruleengine.Rule; +import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleExecutionException; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Map; @@ -34,7 +35,7 @@ public TransformationRule( } @Override - public void runRule(FhirResource resource) throws TransformationRuleException { + public void runRule(FhirResource resource) throws RuleExecutionException { for (TransformationRuleMethod transformation : this.getRules()) { applyTransformation(transformation, resource); } @@ -42,7 +43,7 @@ public void runRule(FhirResource resource) throws TransformationRuleException private void applyTransformation( TransformationRuleMethod transformation, FhirResource resource) - throws TransformationRuleException { + throws RuleExecutionException { String name = transformation.name(); Map args = transformation.args(); logger.logInfo("Applying transformation: ", name); @@ -54,7 +55,7 @@ private void applyTransformation( | IllegalAccessException | InvocationTargetException | InstantiationException e) { - throw new TransformationRuleException("Error invoking method: " + name, e); + throw new RuleExecutionException("Error invoking method: " + name, e); } } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRuleEngine.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRuleEngine.java index 0b43b75e7..c79312cc9 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRuleEngine.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRuleEngine.java @@ -2,6 +2,7 @@ import gov.hhs.cdc.trustedintermediary.etor.ruleengine.FhirResource; import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleEngine; +import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleExecutionException; import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleLoader; import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleLoaderException; import gov.hhs.cdc.trustedintermediary.wrappers.Logger; @@ -53,7 +54,7 @@ public void ensureRulesLoaded() throws RuleLoaderException { } @Override - public void runRules(FhirResource resource) throws TransformationRuleException { + public void runRules(FhirResource resource) throws RuleExecutionException { try { ensureRulesLoaded(); } catch (RuleLoaderException e) { diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRuleException.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRuleException.java deleted file mode 100644 index e1af307c0..000000000 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/TransformationRuleException.java +++ /dev/null @@ -1,7 +0,0 @@ -package gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation; - -public class TransformationRuleException extends Exception { - public TransformationRuleException(String message, Throwable cause) { - super(message, cause); - } -}