1
0
mirror of https://github.com/elisspace/autopsy.git synced 2026-08-30 08:01:57 +00:00

updates to solr visitor

This commit is contained in:
Greg DiCristofaro
2022-01-04 14:47:24 -05:00
parent 6d7d5de178
commit 2b399cbcf9
5 changed files with 18 additions and 25 deletions

View File

@@ -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<T extends Content> extends BaseChildFactory<T> {
@@ -34,10 +33,6 @@ abstract class AbstractContentChildren<T extends Content> extends BaseChildFacto
@Override
protected Node createNodeForKey(T key) {
if (key instanceof SleuthkitVisitableItem) {
return RootContentChildren.createNode(key);
} else {
return null;
}
return RootContentChildren.createNode(key);
}
}

View File

@@ -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;
/**

View File

@@ -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<DataSourceGrouping, Node> HOST_DATA_SOURCES = key -> {
if (key.getDataSource() instanceof SleuthkitVisitableItem) {
return RootContentChildren.createNode(key);
} else {
return null;
}
return RootContentChildren.createNode(key);
};
/**

View File

@@ -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<Collection<Abstr
return getAllFromChildren(ld);
}
@Override
public Collection<AbstractFile> visit(LocalFilesDataSource lfds) {
return getAllFromChildren(lfds);
}
@Override
public Collection<AbstractFile> visit(LocalDirectory ld) {
return getAllFromChildren(ld);

View File

@@ -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<String, String> getContentFields(SleuthkitVisitableItem item) {
private Map<String, String> 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<String, String> 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<Map<String, String>> {
static private class SolrFieldsVisitor extends ContentVisitor.Default<Map<String, String>> {
@Override
protected Map<String, String> defaultVisit(SleuthkitVisitableItem svi) {
protected Map<String, String> defaultVisit(Content svi) {
return new HashMap<>();
}