1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.platform.camel.ihe.mllp.custom;
17
18 import lombok.Setter;
19 import org.apache.camel.CamelContext;
20 import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategy;
21 import org.openehealth.ipf.commons.ihe.hl7v2.Hl7v2TransactionConfiguration;
22 import org.openehealth.ipf.commons.ihe.hl7v2.NakFactory;
23 import org.openehealth.ipf.commons.ihe.hl7v2.audit.MllpAuditDataset;
24 import org.openehealth.ipf.platform.camel.ihe.mllp.core.MllpTransactionComponent;
25 import org.openehealth.ipf.platform.camel.ihe.mllp.core.MllpTransactionEndpointConfiguration;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 import java.util.Map;
30
31
32
33
34
35
36
37 public class CustomMllpComponent<AuditDatasetType extends MllpAuditDataset> extends MllpTransactionComponent<AuditDatasetType> {
38
39 private static final Logger LOG = LoggerFactory.getLogger(CustomMllpComponent.class);
40
41 @Setter
42 private Hl7v2TransactionConfiguration<AuditDatasetType> transactionConfiguration;
43
44 public CustomMllpComponent() {
45 super(null);
46 }
47
48 public CustomMllpComponent(CamelContext camelContext) {
49 super(camelContext, null);
50 }
51
52 @Override
53 protected MllpTransactionEndpointConfiguration createConfig(String uri, Map<String, Object> parameters) throws Exception {
54 MllpTransactionEndpointConfiguration transactionConfig = super.createConfig(uri, parameters);
55 Hl7v2TransactionConfiguration configuration = resolveAndRemoveReferenceParameter(parameters, "hl7TransactionConfig", Hl7v2TransactionConfiguration.class);
56 if (this.transactionConfiguration == null) {
57 if (configuration == null) {
58 throw new IllegalArgumentException("Must provide hl7TransactionConfig attribute with custom MLLP component");
59 } else {
60 this.transactionConfiguration = configuration;
61 }
62 } else {
63 if (configuration != null) {
64 throw new IllegalArgumentException("Must not override preconfigured hl7TransactionConfig in custom MLLP component");
65 }
66 }
67 if (transactionConfig.isAudit() && getClientAuditStrategy() == null) {
68 throw new IllegalArgumentException("Consumer or Producer require ATNA audit, but no clientAuditStrategy is defined for custom MLLP component");
69 }
70 if (transactionConfig.isAudit() && getServerAuditStrategy() == null) {
71 throw new IllegalArgumentException("Consumer or Producer require ATNA audit, but no serverAuditStrategy is defined for custom MLLP component");
72 }
73 return transactionConfig;
74 }
75
76 @Override
77 public Hl7v2TransactionConfiguration<AuditDatasetType> getHl7v2TransactionConfiguration() {
78 return transactionConfiguration;
79 }
80
81 @Override
82 public AuditStrategy<AuditDatasetType> getClientAuditStrategy() {
83 return transactionConfiguration.getClientAuditStrategy();
84 }
85
86 @Override
87 public AuditStrategy<AuditDatasetType> getServerAuditStrategy() {
88 return transactionConfiguration.getServerAuditStrategy();
89 }
90
91 @Override
92 public NakFactory<AuditDatasetType> getNakFactory() {
93 return new NakFactory(transactionConfiguration);
94 }
95
96 }