changeset 168:f70977cf2faf

Avoid Nullpointer exception in listCollections() when no creation time of the collection is returned. artifacts/trunk@1393 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 04 Mar 2011 09:13:18 +0000
parents c9c27aca2f70
children 2f575d594fdb
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 03 17:01:04 2011 +0000
+++ b/ChangeLog	Fri Mar 04 09:13:18 2011 +0000
@@ -1,3 +1,10 @@
+2011-03-04  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java:
+	  If there is no creation time of a collection, we just add an empty
+	  string to the collection node in listCollections(). A
+	  NullPointerException is avoided!
+
 2011-03-03	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* artifact-database/src/main/resources/sql/org-h2-driver.properties,
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Thu Mar 03 17:01:04 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Fri Mar 04 09:13:18 2011 +0000
@@ -33,6 +33,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -1154,9 +1155,13 @@
             Element collection = ec.create("artifact-collection");
             ec.addAttr(collection, "name", c.getName());
             ec.addAttr(collection, "uuid", c.identifier());
-            ec.addAttr(
-                collection, "creation",
-                Long.toString(c.getCreationTime().getTime()));
+
+            Date creationTime = c.getCreationTime();
+            String creation   = creationTime != null
+                ? Long.toString(creationTime.getTime())
+                : "";
+
+            ec.addAttr(collection, "creation", creation);
 
             root.appendChild(collection);
         }

http://dive4elements.wald.intevation.org