Author: richard.opalka(a)jboss.com
Date: 2007-10-10 11:27:16 -0400 (Wed, 10 Oct 2007)
New Revision: 4728
Modified:
stack/native/trunk/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java
Log:
[JBWS-1843] issue fix
Modified:
stack/native/trunk/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java 2007-10-10
14:50:55 UTC (rev 4727)
+++
stack/native/trunk/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java 2007-10-10
15:27:16 UTC (rev 4728)
@@ -32,6 +32,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import javax.wsdl.Definition;
@@ -120,11 +121,12 @@
Definition wsdl11Definition = wsdlDefinitions.getWsdlOneOneDefinition();
if (wsdl11Definition != null)
{
- publishWsdlImports(wsdlFile.toURL(), wsdl11Definition);
+ List<String> published = new LinkedList<String>();
+ publishWsdlImports(wsdlFile.toURL(), wsdl11Definition, published);
// Publish XMLSchema imports
Document document = wsdlDefinitions.getWsdlDocument();
- publishSchemaImports(wsdlFile.toURL(), document.getDocumentElement());
+ publishSchemaImports(wsdlFile.toURL(), document.getDocumentElement(),
published);
}
else
{
@@ -144,7 +146,7 @@
/** Publish the wsdl imports for a given wsdl definition
*/
- private void publishWsdlImports(URL parentURL, Definition parentDefinition) throws
Exception
+ private void publishWsdlImports(URL parentURL, Definition parentDefinition,
List<String> published) throws Exception
{
String baseURI = parentURL.toExternalForm();
@@ -159,6 +161,16 @@
// its an external import, don't publish locally
if (locationURI.startsWith("http://") == false)
{
+ // infinity loops prevention
+ if (published.contains(locationURI))
+ {
+ return;
+ }
+ else
+ {
+ published.add(locationURI);
+ }
+
URL targetURL = new URL(baseURI.substring(0,
baseURI.lastIndexOf("/") + 1) + locationURI);
File targetFile = new File(targetURL.getPath());
targetFile.getParentFile().mkdirs();
@@ -172,12 +184,12 @@
if (log.isDebugEnabled())
log.debug("WSDL import published to: " + targetURL);
- // recursivly publish imports
- publishWsdlImports(targetURL, subdef);
+ // recursively publish imports
+ publishWsdlImports(targetURL, subdef, published);
// Publish XMLSchema imports
Element subdoc = DOMUtils.parse(targetURL.openStream());
- publishSchemaImports(targetURL, subdoc);
+ publishSchemaImports(targetURL, subdoc, published);
}
}
}
@@ -185,7 +197,7 @@
/** Publish the schema imports for a given wsdl definition
*/
- private void publishSchemaImports(URL parentURL, Element element) throws Exception
+ private void publishSchemaImports(URL parentURL, Element element, List<String>
published) throws Exception
{
String baseURI = parentURL.toExternalForm();
@@ -200,6 +212,16 @@
{
if (schemaLocation.startsWith("http://") == false)
{
+ // infinity loops prevention
+ if (published.contains(schemaLocation))
+ {
+ return;
+ }
+ else
+ {
+ published.add(schemaLocation);
+ }
+
URL xsdURL = new URL(baseURI.substring(0,
baseURI.lastIndexOf("/") + 1) + schemaLocation);
File targetFile = new File(xsdURL.getPath());
targetFile.getParentFile().mkdirs();
@@ -229,13 +251,13 @@
// recursivly publish imports
Element subdoc = DOMUtils.parse(xsdURL.openStream());
- publishSchemaImports(xsdURL, subdoc);
+ publishSchemaImports(xsdURL, subdoc, published);
}
}
}
else
{
- publishSchemaImports(parentURL, childElement);
+ publishSchemaImports(parentURL, childElement, published);
}
}
}
Show replies by date