19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.awt.Component;
22 import java.awt.Cursor;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.util.ArrayList;
26 import java.util.Collection;
27 import java.util.List;
28 import java.util.logging.Level;
29 import org.openide.nodes.Node;
30 import org.openide.util.Exceptions;
31 import org.openide.util.Lookup;
32 import org.openide.util.NbBundle;
33 import org.openide.util.lookup.ServiceProvider;
49 @ServiceProvider(service = DataContentViewer.class, position = 4)
54 private static final long INVALID_DOCUMENT_ID = 0L;
57 private ExtractedContentPanel
panel;
58 private volatile Node currentNode = null;
59 private IndexedText currentSource = null;
87 if (node == currentNode) {
93 Lookup nodeLookup = node.getLookup();
100 List<IndexedText> sources =
new ArrayList<>();
101 IndexedText highlightedHitText = null;
102 IndexedText rawContentText = null;
104 if (null != content && solrHasContent(content.
getId())) {
105 QueryResults hits = nodeLookup.lookup(QueryResults.class);
112 highlightedHitText =
new HighlightedText(content.
getId(), hits);
113 }
else if (artifact != null
117 highlightedHitText = getAccountsText(content, nodeLookup);
119 logger.log(Level.SEVERE,
"Failed to create AccountsText for " + content, ex);
122 }
else if (artifact != null
126 highlightedHitText =
new HighlightedText(artifact);
128 logger.log(Level.SEVERE,
"Failed to create HighlightedText for " + artifact, ex);
132 if (highlightedHitText != null) {
133 sources.add(highlightedHitText);
140 rawContentText =
new RawText(content, content.
getId());
141 sources.add(rawContentText);
148 IndexedText rawArtifactText = null;
150 rawArtifactText = getRawArtifactText(nodeLookup);
152 logger.log(Level.SEVERE,
"Error creating RawText for " + content, ex);
155 if (rawArtifactText != null) {
156 sources.add(rawArtifactText);
160 if (null != highlightedHitText) {
161 currentSource = highlightedHitText;
162 }
else if (null != rawContentText) {
163 currentSource = rawContentText;
165 currentSource = rawArtifactText;
169 for (IndexedText source : sources) {
170 int currentPage = source.getCurrentPage();
171 if (currentPage == 0 && source.hasNextPage()) {
175 panel.updateControls(currentSource);
180 IndexedText rawArtifactText = null;
182 if (null != artifact) {
191 if (attribute != null) {
194 rawArtifactText =
new RawText(associatedArtifact, associatedArtifact.
getArtifactID());
199 rawArtifactText =
new RawText(artifact, artifact.
getArtifactID());
202 return rawArtifactText;
210 Collection<? extends BlackboardArtifact> artifacts = nodeLookup.lookupAll(
BlackboardArtifact.class);
211 artifacts = (artifacts == null || artifacts.isEmpty())
212 ? content.getArtifacts(TSK_ACCOUNT)
215 return new AccountsText(content.getId(), artifacts);
219 final IndexedText source = panel.getSelectedSource();
220 if (source == null || !source.isSearchable()) {
224 panel.scrollToAnchor(source.getAnchorPrefix() + Integer.toString(source.currentItem()));
229 return NbBundle.getMessage(this.getClass(),
"ExtractedContentViewer.getTitle");
234 return NbBundle.getMessage(this.getClass(),
"ExtractedContentViewer.toolTip");
245 panel =
new ExtractedContentPanel();
257 setPanel(
new ArrayList<>());
258 panel.resetDisplay();
260 currentSource = null;
272 Collection<? extends BlackboardArtifact> artifacts = node.getLookup().lookupAll(
BlackboardArtifact.class);
273 if (artifacts != null) {
275 final int artifactTypeID = art.getArtifactTypeID();
276 if (artifactTypeID == TSK_ACCOUNT.getTypeID()
277 || artifactTypeID == TSK_KEYWORD_HIT.getTypeID()) {
287 long documentID = getDocumentId(node);
288 if (INVALID_DOCUMENT_ID == documentID) {
292 return solrHasContent(documentID);
317 panel.setSources(sources);
330 if (solrServer.coreIsOpen() ==
false)
336 logger.log(Level.SEVERE,
"Error querying Solr server", ex);
359 if (null != artifact) {
366 if (blackboardAttribute != null) {
370 logger.log(Level.SEVERE,
"Error getting associated artifact attributes", ex);
382 if (content != null) {
383 return content.
getId();
396 IndexedText source = panel.getSelectedSource();
397 if (source == null) {
399 panel.updateControls(null);
402 final boolean hasNextItem = source.hasNextItem();
403 final boolean hasNextPage = source.hasNextPage();
405 if (hasNextItem || hasNextPage) {
409 indexVal = source.currentItem();
411 indexVal = source.nextItem();
415 panel.scrollToAnchor(source.getAnchorPrefix() + Integer.toString(indexVal));
418 panel.updateCurrentMatchDisplay(source.currentItem());
419 panel.updateTotaMatcheslDisplay(source.getNumberHits());
422 if (!source.hasNextItem() && !source.hasNextPage()) {
423 panel.enableNextMatchControl(
false);
425 if (source.hasPreviousItem() || source.hasPreviousPage()) {
426 panel.enablePrevMatchControl(
true);
436 IndexedText source = panel.getSelectedSource();
437 final boolean hasPreviousItem = source.hasPreviousItem();
438 final boolean hasPreviousPage = source.hasPreviousPage();
440 if (hasPreviousItem || hasPreviousPage) {
441 if (!hasPreviousItem) {
444 indexVal = source.currentItem();
446 indexVal = source.previousItem();
450 panel.scrollToAnchor(source.getAnchorPrefix() + Integer.toString(indexVal));
453 panel.updateCurrentMatchDisplay(source.currentItem());
454 panel.updateTotaMatcheslDisplay(source.getNumberHits());
457 if (!source.hasPreviousItem() && !source.hasPreviousPage()) {
458 panel.enablePrevMatchControl(
false);
460 if (source.hasNextItem() || source.hasNextPage()) {
461 panel.enableNextMatchControl(
true);
471 currentSource = panel.getSelectedSource();
473 if (currentSource == null) {
478 panel.updateControls(currentSource);
479 panel.updateSearchControls(currentSource);
485 if (currentSource == null) {
486 panel.updateControls(null);
490 if (currentSource.hasNextPage()) {
491 currentSource.nextPage();
494 panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
495 panel.refreshCurrentMarkup();
496 panel.setCursor(null);
499 panel.updateCurrentPageDisplay(currentSource.getCurrentPage());
505 if (!currentSource.hasNextPage()) {
506 panel.enableNextPageControl(
false);
508 if (currentSource.hasPreviousPage()) {
509 panel.enablePrevPageControl(
true);
512 panel.updateSearchControls(currentSource);
518 if (currentSource == null) {
519 panel.updateControls(null);
523 if (currentSource.hasPreviousPage()) {
524 currentSource.previousPage();
527 panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
528 panel.refreshCurrentMarkup();
529 panel.setCursor(null);
532 panel.updateCurrentPageDisplay(currentSource.getCurrentPage());
538 if (!currentSource.hasPreviousPage()) {
539 panel.enablePrevPageControl(
false);
541 if (currentSource.hasNextPage()) {
542 panel.enableNextPageControl(
true);
545 panel.updateSearchControls(currentSource);
static synchronized Server getServer()
BlackboardArtifact getBlackboardArtifact(long artifactID)
BlackboardAttribute getAttribute(BlackboardAttribute.Type attributeType)
SleuthkitCase getSleuthkitCase()
boolean queryIsIndexed(long contentID)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)