Issue #2581 improve LSR error handling because there was yet another

event type missing

Change-Id: I954d408ecfcfda14f3856f4afc7c04e7ef8148be

Former-commit-id: 85d8f6de32 [formerly 738f97cab1] [formerly eb96c396c2] [formerly 85d8f6de32 [formerly 738f97cab1] [formerly eb96c396c2] [formerly b6a21ccb7c [formerly eb96c396c2 [formerly b85ccd6315e5506c67c39f939c71af363d15a45f]]]]
Former-commit-id: b6a21ccb7c
Former-commit-id: e88fd9b8c5 [formerly ff88e4ab99] [formerly bee76b7681ee23a6fc910b891da62bad416be0e8 [formerly 1b0a722e02]]
Former-commit-id: 66921b4c9694329d3e75c41511e58c7343b02109 [formerly 7c2dc369ff]
Former-commit-id: e258c6e723
This commit is contained in:
Nate Jensen 2014-01-13 12:56:24 -06:00
parent 18410979ad
commit efa03f4d61
5 changed files with 184 additions and 19 deletions

View file

@ -35,6 +35,7 @@ import java.util.Map;
* Oct 14, 2009 jkorman Initial creation * Oct 14, 2009 jkorman Initial creation
* Dec 09, 2013 2581 njensen Added freezing drizzle * Dec 09, 2013 2581 njensen Added freezing drizzle
* Jan 03, 2014 2581 njensen Added coastal flood * Jan 03, 2014 2581 njensen Added coastal flood
* Jan 13, 2014 2581 njensen Added debris flow
* *
* </pre> * </pre>
* *
@ -85,7 +86,8 @@ public enum LSREventType {
WATERSPOUT("WATER SPOUT",38,LSRUnits.NOUNITS), WATERSPOUT("WATER SPOUT",38,LSRUnits.NOUNITS),
WILDFIRE("WILDFIRE",39,LSRUnits.NOUNITS), WILDFIRE("WILDFIRE",39,LSRUnits.NOUNITS),
FREEZINGDRIZZLE("FREEZING DRIZZLE", 40, 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; private final String eventName;

View file

@ -9,6 +9,7 @@ Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
Export-Package: com.raytheon.uf.common.dataplugin, Export-Package: com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.annotations, com.raytheon.uf.common.dataplugin.annotations,
com.raytheon.uf.common.dataplugin.defaults, com.raytheon.uf.common.dataplugin.defaults,
com.raytheon.uf.common.dataplugin.exception,
com.raytheon.uf.common.dataplugin.message, com.raytheon.uf.common.dataplugin.message,
com.raytheon.uf.common.dataplugin.persist, com.raytheon.uf.common.dataplugin.persist,
com.raytheon.uf.common.dataplugin.request com.raytheon.uf.common.dataplugin.request

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 13, 2014 njensen Initial creation
*
* </pre>
*
* @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);
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 13, 2014 2581 njensen Initial creation
*
* </pre>
*
* @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);
}
}

View file

@ -29,6 +29,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.raytheon.edex.esb.Headers; 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.LSREventType;
import com.raytheon.uf.common.dataplugin.lsr.LocalStormReport; import com.raytheon.uf.common.dataplugin.lsr.LocalStormReport;
import com.raytheon.uf.common.pointdata.PointDataContainer; 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 * Dec 09, 2013 2581 njensen Reuse patterns for efficiency
* Check entire time line looking for latlon * Check entire time line looking for latlon
* Jan 07, 2013 2581 njensen Check to end of string for source, not a set length * 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
* *
* </pre> * </pre>
* *
@ -315,11 +317,13 @@ public class LSRParser {
LocalStormReport rpt = new LocalStormReport(); LocalStormReport rpt = new LocalStormReport();
String s = r.getReportLine(); String s = r.getReportLine();
try {
if (parseTimeLine(s, rpt)) { if (parseTimeLine(s, rpt)) {
List<InternalReport> rptLines = r.getSubLines(); List<InternalReport> rptLines = r.getSubLines();
if (rptLines != null) { if (rptLines != null) {
r = rptLines.get(0); r = rptLines.get(0);
if (InternalType.DATE.equals(r.getLineType())) { if (InternalType.DATE.equals(r
.getLineType())) {
s = r.getReportLine(); s = r.getReportLine();
if (parseDateLine(s, rpt)) { if (parseDateLine(s, rpt)) {
// Now check the remarks section. // Now check the remarks section.
@ -336,6 +340,10 @@ public class LSRParser {
} }
} }
} }
} catch (UnrecognizedDataException e) {
logger.error("Error decoding line " + s
+ " - skipping this entry", e);
}
} }
} }
} }
@ -343,7 +351,8 @@ public class LSRParser {
return reports; return reports;
} }
private boolean parseTimeLine(String timeLine, LocalStormReport rpt) { private boolean parseTimeLine(String timeLine, LocalStormReport rpt)
throws UnrecognizedDataException {
boolean timeOk = false; boolean timeOk = false;
if (timeLine != null) { if (timeLine != null) {
@ -366,7 +375,12 @@ public class LSRParser {
} }
} }
ss = timeLine.substring(EVENT, EVENT + EVENT_LENGTH).trim(); 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) ss = timeLine.substring(LOCATION, LOCATION + LOCATION_LENGTH)
.trim(); .trim();