changeset 307:d96bcb40dbf9

Make artifact server bootable again. artifacts/trunk@2425 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 31 Jul 2011 15:18:57 +0000
parents 9dbeb88006e9
children a077bb098eb4
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java artifact-database/src/main/java/de/intevation/artifactdatabase/db/SQL.java
diffstat 4 files changed, 39 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jul 28 14:08:25 2011 +0000
+++ b/ChangeLog	Sun Jul 31 15:18:57 2011 +0000
@@ -1,3 +1,15 @@
+2011-07-31	Sascha L. Teichmann	<teichmann@intevation.de>
+
+	Make artifact server bootable again.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java:
+	  Fixed NPE.
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/db/SQL.java: Fixed NPE.
+	  Added some debug output.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: Fixed
+	  SQL key name. That was broken for long but not recognized.
+	
 2011-07-28	Sascha L. Teichmann	<teichmann@intevation.de>
 
 	* artifacts-common/src/main/java/de/intevation/artifacts/common/utils/LRUCache.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Thu Jul 28 14:08:25 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Sun Jul 31 15:18:57 2011 +0000
@@ -310,7 +310,7 @@
         SQL_USERS_COLLECTIONS = sql.get("users.collections");
         SQL_USERS_COLLECTION_IDS = sql.get("users.collection.ids");
         SQL_USERS_DELETE_ALL_COLLECTIONS =
-            sql.get("users.delete.all.collections");
+            sql.get("users.delete.collections");
         SQL_ARTIFACTS_IN_ONLY_COLLECTION_ONLY =
             sql.get("artifacts.in.one.collection.only");
         SQL_OUTDATE_ARTIFACTS_COLLECTION =
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java	Thu Jul 28 14:08:25 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java	Sun Jul 31 15:18:57 2011 +0000
@@ -472,7 +472,7 @@
 
                 listener.setup(Config.getConfig());
 
-                lifetimeListeners.add(listener);
+                ltls.add(listener);
             }
             catch (ClassNotFoundException cnfe) {
                 logger.error(cnfe.getLocalizedMessage(), cnfe);
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/db/SQL.java	Thu Jul 28 14:08:25 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/db/SQL.java	Sun Jul 31 15:18:57 2011 +0000
@@ -25,6 +25,7 @@
     }
 
     public SQL(Class clazz, String resourcePath, String driver) {
+        statements = loadStatements(clazz, resourcePath, driver);
     }
 
     public static final String driverToProperties(String driver) {
@@ -50,6 +51,8 @@
         String resourcePath,
         String driver
     ) { 
+        logger.debug("loadStatements");
+
         Properties properties = new Properties();
 
         String resDriver = driverToProperties(driver);
@@ -71,6 +74,11 @@
                         DBConnection.DEFAULT_DRIVER + "' found.");
                 }
             }
+            else {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("found resource: " + res);
+                }
+            }
 
             if (in != null) {
                 properties.load(in);
@@ -84,7 +92,23 @@
     }
 
     public String get(String key) {
-        return statements.getProperty(key);
+        boolean debug = logger.isDebugEnabled();
+        if (debug) {
+            logger.debug("looking for SQL " + key);
+            logger.debug("statements != null: " + (statements != null));
+        }
+
+        String sql = statements.getProperty(key);
+
+        if (sql == null) {
+            logger.error("cannot find SQL for key '" + key + "'");
+        }
+
+        if (debug) {
+            logger.debug("-> '" + sql + "'"); 
+        }
+
+        return sql;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org