mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Modified Case class to be TSK error observer
This commit is contained in:
parent
793d3d49b2
commit
a197acb18b
@ -86,12 +86,12 @@ import org.sleuthkit.datamodel.TskException;
|
|||||||
* open at a time. Use getCurrentCase() to retrieve the object for the current
|
* open at a time. Use getCurrentCase() to retrieve the object for the current
|
||||||
* case.
|
* case.
|
||||||
*/
|
*/
|
||||||
public class Case {
|
public class Case implements SleuthkitCase.ErrorObserver {
|
||||||
|
|
||||||
private static final String autopsyVer = Version.getVersion(); // current version of autopsy. Change it when the version is changed
|
private static final String autopsyVer = Version.getVersion(); // current version of autopsy. Change it when the version is changed
|
||||||
private static final String EVENT_CHANNEL_NAME = "%s-Case-Events";
|
private static final String EVENT_CHANNEL_NAME = "%s-Case-Events";
|
||||||
private static String appName = null;
|
private static String appName = null;
|
||||||
private IntervalErrorReportData tskErrorReporter = null;
|
volatile private IntervalErrorReportData tskErrorReporter = null;
|
||||||
private static final int MIN_SECONDS_BETWEEN_ERROR_REPORTS = 60; // No less than 60 seconds between warnings for errors
|
private static final int MIN_SECONDS_BETWEEN_ERROR_REPORTS = 60; // No less than 60 seconds between warnings for errors
|
||||||
private static final int MAX_SANITIZED_NAME_LENGTH = 47;
|
private static final int MAX_SANITIZED_NAME_LENGTH = 47;
|
||||||
|
|
||||||
@ -372,6 +372,17 @@ public class Case {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiveError(String context, String errorMessage) {
|
||||||
|
/* NOTE: We are accessing currentCase.tskErrorReporter from two different threads.
|
||||||
|
* This is ok as long as we only read the value of currentCase.tskErrorReporter
|
||||||
|
* because currentCase.tskErrorReporter is declared as volatile.
|
||||||
|
*/
|
||||||
|
if (null != currentCase.tskErrorReporter) {
|
||||||
|
currentCase.tskErrorReporter.addProblems(context, errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AddImageProcess makeAddImageProcess(String timezone, boolean processUnallocSpace, boolean noFatOrphans) {
|
AddImageProcess makeAddImageProcess(String timezone, boolean processUnallocSpace, boolean noFatOrphans) {
|
||||||
return this.db.makeAddImageProcess(timezone, processUnallocSpace, noFatOrphans);
|
return this.db.makeAddImageProcess(timezone, processUnallocSpace, noFatOrphans);
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,15 @@ package org.sleuthkit.autopsy.casemodule;
|
|||||||
|
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class enables capturing errors and batching them for reporting on a
|
* This class enables capturing errors and batching them for reporting on a
|
||||||
* no-more-than-x number of seconds basis. When created, you specify what type
|
* no-more-than-x number of seconds basis. When created, you specify the minimum
|
||||||
* of error it will be batching, and the minimum time between user
|
* time between user notifications. When the time between notifications has
|
||||||
* notifications. When the time between notifications has expired, the next
|
* expired, the next error encountered will cause a report to be shown to the
|
||||||
* error encountered will cause a report to be shown to the user.
|
* user.
|
||||||
*/
|
*/
|
||||||
class IntervalErrorReportData implements SleuthkitCase.ErrorObserver {
|
class IntervalErrorReportData {
|
||||||
|
|
||||||
private final Case currentCase;
|
private final Case currentCase;
|
||||||
private long newProblems;
|
private long newProblems;
|
||||||
@ -39,7 +38,8 @@ class IntervalErrorReportData implements SleuthkitCase.ErrorObserver {
|
|||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new IntervalErrorReprotData instance.
|
* Create a new IntervalErrorReprotData instance and subscribe for TSK error
|
||||||
|
* notifications for the current case.
|
||||||
*
|
*
|
||||||
* @param currentCase Case for which TSK errors should be tracked
|
* @param currentCase Case for which TSK errors should be tracked
|
||||||
* and displayed.
|
* and displayed.
|
||||||
@ -48,21 +48,21 @@ class IntervalErrorReportData implements SleuthkitCase.ErrorObserver {
|
|||||||
* @param message The message that will be shown when warning
|
* @param message The message that will be shown when warning
|
||||||
* the user
|
* the user
|
||||||
*/
|
*/
|
||||||
public IntervalErrorReportData(Case currentCase, int secondsBetweenReports, String message) {
|
IntervalErrorReportData(Case currentCase, int secondsBetweenReports, String message) {
|
||||||
this.newProblems = 0;
|
this.newProblems = 0;
|
||||||
this.totalProblems = 0;
|
this.totalProblems = 0;
|
||||||
this.lastReportedDate = 0; // arm the first warning by choosing zero
|
this.lastReportedDate = 0; // arm the first warning by choosing zero
|
||||||
this.milliSecondsBetweenReports = secondsBetweenReports * 1000; // convert to milliseconds
|
this.milliSecondsBetweenReports = secondsBetweenReports * 1000; // convert to milliseconds
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.currentCase = currentCase;
|
this.currentCase = currentCase;
|
||||||
this.currentCase.getSleuthkitCase().addErrorObserver(this); // it's ok to use "this" at the end of the constructor
|
this.currentCase.getSleuthkitCase().addErrorObserver(this.currentCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuts down this IntervalErrorReprotData instance.
|
* Un-subscribe from TSK error notifications for current case.
|
||||||
*/
|
*/
|
||||||
public void shutdown() {
|
void shutdown() {
|
||||||
this.currentCase.getSleuthkitCase().removeErrorObserver(this);
|
this.currentCase.getSleuthkitCase().removeErrorObserver(this.currentCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,12 +70,11 @@ class IntervalErrorReportData implements SleuthkitCase.ErrorObserver {
|
|||||||
* (or if this is the first problem encountered), a warning will be shown to
|
* (or if this is the first problem encountered), a warning will be shown to
|
||||||
* the user.
|
* the user.
|
||||||
*
|
*
|
||||||
* @param newProblems the newProblems to set
|
|
||||||
* @param context The context in which the error occurred.
|
* @param context The context in which the error occurred.
|
||||||
* @param errorMessage A description of the error that occurred.
|
* @param errorMessage A description of the error that occurred.
|
||||||
*/
|
*/
|
||||||
private void addProblems(long newProblems, String context, String errorMessage) {
|
void addProblems(String context, String errorMessage) {
|
||||||
this.newProblems += newProblems;
|
this.newProblems += 1;
|
||||||
this.totalProblems += newProblems;
|
this.totalProblems += newProblems;
|
||||||
|
|
||||||
long currentTimeStamp = System.currentTimeMillis();
|
long currentTimeStamp = System.currentTimeMillis();
|
||||||
@ -90,9 +89,4 @@ class IntervalErrorReportData implements SleuthkitCase.ErrorObserver {
|
|||||||
this.newProblems = 0;
|
this.newProblems = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receiveError(String context, String errorMessage) {
|
|
||||||
addProblems(1, context, errorMessage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user