You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by bo...@apache.org on 2007/08/14 03:21:46 UTC

svn commit: r565598 - in /ode/trunk: bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ bpel-store/src/main/java/org/apache/ode/store/

Author: boisvert
Date: Mon Aug 13 18:21:44 2007
New Revision: 565598

URL: http://svn.apache.org/viewvc?view=rev&rev=565598
Log:
DefaultResourceFinder now uses both absolute base directory and a relative point for resolution
Fixes an issue whereby an XSLT reference using the form "urn:/absolute/path" would not work.

Modified:
    ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java
    ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java
    ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java

Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java?view=diff&rev=565598&r1=565597&r2=565598
==============================================================================
--- ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java (original)
+++ ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java Mon Aug 13 18:21:44 2007
@@ -60,6 +60,7 @@
     public OutputStream _outputStream = null;
 
     private File _bpelFile;
+    private File _suDir;
     private ResourceFinder _wsdlFinder;
     private URI _bpel11wsdl;
     private Map<String,Object> _compileProperties;
@@ -129,7 +130,7 @@
     }
 
     /**
-     * Compilation properties ebentually retrieved by the compiler 
+     * Compilation properties eventually retrieved by the compiler 
      * @param compileProperties
      */
     public void setCompileProperties(Map<String, Object> compileProperties) {
@@ -157,6 +158,12 @@
         }
     }
 
+    public void setBaseDirectory(File baseDir) {
+        if (baseDir == null) throw new IllegalArgumentException("Argument 'baseDir' is null");
+        if (!baseDir.exists()) throw new IllegalArgumentException("Directory "+baseDir+" does not exist");
+        _suDir = baseDir;
+    }
+    
     /**
      * <p>
      * Compile a BPEL process from a BOM {@link Process} object.
@@ -183,7 +190,8 @@
         if (_wsdlFinder != null) {
             wf = _wsdlFinder;
         } else {
-            wf = new DefaultResourceFinder(_bpelFile.getAbsoluteFile().getParentFile());
+            File suDir = _suDir != null ? _suDir : _bpelFile.getParentFile(); 
+            wf = new DefaultResourceFinder(_bpelFile.getAbsoluteFile().getParentFile(), suDir.getAbsoluteFile());
         }
 
         CompileListener clistener = new CompileListener() {

Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java?view=diff&rev=565598&r1=565597&r2=565598
==============================================================================
--- ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java (original)
+++ ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java Mon Aug 13 18:21:44 2007
@@ -38,32 +38,43 @@
 public class DefaultResourceFinder implements ResourceFinder {
     private static final Log __log = LogFactory.getLog(DefaultResourceFinder.class);
 
-    private File _suDir;
+    private File _relativeDir;
+    private File _absoluteDir;
 
     /**
      * Default constructor: resolve relative URIs against current working directory.
      */
     public DefaultResourceFinder() {
-        _suDir = new File("");
+        _absoluteDir = new File("");
+        _relativeDir = _absoluteDir;
     }
 
     /**
      * Constructor: resolve relative URIs against specified directory.
-     * @param suDir base path for relative URIs.
+     * @param relativeDir base path for relative URLs.
+     * @param absoluteDir base path for absolute URLs.
      */
-    public DefaultResourceFinder(File suDir) {
-        if (suDir == null) {
-            throw new IllegalArgumentException("Argument 'suDir' is null");
+    public DefaultResourceFinder(File relativeDir, File absoluteDir) {
+        checkDir("relativeDir", relativeDir);
+        checkDir("absoluteDir", absoluteDir);
+        _relativeDir = relativeDir;
+        _absoluteDir = absoluteDir;
         }
-        if (!suDir.exists()) {
-            throw new IllegalArgumentException("Directory does not exist: " + suDir);
+
+    private void checkDir(String arg, File dir) {
+        if (dir == null) {
+            throw new IllegalArgumentException("Argument '"+arg+"' is null");
+        }
+        if (!dir.exists()) {
+            throw new IllegalArgumentException("Directory does not exist: " + dir);
         }
-        _suDir = suDir;
     }
 
-
     public InputStream openResource(URI uri) throws MalformedURLException, IOException {
-        URI suURI = _suDir.toURI();
+        URI absolute = _absoluteDir.toURI();
+        if (__log.isDebugEnabled()) {
+            __log.debug("openResource: uri="+uri+" relativeDir="+_relativeDir+" absoluteDir="+_absoluteDir);
+        }
 
         if (uri.isAbsolute() && uri.getScheme().equals("file")) {
             try {
@@ -76,13 +87,13 @@
 
         // Note that if we get an absolute URI, the relativize operation will simply
         // return the absolute URI.
-        URI relative = suURI.relativize(uri);
+        URI relative = _relativeDir.toURI().relativize(uri);
         if (relative.isAbsolute() && !relative.getScheme().equals("urn")) {
            __log.fatal("openResource: invalid scheme (should be urn:)  " + uri);
            return null;
         }
 
-        File f = new File(suURI.getPath(),relative.getPath());
+        File f = new File(absolute.getPath(), relative.getPath());
         if (!f.exists()) {
             __log.debug("fileNotFound: " + f);
             return null;

Modified: ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java?view=diff&rev=565598&r1=565597&r2=565598
==============================================================================
--- ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java (original)
+++ ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java Mon Aug 13 18:21:44 2007
@@ -156,6 +156,7 @@
             bpelc.setProcessWSDL(bpel11wsdl.toURI());
         
         bpelc.setCompileProperties(prepareCompileProperties(bpelFile));
+        bpelc.setBaseDirectory(_duDirectory);
         try {
             bpelc.compile(bpelFile);
         } catch (IOException e) {
@@ -225,7 +226,7 @@
 
             WSDLFactory4BPEL wsdlFactory = (WSDLFactory4BPEL) WSDLFactoryBPEL20.newInstance();
             WSDLReader r = wsdlFactory.newWSDLReader();
-            DefaultResourceFinder rf = new DefaultResourceFinder(_duDirectory);
+            DefaultResourceFinder rf = new DefaultResourceFinder(_duDirectory, _duDirectory);
             URI basedir = _duDirectory.toURI();
             ArrayList<File> wsdls = listFilesRecursively(_duDirectory, DeploymentUnitDir._wsdlFilter);
             for (File file : wsdls) {