From b68428cb51a532ea44196279a1b192ef68e19edb Mon Sep 17 00:00:00 2001 From: millmanorama Date: Wed, 15 Feb 2017 15:59:58 +0100 Subject: [PATCH] cleanup, comments, delete dead code --- .../datamodel/BlackboardArtifactNode.java | 36 ------------------- .../keywordsearch/ExtractedContentViewer.java | 35 ++++++++---------- 2 files changed, 14 insertions(+), 57 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java index 078d43f1bd..96a0567532 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java @@ -454,13 +454,6 @@ public class BlackboardArtifactNode extends DisplayableItemNode { forLookup.add(content); } -// // if there is a text highlighted version, of the content, add it too -// // currently happens from keyword search module -// TextMarkupLookup highlight = getHighlightLookup(artifact, content); -// if (highlight != null) { -// forLookup.add(highlight); -// } - return Lookups.fixed(forLookup.toArray(new Object[forLookup.size()])); } @@ -474,35 +467,6 @@ public class BlackboardArtifactNode extends DisplayableItemNode { NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.getAssocCont.exception.msg")); } -// private static TextMarkupLookup getHighlightLookup(BlackboardArtifact artifact, Content content) { -// if (artifact.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) { -// return null; -// } -// -// Lookup lookup = Lookup.getDefault(); -// TextMarkupLookup highlightFactory = lookup.lookup(TextMarkupLookup.class); -// try { -// List attributes = artifact.getAttributes(); -// String keyword = null; -// String regexp = null; -// for (BlackboardAttribute att : attributes) { -// final int attributeTypeID = att.getAttributeType().getTypeID(); -// if (attributeTypeID == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID()) { -// keyword = att.getValueString(); -// } else if (attributeTypeID == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD_REGEXP.getTypeID()) { -// regexp = att.getValueString(); -// } -// } -// if (keyword != null) { -// boolean isRegexp = StringUtils.isNotBlank(regexp); -// String origQuery = isRegexp ? regexp : keyword; -// return highlightFactory.createInstance(artifact.getArtifactID(), keyword, isRegexp, origQuery); -// } -// } catch (TskCoreException ex) { -// LOGGER.log(Level.WARNING, "Failed to retrieve Blackboard Attributes", ex); //NON-NLS -// } -// return null; -// } @Override public boolean isLeafTypeNode() { diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java index 0a8c15a728..f358d54a93 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java @@ -30,7 +30,6 @@ import java.util.Set; import java.util.logging.Level; import org.apache.commons.lang.StringUtils; import org.openide.nodes.Node; -import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.openide.util.lookup.ServiceProvider; @@ -98,8 +97,8 @@ public class ExtractedContentViewer implements DataContentViewer { Content content = nodeLookup.lookup(Content.class); /* - * Assemble a collection of all of the indexed text "sources" associated - * with the node. + * Assemble a collection of all of the indexed text "sources" for the + * node. */ List indexedTextSources = new ArrayList<>(); IndexedText highlightedHitText = null; @@ -109,15 +108,21 @@ public class ExtractedContentViewer implements DataContentViewer { QueryResults hits = nodeLookup.lookup(QueryResults.class); BlackboardArtifact artifact = nodeLookup.lookup(BlackboardArtifact.class); if (hits != null) { + /* + * if there is a QueryReslt object, in the lookup use that. This + * happens when a user selects a row in an ad-hoc search result + */ highlightedHitText = new HighlightedText(content.getId(), hits); - } else if (artifact != null && artifact.getArtifactTypeID() - == BlackboardArtifact.ARTIFACT_TYPE.TSK_ACCOUNT.getTypeID()) { + } else if (artifact != null + && artifact.getArtifactTypeID() == TSK_ACCOUNT.getTypeID()) { // if the artifact is an account artifact, get an account text . highlightedHitText = getAccountsText(content, nodeLookup); - } else if (artifact != null && artifact.getArtifactTypeID() - == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) { + } else if (artifact != null + && artifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) { + //if there is kwh artifact use that to construct the HighlightedText highlightedHitText = new HighlightedText(artifact); } + if (highlightedHitText != null) { indexedTextSources.add(highlightedHitText); } @@ -130,6 +135,7 @@ public class ExtractedContentViewer implements DataContentViewer { rawContentText = new RawText(content, content.getId()); indexedTextSources.add(rawContentText); } + /* * Finally, add the "raw" (not highlighted) text, if any, for any * artifact associated with the node. @@ -148,7 +154,6 @@ public class ExtractedContentViewer implements DataContentViewer { currentSource = rawArtifactText; } - //JMTODO: What is this supposed to do? // Push the text sources into the panel. for (IndexedText source : indexedTextSources) { int currentPage = source.getCurrentPage(); @@ -251,7 +256,6 @@ public class ExtractedContentViewer implements DataContentViewer { } panel.scrollToAnchor(source.getAnchorPrefix() + Integer.toString(source.currentItem())); - } @Override @@ -296,17 +300,6 @@ public class ExtractedContentViewer implements DataContentViewer { return false; } -// /** -// * Is there any marked up indexed text in the look up of this node? This -// * will be the case if the node is for a keyword hit artifact produced -// * by either an ad hoc keyword search result (keyword search toolbar -// * widgets) or a keyword search by the keyword search ingest module. -// */ -// Collection sources = node.getLookup().lookupAll(IndexedText.class); -// if (sources.isEmpty() == false) { -// return true; -// } - /* * Is there a credit card artifact in the lookup */ @@ -585,7 +578,7 @@ public class ExtractedContentViewer implements DataContentViewer { } } - class NextPageActionListener implements ActionListener { + private class NextPageActionListener implements ActionListener { @Override public void actionPerformed(ActionEvent e) {