Issue #2807. Added MalformedDataException for VAA decoding.
Former-commit-id:8391b1098e
[formerly8391b1098e
[formerly 085c10211b1fa397ca54b8d4d316055f9225db0c]] Former-commit-id:8f8a6cb90e
Former-commit-id:1f8d00e033
This commit is contained in:
parent
ea372042a5
commit
6d08fd95d4
3 changed files with 45 additions and 29 deletions
|
@ -46,9 +46,13 @@
|
||||||
<bean ref="vaaDecoder" method="decode" />
|
<bean ref="vaaDecoder" method="decode" />
|
||||||
<to uri="direct-vm:indexAlert" />
|
<to uri="direct-vm:indexAlert" />
|
||||||
</pipeline>
|
</pipeline>
|
||||||
|
<doCatch>
|
||||||
|
<exception>com.raytheon.uf.common.dataplugin.exception.MalformedDataException</exception>
|
||||||
|
<to uri="direct-vm:logFailureAsInfo" />
|
||||||
|
</doCatch>
|
||||||
<doCatch>
|
<doCatch>
|
||||||
<exception>java.lang.Throwable</exception>
|
<exception>java.lang.Throwable</exception>
|
||||||
<to uri="log:vaa?level=ERROR"/>
|
<to uri="direct-vm:logFailedData"/>
|
||||||
</doCatch>
|
</doCatch>
|
||||||
</doTry>
|
</doTry>
|
||||||
</pipeline>
|
</pipeline>
|
||||||
|
|
|
@ -19,11 +19,13 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.edex.plugin.vaa;
|
package com.raytheon.uf.edex.plugin.vaa;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.raytheon.edex.esb.Headers;
|
import com.raytheon.edex.esb.Headers;
|
||||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||||
|
import com.raytheon.uf.common.dataplugin.exception.MalformedDataException;
|
||||||
import com.raytheon.uf.common.dataplugin.vaa.VAARecord;
|
import com.raytheon.uf.common.dataplugin.vaa.VAARecord;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
@ -39,6 +41,7 @@ import com.raytheon.uf.edex.plugin.vaa.decoder.VAAParser;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Nov 04, 2009 3267 jkorman Initial creation
|
* Nov 04, 2009 3267 jkorman Initial creation
|
||||||
* Nov 26, 2013 2582 njensen Cleanup
|
* Nov 26, 2013 2582 njensen Cleanup
|
||||||
|
* Mar 10, 2014 2807 skorolev Added MalformedDataException for VAA decoding.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -63,7 +66,8 @@ public class VAADecoder {
|
||||||
* @param headers
|
* @param headers
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public PluginDataObject[] decode(byte[] data, Headers headers) {
|
public PluginDataObject[] decode(byte[] data, Headers headers)
|
||||||
|
throws MalformedDataException, IOException {
|
||||||
|
|
||||||
String traceId = null;
|
String traceId = null;
|
||||||
|
|
||||||
|
@ -77,26 +81,22 @@ public class VAADecoder {
|
||||||
|
|
||||||
if (data != null && data.length > 0) {
|
if (data != null && data.length > 0) {
|
||||||
List<PluginDataObject> obsList = new ArrayList<PluginDataObject>();
|
List<PluginDataObject> obsList = new ArrayList<PluginDataObject>();
|
||||||
try {
|
VAAParser parser = new VAAParser(data, traceId, headers);
|
||||||
VAAParser parser = new VAAParser(data, traceId, headers);
|
for (VAARecord record : parser) {
|
||||||
for (VAARecord record : parser) {
|
if (record != null) {
|
||||||
if (record != null) {
|
// overwrite will only happen if a correction is issued
|
||||||
// overwrite will only happen if a correction is issued
|
// within the same minute as the original
|
||||||
// within the same minute as the original
|
record.setOverwriteAllowed(true);
|
||||||
record.setOverwriteAllowed(true);
|
obsList.add(record);
|
||||||
obsList.add(record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(traceId + "-Error in decode", e);
|
|
||||||
} finally {
|
|
||||||
if ((obsList != null) && (obsList.size() > 0)) {
|
|
||||||
decodedData = obsList.toArray(new PluginDataObject[obsList
|
|
||||||
.size()]);
|
|
||||||
} else {
|
|
||||||
decodedData = new PluginDataObject[0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((obsList != null) && (obsList.size() > 0)) {
|
||||||
|
decodedData = obsList.toArray(new PluginDataObject[obsList
|
||||||
|
.size()]);
|
||||||
|
} else {
|
||||||
|
decodedData = new PluginDataObject[0];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.info(traceId + "- No data in file");
|
logger.info(traceId + "- No data in file");
|
||||||
decodedData = new PluginDataObject[0];
|
decodedData = new PluginDataObject[0];
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.edex.plugin.vaa.decoder;
|
package com.raytheon.uf.edex.plugin.vaa.decoder;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -29,6 +30,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.MalformedDataException;
|
||||||
import com.raytheon.uf.common.dataplugin.vaa.VAARecord;
|
import com.raytheon.uf.common.dataplugin.vaa.VAARecord;
|
||||||
import com.raytheon.uf.common.dataplugin.vaa.VAASubPart;
|
import com.raytheon.uf.common.dataplugin.vaa.VAASubPart;
|
||||||
import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
|
import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
|
||||||
|
@ -47,6 +49,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
|
||||||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||||
* Nov 26, 2013 2582 njensen Cleanup
|
* Nov 26, 2013 2582 njensen Cleanup
|
||||||
* Feb 11, 2014 2763 skorolev Made LFCR correction of input data.
|
* Feb 11, 2014 2763 skorolev Made LFCR correction of input data.
|
||||||
|
* Mar 10, 2014 2807 skorolev Added MalformedDataException for VAA decoding.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -96,12 +99,14 @@ public class VAAParser implements Iterable<VAARecord> {
|
||||||
private final List<VAARecord> records = new ArrayList<VAARecord>();
|
private final List<VAARecord> records = new ArrayList<VAARecord>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param message
|
* @param message
|
||||||
* @param wmoHeader
|
* @param traceId
|
||||||
* @param pdd
|
* @param headers
|
||||||
|
* @throws MalformedDataException
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public VAAParser(byte[] message, String traceId, Headers headers) {
|
public VAAParser(byte[] message, String traceId, Headers headers)
|
||||||
|
throws MalformedDataException, IOException {
|
||||||
this.traceId = traceId;
|
this.traceId = traceId;
|
||||||
byte[] msg = correctLFCR(message);
|
byte[] msg = correctLFCR(message);
|
||||||
wmoHeader = new WMOHeader(msg, headers);
|
wmoHeader = new WMOHeader(msg, headers);
|
||||||
|
@ -150,10 +155,11 @@ public class VAAParser implements Iterable<VAARecord> {
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* Raw message data.
|
* Raw message data.
|
||||||
* @param traceId
|
* @param headers
|
||||||
* Trace id for this data.
|
* @throws MalformedDataException
|
||||||
*/
|
*/
|
||||||
private void setData(byte[] message, Headers headers) {
|
private void setData(byte[] message, Headers headers)
|
||||||
|
throws MalformedDataException {
|
||||||
|
|
||||||
List<InternalReport> reports = InternalReport.identifyMessage(message,
|
List<InternalReport> reports = InternalReport.identifyMessage(message,
|
||||||
headers);
|
headers);
|
||||||
|
@ -240,8 +246,11 @@ public class VAAParser implements Iterable<VAARecord> {
|
||||||
default: {
|
default: {
|
||||||
}
|
}
|
||||||
} // switch
|
} // switch
|
||||||
|
}// for
|
||||||
|
if (vaa.getDataTime() == null) {
|
||||||
|
throw new MalformedDataException(
|
||||||
|
"VAA product does not have a date time group");
|
||||||
}
|
}
|
||||||
|
|
||||||
records.add(vaa);
|
records.add(vaa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,8 +484,11 @@ public class VAAParser implements Iterable<VAARecord> {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param args
|
* @param args
|
||||||
|
* @throws MalformedDataException
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static final void main(String[] args) {
|
public static final void main(String[] args) throws MalformedDataException,
|
||||||
|
IOException {
|
||||||
|
|
||||||
String msg1 = "\u0001\r\r\n738\r\r\nFVXX20 KNES 041708 CAA"
|
String msg1 = "\u0001\r\r\n738\r\r\nFVXX20 KNES 041708 CAA"
|
||||||
+ "\r\r\nVA ADVISORY" + "\r\r\nDTG: 20091104/1708Z"
|
+ "\r\r\nVA ADVISORY" + "\r\r\nDTG: 20091104/1708Z"
|
||||||
|
|
Loading…
Add table
Reference in a new issue