Skip to content
Snippets Groups Projects
Commit c665942a authored by Richard Cordovano's avatar Richard Cordovano
Browse files

Merge remote-tracking branch 'upstream/custom-release-may-2018' into develop

parents 875a619e 9015e2bf
Branches
Tags
No related merge requests found
Showing
with 61 additions and 57 deletions
......@@ -23,7 +23,7 @@
/**
* Stores data about a search before it is done.
*/
final class QueryRequest {
final class AdHocQueryRequest {
private final KeywordSearchQuery query;
private final String queryString;
......@@ -36,7 +36,7 @@ final class QueryRequest {
* @param id ID that callers simply increment from 0
* @param query Query that will be performed.
*/
QueryRequest(Map<String, Object> map, int id, KeywordSearchQuery query) {
AdHocQueryRequest(Map<String, Object> map, int id, KeywordSearchQuery query) {
this.queryString = query.getEscapedQueryString();
this.queryProperties = map;
this.query = query;
......
......@@ -48,7 +48,7 @@
import org.sleuthkit.autopsy.datamodel.EmptyNode;
import org.sleuthkit.autopsy.datamodel.KeyValue;
import org.sleuthkit.autopsy.datamodel.KeyValueNode;
import org.sleuthkit.autopsy.keywordsearch.KeywordSearchResultFactory.KeyValueQueryContent;
import org.sleuthkit.autopsy.keywordsearch.AdHocSearchChildFactory.KeywordHitKey;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute;
......@@ -66,9 +66,9 @@
* Responsible for assembling nodes and columns in the right way and performing
* lazy queries as needed.
*/
class KeywordSearchResultFactory extends ChildFactory<KeyValue> {
class AdHocSearchChildFactory extends ChildFactory<KeyValue> {
private static final Logger logger = Logger.getLogger(KeywordSearchResultFactory.class.getName());
private static final Logger logger = Logger.getLogger(AdHocSearchChildFactory.class.getName());
//common properties (superset of all Node properties) to be displayed as columns
static final List<String> COMMON_PROPERTIES
......@@ -82,9 +82,9 @@ class KeywordSearchResultFactory extends ChildFactory<KeyValue> {
.map(Object::toString))
.collect(Collectors.toList());
private final Collection<QueryRequest> queryRequests;
private final Collection<AdHocQueryRequest> queryRequests;
KeywordSearchResultFactory(Collection<QueryRequest> queryRequests) {
AdHocSearchChildFactory(Collection<AdHocQueryRequest> queryRequests) {
this.queryRequests = queryRequests;
}
......@@ -98,7 +98,7 @@ class KeywordSearchResultFactory extends ChildFactory<KeyValue> {
@Override
protected boolean createKeys(List<KeyValue> toPopulate) {
for (QueryRequest queryRequest : queryRequests) {
for (AdHocQueryRequest queryRequest : queryRequests) {
/**
* Check the validity of the requested query.
*/
......@@ -155,7 +155,7 @@ private boolean createFlatKeys(KeywordSearchQuery queryRequest, List<KeyValue> t
}
int hitNumber = 0;
List<KeyValueQueryContent> tempList = new ArrayList<>();
List<KeywordHitKey> tempList = new ArrayList<>();
for (KeywordHit hit : getOneHitPerObject(queryResults)) {
/**
......@@ -203,7 +203,7 @@ private boolean createFlatKeys(KeywordSearchQuery queryRequest, List<KeyValue> t
hitName = contentName;
}
hitNumber++;
tempList.add(new KeyValueQueryContent(hitName, properties, hitNumber, hit.getSolrObjectId(), content, artifact, queryRequest, queryResults));
tempList.add(new KeywordHitKey(hitName, properties, hitNumber, hit.getSolrObjectId(), content, artifact, queryRequest, queryResults));
}
......@@ -253,8 +253,8 @@ Collection<KeywordHit> getOneHitPerObject(QueryResults queryResults) {
protected Node createNodeForKey(KeyValue key) {
Node resultNode;
if (key instanceof KeyValueQueryContent) {
AdHocQueryResult adHocQueryResult = new AdHocQueryResult((KeyValueQueryContent) key);
if (key instanceof KeywordHitKey) {
AdHocQueryResult adHocQueryResult = new AdHocQueryResult((KeywordHitKey) key);
/**
* Place the Content, Artifact and hit results into the lookup for
......@@ -262,17 +262,17 @@ protected Node createNodeForKey(KeyValue key) {
*/
ArrayList<Object> lookups = new ArrayList<>();
lookups.add(adHocQueryResult);
if (((KeyValueQueryContent) key).getContent() != null) {
lookups.add(((KeyValueQueryContent) key).getContent());
if (((KeywordHitKey) key).getContent() != null) {
lookups.add(((KeywordHitKey) key).getContent());
}
if (((KeyValueQueryContent) key).getArtifact() != null) {
lookups.add(((KeyValueQueryContent) key).getArtifact());
if (((KeywordHitKey) key).getArtifact() != null) {
lookups.add(((KeywordHitKey) key).getArtifact());
}
Node kvNode = new KeyValueNode(key, Children.LEAF, Lookups.fixed(lookups.toArray()));
//wrap in KeywordSearchFilterNode for the markup content, might need to override FilterNode for more customization
resultNode = new KeywordSearchFilterNode(kvNode);
resultNode = new AdHocSearchFilterNode(kvNode);
} else {
resultNode = new EmptyNode("This Node Is Empty");
resultNode.setDisplayName(NbBundle.getMessage(this.getClass(), "KeywordSearchResultFactory.createNodeForKey.noResultsFound.text"));
......@@ -298,7 +298,7 @@ final class AdHocQueryResult {
* which the hit was found.
* @param results The query results.
*/
AdHocQueryResult(KeyValueQueryContent key) {
AdHocQueryResult(KeywordHitKey key) {
this.solrObjectId = key.getSolrObjectId();
this.results = key.getHits();
}
......@@ -327,7 +327,7 @@ QueryResults getResults() {
* Used to display keyword search results in table. Eventually turned into a
* node.
*/
class KeyValueQueryContent extends KeyValue {
class KeywordHitKey extends KeyValue {
private final long solrObjectId;
......@@ -350,7 +350,7 @@ class KeyValueQueryContent extends KeyValue {
* @param query Query used in search
* @param hits Full set of search results (for all files! @@@)
*/
KeyValueQueryContent(String name, Map<String, Object> map, int id, long solrObjectId, Content content, BlackboardArtifact artifact, KeywordSearchQuery query, QueryResults hits) {
KeywordHitKey(String name, Map<String, Object> map, int id, long solrObjectId, Content content, BlackboardArtifact artifact, KeywordSearchQuery query, QueryResults hits) {
super(name, map, id);
this.solrObjectId = solrObjectId;
this.content = content;
......
......@@ -37,14 +37,14 @@
* Delegates the actual work to the various implementations of
* KeywordSearchQuery.
*/
class KeywordSearchQueryDelegator {
class AdHocSearchDelegator {
private List<KeywordList> keywordLists;
private final List<KeywordList> keywordLists;
private List<KeywordSearchQuery> queryDelegates;
private static int resultWindowCount = 0; //keep track of unique window ids to display
private static Logger logger = Logger.getLogger(KeywordSearchQueryDelegator.class.getName());
private static final Logger logger = Logger.getLogger(AdHocSearchDelegator.class.getName());
public KeywordSearchQueryDelegator(List<KeywordList> keywordLists) {
public AdHocSearchDelegator(List<KeywordList> keywordLists) {
this.keywordLists = keywordLists;
init();
}
......@@ -66,14 +66,14 @@ private void init() {
* Post results into a new DataResultViewer.
*/
public void execute() {
Collection<QueryRequest> queryRequests = new ArrayList<>();
Collection<AdHocQueryRequest> queryRequests = new ArrayList<>();
int queryID = 0;
StringBuilder queryConcat = new StringBuilder(); // concatenation of all query strings
for (KeywordSearchQuery q : queryDelegates) {
Map<String, Object> kvs = new LinkedHashMap<>();
final String queryStr = q.getQueryString();
queryConcat.append(queryStr).append(" ");
queryRequests.add(new QueryRequest(kvs, ++queryID, q));
queryRequests.add(new AdHocQueryRequest(kvs, ++queryID, q));
}
String queryConcatStr = queryConcat.toString();
......@@ -85,7 +85,7 @@ public void execute() {
Node rootNode;
if (queryRequests.size() > 0) {
Children childNodes =
Children.create(new KeywordSearchResultFactory(queryRequests), true);
Children.create(new AdHocSearchChildFactory(queryRequests), true);
rootNode = new AbstractNode(childNodes);
} else {
......
......@@ -53,15 +53,17 @@
/**
* FilterNode containing properties and actions for keyword search.
*
* Wraps the generic KeyValue node and customizes the property sheet and lookup
*/
class KeywordSearchFilterNode extends FilterNode {
class AdHocSearchFilterNode extends FilterNode {
/**
* Instantiate a KeywordSearchFilterNode.
*
* @param original The original source node.
*/
KeywordSearchFilterNode(Node original) {
AdHocSearchFilterNode(Node original) {
super(original, null, new ProxyLookup(original.getLookup()));
}
......@@ -116,7 +118,7 @@ private class GetPopupActionsContentVisitor extends ContentVisitor.Default<List<
@Override
public List<Action> visit(Report r) {
List<Action> actionsList = new ArrayList<>();
actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), KeywordSearchFilterNode.this));
actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), AdHocSearchFilterNode.this));
actionsList.addAll(ContextMenuExtensionPoint.getActions());
return actionsList;
......@@ -161,7 +163,7 @@ public List<Action> visit(VirtualDirectory dir) {
private List<Action> getFileActions(boolean enableHashSearch) {
List<Action> actionsList = new ArrayList<>();
actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), KeywordSearchFilterNode.this));
actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), AdHocSearchFilterNode.this));
actionsList.add(new ExternalViewerAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.openExternViewActLbl"), getOriginal()));
actionsList.add(null);
actionsList.add(ExtractAction.getInstance());
......
......@@ -30,12 +30,12 @@
* class and extended classes model the user's intentions, not necessarily how
* the search manager and 3rd party tools actually perform the search.
*/
abstract class KeywordSearchPanel extends javax.swing.JPanel {
abstract class AdHocSearchPanel extends javax.swing.JPanel {
private final String keywordSearchErrorDialogHeader = org.openide.util.NbBundle.getMessage(this.getClass(), "AbstractKeywordSearchPerformer.search.dialogErrorHeader");
protected int filesIndexed;
KeywordSearchPanel() {
AdHocSearchPanel() {
initListeners();
}
......@@ -110,7 +110,7 @@ public void search() {
}
}
KeywordSearchQueryDelegator man = null;
AdHocSearchDelegator man = null;
final List<KeywordList> keywordLists = getKeywordLists();
if (keywordLists.isEmpty()) {
......@@ -119,7 +119,7 @@ public void search() {
KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
return;
}
man = new KeywordSearchQueryDelegator(keywordLists);
man = new AdHocSearchDelegator(keywordLists);
if (man.validate()) {
man.execute();
......
......@@ -44,7 +44,8 @@
* Viewer panel widget for keyword lists that is used in the ingest config and
* options area.
*/
class DropdownListSearchPanel extends KeywordSearchPanel {
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
class DropdownListSearchPanel extends AdHocSearchPanel {
private static final Logger logger = Logger.getLogger(DropdownListSearchPanel.class.getName());
private static DropdownListSearchPanel instance;
......@@ -131,7 +132,7 @@ public void propertyChange(PropertyChangeEvent evt) {
@Override
public void actionPerformed(ActionEvent e) {
if (ingestRunning) {
SearchRunner.getInstance().addKeywordListsToAllJobs(listsTableModel.getSelectedLists());
IngestSearchRunner.getInstance().addKeywordListsToAllJobs(listsTableModel.getSelectedLists());
logger.log(Level.INFO, "Submitted enqueued lists to ingest"); //NON-NLS
} else {
searchAction(e);
......
......@@ -43,7 +43,8 @@
* perform this task at the desired size, and neither could numerous other
* fonts.
*/
public class DropdownSingleTermSearchPanel extends KeywordSearchPanel {
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
public class DropdownSingleTermSearchPanel extends AdHocSearchPanel {
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = Logger.getLogger(DropdownSingleTermSearchPanel.class.getName());
......
......@@ -34,7 +34,7 @@
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.keywordsearch.KeywordSearchResultFactory.AdHocQueryResult;
import org.sleuthkit.autopsy.keywordsearch.AdHocSearchChildFactory.AdHocQueryResult;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.Account;
import org.sleuthkit.datamodel.BlackboardArtifact;
......
......@@ -55,10 +55,10 @@
* Singleton keyword search manager: Launches search threads for each job and
* performs commits, both on timed intervals.
*/
final class SearchRunner {
final class IngestSearchRunner {
private static final Logger logger = Logger.getLogger(SearchRunner.class.getName());
private static SearchRunner instance = null;
private static final Logger logger = Logger.getLogger(IngestSearchRunner.class.getName());
private static IngestSearchRunner instance = null;
private IngestServices services = IngestServices.getInstance();
private Ingester ingester = null;
private long currentUpdateIntervalMs;
......@@ -71,7 +71,7 @@ final class SearchRunner {
// maps a jobID to the search
private Map<Long, SearchJobInfo> jobs = new ConcurrentHashMap<>();
SearchRunner() {
IngestSearchRunner() {
currentUpdateIntervalMs = ((long) KeywordSearchSettings.getUpdateFrequency().getTime()) * 60 * 1000;
ingester = Ingester.getDefault();
jobProcessingExecutor = new ScheduledThreadPoolExecutor(NUM_SEARCH_SCHEDULING_THREADS, new ThreadFactoryBuilder().setNameFormat(SEARCH_SCHEDULER_THREAD_NAME).build());
......@@ -81,9 +81,9 @@ final class SearchRunner {
*
* @return the singleton object
*/
public static synchronized SearchRunner getInstance() {
public static synchronized IngestSearchRunner getInstance() {
if (instance == null) {
instance = new SearchRunner();
instance = new IngestSearchRunner();
}
return instance;
}
......@@ -167,7 +167,7 @@ public synchronized void stopJob(long jobId) {
}
//stop currentSearcher
SearchRunner.Searcher currentSearcher = job.getCurrentSearcher();
IngestSearchRunner.Searcher currentSearcher = job.getCurrentSearcher();
if ((currentSearcher != null) && (!currentSearcher.isDone())) {
logger.log(Level.INFO, "Cancelling search job {0}", jobId); //NON-NLS
currentSearcher.cancel(true);
......@@ -229,7 +229,7 @@ private void doFinalSearch(SearchJobInfo job) {
logger.log(Level.INFO, "Checking for previous search for search job {0} before executing final search", job.getJobId()); //NON-NLS
job.waitForCurrentWorker();
SearchRunner.Searcher finalSearcher = new SearchRunner.Searcher(job, true);
IngestSearchRunner.Searcher finalSearcher = new IngestSearchRunner.Searcher(job, true);
job.setCurrentSearcher(finalSearcher); //save the ref
logger.log(Level.INFO, "Kicking off final search for search job {0}", job.getJobId()); //NON-NLS
finalSearcher.execute(); //start thread
......@@ -252,7 +252,7 @@ private void doFinalSearch(SearchJobInfo job) {
*/
private final class PeriodicSearchTask implements Runnable {
private final Logger logger = Logger.getLogger(SearchRunner.PeriodicSearchTask.class.getName());
private final Logger logger = Logger.getLogger(IngestSearchRunner.PeriodicSearchTask.class.getName());
@Override
public void run() {
......@@ -341,7 +341,7 @@ private class SearchJobInfo {
// Map of keyword to the object ids that contain a hit
private Map<Keyword, Set<Long>> currentResults; //guarded by SearchJobInfo.this
private SearchRunner.Searcher currentSearcher;
private IngestSearchRunner.Searcher currentSearcher;
private AtomicLong moduleReferenceCount = new AtomicLong(0);
private final Object finalSearchLock = new Object(); //used for a condition wait
......@@ -393,11 +393,11 @@ private void setWorkerRunning(boolean flag) {
workerRunning = flag;
}
private synchronized SearchRunner.Searcher getCurrentSearcher() {
private synchronized IngestSearchRunner.Searcher getCurrentSearcher() {
return currentSearcher;
}
private synchronized void setCurrentSearcher(SearchRunner.Searcher searchRunner) {
private synchronized void setCurrentSearcher(IngestSearchRunner.Searcher searchRunner) {
currentSearcher = searchRunner;
}
......@@ -453,7 +453,7 @@ private final class Searcher extends SwingWorker<Object, Void> {
private List<KeywordList> keywordLists;
private Map<Keyword, KeywordList> keywordToList; //keyword to list name mapping
private AggregateProgressHandle progressGroup;
private final Logger logger = Logger.getLogger(SearchRunner.Searcher.class.getName());
private final Logger logger = Logger.getLogger(IngestSearchRunner.Searcher.class.getName());
private boolean finalRun = false;
Searcher(SearchJobInfo job) {
......@@ -483,7 +483,7 @@ public boolean cancel() {
if (progressGroup != null) {
progressGroup.setDisplayName(displayName + " " + NbBundle.getMessage(this.getClass(), "SearchRunner.doInBackGround.cancelMsg"));
}
return SearchRunner.Searcher.this.cancel(true);
return IngestSearchRunner.Searcher.this.cancel(true);
}
}, null);
......
......@@ -288,7 +288,7 @@ public ProcessResult process(AbstractFile abstractFile) {
return ProcessResult.OK;
}
List<String> keywordListNames = settings.getNamesOfEnabledKeyWordLists();
SearchRunner.getInstance().startJob(context, keywordListNames);
IngestSearchRunner.getInstance().startJob(context, keywordListNames);
startedSearching = true;
}
......@@ -309,13 +309,13 @@ public void shutDown() {
if (context.fileIngestIsCancelled()) {
logger.log(Level.INFO, "Keyword search ingest module instance {0} stopping search job due to ingest cancellation", instanceNum); //NON-NLS
SearchRunner.getInstance().stopJob(jobId);
IngestSearchRunner.getInstance().stopJob(jobId);
cleanup();
return;
}
// Remove from the search list and trigger final commit and final search
SearchRunner.getInstance().endJob(jobId);
IngestSearchRunner.getInstance().endJob(jobId);
// We only need to post the summary msg from the last module per job
if (refCounter.decrementAndGet(jobId) == 0) {
......
......@@ -390,7 +390,7 @@ public void closeCaseResources(CaseContext context) throws AutopsyServiceExcepti
* in less than roughly two seconds. This stuff should be reworked using
* an ExecutorService and tasks with Futures.
*/
KeywordSearchResultFactory.BlackboardResultWriter.stopAllWriters();
AdHocSearchChildFactory.BlackboardResultWriter.stopAllWriters();
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment