mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-03 14:30:01 +00:00
4114 refactor method add status method into get status method
This commit is contained in:
@@ -374,7 +374,6 @@ public class Case {
|
||||
* definition that has changed.
|
||||
*/
|
||||
TAG_DEFINITION_CHANGED,
|
||||
|
||||
/**
|
||||
* An item in the central repository has had its comment modified. The
|
||||
* old value is null, the new value is string for current comment.
|
||||
@@ -1540,8 +1539,8 @@ public class Case {
|
||||
eventPublisher.publish(new AutopsyEvent(Events.TAG_DEFINITION_CHANGED.toString(), changedTagName, null));
|
||||
}
|
||||
|
||||
public void notifyCentralRepoCommentChanged(long id) {
|
||||
eventPublisher.publish(new CommentChangedEvent(id));
|
||||
public void notifyCentralRepoCommentChanged(long id, String newComment) {
|
||||
eventPublisher.publish(new CommentChangedEvent(id, newComment));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,11 +52,15 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction {
|
||||
* Constructor to create an instance given a CorrelationAttribute.
|
||||
*
|
||||
* @param correlationAttribute The correlation attribute to modify.
|
||||
* @param fileId The file Id for the AbstractFile this comment
|
||||
* is being made in relation to
|
||||
*/
|
||||
public AddEditCentralRepoCommentAction(CorrelationAttribute correlationAttribute) {
|
||||
public AddEditCentralRepoCommentAction(CorrelationAttribute correlationAttribute, Long fileId) {
|
||||
super(Bundle.AddEditCentralRepoCommentAction_menuItemText_addEditCentralRepoComment());
|
||||
this.correlationAttribute = correlationAttribute;
|
||||
fileId = null;
|
||||
correlationAttribute.getID();
|
||||
this.fileId = fileId; //without a fileId no notification that the comment changed will be sent
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,6 +68,7 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction {
|
||||
*
|
||||
* @param file The file from which a correlation attribute to modify is
|
||||
* derived.
|
||||
*
|
||||
*/
|
||||
public AddEditCentralRepoCommentAction(AbstractFile file) {
|
||||
super(Bundle.AddEditCentralRepoCommentAction_menuItemText_addEditCentralRepoComment());
|
||||
|
||||
@@ -130,7 +130,12 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
|
||||
} else if (jmi.equals(addCommentMenuItem)) {
|
||||
try {
|
||||
OtherOccurrenceNodeInstanceData selectedNode = (OtherOccurrenceNodeInstanceData) tableModel.getRow(otherCasesTable.getSelectedRow());
|
||||
AddEditCentralRepoCommentAction action = new AddEditCentralRepoCommentAction(selectedNode.createCorrelationAttribute());
|
||||
AbstractFile file = selectedNode.getAbstractFile();
|
||||
if (file == null) {
|
||||
System.out.println("FILE IS NULL");
|
||||
}
|
||||
AddEditCentralRepoCommentAction action = new AddEditCentralRepoCommentAction(selectedNode.createCorrelationAttribute(), null);
|
||||
|
||||
action.actionPerformed(null);
|
||||
String currentComment = action.getComment();
|
||||
if (currentComment != null) {
|
||||
|
||||
@@ -22,14 +22,13 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
|
||||
import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
|
||||
import org.sleuthkit.autopsy.datamodel.FileNode;
|
||||
import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* Used by the Common Files search feature to encapsulate instances of a given
|
||||
@@ -83,7 +82,9 @@ public class FileInstanceNode extends FileNode {
|
||||
final String NO_DESCR = Bundle.FileInstanceNode_createSheet_noDescription();
|
||||
|
||||
sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_filesColLbl(), Bundle.CommonFilesSearchResultsViewerTable_filesColLbl(), NO_DESCR, this.getContent().getName()));
|
||||
addHasCommentProperty(sheetSet, tags);
|
||||
DataResultViewerTable.HasCommentStatus hasCommentStatus = getHasCommentProperty(sheetSet, tags);
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
hasCommentStatus));
|
||||
|
||||
sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), NO_DESCR, this.getContent().getParentPath()));
|
||||
sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_hashsetHitsColLbl(), Bundle.CommonFilesSearchResultsViewerTable_hashsetHitsColLbl(), NO_DESCR, getHashSetHitsCsvList(this.getContent())));
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
|
||||
import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
||||
@@ -68,7 +69,10 @@ final class RelationshipNode extends BlackboardArtifactNode {
|
||||
}
|
||||
|
||||
sheetSet.put(new NodeProperty<>("Type", "Type", "Type", getDisplayName()));
|
||||
addHasCommentProperty(sheetSet, tags);
|
||||
DataResultViewerTable.HasCommentStatus hasCommentStatus = getHasCommentProperty(sheetSet, tags);
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
hasCommentStatus));
|
||||
|
||||
final BlackboardArtifact artifact = getArtifact();
|
||||
BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(getArtifact().getArtifactTypeID());
|
||||
if (null != fromID) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.openide.util.NbBundle;
|
||||
import org.openide.util.lookup.ServiceProvider;
|
||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultPanel;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
|
||||
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.datamodel.FileNode;
|
||||
@@ -725,10 +726,12 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
||||
sheet.put(sheetSet);
|
||||
}
|
||||
List<ContentTag> tags = getContentTagsFromDatabase();
|
||||
|
||||
|
||||
AbstractFile file = getContent();
|
||||
sheetSet.put(new NodeProperty<>("Name", "Name", "Name", file.getName()));
|
||||
addHasCommentProperty(sheetSet, tags);
|
||||
DataResultViewerTable.HasCommentStatus hasCommentStatus = getHasCommentProperty(sheetSet, tags);
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
hasCommentStatus));
|
||||
sheetSet.put(new NodeProperty<>("Size", "Size", "Size", file.getSize()));
|
||||
sheetSet.put(new NodeProperty<>("Mime Type", "Mime Type", "Mime Type", StringUtils.defaultString(file.getMIMEType())));
|
||||
sheetSet.put(new NodeProperty<>("Known", "Known", "Known", file.getKnown().getName()));
|
||||
|
||||
@@ -157,7 +157,7 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
||||
updateSheet();
|
||||
}
|
||||
} else if (eventType.equals(Case.Events.CR_COMMENT_CHANGED.toString())) {
|
||||
CommentChangedEvent event = (CommentChangedEvent) evt;
|
||||
CommentChangedEvent event = (CommentChangedEvent) evt;
|
||||
if (event.getContentID() == content.getId()) {
|
||||
updateSheet();
|
||||
}
|
||||
@@ -279,7 +279,7 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
||||
return tags;
|
||||
}
|
||||
|
||||
protected void addHasCommentProperty(Sheet.Set sheetSet, List<ContentTag> tags) {
|
||||
protected HasCommentStatus getHasCommentProperty(Sheet.Set sheetSet, List<ContentTag> tags) {
|
||||
|
||||
HasCommentStatus status = tags.size() > 0 ? HasCommentStatus.TAG_NO_COMMENT : HasCommentStatus.NO_COMMENT;
|
||||
|
||||
@@ -291,22 +291,21 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
||||
}
|
||||
}
|
||||
if (EamDbUtil.useCentralRepo()) {
|
||||
CorrelationAttribute attribute = EamArtifactUtil.getCorrelationAttributeFromContent(getContent());
|
||||
if (attribute != null) {
|
||||
for (CorrelationAttributeInstance instance : attribute.getInstances()) {
|
||||
if (instance != null && instance.getComment() != null && !instance.getComment().trim().isEmpty()) {
|
||||
if (status == HasCommentStatus.TAG_COMMENT) {
|
||||
status = HasCommentStatus.CR_AND_TAG_COMMENTS;
|
||||
} else {
|
||||
status = HasCommentStatus.CR_COMMENT;
|
||||
}
|
||||
break;
|
||||
CorrelationAttribute attribute = EamArtifactUtil.getCorrelationAttributeFromContent(getContent());
|
||||
if (attribute != null) {
|
||||
for (CorrelationAttributeInstance instance : attribute.getInstances()) {
|
||||
if (instance != null && instance.getComment() != null && !instance.getComment().trim().isEmpty()) {
|
||||
if (status == HasCommentStatus.TAG_COMMENT) {
|
||||
status = HasCommentStatus.CR_AND_TAG_COMMENTS;
|
||||
} else {
|
||||
status = HasCommentStatus.CR_COMMENT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
status));
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.ContentTag;
|
||||
@@ -80,7 +81,9 @@ public abstract class AbstractFsContentNode<T extends AbstractFile> extends Abst
|
||||
"Name",
|
||||
"Name",
|
||||
getName()));
|
||||
addHasCommentProperty(sheetSet, tags);
|
||||
DataResultViewerTable.HasCommentStatus hasCommentStatus = getHasCommentProperty(sheetSet, tags);
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
hasCommentStatus));
|
||||
final String NO_DESCR = Bundle.AbstractFsContentNode_noDesc_text();
|
||||
for (AbstractFilePropertyType propType : AbstractFilePropertyType.values()) {
|
||||
final String propString = propType.toString();
|
||||
|
||||
@@ -38,7 +38,6 @@ import java.util.stream.Collectors;
|
||||
import javax.swing.Action;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.Lookup;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.WeakListeners;
|
||||
@@ -52,12 +51,9 @@ import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttribute;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationDataSource;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||
import static org.sleuthkit.autopsy.datamodel.DisplayableItemNode.findLinked;
|
||||
@@ -351,7 +347,9 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
|
||||
NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.srcFile.displayName"),
|
||||
NO_DESCR,
|
||||
this.getSourceName()));
|
||||
addHasCommentProperty(sheetSet, tags);
|
||||
DataResultViewerTable.HasCommentStatus hasCommentStatus = getHasCommentProperty(sheetSet, tags);
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
hasCommentStatus));
|
||||
if (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
|
||||
try {
|
||||
BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
|
||||
@@ -540,7 +538,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
|
||||
NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName()).collect(Collectors.joining(", "))));
|
||||
}
|
||||
|
||||
protected void addHasCommentProperty(Sheet.Set sheetSet, List<Tag> tags) {
|
||||
protected HasCommentStatus getHasCommentProperty(Sheet.Set sheetSet, List<Tag> tags) {
|
||||
HasCommentStatus status = tags.size() > 0 ? HasCommentStatus.TAG_NO_COMMENT : HasCommentStatus.NO_COMMENT;
|
||||
for (Tag tag : tags) {
|
||||
if (tag.getComment() != null && !tag.getComment().trim().isEmpty()) {
|
||||
@@ -564,8 +562,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
|
||||
}
|
||||
}
|
||||
}
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
status));
|
||||
return status;
|
||||
}
|
||||
|
||||
private void updateSheet() {
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.openide.util.NbBundle;
|
||||
import org.openide.util.Utilities;
|
||||
import org.sleuthkit.autopsy.actions.AddContentTagAction;
|
||||
import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
|
||||
import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
|
||||
import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
|
||||
import org.sleuthkit.autopsy.directorytree.ExtractAction;
|
||||
@@ -90,7 +91,9 @@ public class LayoutFileNode extends AbstractAbstractFileNode<LayoutFile> {
|
||||
NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.displayName"),
|
||||
NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.desc"),
|
||||
getName()));
|
||||
addHasCommentProperty(sheetSet, tags);
|
||||
DataResultViewerTable.HasCommentStatus hasCommentStatus = getHasCommentProperty(sheetSet, tags);
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
hasCommentStatus));
|
||||
final String NO_DESCR = NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.noDescr.text");
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
sheetSet.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
|
||||
import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.LocalDirectory;
|
||||
|
||||
@@ -63,7 +64,9 @@ public class LocalDirectoryNode extends SpecialDirectoryNode {
|
||||
Bundle.LocalDirectoryNode_createSheet_name_displayName(),
|
||||
Bundle.LocalDirectoryNode_createSheet_name_desc(),
|
||||
getName()));
|
||||
addHasCommentProperty(sheetSet, tags);
|
||||
DataResultViewerTable.HasCommentStatus hasCommentStatus = getHasCommentProperty(sheetSet, tags);
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
hasCommentStatus));
|
||||
// At present, a LocalDirectory will never be a datasource - the top level of a logical
|
||||
// file set is a VirtualDirectory
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.openide.util.NbBundle;
|
||||
import org.openide.util.Utilities;
|
||||
import org.sleuthkit.autopsy.actions.AddContentTagAction;
|
||||
import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
|
||||
import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
|
||||
@@ -82,7 +83,10 @@ public class LocalFileNode extends AbstractAbstractFileNode<AbstractFile> {
|
||||
NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.name.displayName"),
|
||||
NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.name.desc"),
|
||||
getName()));
|
||||
addHasCommentProperty(sheetSet, tags);
|
||||
DataResultViewerTable.HasCommentStatus hasCommentStatus = getHasCommentProperty(sheetSet, tags);
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
hasCommentStatus));
|
||||
|
||||
final String NO_DESCR = NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.noDescr.text");
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
sheetSet.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.openide.nodes.Sheet;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
@@ -89,7 +90,9 @@ public class VirtualDirectoryNode extends SpecialDirectoryNode {
|
||||
"VirtualDirectoryNode.createSheet.name.displayName"),
|
||||
NbBundle.getMessage(this.getClass(), "VirtualDirectoryNode.createSheet.name.desc"),
|
||||
getName()));
|
||||
addHasCommentProperty(sheetSet, tags);
|
||||
DataResultViewerTable.HasCommentStatus hasCommentStatus = getHasCommentProperty(sheetSet, tags);
|
||||
sheetSet.put(new NodeProperty<>("Has Comment", "Has Comment", "Has Comment",
|
||||
hasCommentStatus));
|
||||
if (!this.content.isDataSource()) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
fillPropertyMap(map, getContent());
|
||||
|
||||
Reference in New Issue
Block a user