mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
More refactoring and cleanup.
Updated strings in confirmation dialog. Moved image writer to new package
This commit is contained in:
parent
d12c5b48a8
commit
7173bd55bb
@ -26,7 +26,7 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback
|
|||||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback.DataSourceProcessorResult;
|
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback.DataSourceProcessorResult;
|
||||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor;
|
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.datasourceprocessors.ImageWriterService;
|
import org.sleuthkit.autopsy.imagewriter.ImageWriterService;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
import org.sleuthkit.datamodel.Image;
|
import org.sleuthkit.datamodel.Image;
|
||||||
|
@ -10,4 +10,7 @@ RawDSInputPanel.jBreakFileUpLabel.text=Break image up into:
|
|||||||
RawDSInputPanel.jNoBreakupRadioButton.text=Do not break up
|
RawDSInputPanel.jNoBreakupRadioButton.text=Do not break up
|
||||||
RawDSInputPanel.j2GBBreakupRadioButton.text=2GB chunks
|
RawDSInputPanel.j2GBBreakupRadioButton.text=2GB chunks
|
||||||
RawDSInputPanel.timeZoneLabel.text=Please select the input timezone:
|
RawDSInputPanel.timeZoneLabel.text=Please select the input timezone:
|
||||||
ImageWriterService.serviceName=Image Writer
|
ImageWriterService.serviceName=Image Writer
|
||||||
|
ImageWriterService.waitingForVHDs=Waiting for VHD(s) to complete
|
||||||
|
ImageWriterService.shouldWait=Wait for VHD(s) in progress to complete?
|
||||||
|
ImageWriterService.localDisk=Local disk image copy
|
||||||
|
@ -16,13 +16,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.datasourceprocessors;
|
package org.sleuthkit.autopsy.imagewriter;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
@ -65,10 +63,6 @@ class ImageWriter implements PropertyChangeListener{
|
|||||||
private ScheduledThreadPoolExecutor periodicTasksExecutor = null;
|
private ScheduledThreadPoolExecutor periodicTasksExecutor = null;
|
||||||
private final boolean doUI;
|
private final boolean doUI;
|
||||||
|
|
||||||
private static final ImageWriterService service = new ImageWriterService();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the Image Writer object.
|
* Create the Image Writer object.
|
||||||
* After creation, startListeners() should be called.
|
* After creation, startListeners() should be called.
|
||||||
@ -133,8 +127,6 @@ class ImageWriter implements PropertyChangeListener{
|
|||||||
// the same image if more ingest modules are run later
|
// the same image if more ingest modules are run later
|
||||||
if(isStarted){
|
if(isStarted){
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
isStarted = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Image image;
|
Image image;
|
||||||
@ -143,8 +135,6 @@ class ImageWriter implements PropertyChangeListener{
|
|||||||
imageHandle = image.getImageHandle();
|
imageHandle = image.getImageHandle();
|
||||||
} catch (TskCoreException ex){
|
} catch (TskCoreException ex){
|
||||||
logger.log(Level.SEVERE, "Error loading image", ex);
|
logger.log(Level.SEVERE, "Error loading image", ex);
|
||||||
|
|
||||||
// Stay subscribed to the events for now. Case close will clean everything up.
|
|
||||||
imageHandle = null;
|
imageHandle = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -170,6 +160,9 @@ class ImageWriter implements PropertyChangeListener{
|
|||||||
logger.log(Level.SEVERE, "Error finishing VHD image", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error finishing VHD image", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Setting this means that finishTask and all the UI updaters are initialized (if running UI)
|
||||||
|
isStarted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for finishImageWriter to complete
|
// Wait for finishImageWriter to complete
|
||||||
@ -181,7 +174,6 @@ class ImageWriter implements PropertyChangeListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized(currentTasksLock){
|
synchronized(currentTasksLock){
|
||||||
unsubscribeFromEvents();
|
|
||||||
if(doUI){
|
if(doUI){
|
||||||
// Some of these may be called twice if the user closes the case
|
// Some of these may be called twice if the user closes the case
|
||||||
progressUpdateTask.cancel(true);
|
progressUpdateTask.cancel(true);
|
||||||
@ -196,13 +188,14 @@ class ImageWriter implements PropertyChangeListener{
|
|||||||
/**
|
/**
|
||||||
* If a task hasn't been started yet, set the cancel flag so it can no longer
|
* If a task hasn't been started yet, set the cancel flag so it can no longer
|
||||||
* start.
|
* start.
|
||||||
|
* This is intended to be used in case close so a job doesn't suddenly start
|
||||||
|
* up during cleanup.
|
||||||
*/
|
*/
|
||||||
void cancelIfNotStarted(){
|
void cancelIfNotStarted(){
|
||||||
synchronized(currentTasksLock){
|
synchronized(currentTasksLock){
|
||||||
if(finishTask == null){
|
if(! isStarted){
|
||||||
isCancelled = true;
|
isCancelled = true;
|
||||||
}
|
}
|
||||||
unsubscribeFromEvents();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +205,9 @@ class ImageWriter implements PropertyChangeListener{
|
|||||||
* never started
|
* never started
|
||||||
*/
|
*/
|
||||||
boolean jobIsInProgress(){
|
boolean jobIsInProgress(){
|
||||||
return((finishTask != null) && (! finishTask.isDone()));
|
synchronized(currentTasksLock){
|
||||||
|
return((isStarted) && (! finishTask.isDone()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -223,9 +218,8 @@ class ImageWriter implements PropertyChangeListener{
|
|||||||
synchronized(currentTasksLock){
|
synchronized(currentTasksLock){
|
||||||
// All of the following is redundant but safe to call on a complete job
|
// All of the following is redundant but safe to call on a complete job
|
||||||
isCancelled = true;
|
isCancelled = true;
|
||||||
unsubscribeFromEvents();
|
|
||||||
|
|
||||||
if(imageHandle != null){
|
if(isStarted){
|
||||||
SleuthkitJNI.cancelFinishImage(imageHandle);
|
SleuthkitJNI.cancelFinishImage(imageHandle);
|
||||||
|
|
||||||
// Stop the progress bar update task.
|
// Stop the progress bar update task.
|
||||||
@ -234,8 +228,10 @@ class ImageWriter implements PropertyChangeListener{
|
|||||||
// when that happens.
|
// when that happens.
|
||||||
// Since we've stopped the update task, we'll stop the associated progress
|
// Since we've stopped the update task, we'll stop the associated progress
|
||||||
// bar now, too.
|
// bar now, too.
|
||||||
progressUpdateTask.cancel(true);
|
if(doUI){
|
||||||
progressHandle.finish();
|
progressUpdateTask.cancel(true);
|
||||||
|
progressHandle.finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,15 +241,19 @@ class ImageWriter implements PropertyChangeListener{
|
|||||||
* Also makes sure the progressUpdateTask is canceled.
|
* Also makes sure the progressUpdateTask is canceled.
|
||||||
*/
|
*/
|
||||||
void waitForJobToFinish(){
|
void waitForJobToFinish(){
|
||||||
// Wait for the finish task to end
|
synchronized(currentTasksLock){
|
||||||
if(finishTask != null){
|
// Wait for the finish task to end
|
||||||
try{
|
if(isStarted){
|
||||||
finishTask.get();
|
try{
|
||||||
} catch (InterruptedException | ExecutionException ex){
|
finishTask.get();
|
||||||
Logger.getLogger(ImageWriter.class.getName()).log(Level.SEVERE, "Error finishing VHD image", ex); //NON-NLS
|
} catch (InterruptedException | ExecutionException ex){
|
||||||
}
|
Logger.getLogger(ImageWriter.class.getName()).log(Level.SEVERE, "Error finishing VHD image", ex); //NON-NLS
|
||||||
progressUpdateTask.cancel(true);
|
}
|
||||||
}
|
if(doUI){
|
||||||
|
progressUpdateTask.cancel(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -16,7 +16,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.datasourceprocessors;
|
package org.sleuthkit.autopsy.imagewriter;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -30,6 +30,13 @@ import org.sleuthkit.autopsy.framework.AutopsyService;
|
|||||||
|
|
||||||
@ServiceProviders(value = {@ServiceProvider(service = AutopsyService.class)})
|
@ServiceProviders(value = {@ServiceProvider(service = AutopsyService.class)})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and handles closing of ImageWriter objects.
|
||||||
|
* Currently, ImageWriter is only enabled for local disks, and local disks can
|
||||||
|
* not be processed in multi user mode. If ImageWriter is ever enabled for multi user
|
||||||
|
* cases this code will need to be revised.
|
||||||
|
*/
|
||||||
|
|
||||||
public class ImageWriterService implements AutopsyService {
|
public class ImageWriterService implements AutopsyService {
|
||||||
|
|
||||||
private static final Set<ImageWriter> imageWriters = new HashSet<>(); // Contains all Image Writer objects
|
private static final Set<ImageWriter> imageWriters = new HashSet<>(); // Contains all Image Writer objects
|
||||||
@ -58,8 +65,8 @@ public class ImageWriterService implements AutopsyService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeCaseResources(CaseContext context) throws AutopsyServiceException {
|
public void closeCaseResources(CaseContext context) throws AutopsyServiceException {
|
||||||
context.getProgressIndicator().progress("Waiting for VHD(s) to complete");
|
context.getProgressIndicator().progress(NbBundle.getMessage(this.getClass(), "ImageWriterService.waitingForVHDs"));
|
||||||
|
|
||||||
synchronized(imageWritersLock){
|
synchronized(imageWritersLock){
|
||||||
// If any of our ImageWriter objects haven't started the finish task, set the cancel flag
|
// If any of our ImageWriter objects haven't started the finish task, set the cancel flag
|
||||||
// to make sure they don't start now. The reason they haven't started is that
|
// to make sure they don't start now. The reason they haven't started is that
|
||||||
@ -82,8 +89,8 @@ public class ImageWriterService implements AutopsyService {
|
|||||||
if(jobsAreInProgress){
|
if(jobsAreInProgress){
|
||||||
// If jobs are in progress, ask the user if they want to wait for them to complete
|
// If jobs are in progress, ask the user if they want to wait for them to complete
|
||||||
NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation(
|
NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation(
|
||||||
"Wait for Image Writer to finish?",
|
NbBundle.getMessage(this.getClass(), "ImageWriterService.shouldWait"),
|
||||||
"Title",
|
NbBundle.getMessage(this.getClass(), "ImageWriterService.localDisk"),
|
||||||
NotifyDescriptor.YES_NO_OPTION,
|
NotifyDescriptor.YES_NO_OPTION,
|
||||||
NotifyDescriptor.WARNING_MESSAGE);
|
NotifyDescriptor.WARNING_MESSAGE);
|
||||||
descriptor.setValue(NotifyDescriptor.NO_OPTION);
|
descriptor.setValue(NotifyDescriptor.NO_OPTION);
|
||||||
@ -103,6 +110,14 @@ public class ImageWriterService implements AutopsyService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stop listening for events
|
||||||
|
for(ImageWriter writer: imageWriters){
|
||||||
|
writer.unsubscribeFromEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear out the list of Image Writers
|
||||||
|
imageWriters.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user