# HG changeset patch # User "Tom Gottfried " # Date 1410951614 -7200 # Node ID 4c1f57839ae95c44919503079a65630c8af81d01 # Parent 62b4f3ca99edeaa74512afad347c04a42efce15b Avoid NPE if river is not accessible. diff -r 62b4f3ca99ed -r 4c1f57839ae9 artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java --- a/artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java Wed Sep 17 12:32:24 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java Wed Sep 17 13:00:14 2014 +0200 @@ -12,6 +12,9 @@ import java.util.Map; import org.apache.log4j.Logger; + +import org.dive4elements.river.model.River; + import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.D4EArtifact; @@ -19,7 +22,6 @@ import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.model.Unit; import org.dive4elements.river.themes.ThemeDocument; -import org.dive4elements.river.utils.RiverUtils; import org.jfree.data.xy.XYDataItem; import org.jfree.data.xy.XYSeries; @@ -140,21 +142,25 @@ Artifact artifact, CallContext context) { this.metaData = metaData; - D4EArtifact d4e = (D4EArtifact) artifact; - RiverAccess access = new RiverAccess(d4e); - Unit unit = RiverUtils.getRiver(d4e).getWstUnit(); + River river = new RiverAccess((D4EArtifact)artifact).getRiver(); + String rivername = ""; + String unit = ""; + if (river != null) { + rivername = river.getName(); + unit = river.getWstUnit().getName(); + } if (metaData.containsKey("X")) { this.metaData.put("X", Resources.getMsg( context.getMeta(), metaData.get("X"), - new Object[] { access.getRiverName() })); + new Object[] { rivername })); } if (metaData.containsKey("Y")) { this.metaData.put("Y", Resources.getMsg( context.getMeta(), - metaData.get("Y"), new Object[] { unit.getName() })); + metaData.get("Y"), new Object[] { unit })); } } }