From 5cb4348f34272fa3de1fa47d8d040b4e16d7495f Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Mon, 28 Oct 2019 14:10:39 -0400 Subject: [PATCH] Merge in new data source deletion code from McKinnon --- .../actions/DeleteDataSourceAction.java | 4 +-- .../sleuthkit/autopsy/casemodule/Case.java | 14 +++++----- .../events/DataSourceDeletedEvent.java | 28 ++++++++++--------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/actions/DeleteDataSourceAction.java b/Core/src/org/sleuthkit/autopsy/actions/DeleteDataSourceAction.java index 3909c59827..b71f9db7a2 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/DeleteDataSourceAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/DeleteDataSourceAction.java @@ -31,7 +31,7 @@ import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException; import org.sleuthkit.datamodel.TskCoreException; /** - * Instances of this Action allow users to delete data sources. + * An Action that allows a user to delete a data source. */ public final class DeleteDataSourceAction extends AbstractAction { @@ -60,7 +60,7 @@ public final class DeleteDataSourceAction extends AbstractAction { kwsService.deleteDataSource(dataSourceID); Case.getCurrentCaseThrows().notifyDataSourceDeleted(dataSourceID); } catch (NoCurrentCaseException | TskCoreException | KeywordSearchServiceException e) { - logger.log(Level.WARNING, String.format("Error Deleting data source (obj_id=%d)", dataSourceID), e); + logger.log(Level.SEVERE, String.format("Error Deleting data source (obj_id=%d)", dataSourceID), e); } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 300b563d02..e70607424e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -399,9 +399,9 @@ public class Case { * TimelineEvent that was added. */ TIMELINE_EVENT_ADDED, - /* An item in the central repository has had its comment - * modified. The old value is null, the new value is string for current - * comment. + /* + * An item in the central repository has had its comment modified. The + * old value is null, the new value is string for current comment. */ CR_COMMENT_CHANGED; @@ -536,8 +536,8 @@ public class Case { */ public static boolean isValidName(String caseName) { return !(caseName.contains("\\") || caseName.contains("/") || caseName.contains(":") - || caseName.contains("*") || caseName.contains("?") || caseName.contains("\"") - || caseName.contains("<") || caseName.contains(">") || caseName.contains("|")); + || caseName.contains("*") || caseName.contains("?") || caseName.contains("\"") + || caseName.contains("<") || caseName.contains(">") || caseName.contains("|")); } /** @@ -1484,12 +1484,12 @@ public class Case { } /** - * Notifies case event subscribers that a data source has been delete from + * Notifies case event subscribers that a data source has been deleted from * the case database. * * This should not be called from the event dispatch thread (EDT) * - * @param dataSourceId The data source that was deleted. + * @param dataSourceId The object ID of the data source that was deleted. */ public void notifyDataSourceDeleted(Long dataSourceId) { eventPublisher.publish(new DataSourceDeletedEvent(dataSourceId)); diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceDeletedEvent.java b/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceDeletedEvent.java index 5317a951d0..5550ad9313 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceDeletedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceDeletedEvent.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2015-2019 Basis Technology Corp. + * Copyright 2019 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,36 +16,38 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.sleuthkit.autopsy.casemodule.events; import java.io.Serializable; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.events.AutopsyEvent; +/** + * An application event that is published when a data source has been deleted. + */ public class DataSourceDeletedEvent extends AutopsyEvent implements Serializable { private static final long serialVersionUID = 1L; - private final long dataSourceId; - + private final long dataSourceID; + /** - * Constructs an event published when a data source is added to a case. + * Constructs an application event that is published when a data source has + * been deleted. * - * @param dataSourceId The data source that was deleted. + * @param dataSourceId The object ID of the data source that was deleted. */ public DataSourceDeletedEvent(Long dataSourceId) { - super(Case.Events.DATA_SOURCE_DELETED.toString(), null, dataSourceId); - this.dataSourceId = dataSourceId; - } - + this.dataSourceID = dataSourceId; + } + /** - * Gets the data source id that is being deleted + * Gets the object ID of the data source that was deleted. * * @return The data source id. */ public long getDataSourceId() { - return dataSourceId; + return dataSourceID; } - + }