From 39cb0ac9e337eaa002bbdf3449bd93c89165f79e Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Mon, 24 Mar 2014 16:07:46 -0500 Subject: [PATCH] Issue #2954 - Handle missing scale files at cave startup. Change-Id: I3f7159b7a48e74fc9ad7a4220d6c30b67240aca1 Former-commit-id: 9334bc2b005cec571d08fbf5ada47bb90433f9d5 [formerly 4b7a68aeca0346f41965b98626e2c728b1a0e532] Former-commit-id: 372e9dc80f2605f75adb193463af4c12bb8fa922 --- .../core/maps/scales/MapScalesManager.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/scales/MapScalesManager.java b/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/scales/MapScalesManager.java index 7d077fcd27..440e228879 100644 --- a/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/scales/MapScalesManager.java +++ b/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/scales/MapScalesManager.java @@ -61,6 +61,7 @@ import com.raytheon.viz.ui.actions.LoadSerializedXml; * Oct 08, 2013 mschenke Initial creation * Oct 22, 2013 2491 bsteffen Change from SerializationUtil to * ProcedureXmlManager + * Mar 24, 2014 2954 mpduff Check for missing map scale files and handle the situation. * * * @@ -99,16 +100,22 @@ public class MapScalesManager { private String bundleXml; - private boolean isCustom; + private final boolean isCustom; private ManagedMapScale(String baseDir, MapScale scale) throws SerializationException { this.isCustom = false; - this.scaleFile = new AutoUpdatingLocalizationFile( - PathManagerFactory.getPathManager() - .getStaticLocalizationFile( - baseDir + IPathManager.SEPARATOR - + scale.getFileName())); + LocalizationFile file = PathManagerFactory.getPathManager() + .getStaticLocalizationFile( + baseDir + IPathManager.SEPARATOR + + scale.getFileName()); + + if (file == null || !file.exists()) { + throw new IllegalStateException( + "scalesInfo.xml references missing file " + + scale.getFileName()); + } + this.scaleFile = new AutoUpdatingLocalizationFile(file); this.scaleFile.addListener(listener); this.partIds = scale.getPartIds(); this.displayName = scale.getDisplayName(); @@ -200,7 +207,7 @@ public class MapScalesManager { // TODO: Need to figure out best way to create custom scales (depends on // maps loaded so it can't be at the projection dialog level) - private Collection customScales = new ArrayList(); + private final Collection customScales = new ArrayList(); /** * Construct a MapScalesManager for the given scales file. File must be