blob: 71ae493674cc746200797b3da1aa756b15a13066 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2002, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.ws.internal.consumption.wsfinder;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.wsdl.Definition;
import javax.wsdl.Port;
import javax.wsdl.Service;
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.http.HTTPAddress;
import javax.wsdl.extensions.soap.SOAPAddress;
import org.eclipse.wst.ws.parser.discovery.WebServicesParserExt;
import org.eclipse.wst.ws.parser.wsil.WWWAuthenticationException;
public class LiveWSDLFilter extends Thread
{
private String wsdlURL_;
private boolean finish_;
private boolean live_;
public LiveWSDLFilter(String wsdlURL)
{
wsdlURL_ = wsdlURL;
finish_ = false;
live_ = false;
}
public String getWSDLURL()
{
return wsdlURL_;
}
public boolean isFinish()
{
return finish_;
}
public boolean isWSDLLive()
{
return live_;
}
public void run()
{
try
{
live_ = validateWSDL();
}
catch (Throwable t)
{
live_ = false;
}
finally
{
finish_ = true;
}
}
private boolean validateWSDL() throws WSDLException, MalformedURLException, IOException, WWWAuthenticationException
{
WebServicesParserExt parser = new WebServicesParserExt();
Definition definition = parser.getWSDLDefinitionVerbose(wsdlURL_);
Map services = definition.getServices();
Iterator serviceIterator = services.values().iterator();
while (serviceIterator.hasNext())
{
Service service = (Service)serviceIterator.next();
Map ports = service.getPorts();
Iterator portIterator = ports.values().iterator();
while (portIterator.hasNext())
{
Port port = (Port)portIterator.next();
List extensibilityElements = port.getExtensibilityElements();
Iterator extensibilityElementsIterator = extensibilityElements.iterator();
while (extensibilityElementsIterator.hasNext())
{
ExtensibilityElement extensibilityElement = (ExtensibilityElement)extensibilityElementsIterator.next();
if ((extensibilityElement instanceof SOAPAddress) || (extensibilityElement instanceof HTTPAddress))
return true;
}
}
}
return false;
}
}