View Javadoc
1   /*
2    * Copyright 2009 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.ws;
17  
18  import org.openehealth.ipf.commons.ihe.core.TransactionConfiguration;
19  import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategy;
20  import org.openehealth.ipf.commons.ihe.ws.cxf.audit.WsAuditDataset;
21  
22  import javax.xml.namespace.QName;
23  
24  import static java.util.Objects.requireNonNull;
25  
26  /**
27   * Contains information about a Web Service-based transaction.
28   * All parameters are static, i. e. do not depend on the endpoint configuration.
29   */
30  public class WsTransactionConfiguration<T extends WsAuditDataset> extends TransactionConfiguration<T> {
31      private final QName bindingName;
32      private final Class<?> sei;
33      private final QName serviceName;
34      private final String wsdlLocation;
35      private final boolean mtom;
36      private final boolean addressing;
37      private final boolean swaOutSupport;
38      private final boolean auditRequestPayload;
39      private final boolean allowAsynchrony;
40  
41      /**
42       * Constructs the transaction configuration.
43       *
44       * @param name
45       *          name of the transaction.
46       * @param description
47       *          human-readable description of the transaction.
48       * @param isQuery
49       *          <code>true</code> if this transaction describes a query, <code>false</code> otherwise.
50       * @param clientAuditStrategy
51       *          {@link AuditStrategy} to be used on client side to accomplish ATNA audit.
52       * @param serverAuditStrategy
53       *          {@link AuditStrategy} to be used on server side to accomplish ATNA audit.
54       * @param serviceName
55       *          the qualified name of the service.
56       * @param sei
57       *          service endpoint interface.
58       * @param bindingName
59       *          the qualified name of the binding to use.
60       * @param mtom
61       *          {@code true} if this service requires MTOM.
62       * @param wsdlLocation
63       *          the location of the WSDL of this webservice.
64       * @param addressing
65       *          {@code true} if this service requires WS-Addressing.
66       * @param swaOutSupport
67       *          <code>true</code> if this service requires SwA for its output.
68       * @param auditRequestPayload
69       *          <code>true</code> if this service must save payload in audit record.
70       * @param allowAsynchrony
71       *      <code>true</code> if service producers should be allowed to request
72       *      asynchronous responses via WS-Addressing &lt;ReplyTo&gt; header.
73       *      (obviously does not make any sense when <code>addressing==false</code>).
74       */
75      public WsTransactionConfiguration(
76              String name,
77              String description,
78              boolean isQuery,
79              AuditStrategy<T> clientAuditStrategy,
80              AuditStrategy<T> serverAuditStrategy,
81              QName serviceName,
82              Class<?> sei,
83              QName bindingName,
84              boolean mtom,
85              String wsdlLocation,
86              boolean addressing,
87              boolean swaOutSupport,
88              boolean auditRequestPayload,
89              boolean allowAsynchrony)
90      {
91          super(name, description, isQuery, clientAuditStrategy, serverAuditStrategy);
92  
93          requireNonNull(serviceName, "serviceName");
94          requireNonNull(sei, "service endpoint interface");
95          requireNonNull(bindingName, "bindingName");
96          requireNonNull(wsdlLocation, "wsdlLocation");
97  
98          this.sei = sei;
99          this.serviceName = serviceName;
100         this.bindingName = bindingName;
101         this.mtom = mtom;
102         this.wsdlLocation = wsdlLocation;
103         this.addressing = addressing;
104         this.swaOutSupport = swaOutSupport;
105         this.auditRequestPayload = auditRequestPayload;
106         this.allowAsynchrony = allowAsynchrony;
107     }
108 
109     /**
110      * @return the qualified name of the WSDL binding to use.
111      */
112     public QName getBindingName() {
113         return bindingName;
114     }
115 
116     /**
117      * @return the qualified name of the WSDL service.
118      */
119     public QName getServiceName() {
120         return serviceName;
121     }
122 
123     /**
124      * @return the class of the service interface.
125      */
126     public Class<?> getSei() {
127         return sei;
128     }
129 
130     /**
131      * @return {@code true} if this service requires MTOM.
132      */
133     public boolean isMtom() {
134         return mtom;
135     }
136 
137     /**
138      * @return location of the WSDL document.
139      */
140     public String getWsdlLocation() {
141         return wsdlLocation;
142     }
143 
144     /**
145      * Whether WS-Addressing should be supported.  
146      * Currently affects only the client side (i.e. the Camel producer). 
147      * 
148      * @return {@code true} if this service requires WS-Addressing.
149      */
150     public boolean isAddressing() {
151         return addressing;
152     }
153 
154     /**
155      * @return <code>true</code> if this service requires SwA for its output.
156      */
157     public boolean isSwaOutSupport() {
158         return swaOutSupport;
159     }
160 
161     /**
162      * @return <code>true</code> if this service must save payload in audit record.
163      */
164     public boolean isAuditRequestPayload() {
165         return auditRequestPayload;
166     }
167 
168     /**
169      * @return
170      *      <code>true</code> if service producers sre allowed to request
171      *      asynchronous responses via WS-Addressing &lt;ReplyTo&gt; header.
172      */
173     public boolean isAllowAsynchrony() {
174         return allowAsynchrony;
175     }
176 }