Fix DataSourceAnalysisEvent.getDataSource NPEs

This commit is contained in:
Richard Cordovano
2018-12-14 13:01:27 -05:00
parent 2fb1409e4a
commit 7b55277f4e
3 changed files with 21 additions and 8 deletions
@@ -46,6 +46,7 @@ import org.sleuthkit.autopsy.events.AutopsyEventPublisher;
import org.sleuthkit.autopsy.ingest.IngestManager;
import org.sleuthkit.autopsy.ingest.events.DataSourceAnalysisCompletedEvent;
import org.sleuthkit.autopsy.ingest.events.DataSourceAnalysisStartedEvent;
import org.sleuthkit.datamodel.Content;
/**
* A collaboration monitor listens to local events and translates them into
@@ -231,9 +232,12 @@ final class CollaborationMonitor {
* @param event A data source analysis started event.
*/
synchronized void addDataSourceAnalysisTask(DataSourceAnalysisStartedEvent event) {
String status = NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.analyzingDataSourceStatus.msg", hostName, event.getDataSource().getName());
jobIdsTodataSourceAnalysisTasks.put(event.getDataSourceIngestJobId(), new Task(++nextTaskId, status));
eventPublisher.publishRemotely(new CollaborationEvent(hostName, getCurrentTasks()));
Content dataSource = event.getDataSource();
if (dataSource != null) {
String status = NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.analyzingDataSourceStatus.msg", hostName, dataSource.getName());
jobIdsTodataSourceAnalysisTasks.put(event.getDataSourceIngestJobId(), new Task(++nextTaskId, status));
eventPublisher.publishRemotely(new CollaborationEvent(hostName, getCurrentTasks()));
}
}
/**
@@ -96,6 +96,7 @@ import org.sleuthkit.autopsy.timeline.ui.detailview.DetailViewPane;
import org.sleuthkit.autopsy.timeline.ui.detailview.tree.EventsTree;
import org.sleuthkit.autopsy.timeline.ui.listvew.ListViewPane;
import org.sleuthkit.autopsy.timeline.utils.RangeDivisionInfo;
import org.sleuthkit.datamodel.Content;
/**
* A container for an AbstractTimelineView. Has a Toolbar on top to hold
@@ -349,8 +350,8 @@ final public class ViewFrame extends BorderPane {
viewModeToggleGroup.add(detailsToggle, ViewMode.DETAIL);
viewModeToggleGroup.add(countsToggle, ViewMode.COUNTS);
modeSegButton.setToggleGroup(viewModeToggleGroup);
viewModeToggleGroup.valueProperty().addListener((observable, oldViewMode, newViewVode) ->
controller.setViewMode(newViewVode != null ? newViewVode : (oldViewMode != null ? oldViewMode : ViewMode.COUNTS))
viewModeToggleGroup.valueProperty().addListener((observable, oldViewMode, newViewVode)
-> controller.setViewMode(newViewVode != null ? newViewVode : (oldViewMode != null ? oldViewMode : ViewMode.COUNTS))
);
controller.viewModeProperty().addListener(viewMode -> syncViewMode());
@@ -501,8 +502,11 @@ final public class ViewFrame extends BorderPane {
"ViewFrame.notification.analysisComplete=Analysis has finished for {0}. The Timeline DB may be out of date."})
public void handleAnalysisCompleted(DataSourceAnalysisCompletedEvent event) {
Platform.runLater(() -> {
notificationPane.getActions().setAll(new UpdateDB(controller));
notificationPane.show(Bundle.ViewFrame_notification_analysisComplete(event.getDataSource().getName()), new ImageView(WARNING));
Content dataSource = event.getDataSource();
if (dataSource != null) {
notificationPane.getActions().setAll(new UpdateDB(controller));
notificationPane.show(Bundle.ViewFrame_notification_analysisComplete(dataSource.getName()), new ImageView(WARNING));
}
});
}
@@ -199,7 +199,7 @@ public class ImageGalleryModule {
if (currentController.isListeningEnabled() == false) {
return;
}
String eventType = event.getPropertyName();
switch (IngestManager.IngestModuleEvent.valueOf(eventType)) {
case FILE_DONE:
@@ -354,6 +354,11 @@ public class ImageGalleryModule {
DataSourceAnalysisEvent dataSourceEvent = (DataSourceAnalysisEvent) event;
Content dataSource = dataSourceEvent.getDataSource();
if (dataSource == null) {
logger.log(Level.SEVERE, String.format("Failed to handle %s event", event.getPropertyName())); //NON-NLS
return;
}
long dataSourceObjId = dataSource.getId();
String eventType = dataSourceEvent.getPropertyName();
try {