Omaha #5237: Replace calls to deprecated LocalizationFile methods
Change-Id: I81bd2c7fcf29db4b9dea4164b826b8880e707686 Former-commit-id: 843e2b439ea1609dff0583e8eaa25feeb3c6f3cb
This commit is contained in:
parent
1ba4b64743
commit
76bdbc2084
7 changed files with 122 additions and 89 deletions
|
@ -22,7 +22,10 @@ package com.raytheon.edex.plugin.gfe.ifpAG;
|
|||
import java.awt.Point;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
|
@ -73,9 +76,11 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 13, 2011 #8393 dgilling Initial creation
|
||||
* 02/19/13 #1637 randerso Added exception handling for Discrete and Weather
|
||||
* 10/31/2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
* 04/22/2014 #3050 randerso Allow exceptions to propagate to caller from readASCIIGridData
|
||||
* 02/19/13 #1637 randerso Added exception handling for Discrete and Weather
|
||||
* 10/31/2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
* 04/22/2014 #3050 randerso Allow exceptions to propagate to caller from readASCIIGridData
|
||||
* Jan 14, 2016 #5237 tgurney Allow outputAsciiGridData to take
|
||||
* OutputStream as well as File
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -186,73 +191,78 @@ public class ASCIIGrid {
|
|||
}
|
||||
|
||||
public void outputAsciiGridData(File outputFile) throws IOException {
|
||||
PrintWriter outputStream = null;
|
||||
try (FileOutputStream outputStream = new FileOutputStream(outputFile)) {
|
||||
outputAsciiGridData(outputFile);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
outputStream = new PrintWriter(outputFile, "US-ASCII");
|
||||
public void outputAsciiGridData(OutputStream outputStream)
|
||||
throws IOException {
|
||||
try (PrintWriter printStream = new PrintWriter(new OutputStreamWriter(
|
||||
outputStream, "US-ASCII"))) {
|
||||
|
||||
// output for each IGridSlice
|
||||
for (IGridSlice gs : gridSlices) {
|
||||
// keyword identifying new ASCIIGrid
|
||||
outputStream.println("ASCIIGRID");
|
||||
printStream.println("ASCIIGRID");
|
||||
|
||||
// data type
|
||||
if (gs.getGridInfo().getGridType().equals(GridType.SCALAR)) {
|
||||
outputStream.println("SCALAR");
|
||||
printStream.println("SCALAR");
|
||||
} else if (gs.getGridInfo().getGridType()
|
||||
.equals(GridType.VECTOR)) {
|
||||
outputStream.println("VECTOR");
|
||||
printStream.println("VECTOR");
|
||||
} else if (gs.getGridInfo().getGridType()
|
||||
.equals(GridType.WEATHER)) {
|
||||
outputStream.println("WEATHER");
|
||||
printStream.println("WEATHER");
|
||||
} else if (gs.getGridInfo().getGridType()
|
||||
.equals(GridType.DISCRETE)) {
|
||||
outputStream.println("DISCRETE");
|
||||
printStream.println("DISCRETE");
|
||||
} else {
|
||||
outputStream.println("NONE");
|
||||
printStream.println("NONE");
|
||||
}
|
||||
|
||||
// parameter name and level
|
||||
if (!gs.getGridInfo().getParmID().getParmLevel()
|
||||
.equals(ParmID.defaultLevel())) {
|
||||
outputStream
|
||||
printStream
|
||||
.println(gs.getGridInfo().getParmID().getParmName()
|
||||
+ "_"
|
||||
+ gs.getGridInfo().getParmID()
|
||||
.getParmLevel());
|
||||
} else {
|
||||
outputStream.println(gs.getGridInfo().getParmID()
|
||||
printStream.println(gs.getGridInfo().getParmID()
|
||||
.getParmName());
|
||||
}
|
||||
|
||||
// database site identifier
|
||||
outputStream.println(gs.getGridInfo().getParmID().getDbId()
|
||||
printStream.println(gs.getGridInfo().getParmID().getDbId()
|
||||
.getSiteId());
|
||||
|
||||
// database optional type
|
||||
if (gs.getGridInfo().getParmID().getDbId().getDbType()
|
||||
.equals("")) {
|
||||
outputStream.println("<notype>");
|
||||
printStream.println("<notype>");
|
||||
} else {
|
||||
outputStream.println(gs.getGridInfo().getParmID().getDbId()
|
||||
printStream.println(gs.getGridInfo().getParmID().getDbId()
|
||||
.getDbType());
|
||||
}
|
||||
|
||||
// database model name
|
||||
outputStream.println(gs.getGridInfo().getParmID().getDbId()
|
||||
printStream.println(gs.getGridInfo().getParmID().getDbId()
|
||||
.getModelName());
|
||||
|
||||
// database time
|
||||
outputStream.println(gs.getGridInfo().getParmID().getDbId()
|
||||
printStream.println(gs.getGridInfo().getParmID().getDbId()
|
||||
.getModelTime());
|
||||
|
||||
// projection identifier
|
||||
outputStream.println(gs.getGridInfo().getGridLoc()
|
||||
printStream.println(gs.getGridInfo().getGridLoc()
|
||||
.getProjection().getProjectionID());
|
||||
|
||||
// grid size (x y), minimum world coordinates (x y),
|
||||
// domain extent (x y)
|
||||
outputStream.println(gs.getGridInfo().getGridLoc().getNx()
|
||||
printStream.println(gs.getGridInfo().getGridLoc().getNx()
|
||||
.toString()
|
||||
+ " "
|
||||
+ gs.getGridInfo().getGridLoc().getNy().toString()
|
||||
|
@ -265,26 +275,26 @@ public class ASCIIGrid {
|
|||
+ " " + gs.getGridInfo().getGridLoc().getExtent().y);
|
||||
|
||||
// units
|
||||
outputStream.println(gs.getGridInfo().getUnitString());
|
||||
printStream.println(gs.getGridInfo().getUnitString());
|
||||
|
||||
// descriptive name
|
||||
outputStream.println(gs.getGridInfo().getDescriptiveName());
|
||||
printStream.println(gs.getGridInfo().getDescriptiveName());
|
||||
|
||||
// minimum possible value, maximum possible value, data
|
||||
// precision,
|
||||
// time independent parameter
|
||||
outputStream.print(gs.getGridInfo().getMinValue() + " "
|
||||
printStream.print(gs.getGridInfo().getMinValue() + " "
|
||||
+ gs.getGridInfo().getMaxValue() + " "
|
||||
+ gs.getGridInfo().getPrecision() + " ");
|
||||
if (gs.getGridInfo().isTimeIndependentParm()) {
|
||||
outputStream.print(1);
|
||||
printStream.print(1);
|
||||
} else {
|
||||
outputStream.print(0);
|
||||
printStream.print(0);
|
||||
}
|
||||
outputStream.println();
|
||||
printStream.println();
|
||||
|
||||
// time constraints (startTime, duration, repeatInterval)
|
||||
outputStream.println(gs.getGridInfo().getTimeConstraints()
|
||||
printStream.println(gs.getGridInfo().getTimeConstraints()
|
||||
.getStartTime()
|
||||
+ " "
|
||||
+ gs.getGridInfo().getTimeConstraints().getDuration()
|
||||
|
@ -293,9 +303,9 @@ public class ASCIIGrid {
|
|||
.getRepeatInterval());
|
||||
|
||||
// valid time range for grid
|
||||
outputStream.print(validTimeFormat.format(gs.getValidTime()
|
||||
printStream.print(validTimeFormat.format(gs.getValidTime()
|
||||
.getStart()) + " ");
|
||||
outputStream.println(validTimeFormat.format(gs.getValidTime()
|
||||
printStream.println(validTimeFormat.format(gs.getValidTime()
|
||||
.getEnd()));
|
||||
|
||||
// output the grid points
|
||||
|
@ -305,7 +315,7 @@ public class ASCIIGrid {
|
|||
ScalarGridSlice scalar = (ScalarGridSlice) gs;
|
||||
for (int i = scalar.getScalarGrid().getYdim() - 1; i >= 0; i--) {
|
||||
for (int j = 0; j < scalar.getScalarGrid().getXdim(); j++) {
|
||||
outputStream
|
||||
printStream
|
||||
.println(round(
|
||||
scalar.getScalarGrid().get(j, i),
|
||||
gs.getGridInfo().getPrecision()));
|
||||
|
@ -316,14 +326,14 @@ public class ASCIIGrid {
|
|||
VectorGridSlice vector = (VectorGridSlice) gs;
|
||||
for (int i = vector.getMagGrid().getYdim() - 1; i >= 0; i--) {
|
||||
for (int j = 0; j < vector.getMagGrid().getXdim(); j++) {
|
||||
outputStream.print(round(
|
||||
printStream.print(round(
|
||||
vector.getMagGrid().get(j, i), gs
|
||||
.getGridInfo().getPrecision()));
|
||||
outputStream.print(' ');
|
||||
outputStream.print(round(
|
||||
printStream.print(' ');
|
||||
printStream.print(round(
|
||||
vector.getDirGrid().get(j, i), gs
|
||||
.getGridInfo().getPrecision()));
|
||||
outputStream.println();
|
||||
printStream.println();
|
||||
}
|
||||
}
|
||||
} else if (gs.getGridInfo().getGridType()
|
||||
|
@ -333,7 +343,7 @@ public class ASCIIGrid {
|
|||
for (int j = 0; j < weather.getWeatherGrid().getXdim(); j++) {
|
||||
String key = weather.getKeys()[weather
|
||||
.getWeatherGrid().get(j, i)].toString();
|
||||
outputStream.println(key);
|
||||
printStream.println(key);
|
||||
}
|
||||
}
|
||||
} else if (gs.getGridInfo().getGridType()
|
||||
|
@ -344,15 +354,11 @@ public class ASCIIGrid {
|
|||
.getXdim(); j++) {
|
||||
String key = discrete.getKeys()[discrete
|
||||
.getDiscreteGrid().get(j, i)].toString();
|
||||
outputStream.println(key);
|
||||
printStream.println(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (outputStream != null) {
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,27 +32,31 @@ import com.raytheon.uf.common.dataplugin.gfe.request.GetASCIIGridsRequest;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.request.GetGridRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
||||
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.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.message.WsId;
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Takes temporary grid in ASCII format, converts to GridSlice, and saves to
|
||||
* requested database.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 14, 2011 #8983 dgilling Initial creation
|
||||
* Jun 13, 2013 #2044 randerso Refactored to use IFPServer
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 14, 2011 8983 dgilling Initial creation
|
||||
* Jun 13, 2013 2044 randerso Refactored to use IFPServer
|
||||
* Jan 08, 2016 5237 tgurney Replace calls to deprecated methods of
|
||||
* LocalizationFile + add desc in javadoc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -63,13 +67,6 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
public class GetASCIIGridsHandler extends BaseGfeRequestHandler implements
|
||||
IRequestHandler<GetASCIIGridsRequest> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
|
||||
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse<String> handleRequest(GetASCIIGridsRequest request)
|
||||
throws Exception {
|
||||
|
@ -84,11 +81,13 @@ public class GetASCIIGridsHandler extends BaseGfeRequestHandler implements
|
|||
ASCIIGrid aGrid = new ASCIIGrid(gridSlices,
|
||||
request.getCoordConversionString(), request.getSiteID());
|
||||
|
||||
LocalizationFile tempFile = getTempFile(request.getWorkstationID());
|
||||
aGrid.outputAsciiGridData(tempFile.getFile());
|
||||
tempFile.save();
|
||||
ILocalizationFile tempFile = getTempFile(request.getWorkstationID());
|
||||
try (SaveableOutputStream tempFileStream = tempFile.openOutputStream()) {
|
||||
aGrid.outputAsciiGridData(tempFileStream);
|
||||
tempFileStream.save();
|
||||
}
|
||||
|
||||
sr.setPayload(tempFile.getName());
|
||||
sr.setPayload(tempFile.getPath());
|
||||
|
||||
return sr;
|
||||
}
|
||||
|
@ -187,7 +186,7 @@ public class GetASCIIGridsHandler extends BaseGfeRequestHandler implements
|
|||
return limitTime.contains(t);
|
||||
}
|
||||
|
||||
private LocalizationFile getTempFile(WsId requestor) throws IOException {
|
||||
private ILocalizationFile getTempFile(WsId requestor) throws IOException {
|
||||
IPathManager pathManager = PathManagerFactory.getPathManager();
|
||||
LocalizationContext ctx = pathManager.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.USER);
|
||||
|
@ -199,7 +198,7 @@ public class GetASCIIGridsHandler extends BaseGfeRequestHandler implements
|
|||
}
|
||||
|
||||
File tmpFile = File.createTempFile("ifpAG", ".txt", parentDir);
|
||||
LocalizationFile locTmpFile = pathManager.getLocalizationFile(ctx,
|
||||
ILocalizationFile locTmpFile = pathManager.getLocalizationFile(ctx,
|
||||
"/gfe/ifpAG/" + tmpFile.getName());
|
||||
|
||||
return locTmpFile;
|
||||
|
|
|
@ -31,11 +31,12 @@ import com.raytheon.edex.plugin.gfe.util.SendNotifications;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.request.SaveCombinationsFileRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.CombinationsFileChangedNotification;
|
||||
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.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.common.util.StringUtil;
|
||||
|
@ -56,6 +57,8 @@ import com.raytheon.uf.common.util.StringUtil;
|
|||
* flushed/closed.
|
||||
* Feb 05, 2014 #2591 Added CombinationFileChangedNotification
|
||||
* Jul 21, 2014 2768 bclement removed FileUpdateMessage
|
||||
* Jan 08, 2016 5237 tgurney Replace calls to deprecated
|
||||
* LocalizationFile methods
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -69,13 +72,6 @@ public class SaveCombinationsFileHandler implements
|
|||
private static final String COMBO_FILE_DIR = FileUtil.join("gfe",
|
||||
"combinations");
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
|
||||
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse<Object> handleRequest(
|
||||
SaveCombinationsFileRequest request) throws Exception {
|
||||
|
@ -86,7 +82,7 @@ public class SaveCombinationsFileHandler implements
|
|||
|
||||
String comboName = request.getFileName();
|
||||
String fileName = FileUtil.join(COMBO_FILE_DIR, comboName) + ".py";
|
||||
LocalizationFile lf = pm.getLocalizationFile(localization, fileName);
|
||||
ILocalizationFile lf = pm.getLocalizationFile(localization, fileName);
|
||||
|
||||
Writer outWriter = null;
|
||||
try {
|
||||
|
@ -118,7 +114,9 @@ public class SaveCombinationsFileHandler implements
|
|||
outWriter.close();
|
||||
}
|
||||
}
|
||||
lf.save();
|
||||
try (SaveableOutputStream lfStream = lf.openOutputStream()) {
|
||||
lfStream.save();
|
||||
}
|
||||
|
||||
/*
|
||||
* placing the notification code here ensures we only send the
|
||||
|
|
|
@ -34,12 +34,13 @@ import com.raytheon.edex.plugin.gfe.reference.MapManager;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
|
||||
import com.raytheon.uf.common.dataquery.db.QueryResult;
|
||||
import com.raytheon.uf.common.dataquery.db.QueryResultRow;
|
||||
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.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.python.PyUtil;
|
||||
import com.raytheon.uf.common.python.PythonScript;
|
||||
|
@ -66,6 +67,8 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
|
|||
* LocalizationSupport
|
||||
* Jul 13, 2015 4500 rjpeter Fix SQL Injection concerns.
|
||||
* Dec 15, 2015 RM17933 mgamazaychikov Add four new corners to PART_OF_STATE.
|
||||
* Jan 08, 2016 5213 tgurney Replace calls to deprecated LocalizationFile
|
||||
* methods
|
||||
* </pre>
|
||||
*
|
||||
* @author wldougher
|
||||
|
@ -278,9 +281,9 @@ public class AreaDictionaryMaker {
|
|||
pyScript.execute("createCityLocation", argMap);
|
||||
|
||||
// check to see if Hazard_TCV was configured for this site
|
||||
LocalizationFile lf = pathMgr.getLocalizationFile(caveStaticConfig,
|
||||
FileUtil.join("gfe", "userPython", "textProducts",
|
||||
"Hazard_TCV.py"));
|
||||
ILocalizationFile lf = pathMgr.getLocalizationFile(
|
||||
caveStaticConfig, FileUtil.join("gfe", "userPython",
|
||||
"textProducts", "Hazard_TCV.py"));
|
||||
if (lf.exists()) {
|
||||
argMap.put("siteID", siteID);
|
||||
pyScript.execute("createTCVAreaDictionary", argMap);
|
||||
|
@ -315,7 +318,7 @@ public class AreaDictionaryMaker {
|
|||
List<Map<String, Object>> attributes, String fileName,
|
||||
String dictName, String group, char separator, String cityQuery) {
|
||||
|
||||
LocalizationFile lf = pathMgr.getLocalizationFile(context,
|
||||
ILocalizationFile lf = pathMgr.getLocalizationFile(context,
|
||||
FileUtil.join("gfe", fileName));
|
||||
|
||||
try (PrintWriter out = new PrintWriter(lf.openOutputStream())) {
|
||||
|
@ -406,8 +409,8 @@ public class AreaDictionaryMaker {
|
|||
statusHandler.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
lf.save();
|
||||
try (SaveableOutputStream lfStream = lf.openOutputStream()) {
|
||||
lfStream.save();
|
||||
} catch (Exception e) {
|
||||
statusHandler.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
|
|
@ -36,12 +36,13 @@ import com.raytheon.edex.utility.ProtectedFiles;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
|
||||
import com.raytheon.uf.common.dataquery.db.QueryResult;
|
||||
import com.raytheon.uf.common.dataquery.db.QueryResultRow;
|
||||
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.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.python.PyUtil;
|
||||
import com.raytheon.uf.common.python.PythonScript;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
|
@ -77,6 +78,8 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
|
|||
* Apr 27, 2015 4259 njensen Updated for new JEP API
|
||||
* Jul 13, 2015 4500 rjpeter Removed SqlQueryTask.
|
||||
* Dec 15, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
* Jan 08, 2016 5237 tgurney Replace calls to deprecated LocalizationFile
|
||||
* methods
|
||||
* </pre>
|
||||
*
|
||||
* @author jelkins
|
||||
|
@ -207,7 +210,7 @@ public class Configurator {
|
|||
context.setContextName(siteID);
|
||||
|
||||
// regenerate siteCFG.py
|
||||
LocalizationFile lf = null;
|
||||
ILocalizationFile lf = null;
|
||||
try {
|
||||
lf = pathMgr.getLocalizationFile(context,
|
||||
FileUtil.join("python", "gfe", "SiteCFG.py"));
|
||||
|
@ -257,7 +260,10 @@ public class Configurator {
|
|||
out.println("}");
|
||||
} // out is closed here
|
||||
|
||||
lf.save();
|
||||
try (SaveableOutputStream lfStream = lf.openOutputStream()) {
|
||||
lfStream.save();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
statusHandler.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.edex.plugin.warning.gis;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -61,12 +62,13 @@ import com.raytheon.uf.common.geospatial.ISpatialQuery.SearchMode;
|
|||
import com.raytheon.uf.common.geospatial.SpatialException;
|
||||
import com.raytheon.uf.common.geospatial.SpatialQueryFactory;
|
||||
import com.raytheon.uf.common.geospatial.SpatialQueryResult;
|
||||
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.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
|
@ -114,6 +116,10 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
|
|||
* caught exception in updateFeatures() & topologySimplifyQueryResults(),
|
||||
* and added composeMessage().
|
||||
* Aug 05, 2015 4486 rjpeter Changed Timestamp to Date.
|
||||
* Jan 08, 2016 5237 tgurney Replaced LocalizationFile with ILocalizationFile
|
||||
* (and removed calls to deprecated methods found
|
||||
* only on the former)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
|
@ -863,9 +869,15 @@ public class GeospatialDataGenerator {
|
|||
context.setContextName(site);
|
||||
|
||||
byte[] data = SerializationUtil.transformToThrift(geoData);
|
||||
LocalizationFile lf = pathMgr.getLocalizationFile(context,
|
||||
ILocalizationFile lf = pathMgr.getLocalizationFile(context,
|
||||
GeospatialFactory.GEO_DIR + fileName);
|
||||
lf.write(data);
|
||||
try (SaveableOutputStream sos = lf.openOutputStream()) {
|
||||
sos.write(data);
|
||||
sos.save();
|
||||
} catch (IOException e) {
|
||||
throw new LocalizationException("Could not write to file "
|
||||
+ lf.getPath(), e);
|
||||
}
|
||||
|
||||
curTime.setFileName(fileName);
|
||||
times.put(curTime.getMetaData(), curTime);
|
||||
|
@ -876,7 +888,13 @@ public class GeospatialDataGenerator {
|
|||
|
||||
lf = pathMgr.getLocalizationFile(context,
|
||||
GeospatialFactory.METADATA_FILE);
|
||||
lf.write(xml.getBytes());
|
||||
try (SaveableOutputStream sos = lf.openOutputStream()) {
|
||||
sos.write(xml.getBytes());
|
||||
sos.save();
|
||||
} catch (IOException e) {
|
||||
throw new LocalizationException("Could not write to file "
|
||||
+ lf.getPath(), e);
|
||||
}
|
||||
} finally {
|
||||
if (ct != null) {
|
||||
ClusterLockUtils.unlock(ct, false);
|
||||
|
@ -891,14 +909,14 @@ public class GeospatialDataGenerator {
|
|||
LocalizationContext context = pathMgr.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.CONFIGURED);
|
||||
context.setContextName(site);
|
||||
LocalizationFile lf = pathMgr.getLocalizationFile(context,
|
||||
ILocalizationFile lf = pathMgr.getLocalizationFile(context,
|
||||
GeospatialFactory.GEO_DIR + fileName);
|
||||
if (lf.exists()) {
|
||||
try {
|
||||
lf.delete();
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.WARN,
|
||||
"Failed to delete area geometry file " + lf.getName(),
|
||||
"Failed to delete area geometry file " + lf.getPath(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ 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.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -51,6 +52,8 @@ import com.raytheon.uf.edex.ndm.ingest.INationalDatasetSubscriber;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 25, 2015 4512 mapeters Initial creation.
|
||||
* Jan 08, 2016 5237 tgurney Replace call to deprecated
|
||||
* LocalizationFile.write()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -125,12 +128,12 @@ public abstract class AbstractRedbookNdmSubscriber implements
|
|||
locFile.getFile().getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
locFile.write(Files.readAllBytes(file.toPath()));
|
||||
try (SaveableOutputStream locFileStream = locFile.openOutputStream()) {
|
||||
locFileStream.write(Files.readAllBytes(file.toPath()));
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Failed to write contents of " + file.getPath() + " to "
|
||||
+ locFile.getFile().getPath(), e);
|
||||
+ locFile.getPath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue