db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1066601 - in /db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration: ./ controller/
Date Wed, 02 Feb 2011 20:02:09 GMT
Author: tfischer
Date: Wed Feb  2 20:02:09 2011
New Revision: 1066601

URL: http://svn.apache.org/viewvc?rev=1066601&view=rev
Log:
better error output if parsing a control configuration fails

Modified:
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ClasspathConfigurationProvider.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ConfigurationProvider.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/DirectoryConfigurationProvider.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/JarConfigurationProvider.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/ControlConfigurationXmlParser.java

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ClasspathConfigurationProvider.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ClasspathConfigurationProvider.java?rev=1066601&r1=1066600&r2=1066601&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ClasspathConfigurationProvider.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ClasspathConfigurationProvider.java
Wed Feb  2 20:02:09 2011
@@ -94,6 +94,13 @@ public class ClasspathConfigurationProvi
                 "control file");
     }
 
+    public String getControlConfigurationLocation()
+    {
+        return getFileName(
+                configurationPaths.getControlConfigurationFile(),
+                configurationPaths.getConfigurationDirectory());
+    }
+
     public InputStream getTemplateInputStream(String name)
             throws ConfigurationException
     {
@@ -130,11 +137,9 @@ public class ClasspathConfigurationProvi
                 "option");
     }
 
-    private InputStream getInputStream(
-                String name,
-                String directory,
-                String fileDescription)
-            throws ConfigurationException
+    private String getFileName(
+            String name,
+            String directory)
     {
         String fileName
                 = getConfigResourceBase()
@@ -142,10 +147,19 @@ public class ClasspathConfigurationProvi
                     + directory
                     + "/"
                     + name;
-
         // make double dots work for resources in jar files
         fileName = FilenameUtils.normalizeNoEndSeparator(fileName);
         fileName = FilenameUtils.separatorsToUnix(fileName);
+        return fileName;
+    }
+
+    private InputStream getInputStream(
+                String name,
+                String directory,
+                String fileDescription)
+            throws ConfigurationException
+    {
+        String fileName = getFileName(name, directory);
 
         InputStream inputStream
                 = getClass().getClassLoader().getResourceAsStream(

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ConfigurationProvider.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ConfigurationProvider.java?rev=1066601&r1=1066600&r2=1066601&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ConfigurationProvider.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ConfigurationProvider.java
Wed Feb  2 20:02:09 2011
@@ -34,12 +34,27 @@ public interface ConfigurationProvider
      * It is the callers responsibility to close the reader after use.
      *
      * @return a reader to access the control configuration, never null.
+     *
      * @throws ConfigurationException if the reader can not be created.
      */
     InputStream getControlConfigurationInputStream()
         throws ConfigurationException;
 
     /**
+     * Returns the location of the control configuration as human readable
+     * String for debugging and error tracking purposes.
+     * 
+     * @return the location of the control configuration, not null.
+     *
+     * @throws ConfigurationException if the location name can not be created.
+     */
+    // The control configuration location is important if loading the control
+    // file fails for a project with multiple units of generation.
+    // Using the location in the error messages helps finding out which
+    // control configuration contains the error.
+    String getControlConfigurationLocation() throws ConfigurationException;
+
+    /**
      * Creates a reader to access a template.
      * It is the callers responsibility to close the reader after use.
      *

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/DirectoryConfigurationProvider.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/DirectoryConfigurationProvider.java?rev=1066601&r1=1066600&r2=1066601&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/DirectoryConfigurationProvider.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/DirectoryConfigurationProvider.java
Wed Feb  2 20:02:09 2011
@@ -82,16 +82,25 @@ public class DirectoryConfigurationProvi
     }
 
     public InputStream getControlConfigurationInputStream()
-        throws ConfigurationException
+            throws ConfigurationException
     {
         return getInputStream(
                 configurationPaths.getControlConfigurationFile(),
                 configurationPaths.getConfigurationDirectory(),
-                "template");
+                "control file");
+    }
+
+    public String getControlConfigurationLocation()
+            throws ConfigurationException
+    {
+        return getFile(
+                configurationPaths.getControlConfigurationFile(),
+                configurationPaths.getConfigurationDirectory(),
+                "control file").getAbsolutePath();
     }
 
     public InputStream getTemplateInputStream(String name)
-        throws ConfigurationException
+            throws ConfigurationException
     {
         return getInputStream(
                 name,
@@ -100,7 +109,7 @@ public class DirectoryConfigurationProvi
     }
 
     public InputStream getOutletConfigurationInputStream(String name)
-        throws ConfigurationException
+            throws ConfigurationException
     {
         return getInputStream(
                 name,
@@ -126,7 +135,7 @@ public class DirectoryConfigurationProvi
                 "option");
     }
 
-    private InputStream getInputStream(
+    private File getFile(
                 String name,
                 String directory,
                 String description)
@@ -150,7 +159,17 @@ public class DirectoryConfigurationProvi
                     + " could not be calculated",
                 e);
         }
+        return file;
+    }
 
+    private InputStream getInputStream(
+                String name,
+                String directory,
+                String description)
+            throws ConfigurationException
+    {
+        File file = getFile(name, directory, description);
+        
         InputStream inputStream;
         try
         {

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/JarConfigurationProvider.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/JarConfigurationProvider.java?rev=1066601&r1=1066600&r2=1066601&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/JarConfigurationProvider.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/JarConfigurationProvider.java
Wed Feb  2 20:02:09 2011
@@ -109,6 +109,15 @@ public class JarConfigurationProvider im
                 "configuration");
     }
 
+
+    public String getControlConfigurationLocation()
+            throws ConfigurationException
+    {
+        return projectPaths.getConfigurationPath() + ":" 
+            + configurationPaths.getConfigurationDirectory() + "/"
+            + configurationPaths.getControlConfigurationFile();
+    }
+
     public InputStream getTemplateInputStream(String name)
             throws ConfigurationException
     {

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/ControlConfigurationXmlParser.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/ControlConfigurationXmlParser.java?rev=1066601&r1=1066600&r2=1066601&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/ControlConfigurationXmlParser.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/ControlConfigurationXmlParser.java
Wed Feb  2 20:02:09 2011
@@ -120,7 +120,10 @@ public class ControlConfigurationXmlPars
             catch (SAXParseException e)
             {
                 throw new ConfigurationException(
-                        "Error parsing controller Configuration at line "
+                        "Error parsing controller Configuration " 
+                            + configurationProvider
+                                .getControlConfigurationLocation()
+                            + " at line "
                             + e.getLineNumber()
                             + " column "
                             + e.getColumnNumber()
@@ -132,7 +135,9 @@ public class ControlConfigurationXmlPars
             catch (Exception e)
             {
                 throw new ConfigurationException(
-                        "Error parsing controller Configuration : "
+                        "Error parsing controller Configuration "
+                            + configurationProvider
+                                .getControlConfigurationLocation()
                             + e.getMessage(),
                         e);
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message