minor cleanup

This commit is contained in:
millmanorama 2017-08-22 03:02:35 -04:00
parent 7d6dfaa7ea
commit 77783d1537
3 changed files with 15 additions and 25 deletions

View File

@ -19,6 +19,7 @@
package org.sleuthkit.autopsy.keywordsearch;
import org.sleuthkit.datamodel.BlackboardArtifact;
/**
* Interface for kewyord search queries.
*/
@ -64,8 +65,6 @@ interface KeywordSearchQuery {
/**
* Modify the query string to be searched as a substring instead of a whole
* word
*
* @param isSubstring
*/
void setSubstringQuery();
@ -105,9 +104,9 @@ interface KeywordSearchQuery {
*
* @param foundKeyword The keyword that was found by the search, this may be
* different than the Keyword that was searched if, for
* example, it was a RegexQuery..
* example, it was a RegexQuery.
* @param hit The keyword hit.
* @param snippet The document snippet that contains the hit
* @param snippet The document snippet that contains the hit.
* @param listName The name of the keyword list that contained the
* keyword for which the hit was found.
*
@ -115,6 +114,5 @@ interface KeywordSearchQuery {
* @return The newly created artifact or Null if there was a problem
* creating it.
*/
BlackboardArtifact writeSingleFileHitsToBlackBoard( Keyword foundKeyword, KeywordHit hit, String snippet, String listName);
BlackboardArtifact writeSingleFileHitsToBlackBoard(Keyword foundKeyword, KeywordHit hit, String snippet, String listName);
}

View File

@ -61,8 +61,6 @@ class QueryResults {
*/
private final Map<Keyword, List<KeywordHit>> results = new HashMap<>();
QueryResults(KeywordSearchQuery query) {
this.keywordSearchQuery = query;
}
@ -71,8 +69,6 @@ class QueryResults {
results.put(keyword, hits);
}
KeywordSearchQuery getQuery() {
return keywordSearchQuery;
}
@ -146,14 +142,14 @@ class QueryResults {
continue;
}
}
BlackboardArtifact writeResult = keywordSearchQuery.writeSingleFileHitsToBlackBoard( keyword, hit, snippet, keywordSearchQuery.getKeywordList().getName());
BlackboardArtifact writeResult = keywordSearchQuery.writeSingleFileHitsToBlackBoard(keyword, hit, snippet, keywordSearchQuery.getKeywordList().getName());
if (writeResult != null) {
newArtifacts.add(writeResult);
if (notifyInbox) {
try {
writeSingleFileInboxMessage(writeResult, hit.getContent());
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Error posting ,message to Ingest Inbox", ex); //NON-NLS
logger.log(Level.WARNING, "Error posting message to Ingest Inbox", ex); //NON-NLS
}
}
} else {
@ -186,7 +182,6 @@ class QueryResults {
* SolrObjectID-ChunkID pairs.
*/
private Collection<KeywordHit> getOneHitPerObject(Keyword keyword) {
HashMap<Long, KeywordHit> hits = new HashMap<>();
// create a list of KeywordHits. KeywordHits with lowest chunkID is added the the list.
@ -201,10 +196,12 @@ class QueryResults {
}
/**
* Generate an ingest inbox message for given keyword in given file
* Generate and post an ingest inbox message for the given keyword in the given content.
*
* @param artifact
* @param hitFile
* @param artifact The keyword hit artifact.
* @param hitContent The content that the hit is in.
*
* @throws TskCoreException If there is a problem generating or posting the inbox message.
*/
private void writeSingleFileInboxMessage(BlackboardArtifact artifact, Content hitContent) throws TskCoreException {
StringBuilder subjectSb = new StringBuilder();
@ -216,9 +213,7 @@ class QueryResults {
subjectSb.append(NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.kwHitLbl"));
}
String uniqueKey = null;
BlackboardAttribute attr;
attr = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD));
BlackboardAttribute attr = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD));
if (attr != null) {
final String keyword = attr.getValueString();
subjectSb.append(keyword);
@ -240,6 +235,7 @@ class QueryResults {
detailsSb.append("<td>").append(EscapeUtil.escapeHtml(attr.getValueString())).append("</td>"); //NON-NLS
detailsSb.append("</tr>"); //NON-NLS
}
//file
detailsSb.append("<tr>"); //NON-NLS
detailsSb.append(NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.fileThLbl"));
@ -262,7 +258,6 @@ class QueryResults {
//regex
if (!keywordSearchQuery.isLiteral()) {
attr = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD_REGEXP));
if (attr != null) {
detailsSb.append("<tr>"); //NON-NLS
@ -270,12 +265,10 @@ class QueryResults {
detailsSb.append("<td>").append(attr.getValueString()).append("</td>"); //NON-NLS
detailsSb.append("</tr>"); //NON-NLS
}
}
detailsSb.append("</table>"); //NON-NLS
IngestServices.getInstance().postMessage(IngestMessage.createDataMessage(MODULE_NAME, subjectSb.toString(), detailsSb.toString(), uniqueKey, artifact));
}
}

View File

@ -512,7 +512,7 @@ final class RegexQuery implements KeywordSearchQuery {
* hit and turns them into artifact attributes. The track 1 data has the
* same fields as the track two data, plus the account holder's name.
*
* @param attributesMap A map of artifact attribute objects, used to avoid
* @param attributeMap A map of artifact attribute objects, used to avoid
* creating duplicate attributes.
* @param matcher A matcher for the snippet.
*/
@ -525,7 +525,7 @@ final class RegexQuery implements KeywordSearchQuery {
* Creates an attribute of the the given type to the given artifact with a
* value parsed from the snippet for a credit account number hit.
*
* @param attributesMap A map of artifact attribute objects, used to avoid
* @param attributeMap A map of artifact attribute objects, used to avoid
* creating duplicate attributes.
* @param attrType The type of attribute to create.
* @param groupName The group name of the regular expression that was
@ -547,5 +547,4 @@ final class RegexQuery implements KeywordSearchQuery {
return null;
});
}
}