Omaha #5237 Replace deprecated LocalizationFile method calls

Changed LocalizationFile.getName() to getPath() in all Raytheon edex plugins.
Also changed LocalizationFile to ILocalizationFile when it was possible to do
so without further code changes.

Change-Id: Ic066dd09a7929606f6987088b6d182a60caea1c1

Former-commit-id: 1864ce834c0c27647c4da46868d9a65e01addd9f
This commit is contained in:
Tom Gurney 2016-01-27 16:51:03 -06:00
parent 2ad363ebca
commit 147144e64f
10 changed files with 69 additions and 98 deletions

View file

@ -31,6 +31,7 @@ import javax.xml.bind.JAXBException;
import com.raytheon.uf.common.dataplugin.binlightning.BinLightningRecord;
import com.raytheon.uf.common.dataplugin.binlightning.impl.LightningStrikePoint;
import com.raytheon.uf.common.localization.ILocalizationFile;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
@ -51,9 +52,11 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometry;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 10, 2014 3226 bclement Initial creation
* Jan 27, 2016 5237 tgurney Replace LocalizationFile with
* ILocalizationFile
*
* </pre>
*
@ -92,11 +95,11 @@ public class LightningGeoFilter {
LOCALIZATION_FILTER_DIR, new String[] { ".xml" }, true,
true);
for (LocalizationFile file : files) {
for (ILocalizationFile file : files) {
Collection<PreparedGeometry> filters = getFilterGeometries(file);
if (!filters.isEmpty()) {
String bareName = getFileNameWithoutExtension(file
.getName());
.getPath());
geometryMap.put(bareName.toLowerCase(), filters);
}
}
@ -112,11 +115,9 @@ public class LightningGeoFilter {
* @return empty list on error
*/
private static Collection<PreparedGeometry> getFilterGeometries(
LocalizationFile file) {
ILocalizationFile file) {
Collection<PreparedGeometry> rval;
InputStream in = null;
try {
in = file.openInputStream();
try (InputStream in = file.openInputStream()) {
GeoFilterResult result = GeoFilterParser.parse(in);
if (result.hasErrors()) {
for (GeoFilterException e : result.getErrors()) {
@ -125,25 +126,10 @@ public class LightningGeoFilter {
log.warn("Filter parsing included errors, filters will be incomplete");
}
return result.getFilters();
} catch (JAXBException e) {
log.error("Unable to parse filter file: " + file.getName(), e);
} catch (IOException | JAXBException | LocalizationException
| SerializationException e) {
log.error("Unable to parse filter file: " + file.getPath(), e);
rval = Collections.emptyList();
} catch (LocalizationException e) {
log.error("Unable to open filter file: " + file.getName(), e);
rval = Collections.emptyList();
} catch (SerializationException e) {
log.error("Unable to parse filter file: " + file.getName(), e);
rval = Collections.emptyList();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
log.error(
"Problem closing localization file: "
+ file.getName(), e);
}
}
}
return rval;
}

View file

@ -61,6 +61,8 @@ import com.raytheon.uf.common.util.mapping.MultipleMappingException;
* Oct 14, 2013 2473 bsteffen Remove lookup of deprecated grib files.
* Jun 05, 2015 4495 njensen Improved error message
* Jul 13, 2015 4537 randerso Removed unused function
* Jan 27, 2016 5237 tgurney Remove deprecated LocalizationFile
* method call
*
* </pre>
*
@ -190,7 +192,7 @@ public class GridParamInfoLookup {
} catch (JAXBException e) {
statusHandler.handle(Priority.PROBLEM,
"Error unmarshalling grid parameter information from file "
+ file.getName(), e);
+ file.getPath(), e);
}
}
for (GridParamInfo gridParamInfo : modelParamMap.values()) {

View file

@ -57,6 +57,8 @@ import com.raytheon.uf.common.util.FileUtil;
* Feb 19, 2015 4125 rjpeter Fix jaxb performance issue
* Apr 10, 2015 4383 dgilling Fix getData so it searches correct localization
* directories for secondary sites.
* Jan 27, 2016 5237 tgurney Remove deprecated LocalizationFile
* method call
*
* </pre>
*
@ -93,7 +95,7 @@ public class ReferenceMgr {
new String[] { ".xml" }, false, true);
if (contents != null) {
for (LocalizationFile lf : contents) {
String s = LocalizationUtil.extractName(lf.getName());
String s = LocalizationUtil.extractName(lf.getPath());
String area = s.replace(".xml", "");
refIDs.add(new ReferenceID(area, lf.isProtected(), lf
.getContext().getLocalizationLevel()));
@ -163,11 +165,6 @@ public class ReferenceMgr {
return sr;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "ReferenceMgr [" + dbGridLocation.getSiteId() + "]";

View file

@ -43,6 +43,7 @@ import com.raytheon.uf.common.activetable.VTECPartners;
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
import com.raytheon.uf.common.dataplugin.warning.PracticeWarningRecord;
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;
@ -82,6 +83,7 @@ import com.raytheon.uf.edex.activetable.ActiveTablePyIncludeUtil;
* Added support for sending TCVAdvisory files to
* VTEC partners
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
* Jan 27, 2016 5237 tgurney Replace LocalizationFile with ILocalizationFile
*
* </pre>
*
@ -129,11 +131,6 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
private static final ThreadLocal<PythonScript> pythonScript = new ThreadLocal<PythonScript>() {
/*
* (non-Javadoc)
*
* @see java.lang.ThreadLocal#initialValue()
*/
@Override
protected PythonScript initialValue() {
IPathManager pathMgr = PathManagerFactory.getPathManager();
@ -172,13 +169,6 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
super(TPC_WATCH_TYPE);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.edex.plugin.gfe.watch.AbstractWatchNotifierSrv#handleWatch
* (java.util.List)
*/
@Override
public void handleWatch(List<AbstractWarningRecord> warningRecs) {
/*
@ -439,7 +429,7 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
return practiceMode ? PRACTICE_PATH : TCV_ADVISORY_PATH;
}
private Map<String, Object> loadJSONDictionary(LocalizationFile lf) {
private Map<String, Object> loadJSONDictionary(ILocalizationFile lf) {
if (lf != null) {
PythonScript script = this.pythonScript.get();
if (script != null) {
@ -447,7 +437,7 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
args.put("localizationType", lf.getContext()
.getLocalizationType());
args.put("siteID", lf.getContext().getContextName());
args.put("fileName", lf.getName());
args.put("fileName", lf.getPath());
try {
@SuppressWarnings("unchecked")
Map<String, Object> retVal = (Map<String, Object>) script
@ -463,7 +453,7 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
return null;
}
private void saveJSONDictionary(LocalizationFile lf,
private void saveJSONDictionary(ILocalizationFile lf,
Map<String, Object> dict) {
if (lf != null) {
PythonScript script = this.pythonScript.get();
@ -472,7 +462,7 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
args.put("localizationType", lf.getContext()
.getLocalizationType());
args.put("siteID", lf.getContext().getContextName());
args.put("fileName", lf.getName());
args.put("fileName", lf.getPath());
args.put("javaObject", dict);
try {
script.execute("saveJsonFromJava", args);
@ -484,13 +474,6 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.edex.plugin.gfe.warning.AbstractWarningNotifierSrv#
* buildNotification(java.util.List,
* com.raytheon.uf.common.activetable.VTECPartners)
*/
@Override
protected String buildNotification(List<AbstractWarningRecord> decodedVTEC,
VTECPartners partnersConfig) {

View file

@ -43,6 +43,8 @@ import com.vividsolutions.jts.io.WKTReader;
* 09/11/2012 DR 15366 D. Friedman Set SRID on radar stations.
* Mar 06, 2014 2876 mpduff Moved NationalDatasetSubscriber.
* Jul 09, 2015 4500 rjpeter Fix SQL Injection concern.
* Jan 27, 2016 5237 tgurney Replace deprecated LocalizationFile
* method call
* </pre>
*/
public class Import88DLocationsUtil implements INationalDatasetSubscriber {
@ -166,7 +168,7 @@ public class Import88DLocationsUtil implements INationalDatasetSubscriber {
statusHandler.handle(
Priority.PROBLEM,
"Could not create output file: "
+ outFile.getName(), e);
+ outFile.getPath(), e);
}
} finally {
if (fis != null) {

View file

@ -61,6 +61,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* ------------ ---------- ----------- --------------------------
* Nov 17, 2010 rjpeter Initial creation
* Aug 26, 2014 3503 bclement removed warning
* Jan 27, 2016 5237 tgurney Remove deprecated LocalizationFile
* method call
*
* </pre>
*
@ -214,7 +216,7 @@ public class LocationCache {
handler.handle(
Priority.WARN,
"Error deleting cwat location file ["
+ localizationFile.getName() + "], "
+ localizationFile.getPath() + "], "
+ e2.getMessage());
}
} finally {
@ -239,7 +241,7 @@ public class LocationCache {
location.setLastModifiyTime(file.lastModified());
} catch (Exception e) {
handler.handle(Priority.ERROR, "Error saving cwat location file ["
+ locationFile.getName() + "], Error: " + e.getMessage());
+ locationFile.getPath() + "], Error: " + e.getMessage());
}
}

View file

@ -142,6 +142,7 @@ import com.raytheon.uf.edex.plugin.ffmp.common.FFTIRatioDiff;
* Sep 09, 2015 4756 dhladky Further generalization of FFG processing.
* Sep 21, 2015 4756 dhladky Allow ARCHIVE types to not be purged out.
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
* Jan 27, 2016 5237 tgurney Replace deprecated LocalizationFile method calls
*
* </pre>
*
@ -998,13 +999,13 @@ public class FFMPGenerator extends CompositeProductGenerator implements
FileUtil.file2bytes(f.getFile(), true));
} catch (FileNotFoundException fnfe) {
statusHandler.handle(Priority.ERROR,
"Unable to locate file " + f.getName());
"Unable to locate file " + f.getPath());
} catch (SerializationException se) {
statusHandler.handle(Priority.ERROR,
"Unable to read file " + f.getName());
"Unable to read file " + f.getPath());
} catch (IOException ioe) {
statusHandler.handle(Priority.ERROR,
"General IO problem with file " + f.getName(), ioe);
"General IO problem with file " + f.getPath(), ioe);
}
return sbl;
@ -1747,16 +1748,16 @@ public class FFMPGenerator extends CompositeProductGenerator implements
FileUtil.file2bytes(f.getFile(), true));
} catch (FileNotFoundException fnfe) {
statusHandler.handle(Priority.ERROR,
"Unable to locate file " + f.getName(), fnfe);
"Unable to locate file " + f.getPath(), fnfe);
} catch (SerializationException se) {
statusHandler.handle(Priority.ERROR, "Unable to serialize file "
+ f.getName(), se);
+ f.getPath(), se);
} catch (IOException ioe) {
statusHandler.handle(Priority.ERROR,
"IO problem reading file " + f.getName(), ioe);
"IO problem reading file " + f.getPath(), ioe);
} catch (Exception e) {
statusHandler.handle(Priority.ERROR,
"General Exception reading file " + f.getName(), e);
"General Exception reading file " + f.getPath(), e);
}
return ffti;

