mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-20 03:24:55 +00:00
Merge pull request #1704 from eugene7646/indexing_interface
Blackboard artifact KWS indexing interface
This commit is contained in:
commit
b8bc3e1899
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Sleuth Kit Data Model
|
||||
*
|
||||
* Copyright 2011-2015 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.casemodule.services;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import org.openide.util.Lookup;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* Provides utility methods for blackboard artifact indexing.
|
||||
*/
|
||||
public final class Blackboard implements Closeable {
|
||||
|
||||
/**
|
||||
* Index the text associated with the given artifact.
|
||||
*
|
||||
* @param artifact The artifact to be indexed.
|
||||
*
|
||||
* @throws
|
||||
* org.sleuthkit.autopsy.casemodule.services.Blackboard.BlackboardException
|
||||
*/
|
||||
public void indexArtifact(BlackboardArtifact artifact) throws BlackboardException {
|
||||
KeywordSearchService searchService = Lookup.getDefault().lookup(KeywordSearchService.class);
|
||||
if (null == searchService) {
|
||||
throw new BlackboardException(NbBundle.getMessage(this.getClass(), "Blackboard.keywordSearchNotFound.exception.msg"));
|
||||
}
|
||||
|
||||
try {
|
||||
searchService.indexArtifact(artifact);
|
||||
} catch (TskCoreException ex) {
|
||||
throw new BlackboardException(NbBundle.getMessage(this.getClass(), "Blackboard.unableToIndexArtifact.exception.msg"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a system exception for the Keyword Search package.
|
||||
*/
|
||||
public static final class BlackboardException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructs a new exception with null as its message.
|
||||
*/
|
||||
public BlackboardException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified message.
|
||||
*
|
||||
* @param message The message.
|
||||
*/
|
||||
public BlackboardException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified message and cause.
|
||||
*
|
||||
* @param message The message.
|
||||
* @param cause The cause.
|
||||
*/
|
||||
public BlackboardException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
}
|
@ -19,3 +19,6 @@ TagsManager.addContentTag.noCaseWarning=Failed to publish new content tag event.
|
||||
TagsManager.deleteContentTag.noCaseWarning=Failed to publish content tag deleted event. There is no case open.
|
||||
TagsManager.addBlackboardArtifactTag.noCaseWarning=Failed to publish new blackboard artifact tag event. There is no case open.
|
||||
TagsManager.deleteBlackboardArtifactTag.noCaseWarning=Failed to publish blackboard artifact tag deleted event. There is no case open.
|
||||
Blackboard.keywordSearchNotFound.exception.msg=Keyword search service not found.
|
||||
Blackboard.unableToIndexArtifact.exception.msg=Unable to index blackboard artifact
|
||||
Blackboard.unableToIndexArtifact.error.msg=Unable to index blackboard artifact {0}
|
||||
|
@ -39,6 +39,7 @@ public class Services implements Closeable {
|
||||
private final FileManager fileManager;
|
||||
private final TagsManager tagsManager;
|
||||
private final KeywordSearchService keywordSearchService;
|
||||
private final Blackboard blackboard;
|
||||
|
||||
public Services(SleuthkitCase tskCase) {
|
||||
fileManager = new FileManager(tskCase);
|
||||
@ -49,6 +50,9 @@ public class Services implements Closeable {
|
||||
|
||||
keywordSearchService = Lookup.getDefault().lookup(KeywordSearchService.class);
|
||||
services.add(keywordSearchService);
|
||||
|
||||
blackboard = new Blackboard();
|
||||
services.add(blackboard);
|
||||
}
|
||||
|
||||
public FileManager getFileManager() {
|
||||
@ -63,6 +67,10 @@ public class Services implements Closeable {
|
||||
return keywordSearchService;
|
||||
}
|
||||
|
||||
public Blackboard getBlackboard() {
|
||||
return blackboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
for (Closeable service : services) {
|
||||
|
@ -25,18 +25,19 @@ import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
|
||||
import org.sleuthkit.autopsy.casemodule.services.FileManager;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||
import org.sleuthkit.autopsy.datamodel.ContentUtils;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
@ -82,6 +83,7 @@ class ContactAnalyzer {
|
||||
Connection connection = null;
|
||||
ResultSet resultSet = null;
|
||||
Statement statement = null;
|
||||
Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
|
||||
|
||||
if (databasePath == null || databasePath.isEmpty()) {
|
||||
return;
|
||||
@ -148,6 +150,15 @@ class ContactAnalyzer {
|
||||
bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL.getTypeID(), moduleName, data1));
|
||||
}
|
||||
oldName = name;
|
||||
|
||||
try {
|
||||
// index the artifact for keyword search
|
||||
blackboard.indexArtifact(bba);
|
||||
} catch (Blackboard.BlackboardException ex) {
|
||||
logger.log(Level.SEVERE, NbBundle.getMessage(Blackboard.class, "Blackboard.unableToIndexArtifact.error.msg", bba.getDisplayName()), ex); //NON-NLS
|
||||
MessageNotifyUtil.Notify.error(
|
||||
NbBundle.getMessage(Blackboard.class, "Blackboard.unableToIndexArtifact.exception.msg"), bba.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.impl.HttpSolrServer;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException;
|
||||
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
|
||||
import org.apache.solr.common.util.ContentStreamBase.StringStream;
|
||||
import org.openide.util.lookup.ServiceProvider;
|
||||
@ -145,6 +146,7 @@ public class SolrSearchService implements KeywordSearchService {
|
||||
try {
|
||||
Ingester.getDefault().ingest(new StringStream(""), solrFields, 0);
|
||||
} catch (Ingester.IngesterException ex) {
|
||||
throw new TskCoreException(ex.getCause().getMessage(), ex);
|
||||
}
|
||||
|
||||
// Next create the index entry for the document content.
|
||||
@ -160,6 +162,7 @@ public class SolrSearchService implements KeywordSearchService {
|
||||
try {
|
||||
Ingester.getDefault().ingest(contentStream, solrFields, contentStream.getSize());
|
||||
} catch (Ingester.IngesterException ex) {
|
||||
throw new TskCoreException(ex.getCause().getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +179,8 @@ public class SolrSearchService implements KeywordSearchService {
|
||||
* @param host the remote hostname or IP address of the Solr server
|
||||
* @param port the remote port for Solr
|
||||
*
|
||||
* @throws org.sleuthkit.autopsy.keywordsearch.KeywordSearchServiceException
|
||||
* @throws
|
||||
* org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user