mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
Merge pull request #891 from rcordovano/new_keyword_lists_enabled_in_all_contexts
New keyword lists enabled in all contexts
This commit is contained in:
commit
53d51db52f
@ -77,6 +77,7 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||
*/
|
||||
@Override
|
||||
public long getVersionNumber() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return HashLookupModuleSettings.serialVersionUID;
|
||||
}
|
||||
|
||||
@ -87,6 +88,7 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||
* @return True if hashes are to be calculated, false otherwise.
|
||||
*/
|
||||
boolean shouldCalculateHashes() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return this.shouldCalculateHashes;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ public final class KeywordSearchIngestModule implements FileIngestModule {
|
||||
List<KeywordList> keywordLists = XmlKeywordSearchList.getCurrent().getListsL();
|
||||
boolean hasKeywordsForSearch = false;
|
||||
for (KeywordList keywordList : keywordLists) {
|
||||
if (settings.isKeywordListEnabled(keywordList.getName()) && !keywordList.getKeywords().isEmpty()) {
|
||||
if (settings.keywordListIsEnabled(keywordList.getName()) && !keywordList.getKeywords().isEmpty()) {
|
||||
hasKeywordsForSearch = true;
|
||||
break;
|
||||
}
|
||||
|
@ -24,29 +24,83 @@ import java.util.List;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
|
||||
|
||||
/**
|
||||
* Settings for a keyword search file ingest module instance.
|
||||
* Ingest job settings for the keywords search module.
|
||||
*/
|
||||
final class KeywordSearchJobSettings implements IngestModuleIngestJobSettings {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final HashSet<String> namesOfEnabledKeywordLists = new HashSet<>();
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private HashSet<String> namesOfEnabledKeywordLists;
|
||||
private HashSet<String> namesOfDisabledKeywordLists; // Added in version 1.1
|
||||
|
||||
/**
|
||||
* Constructs ingest job settings for the keywords search module.
|
||||
*
|
||||
* @param namesOfEnabledKeywordLists A list of enabled keywords lists.
|
||||
*/
|
||||
KeywordSearchJobSettings(List<String> namesOfEnabledKeywordLists) {
|
||||
this.namesOfEnabledKeywordLists.addAll(namesOfEnabledKeywordLists);
|
||||
this(namesOfEnabledKeywordLists, new ArrayList<String>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ingest job settings for the keywords search module.
|
||||
*
|
||||
* @param namesOfEnabledKeywordLists A list of enabled keywords lists.
|
||||
* @param namesOfDisabledKeywordLists A list of disabled keywords lists.
|
||||
*/
|
||||
KeywordSearchJobSettings(List<String> namesOfEnabledKeywordLists, List<String> namesOfDisabledKeywordLists) {
|
||||
this.namesOfEnabledKeywordLists = new HashSet<>(namesOfEnabledKeywordLists);
|
||||
this.namesOfDisabledKeywordLists = new HashSet<>(namesOfDisabledKeywordLists);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public long getVersionNumber() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
boolean isKeywordListEnabled(String keywordListName) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not a keywords list is enabled. If there is no setting
|
||||
* for the requested list, it is deemed to be enabled.
|
||||
*
|
||||
* @param keywordListName The name of the keywords list to check.
|
||||
* @return True if the keywords list is enabled, false otherwise.
|
||||
*/
|
||||
boolean keywordListIsEnabled(String keywordListName) {
|
||||
this.upgradeFromOlderVersions();
|
||||
return namesOfEnabledKeywordLists.contains(keywordListName);
|
||||
}
|
||||
|
||||
List<String> getNamesOfEnabledKeyWordLists() {
|
||||
return new ArrayList<>(namesOfEnabledKeywordLists);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the names of all explicitly enabled keywords lists.
|
||||
*
|
||||
* @return The list of names.
|
||||
*/
|
||||
List<String> getNamesOfEnabledKeyWordLists() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return new ArrayList<>(namesOfEnabledKeywordLists);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of all explicitly disabled keywords lists.
|
||||
*
|
||||
* @return The list of names.
|
||||
*/
|
||||
List<String> getNamesOfDisabledKeyWordLists() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return new ArrayList<>(namesOfDisabledKeywordLists);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize fields set to null when an instance of a previous, but still
|
||||
* compatible, version of this class is de-serialized.
|
||||
*/
|
||||
private void upgradeFromOlderVersions() {
|
||||
if (null == this.namesOfDisabledKeywordLists) {
|
||||
this.namesOfDisabledKeywordLists = new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public final class KeywordSearchJobSettingsPanel extends IngestModuleIngestJobSe
|
||||
for (KeywordList list : keywordLists) {
|
||||
String listName = list.getName();
|
||||
keywordListNames.add(listName);
|
||||
keywordListStates.put(listName, settings.isKeywordListEnabled(listName));
|
||||
keywordListStates.put(listName, settings.keywordListIsEnabled(listName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,12 +160,15 @@ public final class KeywordSearchJobSettingsPanel extends IngestModuleIngestJobSe
|
||||
@Override
|
||||
public IngestModuleIngestJobSettings getSettings() {
|
||||
List<String> enabledListNames = new ArrayList<>();
|
||||
List<String> disabledListNames = new ArrayList<>();
|
||||
for (String listName : keywordListNames) {
|
||||
if (keywordListStates.get(listName)) {
|
||||
enabledListNames.add(listName);
|
||||
} else {
|
||||
disabledListNames.add(listName);
|
||||
}
|
||||
}
|
||||
return new KeywordSearchJobSettings(enabledListNames);
|
||||
return new KeywordSearchJobSettings(enabledListNames, disabledListNames);
|
||||
}
|
||||
|
||||
void reset(KeywordSearchJobSettings newSettings) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user