src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/document/BindingOperation.java

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
equal deleted inserted replaced
-1:000000000000 0:373ffda63c9a
1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.tools.internal.ws.wsdl.document;
27
28 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible;
29 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension;
30 import com.sun.tools.internal.ws.wsdl.framework.Entity;
31 import com.sun.tools.internal.ws.wsdl.framework.EntityAction;
32 import com.sun.tools.internal.ws.wsdl.framework.ExtensibilityHelper;
33 import org.xml.sax.Locator;
34
35 import javax.xml.namespace.QName;
36 import java.util.ArrayList;
37 import java.util.List;
38
39 /**
40 * Entity corresponding to the "operation" child element of a WSDL "binding" element.
41 *
42 * @author WS Development Team
43 */
44 public class BindingOperation extends Entity implements TWSDLExtensible {
45
46 public BindingOperation(Locator locator) {
47 super(locator);
48 _faults = new ArrayList<BindingFault>();
49 _helper = new ExtensibilityHelper();
50 }
51
52 public String getName() {
53 return _name;
54 }
55
56 public void setName(String name) {
57 _name = name;
58 }
59
60 public String getUniqueKey() {
61 if (_uniqueKey == null) {
62 StringBuilder sb = new StringBuilder();
63 sb.append(_name);
64 sb.append(' ');
65 if (_input != null) {
66 sb.append(_input.getName());
67 } else {
68 sb.append(_name);
69 if (_style == OperationStyle.REQUEST_RESPONSE) {
70 sb.append("Request");
71 } else if (_style == OperationStyle.SOLICIT_RESPONSE) {
72 sb.append("Response");
73 }
74 }
75 sb.append(' ');
76 if (_output != null) {
77 sb.append(_output.getName());
78 } else {
79 sb.append(_name);
80 if (_style == OperationStyle.SOLICIT_RESPONSE) {
81 sb.append("Solicit");
82 } else if (_style == OperationStyle.REQUEST_RESPONSE) {
83 sb.append("Response");
84 }
85 }
86 _uniqueKey = sb.toString();
87 }
88
89 return _uniqueKey;
90 }
91
92 public OperationStyle getStyle() {
93 return _style;
94 }
95
96 public void setStyle(OperationStyle s) {
97 _style = s;
98 }
99
100 public BindingInput getInput() {
101 return _input;
102 }
103
104 public void setInput(BindingInput i) {
105 _input = i;
106 }
107
108 public BindingOutput getOutput() {
109 return _output;
110 }
111
112 public void setOutput(BindingOutput o) {
113 _output = o;
114 }
115
116 public void addFault(BindingFault f) {
117 _faults.add(f);
118 }
119
120 public Iterable<BindingFault> faults() {
121 return _faults;
122 }
123
124 @Override
125 public QName getElementName() {
126 return WSDLConstants.QNAME_OPERATION;
127 }
128
129 public Documentation getDocumentation() {
130 return _documentation;
131 }
132
133 public void setDocumentation(Documentation d) {
134 _documentation = d;
135 }
136
137 @Override
138 public String getNameValue() {
139 return getName();
140 }
141
142 @Override
143 public String getNamespaceURI() {
144 return (parent == null) ? null : parent.getNamespaceURI();
145 }
146
147 @Override
148 public QName getWSDLElementName() {
149 return getElementName();
150 }
151
152 @Override
153 public void addExtension(TWSDLExtension e) {
154 _helper.addExtension(e);
155 }
156
157 @Override
158 public Iterable<TWSDLExtension> extensions() {
159 return _helper.extensions();
160 }
161
162 @Override
163 public TWSDLExtensible getParent() {
164 return parent;
165 }
166
167 @Override
168 public void withAllSubEntitiesDo(EntityAction action) {
169 if (_input != null) {
170 action.perform(_input);
171 }
172 if (_output != null) {
173 action.perform(_output);
174 }
175 for (BindingFault _fault : _faults) {
176 action.perform(_fault);
177 }
178 _helper.withAllSubEntitiesDo(action);
179 }
180
181 public void accept(WSDLDocumentVisitor visitor) throws Exception {
182 visitor.preVisit(this);
183 //bug fix: 4947340, extensions should be the first element
184 _helper.accept(visitor);
185 if (_input != null) {
186 _input.accept(visitor);
187 }
188 if (_output != null) {
189 _output.accept(visitor);
190 }
191 for (BindingFault _fault : _faults) {
192 _fault.accept(visitor);
193 }
194 visitor.postVisit(this);
195 }
196
197 @Override
198 public void validateThis() {
199 if (_name == null) {
200 failValidation("validation.missingRequiredAttribute", "name");
201 }
202 if (_style == null) {
203 failValidation("validation.missingRequiredProperty", "style");
204 }
205
206 // verify operation style
207 if (_style == OperationStyle.ONE_WAY) {
208 if (_input == null) {
209 failValidation("validation.missingRequiredSubEntity", "input");
210 }
211 if (_output != null) {
212 failValidation("validation.invalidSubEntity", "output");
213 }
214 if (_faults != null && !_faults.isEmpty()) {
215 failValidation("validation.invalidSubEntity", "fault");
216 }
217 }
218 }
219
220 private ExtensibilityHelper _helper;
221 private Documentation _documentation;
222 private String _name;
223 private BindingInput _input;
224 private BindingOutput _output;
225 private List<BindingFault> _faults;
226 private OperationStyle _style;
227 private String _uniqueKey;
228
229 public void setParent(TWSDLExtensible parent) {
230 this.parent = parent;
231 }
232
233 private TWSDLExtensible parent;
234 }

mercurial