src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/MemberSubmissionAddressingExtensionHandler.java

Fri, 04 Oct 2013 16:21:34 +0100

author
mkos
date
Fri, 04 Oct 2013 16:21:34 +0100
changeset 408
b0610cd08440
parent 368
0989ad8c0860
child 637
9c07ef4934dd
permissions
-rw-r--r--

8025054: Update JAX-WS RI integration to 2.2.9-b130926.1035
Reviewed-by: chegar

ohair@286 1 /*
alanb@368 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
ohair@286 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286 4 *
ohair@286 5 * This code is free software; you can redistribute it and/or modify it
ohair@286 6 * under the terms of the GNU General Public License version 2 only, as
ohair@286 7 * published by the Free Software Foundation. Oracle designates this
ohair@286 8 * particular file as subject to the "Classpath" exception as provided
ohair@286 9 * by Oracle in the LICENSE file that accompanied this code.
ohair@286 10 *
ohair@286 11 * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286 14 * version 2 for more details (a copy is included in the LICENSE file that
ohair@286 15 * accompanied this code).
ohair@286 16 *
ohair@286 17 * You should have received a copy of the GNU General Public License version
ohair@286 18 * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286 20 *
ohair@286 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286 22 * or visit www.oracle.com if you need additional information or have any
ohair@286 23 * questions.
ohair@286 24 */
ohair@286 25
ohair@286 26 package com.sun.tools.internal.ws.wsdl.parser;
ohair@286 27
ohair@286 28 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible;
ohair@286 29 import com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext;
alanb@368 30 import com.sun.tools.internal.ws.resources.ModelerMessages;
alanb@368 31 import com.sun.tools.internal.ws.resources.WsdlMessages;
alanb@368 32 import com.sun.tools.internal.ws.util.xml.XmlUtil;
ohair@286 33 import com.sun.tools.internal.ws.wscompile.ErrorReceiver;
alanb@368 34 import com.sun.tools.internal.ws.wsdl.document.Fault;
alanb@368 35 import com.sun.tools.internal.ws.wsdl.document.Input;
alanb@368 36 import com.sun.tools.internal.ws.wsdl.document.Output;
alanb@368 37 import com.sun.xml.internal.ws.addressing.W3CAddressingMetadataConstants;
ohair@286 38 import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
ohair@286 39 import org.w3c.dom.Element;
alanb@368 40 import org.xml.sax.Locator;
ohair@286 41
ohair@286 42 import javax.xml.namespace.QName;
ohair@286 43 import java.util.Map;
ohair@286 44
alanb@368 45 import static com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionAddressingConstants.WSA_ACTION_QNAME;
alanb@368 46
ohair@286 47 /**
ohair@286 48 * @author Arun Gupta
ohair@286 49 */
ohair@286 50 public class MemberSubmissionAddressingExtensionHandler extends W3CAddressingExtensionHandler {
ohair@286 51
alanb@368 52 private ErrorReceiver errReceiver;
alanb@368 53 private boolean extensionModeOn;
alanb@368 54
alanb@368 55 public MemberSubmissionAddressingExtensionHandler(Map<String, AbstractExtensionHandler> extensionHandlerMap, ErrorReceiver env, boolean extensionModeOn) {
ohair@286 56 super(extensionHandlerMap, env);
alanb@368 57 this.errReceiver = env;
alanb@368 58 this.extensionModeOn = extensionModeOn;
ohair@286 59 }
ohair@286 60
ohair@286 61 @Override
ohair@286 62 public String getNamespaceURI() {
ohair@286 63 return AddressingVersion.MEMBER.wsdlNsUri;
ohair@286 64 }
ohair@286 65
ohair@286 66 protected QName getWSDLExtensionQName() {
ohair@286 67 return AddressingVersion.MEMBER.wsdlExtensionTag;
ohair@286 68 }
ohair@286 69
ohair@286 70 @Override
ohair@286 71 public boolean handlePortExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
ohair@286 72 // ignore any extension elements
ohair@286 73 return false;
ohair@286 74 }
ohair@286 75
alanb@368 76 @Override
alanb@368 77 public boolean handleInputExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
alanb@368 78 if (extensionModeOn) {
alanb@368 79 warn(context.getLocation(e));
alanb@368 80 String actionValue = XmlUtil.getAttributeNSOrNull(e, WSA_ACTION_QNAME);
alanb@368 81 if (actionValue == null || actionValue.equals("")) {
alanb@368 82 return warnEmptyAction(parent, context.getLocation(e));
alanb@368 83 }
alanb@368 84 ((Input) parent).setAction(actionValue);
alanb@368 85 return true;
alanb@368 86 } else {
alanb@368 87 return fail(context.getLocation(e));
alanb@368 88 }
alanb@368 89 }
alanb@368 90
alanb@368 91 private boolean fail(Locator location) {
alanb@368 92 errReceiver.warning(location,
alanb@368 93 ModelerMessages.WSDLMODELER_INVALID_IGNORING_MEMBER_SUBMISSION_ADDRESSING(
alanb@368 94 AddressingVersion.MEMBER.nsUri, W3CAddressingMetadataConstants.WSAM_NAMESPACE_NAME));
alanb@368 95 return false;
alanb@368 96 }
alanb@368 97
alanb@368 98 private void warn(Locator location) {
alanb@368 99 errReceiver.warning(location,
alanb@368 100 ModelerMessages.WSDLMODELER_WARNING_MEMBER_SUBMISSION_ADDRESSING_USED(
alanb@368 101 AddressingVersion.MEMBER.nsUri, W3CAddressingMetadataConstants.WSAM_NAMESPACE_NAME));
alanb@368 102 }
alanb@368 103
alanb@368 104 @Override
alanb@368 105 public boolean handleOutputExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
alanb@368 106 if (extensionModeOn) {
alanb@368 107 warn(context.getLocation(e));
alanb@368 108 String actionValue = XmlUtil.getAttributeNSOrNull(e, WSA_ACTION_QNAME);
alanb@368 109 if (actionValue == null || actionValue.equals("")) {
alanb@368 110 return warnEmptyAction(parent, context.getLocation(e));
alanb@368 111 }
alanb@368 112 ((Output) parent).setAction(actionValue);
alanb@368 113 return true;
alanb@368 114 } else {
alanb@368 115 return fail(context.getLocation(e));
alanb@368 116 }
alanb@368 117 }
alanb@368 118
alanb@368 119 @Override
alanb@368 120 public boolean handleFaultExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
alanb@368 121 if (extensionModeOn) {
alanb@368 122 warn(context.getLocation(e));
alanb@368 123 String actionValue = XmlUtil.getAttributeNSOrNull(e, WSA_ACTION_QNAME);
alanb@368 124 if (actionValue == null || actionValue.equals("")) {
alanb@368 125 errReceiver.warning(context.getLocation(e), WsdlMessages.WARNING_FAULT_EMPTY_ACTION(parent.getNameValue(), parent.getWSDLElementName().getLocalPart(), parent.getParent().getNameValue()));
alanb@368 126 return false; // keep compiler happy
alanb@368 127 }
alanb@368 128 ((Fault) parent).setAction(actionValue);
alanb@368 129 return true;
alanb@368 130 } else {
alanb@368 131 return fail(context.getLocation(e));
alanb@368 132 }
alanb@368 133 }
alanb@368 134
alanb@368 135 private boolean warnEmptyAction(TWSDLExtensible parent, Locator pos) {
alanb@368 136 errReceiver.warning(pos, WsdlMessages.WARNING_INPUT_OUTPUT_EMPTY_ACTION(parent.getWSDLElementName().getLocalPart(), parent.getParent().getNameValue()));
alanb@368 137 return false;
alanb@368 138 }
ohair@286 139 }

mercurial