From 479ae2ec60d4bfa217b24deb99531c08492ab51c Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Thu, 12 Jun 2014 09:48:23 -0400 Subject: [PATCH] Remove Java 8 code from ingest progress snapshots feature --- .../ingest/DataSourceIngestPipeline.java | 4 +- .../autopsy/ingest/FileIngestPipeline.java | 4 +- .../ingest/IngestProgressSnapshotPanel.java | 13 ++++-- .../sleuthkit/autopsy/ingest/IngestTask.java | 46 +++++++++++-------- 4 files changed, 40 insertions(+), 27 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestPipeline.java b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestPipeline.java index 2d8c1f96ad..13dc301040 100755 --- a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestPipeline.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestPipeline.java @@ -75,7 +75,7 @@ final class DataSourceIngestPipeline { for (DataSourceIngestModuleDecorator module : modules) { try { module.startUp(context); - } catch (Exception ex) { + } catch (Exception ex) { // Catch-all exception firewall errors.add(new IngestModuleError(module.getDisplayName(), ex)); } } @@ -92,7 +92,7 @@ final class DataSourceIngestPipeline { module.getDisplayName(), dataSource.getName())); task.updateProgressStatus(module.getDisplayName(), null); module.process(dataSource, new DataSourceIngestModuleProgress(progress)); - } catch (Exception ex) { + } catch (Exception ex) { // Catch-all exception firewall errors.add(new IngestModuleError(module.getDisplayName(), ex)); } if (context.isJobCancelled()) { diff --git a/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java b/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java index 7297c0a36e..3416c9d3f7 100755 --- a/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java @@ -77,7 +77,7 @@ final class FileIngestPipeline { for (FileIngestModuleDecorator module : modules) { try { module.startUp(context); - } catch (Exception ex) { + } catch (Exception ex) { // Catch-all exception firewall errors.add(new IngestModuleError(module.getDisplayName(), ex)); } } @@ -98,7 +98,7 @@ final class FileIngestPipeline { try { task.updateProgressStatus(module.getDisplayName(), file); module.process(file); - } catch (Exception ex) { + } catch (Exception ex) { // Catch-all exception firewall errors.add(new IngestModuleError(module.getDisplayName(), ex)); } if (context.isJobCancelled()) { diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestProgressSnapshotPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestProgressSnapshotPanel.java index e1a1991890..adea6c681f 100755 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestProgressSnapshotPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestProgressSnapshotPanel.java @@ -20,14 +20,13 @@ package org.sleuthkit.autopsy.ingest; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.time.Duration; -import java.time.LocalTime; +import java.util.Date; import java.util.List; import javax.swing.JDialog; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; -import org.sleuthkit.datamodel.AbstractFile; import org.apache.commons.lang3.time.DurationFormatUtils; +import org.sleuthkit.datamodel.AbstractFile; public class IngestProgressSnapshotPanel extends javax.swing.JPanel { @@ -133,8 +132,12 @@ public class IngestProgressSnapshotPanel extends javax.swing.JPanel { cellValue = snapshot.getStartTime(); break; case 5: - long elapsedTime = Duration.between(snapshot.getStartTime(), LocalTime.now()).toMillis(); - cellValue = DurationFormatUtils.formatDurationHMS(elapsedTime); + Date now = new Date(); + long elapsedTime = now.getTime() - snapshot.getStartTime().getTime(); + cellValue = DurationFormatUtils.formatDurationHMS(elapsedTime); + // TODO: Restore when we go to Java 8 +// long elapsedTime = Duration.between(snapshot.getStartTime(), LocalTime.now()).toMillis(); +// cellValue = DurationFormatUtils.formatDurationHMS(elapsedTime); break; default: cellValue = null; diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestTask.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestTask.java index 889121af2a..389e3d6bb8 100755 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestTask.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestTask.java @@ -18,15 +18,15 @@ */ package org.sleuthkit.autopsy.ingest; -import java.time.LocalTime; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Content; class IngestTask { - + private final IngestJob job; private final ProgressSnapshots snapshots; private long threadId; @@ -39,58 +39,68 @@ class IngestTask { IngestJob getIngestJob() { return job; } - + void updateProgressStatus(String ingestModuleDisplayName, AbstractFile file) { snapshots.update(new ProgressSnapshot(threadId, job.getDataSource(), ingestModuleDisplayName, file)); } - + void execute(long threadId) throws InterruptedException { this.threadId = threadId; } - + public static final class ProgressSnapshot { + private final long threadId; private final Content dataSource; private final String ingestModuleDisplayName; private final AbstractFile file; - private final LocalTime startTime; - + private final Date startTime; + // TODO: Restore when we go to Java 8 +// private final LocalTime startTime; + private ProgressSnapshot(long threadId, Content dataSource, String ingestModuleDisplayName, AbstractFile file) { this.threadId = threadId; this.dataSource = dataSource; this.ingestModuleDisplayName = ingestModuleDisplayName; this.file = file; - startTime = LocalTime.now(); + startTime = new Date(); + // TODO: Restore when we go to Java 8 +// startTime = LocalTime.now(); } - + long getThreadId() { return threadId; } - + Content getDataSource() { return dataSource; } - + String getModuleDisplayName() { return ingestModuleDisplayName; } - + AbstractFile getFile() { return file; } - - LocalTime getStartTime() { + + Date getStartTime() { return startTime; - } + } + // TODO: Restore when we go to Java 8 +// LocalTime getStartTime() { +// return startTime; +// } } - + static final class ProgressSnapshots { + private final ConcurrentHashMap snapshots = new ConcurrentHashMap<>(); // Maps ingest thread ids to progress snapshots. - + void update(ProgressSnapshot snapshot) { snapshots.put(snapshot.getThreadId(), snapshot); } - + List getSnapshots() { return new ArrayList(snapshots.values()); }