src/share/jaxws_classes/com/sun/tools/internal/ws/processor/modeler/wsdl/WSDLModelerBase.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.processor.modeler.wsdl;
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.processor.generator.Names;
31 import com.sun.tools.internal.ws.processor.model.Fault;
32 import com.sun.tools.internal.ws.processor.model.Operation;
33 import com.sun.tools.internal.ws.processor.model.Port;
34 import com.sun.tools.internal.ws.processor.model.java.JavaException;
35 import com.sun.tools.internal.ws.processor.modeler.Modeler;
36 import com.sun.tools.internal.ws.resources.ModelerMessages;
37 import com.sun.tools.internal.ws.wscompile.AbortException;
38 import com.sun.tools.internal.ws.wscompile.ErrorReceiver;
39 import com.sun.tools.internal.ws.wscompile.ErrorReceiverFilter;
40 import com.sun.tools.internal.ws.wscompile.WsimportOptions;
41 import com.sun.tools.internal.ws.wsdl.document.*;
42 import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBinding;
43 import com.sun.tools.internal.ws.wsdl.document.mime.MIMEContent;
44 import com.sun.tools.internal.ws.wsdl.document.mime.MIMEMultipartRelated;
45 import com.sun.tools.internal.ws.wsdl.document.mime.MIMEPart;
46 import com.sun.tools.internal.ws.wsdl.document.schema.SchemaKinds;
47 import com.sun.tools.internal.ws.wsdl.document.soap.*;
48 import com.sun.tools.internal.ws.wsdl.framework.Entity;
49 import com.sun.tools.internal.ws.wsdl.framework.GloballyKnown;
50 import com.sun.tools.internal.ws.wsdl.framework.NoSuchEntityException;
51 import com.sun.tools.internal.ws.wsdl.parser.WSDLParser;
52 import com.sun.tools.internal.ws.wsdl.parser.MetadataFinder;
53 import com.sun.xml.internal.ws.spi.db.BindingHelper;
54
55 import org.xml.sax.helpers.LocatorImpl;
56
57 import javax.xml.namespace.QName;
58 import java.util.*;
59
60 /**
61 *
62 * @author WS Development Team
63 *
64 * Base class for WSDL->Model classes.
65 */
66 public abstract class WSDLModelerBase implements Modeler {
67 protected final ErrorReceiverFilter errReceiver;
68 protected final WsimportOptions options;
69 protected MetadataFinder forest;
70
71
72 public WSDLModelerBase(WsimportOptions options, ErrorReceiver receiver, MetadataFinder forest) {
73 this.options = options;
74 this.errReceiver = new ErrorReceiverFilter(receiver);
75 this.forest = forest;
76 }
77
78 /**
79 *
80 * @param port
81 * @param wsdlPort
82 */
83 protected void applyPortMethodCustomization(Port port, com.sun.tools.internal.ws.wsdl.document.Port wsdlPort) {
84 if (isProvider(wsdlPort)) {
85 return;
86 }
87 JAXWSBinding jaxwsBinding = (JAXWSBinding)getExtensionOfType(wsdlPort, JAXWSBinding.class);
88
89 String portMethodName = (jaxwsBinding != null)?((jaxwsBinding.getMethodName() != null)?jaxwsBinding.getMethodName().getName():null):null;
90 if(portMethodName != null){
91 port.setPortGetter(portMethodName);
92 }else{
93 portMethodName = Names.getPortName(port);
94 portMethodName = BindingHelper.mangleNameToClassName(portMethodName);
95 port.setPortGetter("get"+portMethodName);
96 }
97
98 }
99
100 protected boolean isProvider(com.sun.tools.internal.ws.wsdl.document.Port wsdlPort){
101 JAXWSBinding portCustomization = (JAXWSBinding)getExtensionOfType(wsdlPort, JAXWSBinding.class);
102 Boolean isProvider = (portCustomization != null)?portCustomization.isProvider():null;
103 if(isProvider != null){
104 return isProvider;
105 }
106
107 JAXWSBinding jaxwsGlobalCustomization = (JAXWSBinding)getExtensionOfType(document.getDefinitions(), JAXWSBinding.class);
108 isProvider = (jaxwsGlobalCustomization != null)?jaxwsGlobalCustomization.isProvider():null;
109 if (isProvider != null) {
110 return isProvider;
111 }
112 return false;
113 }
114
115 protected SOAPBody getSOAPRequestBody() {
116 SOAPBody requestBody =
117 (SOAPBody)getAnyExtensionOfType(info.bindingOperation.getInput(),
118 SOAPBody.class);
119 if (requestBody == null) {
120 // the WSDL document is invalid
121 error(info.bindingOperation.getInput(), ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_INPUT_MISSING_SOAP_BODY(info.bindingOperation.getName()));
122 }
123 return requestBody;
124 }
125
126 protected boolean isRequestMimeMultipart() {
127 for (TWSDLExtension extension: info.bindingOperation.getInput().extensions()) {
128 if (extension.getClass().equals(MIMEMultipartRelated.class)) {
129 return true;
130 }
131 }
132 return false;
133 }
134
135 protected boolean isResponseMimeMultipart() {
136 for (TWSDLExtension extension: info.bindingOperation.getOutput().extensions()) {
137 if (extension.getClass().equals(MIMEMultipartRelated.class)) {
138 return true;
139 }
140 }
141 return false;
142 }
143
144
145
146
147 protected SOAPBody getSOAPResponseBody() {
148 SOAPBody responseBody =
149 (SOAPBody)getAnyExtensionOfType(info.bindingOperation.getOutput(),
150 SOAPBody.class);
151 if (responseBody == null) {
152 // the WSDL document is invalid
153 error(info.bindingOperation.getOutput(), ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_OUTPUT_MISSING_SOAP_BODY(info.bindingOperation.getName()));
154 }
155 return responseBody;
156 }
157
158 protected com.sun.tools.internal.ws.wsdl.document.Message getOutputMessage() {
159 if (info.portTypeOperation.getOutput() == null) {
160 return null;
161 }
162 return info.portTypeOperation.getOutput().resolveMessage(info.document);
163 }
164
165 protected com.sun.tools.internal.ws.wsdl.document.Message getInputMessage() {
166 return info.portTypeOperation.getInput().resolveMessage(info.document);
167 }
168
169 /**
170 * @param body request or response body, represents soap:body
171 * @param message Input or output message, equivalent to wsdl:message
172 * @return iterator over MessagePart
173 */
174 protected List<MessagePart> getMessageParts(
175 SOAPBody body,
176 com.sun.tools.internal.ws.wsdl.document.Message message, boolean isInput) {
177 String bodyParts = body.getParts();
178 ArrayList<MessagePart> partsList = new ArrayList<MessagePart>();
179 List<MessagePart> parts = new ArrayList<MessagePart>();
180
181 //get Mime parts
182 List mimeParts;
183 if (isInput) {
184 mimeParts = getMimeContentParts(message, info.bindingOperation.getInput());
185 } else {
186 mimeParts = getMimeContentParts(message, info.bindingOperation.getOutput());
187 }
188
189 if (bodyParts != null) {
190 StringTokenizer in = new StringTokenizer(bodyParts.trim(), " ");
191 while (in.hasMoreTokens()) {
192 String part = in.nextToken();
193 MessagePart mPart = message.getPart(part);
194 if (null == mPart) {
195 error(message, ModelerMessages.WSDLMODELER_ERROR_PARTS_NOT_FOUND(part, message.getName()));
196 }
197 mPart.setBindingExtensibilityElementKind(MessagePart.SOAP_BODY_BINDING);
198 partsList.add(mPart);
199 }
200 } else {
201 for (MessagePart mPart : message.getParts()) {
202 if (!mimeParts.contains(mPart)) {
203 mPart.setBindingExtensibilityElementKind(MessagePart.SOAP_BODY_BINDING);
204 }
205 partsList.add(mPart);
206 }
207 }
208
209 for (MessagePart mPart : message.getParts()) {
210 if (mimeParts.contains(mPart)) {
211 mPart.setBindingExtensibilityElementKind(MessagePart.WSDL_MIME_BINDING);
212 parts.add(mPart);
213 } else if(partsList.contains(mPart)) {
214 mPart.setBindingExtensibilityElementKind(MessagePart.SOAP_BODY_BINDING);
215 parts.add(mPart);
216 }
217 }
218
219 return parts;
220 }
221
222 /**
223 * @param message
224 * @return MessageParts referenced by the mime:content
225 */
226 protected List<MessagePart> getMimeContentParts(Message message, TWSDLExtensible ext) {
227 ArrayList<MessagePart> mimeContentParts = new ArrayList<MessagePart>();
228
229 for (MIMEPart mimePart : getMimeParts(ext)) {
230 MessagePart part = getMimeContentPart(message, mimePart);
231 if (part != null) {
232 mimeContentParts.add(part);
233 }
234 }
235 return mimeContentParts;
236 }
237
238 /**
239 * @param mimeParts
240 */
241 protected boolean validateMimeParts(Iterable<MIMEPart> mimeParts) {
242 boolean gotRootPart = false;
243 List<MIMEContent> mimeContents = new ArrayList<MIMEContent>();
244 for (MIMEPart mPart : mimeParts) {
245 for (TWSDLExtension obj : mPart.extensions()) {
246 if (obj instanceof SOAPBody) {
247 if (gotRootPart) {
248 warning(mPart, ModelerMessages.MIMEMODELER_INVALID_MIME_PART_MORE_THAN_ONE_SOAP_BODY(info.operation.getName().getLocalPart()));
249 return false;
250 }
251 gotRootPart = true;
252 } else if (obj instanceof MIMEContent) {
253 mimeContents.add((MIMEContent) obj);
254 }
255 }
256 if (!validateMimeContentPartNames(mimeContents)) {
257 return false;
258 }
259 if(mPart.getName() != null) {
260 warning(mPart, ModelerMessages.MIMEMODELER_INVALID_MIME_PART_NAME_NOT_ALLOWED(info.portTypeOperation.getName()));
261 }
262 }
263 return true;
264
265 }
266
267 private MessagePart getMimeContentPart(Message message, MIMEPart part) {
268 for( MIMEContent mimeContent : getMimeContents(part) ) {
269 String mimeContentPartName = mimeContent.getPart();
270 MessagePart mPart = message.getPart(mimeContentPartName);
271 //RXXXX mime:content MUST have part attribute
272 if(null == mPart) {
273 error(mimeContent, ModelerMessages.WSDLMODELER_ERROR_PARTS_NOT_FOUND(mimeContentPartName, message.getName()));
274 }
275 mPart.setBindingExtensibilityElementKind(MessagePart.WSDL_MIME_BINDING);
276 return mPart;
277 }
278 return null;
279 }
280
281 //List of mimeTypes
282 protected List<String> getAlternateMimeTypes(List<MIMEContent> mimeContents) {
283 List<String> mimeTypes = new ArrayList<String>();
284 //validateMimeContentPartNames(mimeContents.iterator());
285 // String mimeType = null;
286 for(MIMEContent mimeContent:mimeContents){
287 String mimeType = getMimeContentType(mimeContent);
288 if (!mimeTypes.contains(mimeType)) {
289 mimeTypes.add(mimeType);
290 }
291 }
292 return mimeTypes;
293 }
294
295 private boolean validateMimeContentPartNames(List<MIMEContent> mimeContents) {
296 //validate mime:content(s) in the mime:part as per R2909
297 for (MIMEContent mimeContent : mimeContents) {
298 String mimeContnetPart;
299 mimeContnetPart = getMimeContentPartName(mimeContent);
300 if(mimeContnetPart == null) {
301 warning(mimeContent, ModelerMessages.MIMEMODELER_INVALID_MIME_CONTENT_MISSING_PART_ATTRIBUTE(info.operation.getName().getLocalPart()));
302 return false;
303 }
304 }
305 return true;
306 }
307
308 protected Iterable<MIMEPart> getMimeParts(TWSDLExtensible ext) {
309 MIMEMultipartRelated multiPartRelated =
310 (MIMEMultipartRelated) getAnyExtensionOfType(ext,
311 MIMEMultipartRelated.class);
312 if(multiPartRelated == null) {
313 return Collections.emptyList();
314 }
315 return multiPartRelated.getParts();
316 }
317
318 //returns MIMEContents
319 protected List<MIMEContent> getMimeContents(MIMEPart part) {
320 List<MIMEContent> mimeContents = new ArrayList<MIMEContent>();
321 for (TWSDLExtension mimeContent : part.extensions()) {
322 if (mimeContent instanceof MIMEContent) {
323 mimeContents.add((MIMEContent) mimeContent);
324 }
325 }
326 //validateMimeContentPartNames(mimeContents.iterator());
327 return mimeContents;
328 }
329
330 private String getMimeContentPartName(MIMEContent mimeContent){
331 /*String partName = mimeContent.getPart();
332 if(partName == null){
333 throw new ModelerException("mimemodeler.invalidMimeContent.missingPartAttribute",
334 new Object[] {info.operation.getName().getLocalPart()});
335 }
336 return partName;*/
337 return mimeContent.getPart();
338 }
339
340 private String getMimeContentType(MIMEContent mimeContent){
341 String mimeType = mimeContent.getType();
342 if(mimeType == null){
343 error(mimeContent, ModelerMessages.MIMEMODELER_INVALID_MIME_CONTENT_MISSING_TYPE_ATTRIBUTE(info.operation.getName().getLocalPart()));
344 }
345 return mimeType;
346 }
347
348 /**
349 * For Document/Lit the wsdl:part should only have element attribute and
350 * for RPC/Lit or RPC/Encoded the wsdl:part should only have type attribute
351 * inside wsdl:message.
352 */
353 protected boolean isStyleAndPartMatch(
354 SOAPOperation soapOperation,
355 MessagePart part) {
356
357 // style attribute on soap:operation takes precedence over the
358 // style attribute on soap:binding
359
360 if ((soapOperation != null) && (soapOperation.getStyle() != null)) {
361 if ((soapOperation.isDocument()
362 && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
363 || (soapOperation.isRPC()
364 && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
365 return false;
366 }
367 } else {
368 if ((info.soapBinding.isDocument()
369 && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
370 || (info.soapBinding.isRPC()
371 && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
372 return false;
373 }
374 }
375
376 return true;
377 }
378
379
380
381 protected String getRequestNamespaceURI(SOAPBody body) {
382 String namespaceURI = body.getNamespace();
383 if (namespaceURI == null) {
384 if(options.isExtensionMode()){
385 return info.modelPort.getName().getNamespaceURI();
386 }
387 // the WSDL document is invalid
388 // at least, that's my interpretation of section 3.5 of the WSDL 1.1 spec!
389 error(body, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_INPUT_SOAP_BODY_MISSING_NAMESPACE(info.bindingOperation.getName()));
390 }
391 return namespaceURI;
392 }
393
394 protected String getResponseNamespaceURI(SOAPBody body) {
395 String namespaceURI = body.getNamespace();
396 if (namespaceURI == null) {
397 if(options.isExtensionMode()){
398 return info.modelPort.getName().getNamespaceURI();
399 }
400 // the WSDL document is invalid
401 // at least, that's my interpretation of section 3.5 of the WSDL 1.1 spec!
402 error(body, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_OUTPUT_SOAP_BODY_MISSING_NAMESPACE(info.bindingOperation.getName()));
403 }
404 return namespaceURI;
405 }
406
407 /**
408 * @return List of SOAPHeader extensions
409 */
410 protected List<SOAPHeader> getHeaderExtensions(TWSDLExtensible extensible) {
411 List<SOAPHeader> headerList = new ArrayList<SOAPHeader>();
412 for (TWSDLExtension extension : extensible.extensions()) {
413 if (extension.getClass()==MIMEMultipartRelated.class) {
414 for( MIMEPart part : ((MIMEMultipartRelated) extension).getParts() ) {
415 boolean isRootPart = isRootPart(part);
416 for (TWSDLExtension obj : part.extensions()) {
417 if (obj instanceof SOAPHeader) {
418 //bug fix: 5024015
419 if (!isRootPart) {
420 warning((Entity) obj, ModelerMessages.MIMEMODELER_WARNING_IGNORINGINVALID_HEADER_PART_NOT_DECLARED_IN_ROOT_PART(info.bindingOperation.getName()));
421 return new ArrayList<SOAPHeader>();
422 }
423 headerList.add((SOAPHeader) obj);
424 }
425 }
426 }
427 } else if (extension instanceof SOAPHeader) {
428 headerList.add((SOAPHeader) extension);
429 }
430 }
431 return headerList;
432 }
433
434 /**
435 * @param part
436 * @return true if part is the Root part
437 */
438 private boolean isRootPart(MIMEPart part) {
439 for (TWSDLExtension twsdlExtension : part.extensions()) {
440 if (twsdlExtension instanceof SOAPBody) {
441 return true;
442 }
443 }
444 return false;
445 }
446
447 protected Set getDuplicateFaultNames() {
448 // look for fault messages with the same soap:fault name
449 Set<QName> faultNames = new HashSet<QName>();
450 Set<QName> duplicateNames = new HashSet<QName>();
451 for( BindingFault bindingFault : info.bindingOperation.faults() ) {
452 com.sun.tools.internal.ws.wsdl.document.Fault portTypeFault = null;
453 for (com.sun.tools.internal.ws.wsdl.document.Fault aFault : info.portTypeOperation.faults()) {
454 if (aFault.getName().equals(bindingFault.getName())) {
455 if (portTypeFault != null) {
456 // the WSDL document is invalid
457 error(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NOT_UNIQUE(bindingFault.getName(),
458 info.bindingOperation.getName()));
459 } else {
460 portTypeFault = aFault;
461 }
462 }
463 }
464 if (portTypeFault == null) {
465 // the WSDL document is invalid
466 error(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NOT_FOUND(bindingFault.getName(),
467 info.bindingOperation.getName()));
468 }
469 SOAPFault soapFault =
470 (SOAPFault)getExtensionOfType(bindingFault, SOAPFault.class);
471 if (soapFault == null) {
472 // the WSDL document is invalid
473 if(options.isExtensionMode()){
474 warning(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_OUTPUT_MISSING_SOAP_FAULT(bindingFault.getName(),
475 info.bindingOperation.getName()));
476 }else {
477 error(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_OUTPUT_MISSING_SOAP_FAULT(bindingFault.getName(),
478 info.bindingOperation.getName()));
479 }
480 }
481
482 com.sun.tools.internal.ws.wsdl.document.Message faultMessage =
483 portTypeFault.resolveMessage(info.document);
484 if(faultMessage.getParts().isEmpty()) {
485 // the WSDL document is invalid
486 error(faultMessage, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_EMPTY_MESSAGE(bindingFault.getName(),
487 faultMessage.getName()));
488 }
489 // bug fix: 4852729
490 if (!options.isExtensionMode() && (soapFault != null && soapFault.getNamespace() != null)) {
491 warning(soapFault, ModelerMessages.WSDLMODELER_WARNING_R_2716_R_2726("soapbind:fault", soapFault.getName()));
492 }
493 String faultNamespaceURI = (soapFault != null && soapFault.getNamespace() != null)?soapFault.getNamespace():portTypeFault.getMessage().getNamespaceURI();
494 String faultName = faultMessage.getName();
495 QName faultQName = new QName(faultNamespaceURI, faultName);
496 if (faultNames.contains(faultQName)) {
497 duplicateNames.add(faultQName);
498 } else {
499 faultNames.add(faultQName);
500 }
501 }
502 return duplicateNames;
503 }
504
505
506 /**
507 * @param operation
508 * @return true if operation has valid body parts
509 */
510 protected boolean validateBodyParts(BindingOperation operation) {
511 boolean isRequestResponse =
512 info.portTypeOperation.getStyle()
513 == OperationStyle.REQUEST_RESPONSE;
514 List<MessagePart> inputParts = getMessageParts(getSOAPRequestBody(), getInputMessage(), true);
515 if (!validateStyleAndPart(operation, inputParts)) {
516 return false;
517 }
518
519 if(isRequestResponse){
520 List<MessagePart> outputParts = getMessageParts(getSOAPResponseBody(), getOutputMessage(), false);
521 if (!validateStyleAndPart(operation, outputParts)) {
522 return false;
523 }
524 }
525 return true;
526 }
527
528 /**
529 * @param operation
530 * @return true if operation has valid style and part
531 */
532 private boolean validateStyleAndPart(BindingOperation operation, List<MessagePart> parts) {
533 SOAPOperation soapOperation =
534 (SOAPOperation) getExtensionOfType(operation, SOAPOperation.class);
535 for (MessagePart part : parts) {
536 if (part.getBindingExtensibilityElementKind() == MessagePart.SOAP_BODY_BINDING) {
537 if (!isStyleAndPartMatch(soapOperation, part)) {
538 return false;
539 }
540 }
541 }
542 return true;
543 }
544
545 protected String getLiteralJavaMemberName(Fault fault) {
546 String javaMemberName;
547
548 QName memberName = fault.getElementName();
549 javaMemberName = fault.getJavaMemberName();
550 if (javaMemberName == null) {
551 javaMemberName = memberName.getLocalPart();
552 }
553 return javaMemberName;
554 }
555
556 /**
557 * @param ext
558 * @param message
559 * @param name
560 * @return List of MimeContents from ext
561 */
562 protected List<MIMEContent> getMimeContents(TWSDLExtensible ext, Message message, String name) {
563 for (MIMEPart mimePart : getMimeParts(ext)) {
564 List<MIMEContent> mimeContents = getMimeContents(mimePart);
565 for (MIMEContent mimeContent : mimeContents) {
566 if (mimeContent.getPart().equals(name)) {
567 return mimeContents;
568 }
569 }
570 }
571 return null;
572 }
573
574 protected String makePackageQualified(String s) {
575 if (s.indexOf(".") != -1) {
576 // s is already package qualified
577 return s;
578 } else if (options.defaultPackage != null
579 && !options.defaultPackage.equals("")) {
580 return options.defaultPackage + "." + s;
581 } else {//options.defaultPackage seems to be never null, and this is never executed
582 return s;
583 }
584
585 }
586
587
588 protected String getUniqueName(
589 com.sun.tools.internal.ws.wsdl.document.Operation operation,
590 boolean hasOverloadedOperations) {
591 if (hasOverloadedOperations) {
592 return operation.getUniqueKey().replace(' ', '_');
593 } else {
594 return operation.getName();
595 }
596 }
597
598 protected static QName getQNameOf(GloballyKnown entity) {
599 return new QName(
600 entity.getDefining().getTargetNamespaceURI(),
601 entity.getName());
602 }
603
604 protected static TWSDLExtension getExtensionOfType(
605 TWSDLExtensible extensible,
606 Class type) {
607 for (TWSDLExtension extension:extensible.extensions()) {
608 if (extension.getClass().equals(type)) {
609 return extension;
610 }
611 }
612
613 return null;
614 }
615
616 protected TWSDLExtension getAnyExtensionOfType(
617 TWSDLExtensible extensible,
618 Class type) {
619 if (extensible == null) {
620 return null;
621 }
622 for (TWSDLExtension extension:extensible.extensions()) {
623 if(extension.getClass().equals(type)) {
624 return extension;
625 }else if (extension.getClass().equals(MIMEMultipartRelated.class) &&
626 (type.equals(SOAPBody.class) || type.equals(MIMEContent.class)
627 || type.equals(MIMEPart.class))) {
628 for (MIMEPart part : ((MIMEMultipartRelated)extension).getParts()) {
629 //bug fix: 5024001
630 TWSDLExtension extn = getExtensionOfType(part, type);
631 if (extn != null) {
632 return extn;
633 }
634 }
635 }
636 }
637
638 return null;
639 }
640
641 // bug fix: 4857100
642 protected static com.sun.tools.internal.ws.wsdl.document.Message findMessage(
643 QName messageName,
644 WSDLDocument document) {
645 com.sun.tools.internal.ws.wsdl.document.Message message = null;
646 try {
647 message =
648 (com.sun.tools.internal.ws.wsdl.document.Message)document.find(
649 Kinds.MESSAGE,
650 messageName);
651 } catch (NoSuchEntityException e) {
652 }
653 return message;
654 }
655
656 protected static boolean tokenListContains(
657 String tokenList,
658 String target) {
659 if (tokenList == null) {
660 return false;
661 }
662
663 StringTokenizer tokenizer = new StringTokenizer(tokenList, " ");
664 while (tokenizer.hasMoreTokens()) {
665 String s = tokenizer.nextToken();
666 if (target.equals(s)) {
667 return true;
668 }
669 }
670 return false;
671 }
672
673 protected String getUniqueClassName(String className) {
674 int cnt = 2;
675 String uniqueName = className;
676 while (reqResNames.contains(uniqueName.toLowerCase(Locale.ENGLISH))) {
677 uniqueName = className + cnt;
678 cnt++;
679 }
680 reqResNames.add(uniqueName.toLowerCase(Locale.ENGLISH));
681 return uniqueName;
682 }
683
684 protected boolean isConflictingClassName(String name) {
685 if (_conflictingClassNames == null) {
686 return false;
687 }
688
689 return _conflictingClassNames.contains(name);
690 }
691
692 protected boolean isConflictingServiceClassName(String name) {
693 return isConflictingClassName(name);
694 }
695
696 protected boolean isConflictingStubClassName(String name) {
697 return isConflictingClassName(name);
698 }
699
700 protected boolean isConflictingTieClassName(String name) {
701 return isConflictingClassName(name);
702 }
703
704 protected boolean isConflictingPortClassName(String name) {
705 return isConflictingClassName(name);
706 }
707
708 protected boolean isConflictingExceptionClassName(String name) {
709 return isConflictingClassName(name);
710 }
711
712 int numPasses = 0;
713
714 protected void warning(Entity entity, String message){
715 //avoid duplicate warning for the second pass
716 if (numPasses > 1) {
717 return;
718 }
719 if (entity == null) {
720 errReceiver.warning(null, message);
721 } else {
722 errReceiver.warning(entity.getLocator(), message);
723 }
724 }
725
726 protected void error(Entity entity, String message){
727 if (entity == null) {
728 errReceiver.error(null, message);
729 } else {
730 errReceiver.error(entity.getLocator(), message);
731 }
732 throw new AbortException();
733 }
734
735 protected static final String OPERATION_HAS_VOID_RETURN_TYPE =
736 "com.sun.xml.internal.ws.processor.modeler.wsdl.operationHasVoidReturnType";
737 protected static final String WSDL_PARAMETER_ORDER =
738 "com.sun.xml.internal.ws.processor.modeler.wsdl.parameterOrder";
739 public static final String WSDL_RESULT_PARAMETER =
740 "com.sun.xml.internal.ws.processor.modeler.wsdl.resultParameter";
741 public static final String MESSAGE_HAS_MIME_MULTIPART_RELATED_BINDING =
742 "com.sun.xml.internal.ws.processor.modeler.wsdl.mimeMultipartRelatedBinding";
743
744
745 protected ProcessSOAPOperationInfo info;
746
747 private Set _conflictingClassNames;
748 protected Map<String,JavaException> _javaExceptions;
749 protected Map _faultTypeToStructureMap;
750 protected Map<QName, Port> _bindingNameToPortMap;
751
752 private final Set<String> reqResNames = new HashSet<String>();
753
754 public static class ProcessSOAPOperationInfo {
755
756 public ProcessSOAPOperationInfo(
757 Port modelPort,
758 com.sun.tools.internal.ws.wsdl.document.Port port,
759 com.sun.tools.internal.ws.wsdl.document.Operation portTypeOperation,
760 BindingOperation bindingOperation,
761 SOAPBinding soapBinding,
762 WSDLDocument document,
763 boolean hasOverloadedOperations,
764 Map headers) {
765 this.modelPort = modelPort;
766 this.port = port;
767 this.portTypeOperation = portTypeOperation;
768 this.bindingOperation = bindingOperation;
769 this.soapBinding = soapBinding;
770 this.document = document;
771 this.hasOverloadedOperations = hasOverloadedOperations;
772 this.headers = headers;
773 }
774
775 public Port modelPort;
776 public com.sun.tools.internal.ws.wsdl.document.Port port;
777 public com.sun.tools.internal.ws.wsdl.document.Operation portTypeOperation;
778 public BindingOperation bindingOperation;
779 public SOAPBinding soapBinding;
780 public WSDLDocument document;
781 public boolean hasOverloadedOperations;
782 public Map headers;
783
784 // additional data
785 public Operation operation;
786 }
787
788 protected WSDLParser parser;
789 protected WSDLDocument document;
790 protected static final LocatorImpl NULL_LOCATOR = new LocatorImpl();
791 }

mercurial