comparison flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java @ 3870:0c16eace7b6c

Add robustness checks to prevent NPEs flys-artifacts/trunk@5502 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Tue, 18 Sep 2012 10:18:30 +0000
parents 53aa395a29e0
children 3aec5a42696a
comparison
equal deleted inserted replaced
3869:74f9766599b5 3870:0c16eace7b6c
1 package de.intevation.flys.collections; 1 package de.intevation.flys.collections;
2
3 import java.io.IOException;
4 import java.io.OutputStream;
5 import java.util.ArrayList;
6 import java.util.HashMap;
7 import java.util.List;
8 import java.util.Map;
9 import java.util.Set;
10
11 import javax.xml.xpath.XPathConstants;
12
13 import org.apache.log4j.Logger;
14 import org.w3c.dom.Document;
15 import org.w3c.dom.Element;
16 import org.w3c.dom.Node;
17 import org.w3c.dom.NodeList;
2 18
3 import de.intevation.artifactdatabase.Backend; 19 import de.intevation.artifactdatabase.Backend;
4 import de.intevation.artifactdatabase.Backend.PersistentArtifact; 20 import de.intevation.artifactdatabase.Backend.PersistentArtifact;
5 import de.intevation.artifactdatabase.DefaultArtifactCollection; 21 import de.intevation.artifactdatabase.DefaultArtifactCollection;
6 import de.intevation.artifactdatabase.state.Output; 22 import de.intevation.artifactdatabase.state.Output;
17 import de.intevation.flys.artifacts.context.FLYSContext; 33 import de.intevation.flys.artifacts.context.FLYSContext;
18 import de.intevation.flys.exports.OutGenerator; 34 import de.intevation.flys.exports.OutGenerator;
19 import de.intevation.flys.exports.OutputHelper; 35 import de.intevation.flys.exports.OutputHelper;
20 import de.intevation.flys.utils.FLYSUtils; 36 import de.intevation.flys.utils.FLYSUtils;
21 37
22 import java.io.IOException;
23 import java.io.OutputStream;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Set;
29
30 import javax.xml.xpath.XPathConstants;
31
32 import org.apache.log4j.Logger;
33 import org.w3c.dom.Document;
34 import org.w3c.dom.Element;
35 import org.w3c.dom.Node;
36 import org.w3c.dom.NodeList;
37
38 /** 38 /**
39 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 39 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
40 */ 40 */
41 public class FLYSArtifactCollection extends DefaultArtifactCollection { 41 public class FLYSArtifactCollection extends DefaultArtifactCollection {
42 /** The logger used in this class. */ 42 /** The logger used in this class. */
123 AttributeParser oldParser, 123 AttributeParser oldParser,
124 String[] uuids 124 String[] uuids
125 ) { 125 ) {
126 CollectionAttribute cAttribute = 126 CollectionAttribute cAttribute =
127 buildOutAttributes(db, context, oldParser, uuids); 127 buildOutAttributes(db, context, oldParser, uuids);
128
129 if (cAttribute == null) {
130 log.warn("mergeAttributes: cAttribute == null");
131 return null;
132 }
128 133
129 cAttribute.setLoadedRecommendations( 134 cAttribute.setLoadedRecommendations(
130 getLoadedRecommendations(oldParser.getAttributeDocument())); 135 getLoadedRecommendations(oldParser.getAttributeDocument()));
131 136
132 saveCollectionAttribute(db, context, cAttribute); 137 saveCollectionAttribute(db, context, cAttribute);
448 ArtifactDatabase db, 453 ArtifactDatabase db,
449 CallContext context, 454 CallContext context,
450 AttributeParser aParser, 455 AttributeParser aParser,
451 String[] uuids) 456 String[] uuids)
452 { 457 {
453 Document doc = XMLUtils.newDocument();
454
455 FLYSContext flysContext = FLYSUtils.getFlysContext(context); 458 FLYSContext flysContext = FLYSUtils.getFlysContext(context);
456 StateEngine engine = (StateEngine) flysContext.get( 459 StateEngine engine = (StateEngine) flysContext.get(
457 FLYSContext.STATE_ENGINE_KEY); 460 FLYSContext.STATE_ENGINE_KEY);
458 461
459 if (engine == null) { 462 if (engine == null) {

http://dive4elements.wald.intevation.org