Mercurial > dive4elements > river
changeset 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 | 2490d6ef394e |
children | e6b513495281 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java |
diffstat | 2 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Thu Sep 15 07:39:36 2011 +0000 +++ b/flys-artifacts/ChangeLog Thu Sep 15 14:58:36 2011 +0000 @@ -1,3 +1,9 @@ +2011-09-15 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/utils/FLYSUtils.java: Fetch Artifact + from ArtifactDatabase properly. Write better error logs if that process + fails. + 2011-09-14 Felix Wolfsteller <felix.wolfsteller@intevation.de> Extend WDifferences branch to have calculations in dedicated, new state.
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Thu Sep 15 07:39:36 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Thu Sep 15 14:58:36 2011 +0000 @@ -11,6 +11,7 @@ import gnu.trove.TDoubleArrayList; +import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.common.utils.Config; @@ -55,7 +56,19 @@ public static FLYSArtifact getArtifact(String uuid, CallContext context) { try { - return (FLYSArtifact) context.getDatabase().getRawArtifact(uuid); + Artifact artifact = context.getDatabase().getRawArtifact(uuid); + + if (artifact == null) { + logger.error("Artifact '" + uuid + "' does not exist."); + return null; + } + + if (!(artifact instanceof FLYSArtifact)) { + logger.error("Artifact '" +uuid+ "' is no valid FLYSArtifact."); + return null; + } + + return (FLYSArtifact) artifact; } // TODO: catch more selective catch (Exception e) {