diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java index fe70d57eeb..ac7a598365 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java @@ -25,6 +25,7 @@ import java.awt.Window; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.UUID; import javax.swing.JButton; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; @@ -237,10 +238,12 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel errList, List contents) { - dataSourceProcessorDone(result, errList, contents ); + dataSourceProcessorDone(dataSourceId, result, errList, contents ); } }; @@ -263,7 +266,7 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel errList, List contents) { + private void dataSourceProcessorDone(UUID dataSourceId, DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { // disable the cleanup task cleanupTask.disable(); @@ -304,9 +307,10 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel pathsToAddDataSourceTasks; + private final Map uuidsToAddDataSourceTasks; private final Map jobIdsTodataSourceAnalysisTasks; /** @@ -200,7 +195,7 @@ final class CollaborationMonitor { */ LocalTasksManager() { nextTaskId = new AtomicLong(0L); - pathsToAddDataSourceTasks = new HashMap<>(); + uuidsToAddDataSourceTasks = new HashMap<>(); jobIdsTodataSourceAnalysisTasks = new HashMap<>(); } @@ -217,49 +212,54 @@ final class CollaborationMonitor { addDataSourceAddTask(evt); } else if (eventName.equals(Case.Events.DATA_SOURCE_ADDED.toString())) { addDataSourceAddTask(evt); + } else if (eventName.equals(IngestManager.IngestJobEvent.DATA_SOURCE_ANALYSIS_STARTED.toString())) { + addDataSourceAnalysisTask(evt); + } else if (eventName.equals(IngestManager.IngestJobEvent.DATA_SOURCE_ANALYSIS_COMPLETED.toString())) { + removeDataSourceAnalysisTask(evt); + } else if (eventName.equals(IngestManager.IngestJobEvent.DATA_SOURCE_ANALYSIS_CANCELLED.toString())) { + removeDataSourceAnalysisTask(evt); } - - /** - * RJCTODO: When local ADDING_DATA_SOURCE (new) event is received, - * create a new task. When local DATA_SOURCE_ADDED event is - * received, delete the task. The new ADDING_DATA_SOURCE events can - * have full image paths to match up with the Content objects on the - * DATA_SOURCE_ADDED events. - */ - /** - * RJCTODO: When local DATA_SOURCE_INGEST_STARTED event (new) is - * received, create new data source analysis tasks. When local - * DATA_SOURCE_INGEST_COMPLETED (new) or - * DATA_SOURCE_INGEST_CANCELLED (new) is received, delete the task. - * These new events can have data source ingest job ids and data - * source names. - */ } + /** + * Add a task for adding the data source and publishes the updated local + * tasks list to any collaborating nodes. + * + * @param evt RJCTODO + */ synchronized void addDataSourceAddTask(PropertyChangeEvent evt) { - String dataSourcePath = (String) evt.getNewValue(); - String taskStatus = String.format("Adding data source %s", dataSourcePath); // RJCTODO: Bundle - // RJCTODO: This probably will not work, path needs to be sanitized - pathsToAddDataSourceTasks.put(dataSourcePath, new Task(nextTaskId.getAndIncrement(), taskStatus)); + AddingDataSourceEvent event = (AddingDataSourceEvent) evt; + String status = String.format("%s adding data source", hostName); // RJCTODO: Bundle + uuidsToAddDataSourceTasks.put(event.getDataSourceId().hashCode(), new Task(nextTaskId.getAndIncrement(), status)); eventPublisher.publish(new CollaborationEvent(hostName, getCurrentTasks())); } + /** + * Removes the task for adding the data source and publishes the updated + * local tasks list to any collaborating nodes. + * + * @param evt RJCTODO + */ synchronized void removeDataSourceAddTask(PropertyChangeEvent evt) { DataSourceAddedEvent event = (DataSourceAddedEvent) evt; - Content dataSource = event.getDataSource(); - try { - pathsToAddDataSourceTasks.remove(dataSource.getUniquePath()); - } catch (TskCoreException ex) { - // RJCTODO - } + uuidsToAddDataSourceTasks.remove(event.getDataSourceId().hashCode()); eventPublisher.publish(new CollaborationEvent(hostName, getCurrentTasks())); } + /** + * RJCTODO + * + * @param evt + */ synchronized void addDataSourceAnalysisTask(PropertyChangeEvent evt) { eventPublisher.publish(new CollaborationEvent(hostName, getCurrentTasks())); - } + /** + * RJCTODO + * + * @param evt + */ synchronized void removeDataSourceAnalysisTask(PropertyChangeEvent evt) { eventPublisher.publish(new CollaborationEvent(hostName, getCurrentTasks())); } @@ -271,7 +271,7 @@ final class CollaborationMonitor { */ synchronized Map getCurrentTasks() { Map currentTasks = new HashMap<>(); - pathsToAddDataSourceTasks.values().stream().forEach((task) -> { + uuidsToAddDataSourceTasks.values().stream().forEach((task) -> { currentTasks.put(task.getId(), task); }); jobIdsTodataSourceAnalysisTasks.values().stream().forEach((task) -> { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/events/AddingDataSourceEvent.java b/Core/src/org/sleuthkit/autopsy/casemodule/events/AddingDataSourceEvent.java index 21bab6500e..ba0924ef05 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/events/AddingDataSourceEvent.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/events/AddingDataSourceEvent.java @@ -19,8 +19,6 @@ package org.sleuthkit.autopsy.casemodule.events; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; import javax.annotation.concurrent.Immutable; import org.sleuthkit.autopsy.casemodule.Case; @@ -33,26 +31,28 @@ import org.sleuthkit.autopsy.events.AutopsyEvent; public final class AddingDataSourceEvent extends AutopsyEvent implements Serializable { private static final long serialVersionUID = 1L; - private final UUID uuid; - private List dataSourceFileNames; + private final UUID dataSourceId; /** * Constructs an event published when a data source is being added to a * case. * - * @param dataSourceFileNames - * @param uuid + * @param dataSourceId A unique identifier associated with the data source. + * Used to pair this AddindDataSourceEvent with a DataSoruceAddedEvent. */ - public AddingDataSourceEvent(List dataSourceFileNames, UUID uuid) { + public AddingDataSourceEvent(UUID dataSourceId) { super(Case.Events.ADDING_DATA_SOURCE.toString(), null, null); - this.uuid = uuid; + this.dataSourceId = dataSourceId; } - - public UUID getUUID() { - return uuid; + + /** + * Gets the unique id for the data source used to pair this + * AddindDataSourceEvent with a DataSoruceAddedEvent. + * + * @return The unique id. + */ + public UUID getDataSourceId() { + return dataSourceId; } - - public List getDataSourceFileNames() { - return new ArrayList<>(dataSourceFileNames); - } + } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceAddedEvent.java b/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceAddedEvent.java index 0f5dff6a95..eecf18aa20 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceAddedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceAddedEvent.java @@ -19,6 +19,7 @@ package org.sleuthkit.autopsy.casemodule.events; import java.io.Serializable; +import java.util.UUID; import java.util.logging.Level; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.coreutils.Logger; @@ -34,13 +35,16 @@ public final class DataSourceAddedEvent extends AutopsyEvent implements Serializ private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(DataSourceAddedEvent.class.getName()); private transient Content dataSource; + private final UUID dataSourceId; /** * Constructs an event published when a data source is added to a case. * * @param dataSource The data source that was added. + * @param dataSourceId A unique identifier associated with the data source. + * Used to pair this DataSoruceAddedEvent with a AddindDataSourceEvent. */ - public DataSourceAddedEvent(Content dataSource) { + public DataSourceAddedEvent(Content dataSource, UUID dataSourceId) { /** * Putting the object id of the data source into newValue to allow for * lazy loading of the Content object. This bypasses the issues related @@ -49,6 +53,7 @@ public final class DataSourceAddedEvent extends AutopsyEvent implements Serializ */ super(Case.Events.DATA_SOURCE_ADDED.toString(), null, dataSource.getId()); this.dataSource = dataSource; + this.dataSourceId = dataSourceId; } /** @@ -85,6 +90,17 @@ public final class DataSourceAddedEvent extends AutopsyEvent implements Serializ * @return The data source. */ public Content getDataSource() { - return (Content)getNewValue(); + return (Content) getNewValue(); } + + /** + * Gets the unique id for the data source used to pair this + * DataSoruceAddedEvent with a AddindDataSourceEvent. + * + * @return The unique id. + */ + public UUID getDataSourceId() { + return dataSourceId; + } + } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java index a3dc8dade9..1e607de0d9 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java @@ -171,6 +171,18 @@ public class IngestManager { * and the new value is set to null. */ CANCELLED, + /** + * RJCTODO + */ + DATA_SOURCE_ANALYSIS_STARTED, + /** + * RJCTODO + */ + DATA_SOURCE_ANALYSIS_COMPLETED, + /** + * RJCTODO + */ + DATA_SOURCE_ANALYSIS_CANCELLED }; /** diff --git a/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisCancelledEvent.java b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisCancelledEvent.java new file mode 100644 index 0000000000..74feb1e954 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisCancelledEvent.java @@ -0,0 +1,36 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2015 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.ingest.events; + +import java.io.Serializable; +import org.sleuthkit.autopsy.events.AutopsyEvent; +import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.datamodel.Content; + +/** + * RJCTODO + */ +public class DataSourceAnalysisCancelledEvent extends DataSourceAnalysisEvent implements Serializable { + + private static final long serialVersionUID = 1L; + + public DataSourceAnalysisCancelledEvent(long ingestJobId, long dataSourceIngestJobId, Content dataSource) { + super(IngestManager.IngestJobEvent.DATA_SOURCE_ANALYSIS_CANCELLED, ingestJobId, dataSourceIngestJobId, dataSource); + } +} diff --git a/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisCompletedEvent.java b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisCompletedEvent.java new file mode 100644 index 0000000000..97e93901d3 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisCompletedEvent.java @@ -0,0 +1,36 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2015 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.ingest.events; + +import java.io.Serializable; +import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.datamodel.Content; + +/** + * RJCTODO + */ +public class DataSourceAnalysisCompletedEvent extends DataSourceAnalysisEvent implements Serializable { + + private static final long serialVersionUID = 1L; + + public DataSourceAnalysisCompletedEvent(long ingestJobId, long dataSourceIngestJobId, Content dataSource) { + super(IngestManager.IngestJobEvent.DATA_SOURCE_ANALYSIS_COMPLETED, ingestJobId, dataSourceIngestJobId, dataSource); + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java new file mode 100644 index 0000000000..d4e5164396 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java @@ -0,0 +1,43 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2015 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.ingest.events; + +import java.io.Serializable; +import org.sleuthkit.autopsy.events.AutopsyEvent; +import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.datamodel.Content; + +/** + * RJCTODO + */ +public abstract class DataSourceAnalysisEvent extends AutopsyEvent implements Serializable { + + private static final long serialVersionUID = 1L; + private final long ingestJobId; + private final long dataSourceIngestJobId; + private transient Content dataSource; + + public DataSourceAnalysisEvent(IngestManager.IngestJobEvent eventType, long ingestJobId, long dataSourceIngestJobId, Content dataSource) { + super(eventType.toString(), null, null); + this.ingestJobId = ingestJobId; + this.dataSourceIngestJobId = dataSourceIngestJobId; + this.dataSource = dataSource; + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisStartedEvent.java b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisStartedEvent.java new file mode 100644 index 0000000000..6acc428b11 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisStartedEvent.java @@ -0,0 +1,36 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2015 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.ingest.events; + +import java.io.Serializable; +import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.datamodel.Content; + +/** + * RJCTODO + */ +public class DataSourceAnalysisStartedEvent extends DataSourceAnalysisEvent implements Serializable { + + private static final long serialVersionUID = 1L; + + public DataSourceAnalysisStartedEvent(long ingestJobId, long dataSourceIngestJobId, Content dataSource) { + super(IngestManager.IngestJobEvent.DATA_SOURCE_ANALYSIS_STARTED, ingestJobId, dataSourceIngestJobId, dataSource); + } + +}