2229: Part 14: Use getOpenCase() instead of getCurrentCase() in ReportKML.java

This commit is contained in:
U-BASIS\zhaohui 2018-03-02 17:17:34 -05:00
parent 4480b37e8d
commit 1be23038f0

View File

@ -43,6 +43,7 @@ import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter; import org.jdom2.output.XMLOutputter;
import org.jdom2.CDATA; import org.jdom2.CDATA;
import org.openide.filesystems.FileUtil; import org.openide.filesystems.FileUtil;
import org.openide.util.Exceptions;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
/** /**
@ -111,7 +112,6 @@ class ReportKML implements GeneralReportModule {
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportKML.progress.querying")); progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportKML.progress.querying"));
String kmlFileFullPath = baseReportDir + REPORT_KML; //NON-NLS String kmlFileFullPath = baseReportDir + REPORT_KML; //NON-NLS
currentCase = Case.getCurrentCase();
skCase = currentCase.getSleuthkitCase(); skCase = currentCase.getSleuthkitCase();
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportKML.progress.loading")); progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportKML.progress.loading"));
@ -381,7 +381,7 @@ class ReportKML implements GeneralReportModule {
if (result == ReportProgressPanel.ReportStatus.ERROR) { if (result == ReportProgressPanel.ReportStatus.ERROR) {
prependedStatus = "Incomplete "; prependedStatus = "Incomplete ";
} }
Case.getCurrentCase().addReport(kmlFileFullPath, Case.getOpenCase().addReport(kmlFileFullPath,
NbBundle.getMessage(this.getClass(), "ReportKML.genReport.srcModuleName.text"), NbBundle.getMessage(this.getClass(), "ReportKML.genReport.srcModuleName.text"),
prependedStatus + NbBundle.getMessage(this.getClass(), "ReportKML.genReport.reportName")); prependedStatus + NbBundle.getMessage(this.getClass(), "ReportKML.genReport.reportName"));
} catch (IOException ex) { } catch (IOException ex) {
@ -391,6 +391,9 @@ class ReportKML implements GeneralReportModule {
String errorMessage = String.format("Error adding %s to case as a report", kmlFileFullPath); //NON-NLS String errorMessage = String.format("Error adding %s to case as a report", kmlFileFullPath); //NON-NLS
logger.log(Level.SEVERE, errorMessage, ex); logger.log(Level.SEVERE, errorMessage, ex);
result = ReportProgressPanel.ReportStatus.ERROR; result = ReportProgressPanel.ReportStatus.ERROR;
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex);
result = ReportProgressPanel.ReportStatus.ERROR;
} }
progressPanel.complete(result); progressPanel.complete(result);