Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
easyWSDL - easyWSDL toolbox Platform. Copyright (c) 2008, eBM Websourcing All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of California, Berkeley nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 package org.ow2.easywsdl.wsdl.impl.generic;
 
 import java.net.URI;
 import java.net.URL;
 import java.util.List;
 import java.util.Map;
 
 

Author(s):
Nicolas Salatge - eBM WebSourcing
 
 public class WSDLReaderImpl extends AbstractWSDLReaderImpl implements
         WSDLReader {
 
 	private final List<ClassaddedObjectFactories;
 
     private final static Logger log = Logger.getLogger(WSDLReaderImpl.class.getName());
 
 	private final AbstractWSDLReaderImpl reader11;
 	private final AbstractWSDLReaderImpl reader20;
 	
 	public WSDLReaderImpl() throws WSDLException {
 		this(null);
 	}
 
 	public WSDLReaderImpl(List<ClassaddedObjectFactoriesthrows WSDLException {
 		this. = addedObjectFactories;
 	}

    
 
     public Description read(final URL wsdlURLthrows WSDLExceptionMalformedURLExceptionIOExceptionURISyntaxException {
         try {
             InputSource inputSource = new InputSource(wsdlURL.openStream());
             inputSource.setSystemId(wsdlURL.toString());
 
             final WSDLVersionConstants version = WSDLVersionDetector.getVersion(inputSource);
 
             inputSource = new InputSource(wsdlURL.openStream());
             inputSource.setSystemId(wsdlURL.toString());
            return this.read(versioninputSourcenullnull);
        } catch (final MalformedURLException e) {
            throw new RuntimeException("The provided well-formed URL has been detected as malformed !!");
        }
    }
	public Description read(InputSource sourceMap<URIAbsItfDescriptiondescriptionImportsMap<URIAbsItfSchemaschemaImportsthrows WSDLExceptionMalformedURLExceptionURISyntaxException {
		return this.read(sourcedescriptionImportsschemaImportstrue);
	}

    
    public Description read(final InputSource inputSourcefinal Map<URIAbsItfDescriptiondescriptionImportsfinal Map<URIAbsItfSchemaschemaImportsfinal boolean deleteImportsthrows WSDLExceptionMalformedURLExceptionURISyntaxException {
        
        if (inputSource.getByteStream() != null) {
            final String systemId = inputSource.getSystemId();
            if (systemId != null ) {
                this.setDocumentBaseURI(new URI(systemId));
            }
            
            final InputStream originalInputStream = inputSource.getByteStream();
            final InputStreamForker isf = new InputStreamForker(originalInputStream);
            
            inputSource.setByteStream(isf.getInputStreamOne());
            final WSDLVersionConstants version = WSDLVersionDetector.getVersion(inputSource);
            
            inputSource.setByteStream(isf.getInputStreamTwo());
            return this.read(versioninputSourcedescriptionImportsschemaImportsdeleteImports);
        }
        else {
            throw new UnsupportedOperationException("This method supports only InputSource with byte stream.");
        }
	}
    private Description read(final WSDLVersionConstants versionfinal InputSource sourcefinal Map<URIAbsItfDescriptiondescriptionImportsfinal Map<URIAbsItfSchemaschemaImportsthrows WSDLExceptionMalformedURLExceptionURISyntaxException {
    	return this.read(versionsourcedescriptionImportsschemaImportstrue);
    }
    
    private Description read(final WSDLVersionConstants versionfinal InputSource sourcefinal Map<URIAbsItfDescriptiondescriptionImportsfinal Map<URIAbsItfSchemaschemaImportsfinal boolean deleteImportsthrows WSDLExceptionMalformedURLExceptionURISyntaxException {
        
        final AbstractWSDLReaderImpl reader;
        if (version == .) {
            reader = ;
        } else if (version == .) {
            reader = ;
        } else {
            throw new WSDLException("unknown version of wsdl");
        }
        reader.setFeatures(this.getFeatures());
        return reader.read(sourcedescriptionImportsschemaImportsdeleteImports);
    }

	public Description readWSDL(Document docthrows WSDLException {
	    try {
            return this.read(doc);
        } catch (URISyntaxException e) {
            throw new WSDLException(e);
        }
	}

    public Description read(final Document documentthrows WSDLExceptionURISyntaxException {
        
        try {
            final WSDLVersionConstants version = WSDLVersionDetector.getVersion(document);
            
            // The DOM Document needs to be converted into an InputStource
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final StreamResult streamResult = new StreamResult(baos);
            // FIXME: The Transformer creation is not thread-safe
            final Transformer transformer = TransformerFactory.newInstance()
                    .newTransformer();
            transformer.transform(new DOMSource(document), streamResult);
            baos.flush();
            baos.close();
            final InputSource documentInputSource = new InputSource(
                    new ByteArrayInputStream(baos.toByteArray()));
            documentInputSource.setSystemId(document.getBaseURI());
            
            return this.read(versiondocumentInputSourcenullnulltrue);
        } catch (final TransformerConfigurationException e) {
            throw new WSDLException(e);
        } catch (final TransformerFactoryConfigurationError e) {
            throw new WSDLException(e);
        } catch (final TransformerException e) {
            throw new WSDLException(e);
        } catch (final IOException e) {
            throw new WSDLException(e);
        }
    }

    
        
        return this.read(inputSourcenullnulltrue);
    }
New to GrepCode? Check out our FAQ X