1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.platform.camel.ihe.ws;
17
18 import org.apache.camel.impl.DefaultComponent;
19 import org.apache.cxf.feature.AbstractFeature;
20 import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
21 import org.apache.cxf.interceptor.Interceptor;
22 import org.apache.cxf.interceptor.InterceptorProvider;
23 import org.apache.cxf.message.Message;
24 import org.openehealth.ipf.commons.audit.AuditContext;
25 import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategy;
26 import org.openehealth.ipf.commons.ihe.ws.WsInteractionId;
27 import org.openehealth.ipf.commons.ihe.ws.WsTransactionConfiguration;
28 import org.openehealth.ipf.commons.ihe.ws.cxf.audit.WsAuditDataset;
29 import org.openehealth.ipf.platform.camel.ihe.atna.AuditableComponent;
30 import org.openehealth.ipf.platform.camel.ihe.atna.util.AuditConfiguration;
31
32 import java.util.List;
33 import java.util.Map;
34
35
36
37
38
39
40
41
42 abstract public class AbstractWsComponent<
43 AuditDatasetType extends WsAuditDataset,
44 ConfigType extends WsTransactionConfiguration<AuditDatasetType>,
45 InteractionIdType extends WsInteractionId<ConfigType>>
46 extends DefaultComponent implements AuditableComponent<AuditDatasetType> {
47
48 private final InteractionIdType interactionId;
49
50 public AbstractWsComponent(InteractionIdType interactionId) {
51 this.interactionId = interactionId;
52 }
53
54 public InteractionIdType getInteractionId() {
55 return interactionId;
56 }
57
58 protected InterceptorProvider getCustomInterceptors(Map<String, Object> parameters) {
59 AbstractBasicInterceptorProvider provider = new AbstractBasicInterceptorProvider() {
60 };
61 provider.setInInterceptors(castList(resolveAndRemoveReferenceListParameter(
62 parameters, "inInterceptors", Interceptor.class)));
63 provider.setInFaultInterceptors(castList(resolveAndRemoveReferenceListParameter(
64 parameters, "inFaultInterceptors", Interceptor.class)));
65 provider.setOutInterceptors(castList(resolveAndRemoveReferenceListParameter(
66 parameters, "outInterceptors", Interceptor.class)));
67 provider.setOutFaultInterceptors(castList(resolveAndRemoveReferenceListParameter(
68 parameters, "outFaultInterceptors", Interceptor.class)));
69 return provider;
70 }
71
72 protected AuditContext getAuditContext(Map<String, Object> parameters) {
73 return AuditConfiguration.obtainAuditContext(this, parameters);
74 }
75
76 @SuppressWarnings({"unchecked", "rawtypes"})
77 private List<Interceptor<? extends Message>> castList(
78 List<Interceptor> param) {
79 return (List<Interceptor<? extends Message>>) (List<?>) param;
80 }
81
82 protected List<AbstractFeature> getFeatures(Map<String, Object> parameters) {
83 return resolveAndRemoveReferenceListParameter(parameters, "features", AbstractFeature.class);
84 }
85
86 protected List<String> getSchemaLocations(Map<String, Object> parameters) {
87 return resolveAndRemoveReferenceListParameter(parameters, "schemaLocations", String.class);
88 }
89
90 protected Map<String, Object> getProperties(Map<String, Object> parameters) {
91 List<Map> mapList = resolveAndRemoveReferenceListParameter(parameters, "properties", Map.class);
92 return (mapList != null && mapList.size() == 1) ? mapList.get(0) : null;
93 }
94
95 @Override
96 public AuditStrategy<AuditDatasetType> getClientAuditStrategy() {
97 return getWsTransactionConfiguration().getClientAuditStrategy();
98 }
99
100 @Override
101 public AuditStrategy<AuditDatasetType> getServerAuditStrategy() {
102 return getWsTransactionConfiguration().getServerAuditStrategy();
103 }
104
105
106
107
108
109 public ConfigType getWsTransactionConfiguration() {
110 return interactionId.getWsTransactionConfiguration();
111 }
112 }