View file

@ -44,8 +44,8 @@ import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.localization.ILocalizationFile;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.parameter.Parameter;
import com.raytheon.uf.common.serialization.SerializationException;
@ -61,18 +61,20 @@ import com.raytheon.uf.edex.plugin.grid.netcdf.description.product.NetcdfGridPro
/**
* Base class for decoding NetCDF Grid files.
*
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 03, 2015 4696 nabowle Initial creation
* Sep 10, 2015 4696 nabowle Refactored. Renamed. No longer abstract.
*
* Jan 27, 2016 5237 tgurney Replace LocalizationFile with
* ILocalizationFile
*
* </pre>
*
*
* @author nabowle
* @version 1.0
*/
@ -96,10 +98,10 @@ public class NetcdfGridDecoder {
* Decodes the provided file. Note: This will like be memory intensive. If
* the files are expected to create many records, it's better to split the
* file, and decode and store records individually.
*
*
* This method will decode all the records together and return them for
* batch storage.
*
*
* @param f
* The data file.
* @return The decoded grid records, or an empty array if no records could
@ -150,8 +152,8 @@ public class NetcdfGridDecoder {
Variable dataVar = file.findVariable(product.getData().getName());
if (dataVar == null) {
logger.error("No {} {} data in file: {}", descriptions
.getDatasetId(), product.getData().getName(),
f.getName());
.getDatasetId(), product.getData().getName(), f
.getName());
return EMPTY_RECORDS;
}
@ -268,7 +270,7 @@ public class NetcdfGridDecoder {
/**
* Does some preliminary decoding of common values and combines those with
* the level index and a product description to specify individual records.
*
*
* @param f
* The file to split.
* @return An iterator over the record descriptions.
@ -299,8 +301,7 @@ public class NetcdfGridDecoder {
DataTime dataTime = descriptions.getDataTime().getDataTime(file);
if (dataTime == null) {
throw new NetcdfDecoderException(
"Cannot decode the data time.");
throw new NetcdfDecoderException("Cannot decode the data time.");
}
GridCoverage location = getCoverage(file, descriptions);
@ -323,7 +324,8 @@ public class NetcdfGridDecoder {
}
NetcdfGridRecordInfo info;
for (NetcdfGridProductDescription prod : descriptions.getDescriptions()) {
for (NetcdfGridProductDescription prod : descriptions
.getDescriptions()) {
for (int i = 0; i < numLevels; i++) {
info = new NetcdfGridRecordInfo();
info.setDataTime(dataTime);
@ -399,25 +401,25 @@ public class NetcdfGridDecoder {
/**
* The {@link IPathManager} is used to look up the configured description
* file.
*
*
* @throws JAXBException
* @throws SerializationException
*/
public void setPathManager(IPathManager pathManager) {
LocalizationFile[] files = pathManager.listStaticFiles("grid/netcdf",
ILocalizationFile[] files = pathManager.listStaticFiles("grid/netcdf",
new String[] { ".xml" }, true, true);
NetcdfGridProductDescriptions descriptions;
for (LocalizationFile file : files) {
for (ILocalizationFile file : files) {
logger.info("Loading Netcdf Grid description from "
+ file.getName());
+ file.getPath());
try (InputStream inputStream = file.openInputStream()) {
descriptions = JAXB.unmarshal(inputStream,
NetcdfGridProductDescriptions.class);
this.descriptionsList.add(descriptions);
} catch (LocalizationException | IOException e) {
logger.error("Unable to load product descriptions from {}",
file.getName(), e);
file.getPath(), e);
}
}

View file

@ -60,6 +60,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* in case they were written by another member of the cluster.
* Mar 12, 2013 1646 mpduff Format the output.
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
* Jan 27, 2016 5237 tgurney Replace deprecated LocalizationFile method call
*
* </pre>
*
@ -113,7 +114,7 @@ class FileManager {
LocalizationContext context = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
LocalizationFile locFile = pm
.getLocalizationFile(context, lf.getName());
.getLocalizationFile(context, lf.getPath());
try {
JAXBManager jaxbManager = getJaxbManager();
Marshaller marshaller = jaxbManager.getJaxbContext()

View file

@ -28,6 +28,8 @@ import com.raytheon.uf.edex.auth.roles.IRoleStorage;
* ------------ ---------- ----------- --------------------------
* May 25, 2010 rgeorge Initial creation
* Oct 09, 2013 2361 njensen Use JAXBManager for XML
* Jan 27, 2016 5237 tgurney Replace deprecated LocalizationFile
* method calls
*
* </pre>
*
@ -86,15 +88,15 @@ public class NwsRoleStorage implements IRoleStorage {
if (locFile.exists()) {
file = locFile.getFile();
if (lastUsedFileMap.get(locFile.getName()) == null
if (lastUsedFileMap.get(locFile.getPath()) == null
|| (file != null && (file.equals(lastUsedFileMap
.get(locFile.getName())) == false || file
.get(locFile.getPath())) == false || file
.lastModified() > lastModificationTimeMap
.get(locFile.getName())))) {
.get(locFile.getPath())))) {
// First time we found a role file, or we have a different
// file to
// use or we were modified since our last check
lastUsedFileMap.put(locFile.getName(), file);
lastUsedFileMap.put(locFile.getPath(), file);
try {
roleData = jaxb.unmarshalFromXmlFile(file
.getAbsolutePath());
@ -105,7 +107,7 @@ public class NwsRoleStorage implements IRoleStorage {
"Error loading file: " + file.getName(), e);
}
lastModificationTimeMap.put(locFile.getName(),
lastModificationTimeMap.put(locFile.getPath(),
file.lastModified());
}
}
@ -132,13 +134,6 @@ public class NwsRoleStorage implements IRoleStorage {
return roleData;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.plugin.nwsauth.roles.IRoleStorage#isAuthorized
* (java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean isAuthorized(String permission, String user,
String application) throws AuthorizationException {