mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
added property change support to IngestManager to notify of service events
This commit is contained in:
parent
6810c188f3
commit
b13997e752
@ -94,18 +94,18 @@ public class IngestImageThread extends SwingWorker {
|
||||
//notify services of completion
|
||||
if (!this.isCancelled()) {
|
||||
service.complete();
|
||||
IngestManager.firePropertyChange(IngestManager.SERVICE_COMPLETED_EVT, service.getName(), "");
|
||||
}
|
||||
} catch (CancellationException e) {
|
||||
//task was cancelled
|
||||
service.stop();
|
||||
|
||||
handleInterruption();
|
||||
} catch (InterruptedException ex) {
|
||||
service.stop();
|
||||
handleInterruption();
|
||||
} catch (ExecutionException ex) {
|
||||
service.stop();
|
||||
handleInterruption();
|
||||
logger.log(Level.SEVERE, "Fatal error during image ingest from sevice: " + service.getName() + " image: " + image.getName(), ex);
|
||||
} catch (Exception ex) {
|
||||
service.stop();
|
||||
handleInterruption();
|
||||
logger.log(Level.SEVERE, "Fatal error during image ingest in service: " + service.getName() + " image: " + image.getName(), ex);
|
||||
} finally {
|
||||
progress.finish();
|
||||
@ -114,4 +114,9 @@ public class IngestImageThread extends SwingWorker {
|
||||
manager.removeImageIngestWorker(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleInterruption() {
|
||||
service.stop();
|
||||
IngestManager.firePropertyChange(IngestManager.SERVICE_STOPPED_EVT, service.getName(), "");
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.ingest;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -66,6 +68,16 @@ public class IngestManager {
|
||||
//services
|
||||
final Collection<IngestServiceImage> imageServices = enumerateImageServices();
|
||||
final Collection<IngestServiceFsContent> fsContentServices = enumerateFsContentServices();
|
||||
//notifications
|
||||
private final static PropertyChangeSupport pcs = new PropertyChangeSupport(IngestManager.class);
|
||||
|
||||
private enum IngestManagerEvents {
|
||||
|
||||
SERVICE_STARTED, SERVICE_COMPLETED, SERVICE_STOPPED
|
||||
};
|
||||
public final static String SERVICE_STARTED_EVT = IngestManagerEvents.SERVICE_STARTED.name();
|
||||
public final static String SERVICE_COMPLETED_EVT = IngestManagerEvents.SERVICE_COMPLETED.name();
|
||||
public final static String SERVICE_STOPPED_EVT = IngestManagerEvents.SERVICE_STOPPED.name();
|
||||
|
||||
/**
|
||||
*
|
||||
@ -88,6 +100,17 @@ public class IngestManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add property change listener to listen to ingest events
|
||||
* @param l PropertyChangeListener to add
|
||||
*/
|
||||
public static void addPropertyChangeListener(final PropertyChangeListener l) {
|
||||
pcs.addPropertyChangeListener(l);
|
||||
}
|
||||
static void firePropertyChange(String property, Object oldV, Object newV) {
|
||||
pcs.firePropertyChange(property, oldV, newV);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple image version of execute, enqueues multiple images and associated services at once
|
||||
* @param services services to execute on every image
|
||||
@ -156,6 +179,7 @@ public class IngestManager {
|
||||
//image services are now initialized per instance
|
||||
quService.init(this);
|
||||
newImageWorker.execute();
|
||||
firePropertyChange(SERVICE_STARTED_EVT, quService.getName(), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -685,6 +709,16 @@ public class IngestManager {
|
||||
logger.log(Level.INFO, "Starting background processing");
|
||||
stats.start();
|
||||
|
||||
//notify main thread services started
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (IngestServiceFsContent s : fsContentServices) {
|
||||
firePropertyChange(SERVICE_STARTED_EVT, s.getName(), "");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
progress = ProgressHandleFactory.createHandle("File Ingest", new Cancellable() {
|
||||
|
||||
@Override
|
||||
@ -738,6 +772,7 @@ public class IngestManager {
|
||||
if (!this.isCancelled()) {
|
||||
for (IngestServiceFsContent s : fsContentServices) {
|
||||
s.complete();
|
||||
firePropertyChange(SERVICE_COMPLETED_EVT, s.getName(), "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -769,6 +804,7 @@ public class IngestManager {
|
||||
private void handleInterruption() {
|
||||
for (IngestServiceFsContent s : fsContentServices) {
|
||||
s.stop();
|
||||
firePropertyChange(SERVICE_STOPPED_EVT, s.getName(), "");
|
||||
}
|
||||
//empty queues
|
||||
emptyFsContents();
|
||||
|
Loading…
x
Reference in New Issue
Block a user