1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.platform.camel.ihe.hl7v2.intercept;
17
18 import ca.uhn.hl7v2.model.Message;
19 import org.apache.camel.Exchange;
20 import org.openehealth.ipf.commons.ihe.hl7v2.Hl7v2TransactionConfiguration;
21 import org.openehealth.ipf.platform.camel.core.util.Exchanges;
22 import org.openehealth.ipf.platform.camel.ihe.core.InterceptorSupport;
23 import org.openehealth.ipf.platform.camel.ihe.hl7v2.HL7v2Endpoint;
24
25
26
27
28
29
30 public class AcceptanceInterceptorUtils {
31
32 private AcceptanceInterceptorUtils() {
33 throw new IllegalStateException("Helper class");
34 }
35
36
37
38
39
40 public static void processRequest(
41 InterceptorSupport<HL7v2Endpoint> interceptor,
42 Exchange exchange) throws Exception
43 {
44
45 Hl7v2TransactionConfiguration config = interceptor.getEndpoint().getHl7v2TransactionConfiguration();
46 config.checkRequestAcceptance(exchange.getIn().getBody(Message.class));
47
48
49 interceptor.getWrappedProcessor().process(exchange);
50 }
51
52
53
54
55
56 public static void processResponse(
57 InterceptorSupport<HL7v2Endpoint> interceptor,
58 Exchange exchange) throws Exception
59 {
60
61 interceptor.getWrappedProcessor().process(exchange);
62
63
64 Hl7v2TransactionConfiguration config = interceptor.getEndpoint().getHl7v2TransactionConfiguration();
65 config.checkResponseAcceptance(Exchanges.resultMessage(exchange).getBody(Message.class));
66 }
67 }