All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.sun.tools.ws.wsdl.parser.MIMEExtensionHandler Maven / Gradle / Ivy
Go to download
Open source Reference Implementation of JSR-224: Java API for XML Web Services
/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the license at
* https://glassfish.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at https://glassfish.dev.java.net/public/CDDLv1.0.html.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* you own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Copyright 2006 Sun Microsystems Inc. All Rights Reserved
*/
package com.sun.tools.ws.wsdl.parser;
import com.sun.tools.ws.api.wsdl.TWSDLExtensible;
import com.sun.tools.ws.api.wsdl.TWSDLParserContext;
import com.sun.tools.ws.util.xml.XmlUtil;
import com.sun.tools.ws.wsdl.document.WSDLConstants;
import com.sun.tools.ws.wsdl.document.mime.*;
import org.w3c.dom.Element;
import java.util.Iterator;
import java.util.Map;
/**
* The MIME extension handler for WSDL.
*
* @author WS Development Team
*/
public class MIMEExtensionHandler extends AbstractExtensionHandler {
public MIMEExtensionHandler(Map extensionHandlerMap) {
super(extensionHandlerMap);
}
public String getNamespaceURI() {
return Constants.NS_WSDL_MIME;
}
@Override
public boolean doHandleExtension(
TWSDLParserContext context,
TWSDLExtensible parent,
Element e) {
if (parent.getWSDLElementName().equals(WSDLConstants.QNAME_OUTPUT)) {
return handleInputOutputExtension(context, parent, e);
} else if (parent.getWSDLElementName().equals(WSDLConstants.QNAME_INPUT)) {
return handleInputOutputExtension(context, parent, e);
} else if (parent.getWSDLElementName().equals(MIMEConstants.QNAME_PART)) {
return handleMIMEPartExtension(context, parent, e);
} else {
// context.fireIgnoringExtension(
// new QName(e.getNamespaceURI(), e.getLocalName()),
// parent.getWSDLElementName());
return false;
}
}
protected boolean handleInputOutputExtension(
TWSDLParserContext context,
TWSDLExtensible parent,
Element e) {
if (XmlUtil.matchesTagNS(e, MIMEConstants.QNAME_MULTIPART_RELATED)) {
context.push();
context.registerNamespaces(e);
MIMEMultipartRelated mpr = new MIMEMultipartRelated(context.getLocation(e));
for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
Element e2 = Util.nextElement(iter);
if (e2 == null)
break;
if (XmlUtil.matchesTagNS(e2, MIMEConstants.QNAME_PART)) {
context.push();
context.registerNamespaces(e2);
MIMEPart part = new MIMEPart(context.getLocation(e2));
String name =
XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAME);
if (name != null) {
part.setName(name);
}
for (Iterator iter2 = XmlUtil.getAllChildren(e2);
iter2.hasNext();
) {
Element e3 = Util.nextElement(iter2);
if (e3 == null)
break;
AbstractExtensionHandler h = getExtensionHandlers().get(e3.getNamespaceURI());
boolean handled = false;
if (h != null) {
handled = h.doHandleExtension(context, part, e3);
}
if (!handled) {
String required =
XmlUtil.getAttributeNSOrNull(
e3,
Constants.ATTR_REQUIRED,
Constants.NS_WSDL);
if (required != null
&& required.equals(Constants.TRUE)) {
Util.fail(
"parsing.requiredExtensibilityElement",
e3.getTagName(),
e3.getNamespaceURI());
} else {
// context.fireIgnoringExtension(
// new QName(
// e3.getNamespaceURI(),
// e3.getLocalName()),
// part.getElementName());
}
}
}
mpr.add(part);
context.pop();
// context.fireDoneParsingEntity(
// MIMEConstants.QNAME_PART,
// part);
} else {
Util.fail(
"parsing.invalidElement",
e2.getTagName(),
e2.getNamespaceURI());
}
}
parent.addExtension(mpr);
context.pop();
// context.fireDoneParsingEntity(
// MIMEConstants.QNAME_MULTIPART_RELATED,
// mpr);
return true;
} else if (XmlUtil.matchesTagNS(e, MIMEConstants.QNAME_CONTENT)) {
MIMEContent content = parseMIMEContent(context, e);
parent.addExtension(content);
return true;
} else if (XmlUtil.matchesTagNS(e, MIMEConstants.QNAME_MIME_XML)) {
MIMEXml mimeXml = parseMIMEXml(context, e);
parent.addExtension(mimeXml);
return true;
} else {
Util.fail(
"parsing.invalidExtensionElement",
e.getTagName(),
e.getNamespaceURI());
return false; // keep compiler happy
}
}
@Override
protected boolean handleMIMEPartExtension(
TWSDLParserContext context,
TWSDLExtensible parent,
Element e) {
if (XmlUtil.matchesTagNS(e, MIMEConstants.QNAME_CONTENT)) {
MIMEContent content = parseMIMEContent(context, e);
parent.addExtension(content);
return true;
} else if (XmlUtil.matchesTagNS(e, MIMEConstants.QNAME_MIME_XML)) {
MIMEXml mimeXml = parseMIMEXml(context, e);
parent.addExtension(mimeXml);
return true;
} else {
Util.fail(
"parsing.invalidExtensionElement",
e.getTagName(),
e.getNamespaceURI());
return false; // keep compiler happy
}
}
protected MIMEContent parseMIMEContent(TWSDLParserContext context, Element e) {
context.push();
context.registerNamespaces(e);
MIMEContent content = new MIMEContent(context.getLocation(e));
String part = XmlUtil.getAttributeOrNull(e, Constants.ATTR_PART);
if (part != null) {
content.setPart(part);
}
String type = XmlUtil.getAttributeOrNull(e, Constants.ATTR_TYPE);
if (type != null) {
content.setType(type);
}
context.pop();
// context.fireDoneParsingEntity(MIMEConstants.QNAME_CONTENT, content);
return content;
}
protected MIMEXml parseMIMEXml(TWSDLParserContext context, Element e) {
context.push();
context.registerNamespaces(e);
MIMEXml mimeXml = new MIMEXml(context.getLocation(e));
String part = XmlUtil.getAttributeOrNull(e, Constants.ATTR_PART);
if (part != null) {
mimeXml.setPart(part);
}
context.pop();
// context.fireDoneParsingEntity(MIMEConstants.QNAME_MIME_XML, mimeXml);
return mimeXml;
}
}