changeset 3606:2b308a5d5281

Fix for NPE flys-artifacts/trunk@5233 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Wed, 22 Aug 2012 12:25:28 +0000
parents 7196f06e0928
children e0f54fab55d3
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java
diffstat 2 files changed, 41 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Aug 22 11:58:48 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Aug 22 12:25:28 2012 +0000
@@ -1,9 +1,14 @@
-2012-08-20	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+2012-08-22	Christian Lins	<christian.lins@intevation.de>
+
+	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  Fix for NullPointerException.
+
+2012-08-22	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java:
 	  Made indices of analysis periods QWs zero based.
 
-2012-08-20	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+2012-08-22	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/fixings/QW.java:
 	  Store index, too.
@@ -16,7 +21,7 @@
 	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java:
 	  Set QD index to the values of the column cache columns.
 
-2012-08-20	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+2012-08-22	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	Use the column cache to establish a consistent index scheme.
 	TODO: Store the index values in the created QWDs.
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Wed Aug 22 11:58:48 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Wed Aug 22 12:25:28 2012 +0000
@@ -1,5 +1,24 @@
 package de.intevation.flys.collections;
 
+import de.intevation.artifactdatabase.Backend;
+import de.intevation.artifactdatabase.Backend.PersistentArtifact;
+import de.intevation.artifactdatabase.DefaultArtifactCollection;
+import de.intevation.artifactdatabase.state.Output;
+import de.intevation.artifactdatabase.state.Settings;
+import de.intevation.artifactdatabase.state.StateEngine;
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.ArtifactDatabase;
+import de.intevation.artifacts.ArtifactDatabaseException;
+import de.intevation.artifacts.ArtifactNamespaceContext;
+import de.intevation.artifacts.CallContext;
+import de.intevation.artifacts.CallMeta;
+import de.intevation.artifacts.common.utils.XMLUtils;
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.context.FLYSContext;
+import de.intevation.flys.exports.OutGenerator;
+import de.intevation.flys.exports.OutputHelper;
+import de.intevation.flys.utils.FLYSUtils;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -11,35 +30,11 @@
 import javax.xml.xpath.XPathConstants;
 
 import org.apache.log4j.Logger;
-
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import de.intevation.artifacts.Artifact;
-import de.intevation.artifacts.ArtifactDatabase;
-import de.intevation.artifacts.ArtifactDatabaseException;
-import de.intevation.artifacts.ArtifactNamespaceContext;
-import de.intevation.artifacts.CallContext;
-import de.intevation.artifacts.CallMeta;
-
-import de.intevation.artifacts.common.utils.XMLUtils;
-
-import de.intevation.artifactdatabase.Backend;
-import de.intevation.artifactdatabase.Backend.PersistentArtifact;
-import de.intevation.artifactdatabase.DefaultArtifactCollection;
-import de.intevation.artifactdatabase.state.Output;
-import de.intevation.artifactdatabase.state.Settings;
-import de.intevation.artifactdatabase.state.StateEngine;
-
-import de.intevation.flys.artifacts.context.FLYSContext;
-import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.exports.OutGenerator;
-import de.intevation.flys.exports.OutputHelper;
-
-import de.intevation.flys.utils.FLYSUtils;
-
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
@@ -459,10 +454,16 @@
 
         FLYSContext flysContext = FLYSUtils.getFlysContext(context);
         StateEngine engine = (StateEngine) flysContext.get(
-        FLYSContext.STATE_ENGINE_KEY);
+                FLYSContext.STATE_ENGINE_KEY);
 
         FLYSArtifact masterArtifact = getMasterArtifact(context);
 
+        if(masterArtifact == null) {
+            log.debug("buildOutAttributes: masterArtifact == null");
+            return null;
+        }
+
+        // FIXME: ec is not used?
         XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
             doc,
             ArtifactNamespaceContext.NAMESPACE_URI,
@@ -483,7 +484,11 @@
 
         aParser.parse();
 
-        return new AttributeWriter(
+        if(engine == null) {
+            log.debug("buildOutAttributes: engine == null");
+        }
+
+        AttributeWriter aWriter = new AttributeWriter(
             db,
             aParser.getCollectionAttribute(),
             aParser.getOuts(),
@@ -491,7 +496,8 @@
             oParser.getOuts(),
             oParser.getFacets(),
             engine.getCompatibleFacets(masterArtifact.getStateHistoryIds())
-            ).write();
+            );
+        return aWriter.write();
     }
 
 

http://dive4elements.wald.intevation.org