19 package org.sleuthkit.autopsy.actions;
21 import java.util.Collection;
22 import java.util.concurrent.ExecutionException;
23 import java.util.logging.Level;
24 import javafx.application.Platform;
25 import javafx.scene.control.Alert;
26 import javax.swing.SwingWorker;
27 import org.openide.util.NbBundle;
28 import org.openide.util.Utilities;
55 if (null == instance) {
66 "# {0} - old tag name",
67 "# {1} - content obj id",
68 "ReplaceContentTagAction.replaceTag.alert=Unable to replace tag {0} for {1}."})
70 protected void replaceTag(ContentTag oldTag, TagName newTagName, String newComment) {
71 new SwingWorker<Void, Void>() {
74 protected Void doInBackground()
throws Exception {
79 logger.log(Level.SEVERE,
"Error replacing artifact tag. No open case found.", ex);
81 ->
new Alert(Alert.AlertType.ERROR, Bundle.ReplaceContentTagAction_replaceTag_alert(oldTag.getName().getDisplayName(), oldTag.getContent().getName())).show()
87 logger.log(Level.INFO,
"Replacing tag {0} with tag {1} for artifact {2}",
new Object[]{oldTag.getName().getDisplayName(), newTagName.getDisplayName(), oldTag.getContent().getName()});
91 if(imageTag != null) {
96 ContentTag newTag = tagsManager.
addContentTag(oldTag.getContent(), newTagName, newComment);
99 if(imageTag != null) {
102 }
catch (TskCoreException tskCoreException) {
103 logger.log(Level.SEVERE,
"Error replacing artifact tag", tskCoreException);
105 ->
new Alert(Alert.AlertType.ERROR, Bundle.ReplaceContentTagAction_replaceTag_alert(oldTag.getName().getDisplayName(), oldTag.getContent().getName())).show()
112 protected void done() {
116 }
catch (InterruptedException | ExecutionException ex) {
117 logger.log(Level.SEVERE,
"Unexpected exception while replacing content tag", ex);
129 Collection<? extends ContentTag> getTagsToReplace() {
130 return Utilities.actionsGlobalContext().lookupAll(ContentTag.class);
static final Logger logger
static ReplaceContentTagAction instance
ReplaceContentTagAction()
static final long serialVersionUID
static< T > void deleteTag(ContentViewerTag< T > contentViewerTag)
static synchronized ReplaceContentTagAction getInstance()
static< T > ContentViewerTag< T > getTag(ContentTag contentTag, Class< T > clazz)
void replaceTag(ContentTag oldTag, TagName newTagName, String newComment)
TagsManager getTagsManager()
static< T > ContentViewerTag< T > saveTag(ContentTag contentTag, T tagDataBean)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()