Omaha #5237 Replace deprecated LocalizationFile methods.
Former-commit-id: f280b7ad602705c82e076bc1b2e5137e9f1d7ccc
This commit is contained in:
parent
09697836d9
commit
05613d6965
6 changed files with 132 additions and 143 deletions
|
@ -21,8 +21,8 @@ package com.raytheon.edex.plugin.bufrua.util;
|
|||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -30,12 +30,13 @@ import java.util.Map;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManager;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
||||
|
@ -45,9 +46,11 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 15, 2010 mnash Initial creation
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- --------- -------------------------------------
|
||||
* Jul 15, 2010 5571 mnash Initial creation
|
||||
* Feb 16, 2016 5237 bsteffen Replace deprecated localization API.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -80,7 +83,7 @@ public class RaobSitesInUseUtil {
|
|||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private static void parseFile(String site) throws IOException {
|
||||
private static void parseFile(String site) {
|
||||
if (parsed && raobSite.equals(site)) {
|
||||
return;
|
||||
}
|
||||
|
@ -93,7 +96,7 @@ public class RaobSitesInUseUtil {
|
|||
}
|
||||
|
||||
siteMap.clear();
|
||||
PathManager pm = (PathManager) PathManagerFactory.getPathManager();
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
|
||||
LocalizationContext context = null;
|
||||
if (site != null) {
|
||||
|
@ -104,10 +107,10 @@ public class RaobSitesInUseUtil {
|
|||
LocalizationLevel.SITE);
|
||||
}
|
||||
|
||||
LocalizationFile file = pm.getLocalizationFile(context, "upperair"
|
||||
ILocalizationFile file = pm.getLocalizationFile(context, "upperair"
|
||||
+ File.separator + "raobSitesInUse.txt");
|
||||
|
||||
if (!file.exists()) {
|
||||
if (file == null || !file.exists()) {
|
||||
LocalizationContext baseContext = pm.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
|
||||
file = pm.getLocalizationFile(baseContext, "upperair"
|
||||
|
@ -116,33 +119,34 @@ public class RaobSitesInUseUtil {
|
|||
.info("Site raobSitesInUse.txt file not configured for "
|
||||
+ site + ". Using the base file.");
|
||||
}
|
||||
if (file != null) {
|
||||
BufferedReader buf = new BufferedReader(new FileReader(
|
||||
file.getFile()));
|
||||
System.out.println("temping");
|
||||
String temp = buf.readLine();
|
||||
temp = buf.readLine();
|
||||
String radarType = "";
|
||||
List<UpperAirSite> sites = new ArrayList<UpperAirSite>();
|
||||
while (temp != null) {
|
||||
temp = temp.trim();
|
||||
if (temp.startsWith("#")) {
|
||||
sites = new ArrayList<UpperAirSite>();
|
||||
radarType = temp.substring(1, temp.indexOf(" ", 2));
|
||||
siteMap.put(radarType.trim(), sites);
|
||||
} else if (!temp.isEmpty()) {
|
||||
Matcher m = raob_pattern.matcher(temp);
|
||||
while (m.find()) {
|
||||
UpperAirSite uaSite = new UpperAirSite();
|
||||
uaSite.setIcao(m.group(1));
|
||||
uaSite.setSiteId(m.group(2));
|
||||
uaSite.setCity(m.group(3));
|
||||
sites.add(uaSite);
|
||||
}
|
||||
}
|
||||
if (file != null && file.exists()) {
|
||||
try (BufferedReader buf = new BufferedReader(new InputStreamReader(
|
||||
file.openInputStream()))) {
|
||||
String temp = buf.readLine();
|
||||
temp = buf.readLine();
|
||||
String radarType = "";
|
||||
List<UpperAirSite> sites = new ArrayList<UpperAirSite>();
|
||||
while (temp != null) {
|
||||
temp = temp.trim();
|
||||
if (temp.startsWith("#")) {
|
||||
sites = new ArrayList<UpperAirSite>();
|
||||
radarType = temp.substring(1, temp.indexOf(" ", 2));
|
||||
siteMap.put(radarType.trim(), sites);
|
||||
} else if (!temp.isEmpty()) {
|
||||
Matcher m = raob_pattern.matcher(temp);
|
||||
while (m.find()) {
|
||||
UpperAirSite uaSite = new UpperAirSite();
|
||||
uaSite.setIcao(m.group(1));
|
||||
uaSite.setSiteId(m.group(2));
|
||||
uaSite.setCity(m.group(3));
|
||||
sites.add(uaSite);
|
||||
}
|
||||
}
|
||||
temp = buf.readLine();
|
||||
}
|
||||
} catch (IOException | LocalizationException e) {
|
||||
statusHandler.error("Error reading " + file.getPath(), e);
|
||||
}
|
||||
buf.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,11 +157,7 @@ public class RaobSitesInUseUtil {
|
|||
* @return
|
||||
*/
|
||||
public static List<UpperAirSite> getSite(String site, String type) {
|
||||
try {
|
||||
parseFile(site);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
parseFile(site);
|
||||
return siteMap.get(type);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.grib.decoderpostprocessors;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -34,10 +35,9 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
|
||||
import com.raytheon.edex.plugin.grib.exception.GribException;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.localization.FileUpdatedMessage;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.ILocalizationPathObserver;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.parameter.Parameter;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
|
@ -45,32 +45,33 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Adjusts temperature values that are mislabled as Celsius or Kelvin when they
|
||||
* actually represent the other one. Loads a list of parameters and thresholds
|
||||
* from a localization file. Assumes that all values above the threshold for a
|
||||
* parameter are in Kelvin and will convert if the declared unit is Celsius.
|
||||
* Values below the threshold are assumed to be in Celsius and will be converted
|
||||
* if the declared unit is Kelvin
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Mar 28, 2010 2874 bsteffen Initial creation
|
||||
* Apr 25, 2014 2060 njensen Use JAXB instead of JAXBManager
|
||||
* Oct 07, 2015 3756 nabowle Extends DecoderPostProcessor.
|
||||
*
|
||||
*
|
||||
* Feb 16, 2016 5237 bsteffen Replace deprecated localization API.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class TemperatureCorrectionPostProcessor extends DecoderPostProcessor
|
||||
implements ILocalizationFileObserver {
|
||||
implements ILocalizationPathObserver {
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TemperatureCorrectionPostProcessor.class);
|
||||
|
@ -86,21 +87,21 @@ public class TemperatureCorrectionPostProcessor extends DecoderPostProcessor
|
|||
|
||||
private Map<String, Double> paramThresholdMap;
|
||||
|
||||
public TemperatureCorrectionPostProcessor() throws GribException {
|
||||
LocalizationFile file = readConfiguration();
|
||||
if (file != null) {
|
||||
file.addFileUpdatedObserver(this);
|
||||
}
|
||||
public TemperatureCorrectionPostProcessor() {
|
||||
readConfiguration();
|
||||
PathManagerFactory.getPathManager().addLocalizationPathObserver(
|
||||
LOCALIZATON_LOCATION, this);
|
||||
|
||||
}
|
||||
|
||||
protected LocalizationFile readConfiguration() {
|
||||
LocalizationFile file = PathManagerFactory.getPathManager()
|
||||
protected void readConfiguration() {
|
||||
ILocalizationFile file = PathManagerFactory.getPathManager()
|
||||
.getStaticLocalizationFile(LOCALIZATON_LOCATION);
|
||||
Map<String, Double> paramThresholdMap = new HashMap<String, Double>(8);
|
||||
if (file != null && file.exists()) {
|
||||
TemperatureCorrectionParameters params = null;
|
||||
try {
|
||||
params = JAXB.unmarshal(file.getFile(),
|
||||
try (InputStream is = file.openInputStream()) {
|
||||
params = JAXB.unmarshal(is,
|
||||
TemperatureCorrectionParameters.class);
|
||||
} catch (Exception e) {
|
||||
/* Some hope of recovering with a better file. */
|
||||
|
@ -119,11 +120,10 @@ public class TemperatureCorrectionPostProcessor extends DecoderPostProcessor
|
|||
}
|
||||
}
|
||||
this.paramThresholdMap = paramThresholdMap;
|
||||
return file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileUpdated(FileUpdatedMessage message) {
|
||||
public void fileChanged(ILocalizationFile file) {
|
||||
try {
|
||||
readConfiguration();
|
||||
} catch (Exception e) {
|
||||
|
@ -209,4 +209,5 @@ public class TemperatureCorrectionPostProcessor extends DecoderPostProcessor
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package com.raytheon.edex.plugin.grib.spatial;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -43,10 +44,10 @@ import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
|||
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
|
||||
import com.raytheon.uf.common.gridcoverage.lookup.GridCoverageLookup;
|
||||
import com.raytheon.uf.common.gridcoverage.subgrid.SubGrid;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
||||
|
@ -82,6 +83,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Jul 21, 2014 3373 bclement JAXB managers only live during initializeGrids()
|
||||
* Mar 04, 2015 3959 rjpeter Update for grid based subgridding.
|
||||
* Sep 28, 2015 4868 rjpeter Allow subgrids to be defined per coverage.
|
||||
* Feb 16, 2016 5237 bsteffen Replace deprecated localization API.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -633,16 +636,15 @@ public class GribSpatialCache {
|
|||
private Coordinate getDefaultSubGridCenterPoint() throws Exception {
|
||||
Coordinate defaultCenterPoint = null;
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationFile defaultSubGridLocationFile = pm
|
||||
ILocalizationFile defaultSubGridLocationFile = pm
|
||||
.getStaticLocalizationFile("/grib/defaultSubGridCenterPoint.xml");
|
||||
SingleTypeJAXBManager<DefaultSubGridCenterPoint> subGridCenterJaxb = new SingleTypeJAXBManager<DefaultSubGridCenterPoint>(
|
||||
DefaultSubGridCenterPoint.class);
|
||||
if ((defaultSubGridLocationFile != null)
|
||||
&& defaultSubGridLocationFile.exists()) {
|
||||
try {
|
||||
DefaultSubGridCenterPoint defaultSubGridLocation = defaultSubGridLocationFile
|
||||
.jaxbUnmarshal(DefaultSubGridCenterPoint.class,
|
||||
subGridCenterJaxb);
|
||||
try (InputStream is = defaultSubGridLocationFile.openInputStream()) {
|
||||
DefaultSubGridCenterPoint defaultSubGridLocation = subGridCenterJaxb
|
||||
.unmarshalFromInputStream(is);
|
||||
if ((defaultSubGridLocation != null)
|
||||
&& (defaultSubGridLocation.getCenterLatitude() != null)
|
||||
&& (defaultSubGridLocation.getCenterLongitude() != null)) {
|
||||
|
@ -657,8 +659,7 @@ public class GribSpatialCache {
|
|||
} catch (Exception e) {
|
||||
statusHandler.error(
|
||||
"Unable to load default sub grid location from file: "
|
||||
+ defaultSubGridLocationFile.getFile()
|
||||
.getAbsolutePath(), e);
|
||||
+ defaultSubGridLocationFile.getPath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.grib.util;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
|
@ -38,9 +39,9 @@ import com.raytheon.edex.plugin.grib.spatial.GribSpatialCache;
|
|||
import com.raytheon.uf.common.dataplugin.grid.mapping.DatasetIdMapper;
|
||||
import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
||||
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -69,6 +70,7 @@ import com.raytheon.uf.common.util.mapping.MultipleMappingException;
|
|||
* Dec 16, 2015 5182 tjensen Added functionality for file name regex
|
||||
* matching and support for meta characters in
|
||||
* model names.
|
||||
* Feb 16, 2016 5237 bsteffen Replace deprecated localization API.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -288,7 +290,7 @@ public class GribModelLookup {
|
|||
LocalizationContext.LocalizationType.EDEX_STATIC,
|
||||
LocalizationContext.LocalizationLevel.SITE);
|
||||
|
||||
LocalizationFile[] modelFiles = PathManagerFactory.getPathManager()
|
||||
ILocalizationFile[] modelFiles = PathManagerFactory.getPathManager()
|
||||
.listFiles(
|
||||
new LocalizationContext[] { edexStaticBase,
|
||||
edexStaticSite },
|
||||
|
@ -297,10 +299,9 @@ public class GribModelLookup {
|
|||
|
||||
GridModelSet modelSet = new GridModelSet();
|
||||
|
||||
for (LocalizationFile modelFile : modelFiles) {
|
||||
try {
|
||||
GridModelSet fileSet = JAXB.unmarshal(modelFile.getFile(),
|
||||
GridModelSet.class);
|
||||
for (ILocalizationFile modelFile : modelFiles) {
|
||||
try (InputStream is = modelFile.openInputStream()) {
|
||||
GridModelSet fileSet = JAXB.unmarshal(is, GridModelSet.class);
|
||||
modelSet.addModels(fileSet.getModels());
|
||||
} catch (Exception e) {
|
||||
logger.error("Unable to unmarshal grib models file:"
|
||||
|
|
|
@ -22,18 +22,20 @@ package com.raytheon.edex.util.grib;
|
|||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.edex.plugin.grib.exception.GribException;
|
||||
import com.raytheon.edex.plugin.grib.util.DataFieldTableLookup;
|
||||
import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.parameter.Parameter;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
||||
|
@ -48,6 +50,7 @@ import com.raytheon.uf.common.time.DataTime;
|
|||
* ------------- -------- ----------- --------------------------
|
||||
* Apr 15, 2010 4553 bphillip Initial Creation
|
||||
* Oct 15, 2013 2473 bsteffen Remove e.printStackTrace()
|
||||
* Feb 16, 2016 5237 bsteffen Replace deprecated localization API.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -246,9 +249,9 @@ public class GribParamTranslator {
|
|||
.getPathManager().getTieredLocalizationFile(
|
||||
LocalizationType.COMMON_STATIC,
|
||||
"grid" + File.separator + "master_grib2_lookup.txt");
|
||||
loadDefs(files.get(LocalizationLevel.BASE).getFile(), 2);
|
||||
loadDefs(files.get(LocalizationLevel.BASE), 2);
|
||||
if (files.containsKey(LocalizationLevel.SITE)) {
|
||||
loadDefs(files.get(LocalizationLevel.SITE).getFile(), 2);
|
||||
loadDefs(files.get(LocalizationLevel.SITE), 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,9 +267,9 @@ public class GribParamTranslator {
|
|||
.getPathManager().getTieredLocalizationFile(
|
||||
LocalizationType.COMMON_STATIC,
|
||||
"grid" + File.separator + "master_grib1_lookup.txt");
|
||||
loadDefs(files.get(LocalizationLevel.BASE).getFile(), 1);
|
||||
loadDefs(files.get(LocalizationLevel.BASE), 1);
|
||||
if (files.containsKey(LocalizationLevel.SITE)) {
|
||||
loadDefs(files.get(LocalizationLevel.SITE).getFile(), 1);
|
||||
loadDefs(files.get(LocalizationLevel.SITE), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,10 +279,9 @@ public class GribParamTranslator {
|
|||
.getPathManager().getTieredLocalizationFile(
|
||||
LocalizationType.COMMON_STATIC,
|
||||
"grid" + File.separator + "parameterNameAlias.txt");
|
||||
loadParameterNameAliases(files.get(LocalizationLevel.BASE).getFile());
|
||||
loadParameterNameAliases(files.get(LocalizationLevel.BASE));
|
||||
if (files.containsKey(LocalizationLevel.SITE)) {
|
||||
loadParameterNameAliases(files.get(LocalizationLevel.SITE)
|
||||
.getFile());
|
||||
loadParameterNameAliases(files.get(LocalizationLevel.SITE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,12 +295,10 @@ public class GribParamTranslator {
|
|||
* @throws GribException
|
||||
* If errors occur while processing the file
|
||||
*/
|
||||
private void loadDefs(File lookupFile, int gribVersion)
|
||||
private void loadDefs(ILocalizationFile lookupFile, int gribVersion)
|
||||
throws GribException {
|
||||
BufferedReader in = null;
|
||||
String[] tokens = null;
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(lookupFile));
|
||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(
|
||||
lookupFile.openInputStream()))) {
|
||||
String str;
|
||||
|
||||
/*
|
||||
|
@ -310,7 +310,7 @@ public class GribParamTranslator {
|
|||
continue;
|
||||
}
|
||||
|
||||
tokens = str.split(" ");
|
||||
String[] tokens = str.split(" ");
|
||||
if (tokens.length < 2) {
|
||||
continue;
|
||||
}
|
||||
|
@ -320,24 +320,17 @@ public class GribParamTranslator {
|
|||
grib2Map.put(tokens[0], tokens[tokens.length - 1]);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | LocalizationException e) {
|
||||
throw new GribException(
|
||||
"Error processing master grib parameters file", e);
|
||||
}
|
||||
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
throw new GribException(
|
||||
"Error processing master grib parameters file", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadParameterNameAliases(File lookupFile) throws GribException {
|
||||
BufferedReader in = null;
|
||||
String[] tokens = null;
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(lookupFile));
|
||||
private void loadParameterNameAliases(ILocalizationFile lookupFile)
|
||||
throws GribException {
|
||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(
|
||||
lookupFile.openInputStream()))) {
|
||||
String str;
|
||||
|
||||
/*
|
||||
|
@ -349,7 +342,7 @@ public class GribParamTranslator {
|
|||
continue;
|
||||
}
|
||||
|
||||
tokens = str.split("::");
|
||||
String[] tokens = str.split("::");
|
||||
if (tokens.length < 3) {
|
||||
continue;
|
||||
}
|
||||
|
@ -364,14 +357,7 @@ public class GribParamTranslator {
|
|||
parameterName);
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new GribException(
|
||||
"Error processing master grib parameters file", e);
|
||||
}
|
||||
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | LocalizationException e) {
|
||||
throw new GribException(
|
||||
"Error processing master grib parameters file", e);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.plugin.redbook.decoder;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
|
@ -28,11 +29,10 @@ import javax.xml.bind.annotation.XmlAttribute;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.raytheon.uf.common.localization.FileUpdatedMessage;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.ILocalizationPathObserver;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -52,6 +52,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Nov 04, 2013 2361 njensen Use JAXB for XML instead of SerializationUtil
|
||||
* Jun 25, 2015 4512 mapeters Added addEntry(), check for redbookFcstMap.xml
|
||||
* in common_static before edex_static
|
||||
* Feb 16, 2016 5237 bsteffen Replace deprecated localization API.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -93,10 +94,29 @@ public class RedbookFcstMap {
|
|||
mapping.put(key, value);
|
||||
}
|
||||
|
||||
private static RedbookFcstMap load(LocalizationFile xmlFile) {
|
||||
private static RedbookFcstMap load() {
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
/*
|
||||
* Check common_static/configured first, as it is now being saved there.
|
||||
* If not found, check edex_static/base, where it used to be stored (in
|
||||
* the future edex_static should no longer need to be checked).
|
||||
*/
|
||||
LocalizationContext context = pathMgr.getContext(
|
||||
LocalizationContext.LocalizationType.COMMON_STATIC,
|
||||
LocalizationContext.LocalizationLevel.CONFIGURED);
|
||||
ILocalizationFile xmlFile = pathMgr.getLocalizationFile(context,
|
||||
REDBOOK_FCST_MAP_XML);
|
||||
if (xmlFile == null || !xmlFile.exists()) {
|
||||
context = pathMgr.getContext(
|
||||
LocalizationContext.LocalizationType.EDEX_STATIC,
|
||||
LocalizationContext.LocalizationLevel.BASE);
|
||||
xmlFile = pathMgr
|
||||
.getLocalizationFile(context, REDBOOK_FCST_MAP_XML);
|
||||
}
|
||||
|
||||
RedbookFcstMap loadedMap = null;
|
||||
try {
|
||||
loadedMap = JAXB.unmarshal(xmlFile.getFile(), RedbookFcstMap.class);
|
||||
try (InputStream is = xmlFile.openInputStream()) {
|
||||
loadedMap = JAXB.unmarshal(is, RedbookFcstMap.class);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getMessage(), e);
|
||||
}
|
||||
|
@ -119,34 +139,14 @@ public class RedbookFcstMap {
|
|||
*/
|
||||
public static synchronized RedbookFcstMap getInstance() {
|
||||
if (instance == null) {
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
/*
|
||||
* Check common_static/configured first, as it is now being saved
|
||||
* there. If not found, check edex_static/base, where it used to be
|
||||
* stored (in the future edex_static should no longer need to be
|
||||
* checked).
|
||||
*/
|
||||
LocalizationContext context = pathMgr.getContext(
|
||||
LocalizationContext.LocalizationType.COMMON_STATIC,
|
||||
LocalizationContext.LocalizationLevel.CONFIGURED);
|
||||
LocalizationFile xmlFile = pathMgr.getLocalizationFile(context,
|
||||
REDBOOK_FCST_MAP_XML);
|
||||
if (xmlFile == null || !xmlFile.exists()) {
|
||||
context = pathMgr.getContext(
|
||||
LocalizationContext.LocalizationType.EDEX_STATIC,
|
||||
LocalizationContext.LocalizationLevel.BASE);
|
||||
xmlFile = pathMgr.getLocalizationFile(context,
|
||||
REDBOOK_FCST_MAP_XML);
|
||||
}
|
||||
|
||||
final LocalizationFile finalXmlFile = xmlFile;
|
||||
instance = load(xmlFile);
|
||||
xmlFile.addFileUpdatedObserver(new ILocalizationFileObserver() {
|
||||
instance = load();
|
||||
PathManagerFactory.getPathManager().addLocalizationPathObserver(REDBOOK_FCST_MAP_XML, new ILocalizationPathObserver() {
|
||||
|
||||
@Override
|
||||
public void fileUpdated(FileUpdatedMessage message) {
|
||||
RedbookFcstMap updatedMap = load(finalXmlFile);
|
||||
public void fileChanged(ILocalizationFile file) {
|
||||
RedbookFcstMap updatedMap = load();
|
||||
instance.mapping.clear();
|
||||
instance.mapping.putAll(updatedMap.mapping);
|
||||
instance.mapping.putAll(updatedMap.mapping);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue