From 2b399cbcf96dcc5c6c0e1f75e20dba76788157f7 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 4 Jan 2022 14:47:24 -0500 Subject: [PATCH] updates to solr visitor --- .../datamodel/AbstractContentChildren.java | 11 +++-------- .../datamodel/AutopsyTreeChildFactory.java | 1 - .../sleuthkit/autopsy/datamodel/HostNode.java | 7 +------ .../autopsy/ingest/GetFilesContentVisitor.java | 6 ++++++ .../autopsy/keywordsearch/Ingester.java | 18 ++++++++---------- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentChildren.java b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentChildren.java index ebddf6d922..bc2c7dc86a 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentChildren.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentChildren.java @@ -20,11 +20,10 @@ package org.sleuthkit.autopsy.datamodel; import org.openide.nodes.Node; import org.sleuthkit.datamodel.Content; -import org.sleuthkit.datamodel.SleuthkitVisitableItem; /** - * Abstract subclass for ContentChildren implementation - * that handles creating Nodes from Content objects. + * Abstract subclass for ContentChildren implementation that handles creating + * Nodes from Content objects. */ abstract class AbstractContentChildren extends BaseChildFactory { @@ -34,10 +33,6 @@ abstract class AbstractContentChildren extends BaseChildFacto @Override protected Node createNodeForKey(T key) { - if (key instanceof SleuthkitVisitableItem) { - return RootContentChildren.createNode(key); - } else { - return null; - } + return RootContentChildren.createNode(key); } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java b/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java index 94a81e97ed..e0f2ef0d66 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java @@ -38,7 +38,6 @@ import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.Person; import org.sleuthkit.datamodel.PersonManager; import org.sleuthkit.datamodel.SleuthkitCase; -import org.sleuthkit.datamodel.SleuthkitVisitableItem; import org.sleuthkit.datamodel.TskCoreException; /** diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/HostNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/HostNode.java index 834331f3d0..8aa1ab6d51 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/HostNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/HostNode.java @@ -50,7 +50,6 @@ import org.sleuthkit.autopsy.corecomponents.SelectionResponder; import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.datamodel.Host; import org.sleuthkit.datamodel.Person; -import org.sleuthkit.datamodel.SleuthkitVisitableItem; import org.sleuthkit.datamodel.TskCoreException; /** @@ -159,11 +158,7 @@ public class HostNode extends DisplayableItemNode implements SelectionResponder{ * results, reports, etc.) */ private static final Function HOST_DATA_SOURCES = key -> { - if (key.getDataSource() instanceof SleuthkitVisitableItem) { - return RootContentChildren.createNode(key); - } else { - return null; - } + return RootContentChildren.createNode(key); }; /** diff --git a/Core/src/org/sleuthkit/autopsy/ingest/GetFilesContentVisitor.java b/Core/src/org/sleuthkit/autopsy/ingest/GetFilesContentVisitor.java index 7dfbdacb4c..19e4a4b6b0 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/GetFilesContentVisitor.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/GetFilesContentVisitor.java @@ -30,6 +30,7 @@ import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Image; import org.sleuthkit.datamodel.VirtualDirectory; import org.sleuthkit.datamodel.LocalDirectory; +import org.sleuthkit.datamodel.LocalFilesDataSource; import org.sleuthkit.datamodel.Pool; import org.sleuthkit.datamodel.Report; import org.sleuthkit.datamodel.TskException; @@ -48,6 +49,11 @@ abstract class GetFilesContentVisitor implements ContentVisitor visit(LocalFilesDataSource lfds) { + return getAllFromChildren(lfds); + } + @Override public Collection visit(LocalDirectory ld) { return getAllFromChildren(ld); diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Ingester.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Ingester.java index 052a0b0b16..4aa19564df 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Ingester.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Ingester.java @@ -31,7 +31,6 @@ import org.apache.solr.common.SolrInputDocument; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; -import org.sleuthkit.autopsy.datamodel.ContentUtils; import org.sleuthkit.autopsy.healthmonitor.HealthMonitor; import org.sleuthkit.autopsy.healthmonitor.TimingMetric; import org.sleuthkit.autopsy.ingest.IngestJobContext; @@ -47,8 +46,7 @@ import org.sleuthkit.datamodel.LocalDirectory; import org.sleuthkit.datamodel.LocalFile; import org.sleuthkit.datamodel.Report; import org.sleuthkit.datamodel.SlackFile; -import org.sleuthkit.datamodel.SleuthkitItemVisitor; -import org.sleuthkit.datamodel.SleuthkitVisitableItem; +import org.sleuthkit.datamodel.ContentVisitor; import org.sleuthkit.datamodel.TskCoreException; /** @@ -120,11 +118,11 @@ class Ingester { * Creates a field map from a SleuthkitVisitableItem, that is later sent to * Solr. * - * @param item SleuthkitVisitableItem to get fields from + * @param item Content to get fields from * * @return the map from field name to value (as a string) */ - private Map getContentFields(SleuthkitVisitableItem item) { + private Map getContentFields(Content item) { return item.accept(SOLR_FIELDS_VISITOR); } @@ -146,7 +144,7 @@ class Ingester { * @throws org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException */ // TODO (JIRA-3118): Cancelled text indexing does not propagate cancellation to clients - < T extends SleuthkitVisitableItem> boolean indexText(Reader sourceReader, long sourceID, String sourceName, T source, IngestJobContext context) throws Ingester.IngesterException { + < T extends Content> boolean indexText(Reader sourceReader, long sourceID, String sourceName, T source, IngestJobContext context) throws Ingester.IngesterException { boolean doLanguageDetection = true; return indexText(sourceReader, sourceID, sourceName, source, context, doLanguageDetection); } @@ -170,7 +168,7 @@ class Ingester { * @throws org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException */ // TODO (JIRA-3118): Cancelled text indexing does not propagate cancellation to clients - < T extends SleuthkitVisitableItem> boolean indexStrings(Reader sourceReader, long sourceID, String sourceName, T source, IngestJobContext context) throws Ingester.IngesterException { + < T extends Content> boolean indexStrings(Reader sourceReader, long sourceID, String sourceName, T source, IngestJobContext context) throws Ingester.IngesterException { // Per JIRA-7100, it was determined that language detection on extracted strings can take a really long time. boolean doLanguageDetection = false; return indexText(sourceReader, sourceID, sourceName, source, context, doLanguageDetection); @@ -195,7 +193,7 @@ class Ingester { * @throws org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException */ // TODO (JIRA-3118): Cancelled text indexing does not propagate cancellation to clients - private < T extends SleuthkitVisitableItem> boolean indexText(Reader sourceReader, long sourceID, String sourceName, T source, IngestJobContext context, boolean doLanguageDetection) throws Ingester.IngesterException { + private < T extends Content> boolean indexText(Reader sourceReader, long sourceID, String sourceName, T source, IngestJobContext context, boolean doLanguageDetection) throws Ingester.IngesterException { int numChunks = 0; //unknown until chunking is done Map contentFields = Collections.unmodifiableMap(getContentFields(source)); @@ -342,10 +340,10 @@ class Ingester { /** * Visitor used to create fields to send to SOLR index. */ - static private class SolrFieldsVisitor extends SleuthkitItemVisitor.Default> { + static private class SolrFieldsVisitor extends ContentVisitor.Default> { @Override - protected Map defaultVisit(SleuthkitVisitableItem svi) { + protected Map defaultVisit(Content svi) { return new HashMap<>(); }