# HG changeset patch # User Ingo Weinzierl # Date 1316098716 0 # Node ID f58be0d661b9c7d626a66b4bf7148d34b910680b # Parent 2490d6ef394e80aaee89e62fb10b9061dd24bb72 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly. flys-artifacts/trunk@2759 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 2490d6ef394e -r f58be0d661b9 flys-artifacts/ChangeLog --- 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 + + * 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 Extend WDifferences branch to have calculations in dedicated, new state. diff -r 2490d6ef394e -r f58be0d661b9 flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java --- 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) {