[Yanel-commits] rev 33649 - public/yanel/trunk/src/core/java/org/wyona/yanel/core/source

michi at wyona.com michi at wyona.com
Wed Mar 19 09:45:18 CET 2008


Author: michi
Date: 2008-03-19 09:45:17 +0100 (Wed, 19 Mar 2008)
New Revision: 33649

Modified:
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/RTYanelHtdocsResolver.java
Log:
exception messages improved

Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/RTYanelHtdocsResolver.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/RTYanelHtdocsResolver.java	2008-03-19 08:44:54 UTC (rev 33648)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/RTYanelHtdocsResolver.java	2008-03-19 08:45:17 UTC (rev 33649)
@@ -33,6 +33,9 @@
         this.resource = resource;
     }
 
+    /**
+     *
+     */
     public Source resolve(String href, String base) throws SourceException {
         String prefix = SCHEME + ":";
         // only accept 'rtyanelhtdocs:' URIs
@@ -51,15 +54,20 @@
             if (log.isDebugEnabled()) {
                 log.debug("Package: " + packageName);
             }
-            InputStream in = resource.getClass().getClassLoader().getResource(packageName.replace('.','/') + "/yanel-htdocs" + path).openStream();
-            return new StreamSource(in);
+            java.net.URL url = resource.getClass().getClassLoader().getResource(packageName.replace('.','/') + "/yanel-htdocs" + path);
+            if (url == null) {
+                log.info("Path " + path + " does not seem to be contained within package " + packageName + " of resource " + resource.getResourceTypeUniversalName());
+            }
+            return new StreamSource(url.openStream());
         } catch (Exception e) {
+            File resourceConfigDir = resource.getRTD().getConfigFile().getParentFile();
+            log.info("Fallback to resource config location: " + resourceConfigDir);
             try {
-                File resourceFile = new File(resource.getRTD().getConfigFile().getParentFile().getAbsolutePath() + "/yanel-htdocs" + path.replace('/', File.separatorChar));
+                File resourceFile = new File(resourceConfigDir.getAbsolutePath() + "/yanel-htdocs" + path.replace('/', File.separatorChar));
                 InputStream in = new java.io.FileInputStream(resourceFile);
                 return new StreamSource(in);
             } catch (Exception ex) {
-                String errorMsg = "Could not resolve URI: " + path + ": " + e.toString();
+                String errorMsg = "Could not resolve URI: " + path + " (" + e.toString() + ", " + resourceConfigDir + ")";
                 log.error(errorMsg, e);
                 throw new SourceException(errorMsg, e);
             }



More information about the Yanel-commits mailing list