Author: mriou
Date: Fri Sep 29 12:28:16 2006
New Revision: 451397
URL: http://svn.apache.org/viewvc?view=rev&rev=451397
Log:
Support for relative urls on imports.
Removed:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DUWsdlFinder.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DUXsltFinder.java
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultWsdlFinder.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultXsltFinder.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinder.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/XsltFinder.java
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java?view=diff&rev=451397&r1=451396&r2=451397
==============================================================================
---
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java
(original)
+++
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java
Fri Sep 29 12:28:16 2006
@@ -247,7 +247,7 @@
compiler.setCompileListener(clistener);
compiler.setWsdlFinder(wf);
if (_bpel11wsdl != null) {
- compiler.addWsdlImport(_bpel11wsdl);
+ compiler.addWsdlImport(_bpelFile, _bpel11wsdl);
} else {
CompilationMessage cmsg = __cmsgs.errBpel11RequiresWsdl();
logCompilationMessage(cmsg);
@@ -264,7 +264,7 @@
OProcess oprocess;
try {
- oprocess = compiler.compile(process);
+ oprocess = compiler.compile(_bpelFile, process);
}
catch (CompilationException cex) {
this.invalidate();
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java?view=diff&rev=451397&r1=451396&r2=451397
==============================================================================
---
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
(original)
+++
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
Fri Sep 29 12:28:16 2006
@@ -56,6 +56,7 @@
import java.util.List;
import java.util.Map;
import java.util.Stack;
+import java.io.File;
/**
@@ -108,14 +109,11 @@
setWsdlFinder(null);
}
- public void addWsdlImport(URI wsdlImport) {
+ public void addWsdlImport(File importFrom, URI wsdlImport) {
try {
WSDLReader r = _wsdlFactory.newWSDLReader();
- // TODO ODE-107 Make URI resolution relative
- // to BPEL process URI : _processDef.getSource();
-
-
_wsdlRegistry.addDefinition(_wsdlFinder.loadDefinition(r,wsdlImport));
+ _wsdlRegistry.addDefinition(_wsdlFinder.loadDefinition(r,
importFrom, wsdlImport));
if (__log.isDebugEnabled())
__log.debug("Added WSDL Definition: " + wsdlImport);
} catch (CompilationException ce) {
@@ -485,7 +483,7 @@
/**
* Compile a process.
*/
- public OProcess compile(final Process process) throws CompilationException
{
+ public OProcess compile(File bpelFile, final Process process) throws
CompilationException {
_processDef = process;
_generatedDate = new Date();
_structureStack.clear();
@@ -521,7 +519,7 @@
// by the 1.1 parser.
for (Import imprt : _processDef.getImports()) {
try {
- compile(imprt);
+ compile(bpelFile, imprt);
} catch (CompilationException bce) {
// We try to recover from import problems by continuing
recoveredFromError(imprt, bce);
@@ -640,13 +638,13 @@
*
* @param imprt BOM representation of the import
*/
- private void compile(Import imprt) {
+ private void compile(File bpelFile, Import imprt) {
try {
if (imprt.getImportType() == null)
throw new
CompilationException(__cmsgs.errUnspecifiedImportType().setSource(imprt));
if (Import.IMPORTTYPE_WSDL11.equals(imprt.getImportType())) {
- addWsdlImport(imprt.getLocation());
+ addWsdlImport(bpelFile, imprt.getLocation());
} else if
(Import.IMPORTTYPE_XMLSCHEMA10.equals(imprt.getImportType())) {
addXsdImport(imprt.getLocation());
} else
@@ -1325,7 +1323,7 @@
} catch (URISyntaxException e) {
throw new
CompilationException(__cmsgs.errInvalidDocXsltUri(docStrUri));
}
- String sheetBody = _xsltFinder.loadXsltSheet(docUri);
+ String sheetBody = _xsltFinder.loadXsltSheet(new
File(_processDef.getSource()), docUri);
if (sheetBody == null) {
throw new CompilationException(__cmsgs.errCantFindXslt(docStrUri));
}
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultWsdlFinder.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultWsdlFinder.java?view=diff&rev=451397&r1=451396&r2=451397
==============================================================================
---
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultWsdlFinder.java
(original)
+++
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultWsdlFinder.java
Fri Sep 29 12:28:16 2006
@@ -47,12 +47,14 @@
_suDir = new File(u);
}
- public Definition4BPEL loadDefinition(WSDLReader r, URI uri) throws
WSDLException {
+ public Definition4BPEL loadDefinition(WSDLReader r, File importFrom, URI
uri) throws WSDLException {
// Eliminating whatever path has been provided, we always look into
our SU
// deployment directory.
String strUri = uri.toString();
-// String filename = strUri.substring(strUri.lastIndexOf("/"),
strUri.length());
- return (Definition4BPEL) r.readWSDL(new File(_suDir,
strUri).getPath());
+ // Allowing both relative or absolute
+ if (!strUri.startsWith("/"))
+ return (Definition4BPEL) r.readWSDL(new
File(importFrom.getParent(), strUri).getPath());
+ else return (Definition4BPEL) r.readWSDL(new File(_suDir,
strUri).getPath());
}
public InputStream openResource(URI uri) throws MalformedURLException,
IOException {
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultXsltFinder.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultXsltFinder.java?view=diff&rev=451397&r1=451396&r2=451397
==============================================================================
---
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultXsltFinder.java
(original)
+++
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultXsltFinder.java
Fri Sep 29 12:28:16 2006
@@ -35,29 +35,35 @@
private File _suDir;
public DefaultXsltFinder() {
- _suDir = new File(".");
+ _suDir = new File(".");
}
public DefaultXsltFinder(File suDir) {
- _suDir = suDir;
+ _suDir = suDir;
}
public void setBaseURI(URI u) {
- _suDir = new File(u);
+ _suDir = new File(u);
}
- public String loadXsltSheet(URI uri) {
- // Eliminating whatever path has been provided, we always look into our
SU
- // deployment directory.
- String strUri = uri.toString();
-// String filename = strUri.substring(strUri.lastIndexOf("/"),
strUri.length());
- try {
- return new String(StreamUtils.read(new FileInputStream(new
File(_suDir, strUri))));
- } catch (IOException e) {
- if (DefaultXsltFinder.__log.isDebugEnabled())
- DefaultXsltFinder.__log.debug("error obtaining resource '" + uri +
"' from repository.", e);
- return null;
- }
+ public String loadXsltSheet(File importFrom, URI uri) {
+ // Eliminating whatever path has been provided, we always look into
our SU
+ // deployment directory.
+ String strUri = uri.toString();
+
+ File xslFile;
+ if (new File(importFrom.getParent(), strUri).exists())
+ xslFile = new File(importFrom.getParent(), strUri);
+ else
+ xslFile = new File(_suDir, strUri);
+
+ try {
+ return new String(StreamUtils.read(new FileInputStream(xslFile)));
+ } catch (IOException e) {
+ if (DefaultXsltFinder.__log.isDebugEnabled())
+ DefaultXsltFinder.__log.debug("error obtaining resource '" +
uri + "' from repository.", e);
+ return null;
+ }
}
}
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinder.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinder.java?view=diff&rev=451397&r1=451396&r2=451397
==============================================================================
---
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinder.java
(original)
+++
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinder.java
Fri Sep 29 12:28:16 2006
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
@@ -46,7 +47,7 @@
* @return the definition
* @throws WSDLException if one occurs while reading the WSDL or its imports.
*/
- Definition4BPEL loadDefinition(WSDLReader f, URI uri) throws WSDLException;
+ Definition4BPEL loadDefinition(WSDLReader f, File importFrom, URI uri)
throws WSDLException;
InputStream openResource(URI uri) throws MalformedURLException, IOException;
}
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java?view=diff&rev=451397&r1=451396&r2=451397
==============================================================================
---
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
(original)
+++
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
Fri Sep 29 12:28:16 2006
@@ -32,61 +32,61 @@
public class WsdlFinderXMLEntityResolver implements XMLEntityResolver {
- private static final Log __log = LogFactory
- .getLog(WsdlFinderXMLEntityResolver.class);
+ private static final Log __log = LogFactory
+ .getLog(WsdlFinderXMLEntityResolver.class);
- /**
- * Flag indicating whether the resolver should fail with an exception if the
- * requested resource is not found. The interface suggests that null should
be
- * returned so that a "default" resolution mechanism can be used; however, we
- * don't necessarily want to use this default mechanism.
- */
- private boolean _failIfNotFound = true;
-
- private WsdlFinder _wsdlFinder;
-
- public WsdlFinderXMLEntityResolver(WsdlFinder finder) {
- _wsdlFinder = finder;
- }
-
- public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
- throws XNIException, IOException {
-
- if (__log.isDebugEnabled())
- __log.debug("resolveEntity(" + resourceIdentifier + ")");
-
- XMLInputSource src = new XMLInputSource(resourceIdentifier);
- URI location;
-
- try {
- if (resourceIdentifier.getExpandedSystemId() == null)
- location = new URI(resourceIdentifier.getNamespace());
- else
- location = new URI(resourceIdentifier.getExpandedSystemId());
- } catch (URISyntaxException e) {
- __log.debug("resolveEntity: URI syntax error", e);
- throw new IOException(e.getMessage());
- }
+ /**
+ * Flag indicating whether the resolver should fail with an exception if
the
+ * requested resource is not found. The interface suggests that null
should be
+ * returned so that a "default" resolution mechanism can be used; however,
we
+ * don't necessarily want to use this default mechanism.
+ */
+ private boolean _failIfNotFound = true;
- if (__log.isDebugEnabled())
- __log.debug("resolveEntity: Expecting to find " +
resourceIdentifier.getNamespace()
- + " at " + location);
-
- try {
- src.setByteStream(_wsdlFinder.openResource(location));
- } catch (IOException ioex) {
- __log.debug("resolveEntity: IOExcepption opening " + location,ioex);
-
- if (_failIfNotFound) {
- __log.debug("resolveEntity: failIfNotFound set, rethrowing...");
- throw ioex;
- }
+ private WsdlFinder _wsdlFinder;
- __log.debug("resolveEntity: failIfNotFound NOT set, returning NULL");
- return null;
+ public WsdlFinderXMLEntityResolver(WsdlFinder finder) {
+ _wsdlFinder = finder;
}
- return src;
- }
+ public XMLInputSource resolveEntity(XMLResourceIdentifier
resourceIdentifier)
+ throws XNIException, IOException {
+
+ if (__log.isDebugEnabled())
+ __log.debug("resolveEntity(" + resourceIdentifier + ")");
+
+ XMLInputSource src = new XMLInputSource(resourceIdentifier);
+ URI location;
+
+ try {
+ if (resourceIdentifier.getExpandedSystemId() == null)
+ location = new URI(resourceIdentifier.getNamespace());
+ else
+ location = new URI(resourceIdentifier.getExpandedSystemId());
+ } catch (URISyntaxException e) {
+ __log.debug("resolveEntity: URI syntax error", e);
+ throw new IOException(e.getMessage());
+ }
+
+ if (__log.isDebugEnabled())
+ __log.debug("resolveEntity: Expecting to find " +
resourceIdentifier.getNamespace()
+ + " at " + location);
+
+ try {
+ src.setByteStream(_wsdlFinder.openResource(location));
+ } catch (IOException ioex) {
+ __log.debug("resolveEntity: IOExcepption opening " +
location,ioex);
+
+ if (_failIfNotFound) {
+ __log.debug("resolveEntity: failIfNotFound set,
rethrowing...");
+ throw ioex;
+ }
+
+ __log.debug("resolveEntity: failIfNotFound NOT set, returning
NULL");
+ return null;
+ }
+
+ return src;
+ }
}
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/XsltFinder.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/XsltFinder.java?view=diff&rev=451397&r1=451396&r2=451397
==============================================================================
---
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/XsltFinder.java
(original)
+++
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/XsltFinder.java
Fri Sep 29 12:28:16 2006
@@ -20,6 +20,7 @@
package org.apache.ode.bpel.compiler;
import java.net.URI;
+import java.io.File;
/**
* Simple wrapper for XSLT location.
@@ -37,5 +38,5 @@
* @param uri of the xslt sheet.
* @return the sheet content
*/
- public String loadXsltSheet(URI uri);
+ public String loadXsltSheet(File importFrom, URI uri);
}