Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java @ 1174:f58be0d661b9
Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
flys-artifacts/trunk@2759 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 15 Sep 2011 14:58:36 +0000 |
parents | 5f53b443d67c |
children | 8d08f6641372 |
comparison
equal
deleted
inserted
replaced
1173:2490d6ef394e | 1174:f58be0d661b9 |
---|---|
9 | 9 |
10 import org.w3c.dom.Document; | 10 import org.w3c.dom.Document; |
11 | 11 |
12 import gnu.trove.TDoubleArrayList; | 12 import gnu.trove.TDoubleArrayList; |
13 | 13 |
14 import de.intevation.artifacts.Artifact; | |
14 import de.intevation.artifacts.CallContext; | 15 import de.intevation.artifacts.CallContext; |
15 | 16 |
16 import de.intevation.artifacts.common.utils.Config; | 17 import de.intevation.artifacts.common.utils.Config; |
17 import de.intevation.artifacts.common.utils.XMLUtils; | 18 import de.intevation.artifacts.common.utils.XMLUtils; |
18 | 19 |
53 } | 54 } |
54 | 55 |
55 | 56 |
56 public static FLYSArtifact getArtifact(String uuid, CallContext context) { | 57 public static FLYSArtifact getArtifact(String uuid, CallContext context) { |
57 try { | 58 try { |
58 return (FLYSArtifact) context.getDatabase().getRawArtifact(uuid); | 59 Artifact artifact = context.getDatabase().getRawArtifact(uuid); |
60 | |
61 if (artifact == null) { | |
62 logger.error("Artifact '" + uuid + "' does not exist."); | |
63 return null; | |
64 } | |
65 | |
66 if (!(artifact instanceof FLYSArtifact)) { | |
67 logger.error("Artifact '" +uuid+ "' is no valid FLYSArtifact."); | |
68 return null; | |
69 } | |
70 | |
71 return (FLYSArtifact) artifact; | |
59 } | 72 } |
60 // TODO: catch more selective | 73 // TODO: catch more selective |
61 catch (Exception e) { | 74 catch (Exception e) { |
62 logger.error("Cannot get FLYSArtifact " + uuid + " from database (" + e.getMessage() + ")."); | 75 logger.error("Cannot get FLYSArtifact " + uuid + " from database (" + e.getMessage() + ")."); |
63 return null; | 76 return null; |