Issue #1064 Fixed issue with grib splitter writing to nonexistent directories

Change-Id: I2b0246d3589074c29606a030f317d825cfc5f2e3

Former-commit-id: ccb9b1b4e9caf8523706535b141b0e54dd798c70
This commit is contained in:
Benjamin Phillippe 2012-08-15 16:20:56 -05:00 committed by Steve Harris
parent e1c07b5803
commit a501aacb3b

View file

@ -48,6 +48,8 @@ import com.raytheon.uf.edex.python.decoder.PythonDecoder;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 3/12/10 4758 bphillip Initial creation
* 8/15/12 1064 bphillip Added code to ensure the destination folders for large file splits are
* present
* </pre>
*
* @author njensen
@ -55,10 +57,38 @@ import com.raytheon.uf.edex.python.decoder.PythonDecoder;
*/
public class GribDecoder {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(GribDecoder.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GribDecoder.class);
/** The size limit for grib files before an attempt is made to split them */
private static final long TEN_MEGABYTES = 10485760;
/** The directory which split grib 1 files are written to */
private static final File LARGE_GRIB1_DIR = new File(
System.getProperty("edex.home")
+ "/data/manual/grib/grib1LargeSplit/");
/** The directory which split grib2 files are written to */
private static final File LARGE_GRIB2_DIR = new File(
System.getProperty("edex.home")
+ "/data/manual/grib/grib2LargeSplit/");
static {
/*
* Ensure the grib1 split output directory exists
*/
if (!LARGE_GRIB1_DIR.exists()) {
LARGE_GRIB1_DIR.mkdirs();
}
/*
* Ensure the grib2 split output directory exists
*/
if (!LARGE_GRIB2_DIR.exists()) {
LARGE_GRIB2_DIR.mkdirs();
}
}
public GribDecoder() {
}
@ -136,7 +166,7 @@ public class GribDecoder {
}
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, "Failed to decode file: ["
+ file.getAbsolutePath() + "]", e);
+ file.getAbsolutePath() + "]", e);
records = new GribRecord[0];
} finally {
try {
@ -176,7 +206,6 @@ public class GribDecoder {
out = new FileOutputStream(System.getProperty("edex.home")
+ "/data/manual/grib/grib" + edition + "LargeSplit/" + fileName + "_record_" + (i + 1));
out.write(transfer);
out.close();
} finally {
if (out != null) {
out.close();