1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.ws;
17
18 import org.apache.cxf.endpoint.Client;
19 import org.apache.cxf.feature.AbstractFeature;
20 import org.apache.cxf.interceptor.InterceptorProvider;
21 import org.openehealth.ipf.commons.audit.AuditContext;
22 import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategy;
23 import org.openehealth.ipf.commons.ihe.ws.correlation.AsynchronyCorrelator;
24 import org.openehealth.ipf.commons.ihe.ws.cxf.audit.AuditOutRequestInterceptor;
25 import org.openehealth.ipf.commons.ihe.ws.cxf.audit.AuditResponseInterceptor;
26 import org.openehealth.ipf.commons.ihe.ws.cxf.audit.WsAuditDataset;
27
28 import java.util.List;
29 import java.util.Map;
30
31
32
33
34 public class JaxWsRequestClientFactory<AuditDatasetType extends WsAuditDataset> extends JaxWsClientFactory<AuditDatasetType> {
35
36 public JaxWsRequestClientFactory(
37 WsTransactionConfiguration<AuditDatasetType> wsTransactionConfiguration,
38 String serviceUrl,
39 AuditStrategy<AuditDatasetType> auditStrategy,
40 AuditContext auditContext,
41 InterceptorProvider customInterceptors,
42 List<AbstractFeature> features,
43 Map<String, Object> properties,
44 AsynchronyCorrelator<AuditDatasetType> correlator)
45 {
46 super(wsTransactionConfiguration, serviceUrl, auditStrategy, auditContext,
47 customInterceptors, features, properties, correlator);
48 }
49
50 @Override
51 protected void configureInterceptors(Client client) {
52 super.configureInterceptors(client);
53
54
55 if (auditStrategy != null) {
56 if (wsTransactionConfiguration.isAuditRequestPayload()) {
57 installPayloadInterceptors(client);
58 }
59
60 client.getOutInterceptors().add(new AuditOutRequestInterceptor<>(
61 auditStrategy, auditContext, correlator, getWsTransactionConfiguration()));
62
63 AuditResponseInterceptor<AuditDatasetType> auditInterceptor =
64 new AuditResponseInterceptor<>(auditStrategy, auditContext, false, correlator, false);
65 client.getInInterceptors().add(auditInterceptor);
66 client.getInFaultInterceptors().add(auditInterceptor);
67 }
68 }
69 }