Modified exception throwing and moved logging to upper levels

This commit is contained in:
Sophie Mori 2016-09-15 11:29:17 -04:00
parent 3bb09d8b64
commit 4c36a1d353

View File

@ -171,7 +171,7 @@ public class STIXReportModule implements GeneralReportModule {
} }
try { try {
processFile(file.getAbsolutePath(), progressPanel, output); processFile(file.getAbsolutePath(), progressPanel, output);
} catch (TskCoreException ex) { } catch (TskCoreException | JAXBException ex) {
logger.log(Level.SEVERE, String.format("Unable to process STIX file %s", file), ex); //NON-NLS logger.log(Level.SEVERE, String.format("Unable to process STIX file %s", file), ex); //NON-NLS
MessageNotifyUtil.Notify.show("STIXReportModule", //NON-NLS MessageNotifyUtil.Notify.show("STIXReportModule", //NON-NLS
ex.getLocalizedMessage(), ex.getLocalizedMessage(),
@ -213,10 +213,11 @@ public class STIXReportModule implements GeneralReportModule {
* @param stixFile - Name of the file * @param stixFile - Name of the file
* @param progressPanel - Progress panel (for updating) * @param progressPanel - Progress panel (for updating)
* *
* @throws JAXBException
* @throws TskCoreException * @throws TskCoreException
*/ */
private void processFile(String stixFile, ReportProgressPanel progressPanel, BufferedWriter output) throws private void processFile(String stixFile, ReportProgressPanel progressPanel, BufferedWriter output) throws
TskCoreException { JAXBException, TskCoreException {
// Load the STIX file // Load the STIX file
STIXPackage stix; STIXPackage stix;
@ -244,10 +245,9 @@ public class STIXReportModule implements GeneralReportModule {
* *
* @return Unmarshalled file contents * @return Unmarshalled file contents
* *
* @throws TskCoreException * @throws JAXBException
*/ */
private STIXPackage loadSTIXFile(String stixFileName) throws TskCoreException { private STIXPackage loadSTIXFile(String stixFileName) throws JAXBException {
try {
// Create STIXPackage object from xml. // Create STIXPackage object from xml.
File file = new File(stixFileName); File file = new File(stixFileName);
JAXBContext jaxbContext = JAXBContext.newInstance("org.mitre.stix.stix_1:org.mitre.stix.common_1:org.mitre.stix.indicator_2:" //NON-NLS JAXBContext jaxbContext = JAXBContext.newInstance("org.mitre.stix.stix_1:org.mitre.stix.common_1:org.mitre.stix.indicator_2:" //NON-NLS
@ -255,10 +255,6 @@ public class STIXReportModule implements GeneralReportModule {
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
STIXPackage stix = (STIXPackage) jaxbUnmarshaller.unmarshal(file); STIXPackage stix = (STIXPackage) jaxbUnmarshaller.unmarshal(file);
return stix; return stix;
} catch (JAXBException ex) {
logger.log(Level.SEVERE, String.format("Unable to load STIX file %s", stixFileName), ex.getLocalizedMessage()); //NON-NLS
throw new TskCoreException("Error loading STIX file (" + ex.toString() + ")"); //NON-NLS
}
} }
/** /**