diff --git a/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java b/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java index 5d0a18cef7..c41996bdc8 100644 --- a/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java @@ -214,17 +214,14 @@ public class MetarDecoder extends AbstractDecoder { List retVal = new ArrayList(); -// String fileName = null; -// if (headers != null) { -// fileName = (String) headers -// .get(DecoderTools.INGEST_FILE_NAME); -// } - Calendar baseTime; + Calendar baseTime = TimeTools.getSystemCalendar(); WMOHeader wmoHdr = sep.getWMOHeader(); - if((wmoHdr != null)&&(wmoHdr.isValid())) { - baseTime = TimeTools.findDataTime(wmoHdr.getYYGGgg(), headers); - } else { - baseTime = TimeTools.getSystemCalendar(); + if(TimeTools.allowArchive()) { + if((wmoHdr != null)&&(wmoHdr.isValid())) { + baseTime = TimeTools.findDataTime(wmoHdr.getYYGGgg(), headers); + } else { + logger.error("ARCHIVE MODE-No WMO Header found in file" + headers.get(WMOHeader.INGEST_FILE_NAME)); + } } while (sep.hasNext()) { @@ -326,6 +323,15 @@ public class MetarDecoder extends AbstractDecoder { Calendar obsTime = record.getTimeObs(); if (obsTime != null) { Calendar currTime = TimeTools.copy(baseTime); + + // Do this only for archive mode!!! Otherwise valid data will not pass if the WMO header + // date/time is much less than the obstime. For instance + // WMO Header time = dd1200 + // Observed time = dd1235 + // To solve this will require greater precision in the file timestamp. + if(TimeTools.allowArchive()) { + currTime.add(Calendar.HOUR, 1); + } currTime.add(Calendar.MINUTE, METAR_FUTURE_LIMIT); long diff = currTime.getTimeInMillis() diff --git a/edexOsgi/com.raytheon.edex.textdb/src/com/raytheon/edex/textdb/dbapi/impl/TextDB.java b/edexOsgi/com.raytheon.edex.textdb/src/com/raytheon/edex/textdb/dbapi/impl/TextDB.java index 0fe437bb3a..a04115a4d3 100644 --- a/edexOsgi/com.raytheon.edex.textdb/src/com/raytheon/edex/textdb/dbapi/impl/TextDB.java +++ b/edexOsgi/com.raytheon.edex.textdb/src/com/raytheon/edex/textdb/dbapi/impl/TextDB.java @@ -50,6 +50,7 @@ import com.raytheon.uf.common.message.Header; import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.site.SiteMap; import com.raytheon.uf.edex.core.props.PropertiesFactory; +import com.raytheon.uf.edex.decodertools.time.TimeTools; import com.raytheon.uf.edex.wmo.message.AFOSProductId; import com.raytheon.uf.edex.wmo.message.WMOHeader; @@ -854,8 +855,14 @@ public class TextDB { } product.append(reportData); - long writeTime = System.currentTimeMillis(); - + + Long writeTime = new Long(System.currentTimeMillis()); + if(TimeTools.allowArchive()) { + Calendar c = header.getHeaderDate(); + writeTime = new Long(c.getTimeInMillis()); + + } + StdTextProduct textProduct = (operationalMode ? new OperationalStdTextProduct() : new PracticeStdTextProduct()); textProduct.setWmoid(wmoid); diff --git a/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/decodertools/time/TimeTools.java b/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/decodertools/time/TimeTools.java index e709657fd8..4b264434b3 100644 --- a/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/decodertools/time/TimeTools.java +++ b/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/decodertools/time/TimeTools.java @@ -128,7 +128,8 @@ public class TimeTools { /** * Get a calendar that expresses the current system time based from specified - * date information if the + * date information only if the archive flag is set. Otherwise the current + * system time is returned. * @param year Year to set. * @param month * @param day @@ -503,7 +504,7 @@ public class TimeTools { * @return Is the month valid? */ public static final boolean isValidMonth(int month) { - return ((month > -1)&&(month <= 12)); + return ((month > 0)&&(month <= 12)); } /**