diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.lsr/src/com/raytheon/uf/common/dataplugin/lsr/LSREventType.java b/edexOsgi/com.raytheon.uf.common.dataplugin.lsr/src/com/raytheon/uf/common/dataplugin/lsr/LSREventType.java index fd2fe785cd..7c95421386 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.lsr/src/com/raytheon/uf/common/dataplugin/lsr/LSREventType.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.lsr/src/com/raytheon/uf/common/dataplugin/lsr/LSREventType.java @@ -35,6 +35,7 @@ import java.util.Map; * Oct 14, 2009 jkorman Initial creation * Dec 09, 2013 2581 njensen Added freezing drizzle * Jan 03, 2014 2581 njensen Added coastal flood + * Jan 13, 2014 2581 njensen Added debris flow * * * @@ -85,7 +86,8 @@ public enum LSREventType { WATERSPOUT("WATER SPOUT",38,LSRUnits.NOUNITS), WILDFIRE("WILDFIRE",39,LSRUnits.NOUNITS), FREEZINGDRIZZLE("FREEZING DRIZZLE", 40, LSRUnits.NOUNITS), - COASTALFLOOD("COASTAL FLOOD", 41, LSRUnits.NOUNITS); + COASTALFLOOD("COASTAL FLOOD", 41, LSRUnits.NOUNITS), + DEBRISFLOW("DEBRIS FLOW", 42, LSRUnits.NOUNITS); private final String eventName; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.dataplugin/META-INF/MANIFEST.MF index dee4ff2d80..7528d681f3 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/META-INF/MANIFEST.MF @@ -9,6 +9,7 @@ Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization Export-Package: com.raytheon.uf.common.dataplugin, com.raytheon.uf.common.dataplugin.annotations, com.raytheon.uf.common.dataplugin.defaults, + com.raytheon.uf.common.dataplugin.exception, com.raytheon.uf.common.dataplugin.message, com.raytheon.uf.common.dataplugin.persist, com.raytheon.uf.common.dataplugin.request diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/exception/BadDataException.java b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/exception/BadDataException.java new file mode 100644 index 0000000000..53a495ff28 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/exception/BadDataException.java @@ -0,0 +1,74 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.dataplugin.exception; + +/** + * An exception for bad data. Intended primarily to be subclassed but + * potentially used in catch blocks. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 13, 2014            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public abstract class BadDataException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Default Constructor + * + */ + public BadDataException() { + super(); + } + + /** + * @param message + */ + public BadDataException(String message) { + super(message); + } + + /** + * @param message + * @param cause + */ + public BadDataException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param cause + */ + public BadDataException(Throwable cause) { + super(cause); + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/exception/UnrecognizedDataException.java b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/exception/UnrecognizedDataException.java new file mode 100644 index 0000000000..1d048ecae9 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/exception/UnrecognizedDataException.java @@ -0,0 +1,74 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.dataplugin.exception; + +/** + * An exception for when the data may be valid but the code does not recognize + * it and/or doesn't know to handle it. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 13, 2014 2581       njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class UnrecognizedDataException extends BadDataException { + + private static final long serialVersionUID = 1L; + + /** + * Default Constructor + * + */ + public UnrecognizedDataException() { + super(); + } + + /** + * @param message + */ + public UnrecognizedDataException(String message) { + super(message); + } + + /** + * @param message + * @param cause + */ + public UnrecognizedDataException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param cause + */ + public UnrecognizedDataException(Throwable cause) { + super(cause); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/decoder/LSRParser.java b/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/decoder/LSRParser.java index 9e75eac277..b8da362fb3 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/decoder/LSRParser.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/decoder/LSRParser.java @@ -29,6 +29,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import com.raytheon.edex.esb.Headers; +import com.raytheon.uf.common.dataplugin.exception.UnrecognizedDataException; import com.raytheon.uf.common.dataplugin.lsr.LSREventType; import com.raytheon.uf.common.dataplugin.lsr.LocalStormReport; import com.raytheon.uf.common.pointdata.PointDataContainer; @@ -55,6 +56,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; * Dec 09, 2013 2581 njensen Reuse patterns for efficiency * Check entire time line looking for latlon * Jan 07, 2013 2581 njensen Check to end of string for source, not a set length + * Jan 13, 2013 2581 njensen Improved error handling and logging * * * @@ -315,26 +317,32 @@ public class LSRParser { LocalStormReport rpt = new LocalStormReport(); String s = r.getReportLine(); - if (parseTimeLine(s, rpt)) { - List rptLines = r.getSubLines(); - if (rptLines != null) { - r = rptLines.get(0); - if (InternalType.DATE.equals(r.getLineType())) { - s = r.getReportLine(); - if (parseDateLine(s, rpt)) { - // Now check the remarks section. - parseRemarks(rptLines, rpt); - rpt.setWmoHeader(wmoHeader - .getWmoHeader()); - rpt.setOfficeid(officeid); - rpt.setTraceId(traceId); + try { + if (parseTimeLine(s, rpt)) { + List rptLines = r.getSubLines(); + if (rptLines != null) { + r = rptLines.get(0); + if (InternalType.DATE.equals(r + .getLineType())) { + s = r.getReportLine(); + if (parseDateLine(s, rpt)) { + // Now check the remarks section. + parseRemarks(rptLines, rpt); + rpt.setWmoHeader(wmoHeader + .getWmoHeader()); + rpt.setOfficeid(officeid); + rpt.setTraceId(traceId); - reports.add(rpt); + reports.add(rpt); + } + } else { + logger.error("Date Line expected"); } - } else { - logger.error("Date Line expected"); } } + } catch (UnrecognizedDataException e) { + logger.error("Error decoding line " + s + + " - skipping this entry", e); } } } @@ -343,7 +351,8 @@ public class LSRParser { return reports; } - private boolean parseTimeLine(String timeLine, LocalStormReport rpt) { + private boolean parseTimeLine(String timeLine, LocalStormReport rpt) + throws UnrecognizedDataException { boolean timeOk = false; if (timeLine != null) { @@ -366,7 +375,12 @@ public class LSRParser { } } ss = timeLine.substring(EVENT, EVENT + EVENT_LENGTH).trim(); - rpt.setEventType(LSREventType.lookup(ss)); + LSREventType eventType = LSREventType.lookup(ss); + if (eventType == null) { + throw new UnrecognizedDataException( + "LSRParser does not recognize eventType " + ss); + } + rpt.setEventType(eventType); ss = timeLine.substring(LOCATION, LOCATION + LOCATION_LENGTH) .trim();