001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.tools.ws.wsdl.parser;
038:
039: import com.sun.tools.ws.api.wsdl.TWSDLExtensible;
040: import com.sun.tools.ws.api.wsdl.TWSDLParserContext;
041: import com.sun.tools.ws.util.xml.XmlUtil;
042: import com.sun.tools.ws.wsdl.document.http.*;
043: import org.w3c.dom.Element;
044:
045: import java.util.Map;
046:
047: /**
048: * The HTTP extension handler for WSDL.
049: *
050: * @author WS Development Team
051: */
052: public class HTTPExtensionHandler extends AbstractExtensionHandler {
053:
054: public HTTPExtensionHandler(
055: Map<String, AbstractExtensionHandler> extensionHandlerMap) {
056: super (extensionHandlerMap);
057: }
058:
059: public String getNamespaceURI() {
060: return Constants.NS_WSDL_HTTP;
061: }
062:
063: public boolean handleDefinitionsExtension(
064: TWSDLParserContext context, TWSDLExtensible parent,
065: Element e) {
066: Util.fail("parsing.invalidExtensionElement", e.getTagName(), e
067: .getNamespaceURI());
068: return false;
069: }
070:
071: public boolean handleTypesExtension(
072: com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
073: TWSDLExtensible parent, Element e) {
074: Util.fail("parsing.invalidExtensionElement", e.getTagName(), e
075: .getNamespaceURI());
076: return false;
077: }
078:
079: public boolean handleBindingExtension(TWSDLParserContext context,
080: TWSDLExtensible parent, Element e) {
081: if (XmlUtil.matchesTagNS(e, HTTPConstants.QNAME_BINDING)) {
082: context.push();
083: context.registerNamespaces(e);
084:
085: HTTPBinding binding = new HTTPBinding(context
086: .getLocation(e));
087:
088: String verb = Util.getRequiredAttribute(e,
089: Constants.ATTR_VERB);
090: binding.setVerb(verb);
091:
092: parent.addExtension(binding);
093: context.pop();
094: // context.fireDoneParsingEntity(HTTPConstants.QNAME_BINDING, binding);
095: return true;
096: } else {
097: Util.fail("parsing.invalidExtensionElement",
098: e.getTagName(), e.getNamespaceURI());
099: return false;
100: }
101: }
102:
103: public boolean handleOperationExtension(TWSDLParserContext context,
104: TWSDLExtensible parent, Element e) {
105: if (XmlUtil.matchesTagNS(e, HTTPConstants.QNAME_OPERATION)) {
106: context.push();
107: context.registerNamespaces(e);
108:
109: HTTPOperation operation = new HTTPOperation(context
110: .getLocation(e));
111:
112: String location = Util.getRequiredAttribute(e,
113: Constants.ATTR_LOCATION);
114: operation.setLocation(location);
115:
116: parent.addExtension(operation);
117: context.pop();
118: // context.fireDoneParsingEntity(
119: // HTTPConstants.QNAME_OPERATION,
120: // operation);
121: return true;
122: } else {
123: Util.fail("parsing.invalidExtensionElement",
124: e.getTagName(), e.getNamespaceURI());
125: return false;
126: }
127: }
128:
129: public boolean handleInputExtension(TWSDLParserContext context,
130: TWSDLExtensible parent, Element e) {
131: if (XmlUtil.matchesTagNS(e, HTTPConstants.QNAME_URL_ENCODED)) {
132: parent.addExtension(new HTTPUrlEncoded(context
133: .getLocation(e)));
134: return true;
135: } else if (XmlUtil.matchesTagNS(e,
136: HTTPConstants.QNAME_URL_REPLACEMENT)) {
137: parent.addExtension(new HTTPUrlReplacement(context
138: .getLocation(e)));
139: return true;
140: } else {
141: Util.fail("parsing.invalidExtensionElement",
142: e.getTagName(), e.getNamespaceURI());
143: return false;
144: }
145: }
146:
147: public boolean handleOutputExtension(TWSDLParserContext context,
148: TWSDLExtensible parent, Element e) {
149: Util.fail("parsing.invalidExtensionElement", e.getTagName(), e
150: .getNamespaceURI());
151: return false;
152: }
153:
154: public boolean handleFaultExtension(TWSDLParserContext context,
155: TWSDLExtensible parent, Element e) {
156: Util.fail("parsing.invalidExtensionElement", e.getTagName(), e
157: .getNamespaceURI());
158: return false;
159: }
160:
161: public boolean handleServiceExtension(TWSDLParserContext context,
162: TWSDLExtensible parent, Element e) {
163: Util.fail("parsing.invalidExtensionElement", e.getTagName(), e
164: .getNamespaceURI());
165: return false;
166: }
167:
168: public boolean handlePortExtension(TWSDLParserContext context,
169: TWSDLExtensible parent, Element e) {
170: if (XmlUtil.matchesTagNS(e, HTTPConstants.QNAME_ADDRESS)) {
171: context.push();
172: context.registerNamespaces(e);
173:
174: HTTPAddress address = new HTTPAddress(context
175: .getLocation(e));
176:
177: String location = Util.getRequiredAttribute(e,
178: Constants.ATTR_LOCATION);
179: address.setLocation(location);
180:
181: parent.addExtension(address);
182: context.pop();
183: // context.fireDoneParsingEntity(HTTPConstants.QNAME_ADDRESS, address);
184: return true;
185: } else {
186: Util.fail("parsing.invalidExtensionElement",
187: e.getTagName(), e.getNamespaceURI());
188: return false;
189: }
190: }
191:
192: public boolean handlePortTypeExtension(TWSDLParserContext context,
193: TWSDLExtensible parent, Element e) {
194: Util.fail("parsing.invalidExtensionElement", e.getTagName(), e
195: .getNamespaceURI());
196: return false;
197: }
198: }
|