Issue #2249 Add check for director when checking for file created by the TextEditorDialog.

Change-Id: Iede767fca5a720e1972c772f752bcf830f8c092b

Former-commit-id: b3b6ed29e6 [formerly 604ff6a0dd [formerly bfa59e5de2ad0d6bb0625b275c43aede596cb2c2]]
Former-commit-id: 604ff6a0dd
Former-commit-id: f5fa113ded
This commit is contained in:
Roger Ferrel 2013-09-18 09:47:46 -05:00
parent 86ecc443b8
commit 27efe780b1
3 changed files with 37 additions and 7 deletions

View file

@ -4968,6 +4968,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
oup.setWmoType(fixNOR(prod.getBbbid()));
oup.setUserDateTimeStamp(prod.getHdrtime());
StringBuilder fileName = new StringBuilder();
// The .wan extension followed by the 10 digit epoch seconds
// of simulated time is used in EDEX's WarningDecoder to
// determine the base time.
fileName.append(awipsID).append(".wan")
.append(TimeUtil.getUnixTime(TimeUtil.newDate()));
oup.setFilename(fileName.toString());

View file

@ -128,7 +128,7 @@ class StdWarningDecoder():
except :
LogStream.logProblem('Unable to get timestamp from filename: "%s"' % (self._incomingFilename))
else:
# Use the epoch seconds from file generated by the text editor dialog,
# Use the epoch seconds in the file generated by TextEditorDialog.java.
self._time = long(warningTimestamp)
os.umask(0) #ensure proper permissions

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.uf.edex.decodertools.time;
import java.io.File;
import java.text.ParseException;
import java.util.Calendar;
import java.util.TimeZone;
@ -68,10 +69,21 @@ public class TimeTools {
.compile("(.*\\.)(\\d{8}|\\d{10})$");
/**
* Time stamp for a file name created by the Text Editor Dialog.
* Time stamp for a file name created by the Text Editor Dialog. This
* assumes the 10 digit following .wan is the warning's issue time in epoch
* seconds.
*/
private static final Pattern FILE_WARNING_TIMESTAMP = Pattern
.compile(".*\\.wan(\\d{10})$");
private static final String TEXT_EDITOR_WARNING = ".*\\.wan(\\d{10})$";
/**
* Environment variable with the root directory.
*/
private static final String DATA_ARCHIVE_ROOT = "data.archive.root";
/**
* Pattern for getting time stamp from Text Editor Dialog created files.
*/
private static Pattern FILE_WARNING_TIMESTAMP = null;
public static final Pattern WMO_TIMESTAMP = Pattern
.compile("([0-3][0-9])(\\d{2})(\\d{2})[Zz]?");
@ -113,7 +125,7 @@ public class TimeTools {
}
/** Allows the check on archive to be overriden for testing. */
/** Allows the check on archive to be overridden for testing. */
static ICheckAllowArchive checkAllowArchive = new CheckOSEnv();
/**
@ -246,12 +258,26 @@ public class TimeTools {
}
/**
* Get the time stamp of a warning file name.
* Get the time stamp of a warning file name based on the name generated by
* the TextEditorDialog.
*
* @param fileName
* @return timestamp if if matches FILE_WARNING_TIMESTAMP otherwise null
* @return timestamp warning's issue time in epoch seconds when fileName is
* a Text Editor Dialog file otherwise null
*/
public static final String getWarningTimestamp(String fileName) {
if (FILE_WARNING_TIMESTAMP == null) {
// Create pattern to test if fileName is in a director relative to
// DATA_ARCHIVE_ROOT and ends with the expected extension.
StringBuilder pattern = new StringBuilder("^");
pattern.append(System.getProperty(DATA_ARCHIVE_ROOT));
if (!pattern.substring(pattern.length() - 1).equals(File.separator)) {
pattern.append(File.separator);
}
pattern.append(TEXT_EDITOR_WARNING);
FILE_WARNING_TIMESTAMP = Pattern.compile(pattern.toString());
}
String timestamp = null;
Matcher matcher = FILE_WARNING_TIMESTAMP.matcher(fileName);
if (matcher.find()) {