mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
update to enum
This commit is contained in:
parent
4d5e2362e7
commit
5ca2fa1931
@ -81,7 +81,9 @@ import org.sleuthkit.datamodel.TskData;
|
||||
final class PhotoRecCarverFileIngestModule implements FileIngestModule {
|
||||
|
||||
static final boolean DEFAULT_CONFIG_KEEP_CORRUPTED_FILES = false;
|
||||
static final boolean DEFAULT_CONFIG_FILE_OPT_OPTIONS = false;
|
||||
static final PhotoRecCarverIngestJobSettings.ExtensionFilterOption DEFAULT_CONFIG_EXTENSION_FILTER =
|
||||
PhotoRecCarverIngestJobSettings.ExtensionFilterOption.NO_FILTER;
|
||||
|
||||
static final boolean DEFAULT_CONFIG_INCLUDE_ELSE_EXCLUDE = false;
|
||||
|
||||
private static final String PHOTOREC_DIRECTORY = "photorec_exec"; //NON-NLS
|
||||
@ -139,7 +141,9 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule {
|
||||
toRet.addAll(Arrays.asList("options", "keep_corrupted_file"));
|
||||
}
|
||||
|
||||
if (settings.hasFileOptOption()) {
|
||||
if (settings.getExtensionFilterOption() !=
|
||||
PhotoRecCarverIngestJobSettings.ExtensionFilterOption.NO_FILTER) {
|
||||
|
||||
// add the file opt menu item
|
||||
toRet.add("fileopt");
|
||||
|
||||
@ -148,15 +152,17 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule {
|
||||
|
||||
// if we are including file extensions, then we are excluding
|
||||
// everything else and vice-versa.
|
||||
String everythingEnable = settings.isIncludeElseExclude()
|
||||
String everythingEnable = settings.getExtensionFilterOption() ==
|
||||
PhotoRecCarverIngestJobSettings.ExtensionFilterOption.INCLUDE
|
||||
? disable : enable;
|
||||
|
||||
toRet.addAll(Arrays.asList("everything", everythingEnable));
|
||||
|
||||
final String itemEnable = settings.isIncludeElseExclude()
|
||||
final String itemEnable = settings.getExtensionFilterOption() ==
|
||||
PhotoRecCarverIngestJobSettings.ExtensionFilterOption.INCLUDE
|
||||
? enable : disable;
|
||||
|
||||
settings.getIncludeExcludeExtensions().forEach((extension) -> {
|
||||
settings.getExtensions().forEach((extension) -> {
|
||||
toRet.addAll(Arrays.asList(extension, itemEnable));
|
||||
});
|
||||
}
|
||||
@ -190,13 +196,15 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule {
|
||||
})
|
||||
public void startUp(IngestJobContext context) throws IngestModule.IngestModuleException {
|
||||
// validate settings
|
||||
if (this.settings.hasFileOptOption()) {
|
||||
if (this.settings.getIncludeExcludeExtensions().isEmpty() && this.settings.isIncludeElseExclude()) {
|
||||
if (this.settings.getExtensionFilterOption() != PhotoRecCarverIngestJobSettings.ExtensionFilterOption.NO_FILTER) {
|
||||
if (this.settings.getExtensions().isEmpty() &&
|
||||
this.settings.getExtensionFilterOption() == PhotoRecCarverIngestJobSettings.ExtensionFilterOption.INCLUDE) {
|
||||
|
||||
throw new IngestModule.IngestModuleException(
|
||||
Bundle.PhotoRecCarverFileIngestModule_startUp_noExtensionsProvided_description());
|
||||
}
|
||||
|
||||
List<String> invalidExtensions = this.settings.getIncludeExcludeExtensions().stream()
|
||||
List<String> invalidExtensions = this.settings.getExtensions().stream()
|
||||
.filter((ext) -> !PhotoRecCarverFileOptExtensions.isValidExtension(ext))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
@ -28,20 +28,37 @@ import java.util.List;
|
||||
*/
|
||||
final class PhotoRecCarverIngestJobSettings implements IngestModuleIngestJobSettings {
|
||||
|
||||
/**
|
||||
* What kind of filtering should occur for the extension list.
|
||||
*/
|
||||
static enum ExtensionFilterOption {
|
||||
/**
|
||||
* The file extensions should be included (and others should be
|
||||
* filtered).
|
||||
*/
|
||||
INCLUDE,
|
||||
/**
|
||||
* The extensions should be excluded from the results list.
|
||||
*/
|
||||
EXCLUDE,
|
||||
/**
|
||||
* No extension filtering should take place.
|
||||
*/
|
||||
NO_FILTER
|
||||
};
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private boolean keepCorruptedFiles;
|
||||
private List<String> includeExcludeExtensions;
|
||||
private boolean fileOptOption;
|
||||
private boolean includeElseExclude;
|
||||
private List<String> extensions;
|
||||
private ExtensionFilterOption extensionFilterOption;
|
||||
|
||||
/**
|
||||
* Instantiate the ingest job settings with default values.
|
||||
*/
|
||||
PhotoRecCarverIngestJobSettings() {
|
||||
this(PhotoRecCarverFileIngestModule.DEFAULT_CONFIG_KEEP_CORRUPTED_FILES,
|
||||
PhotoRecCarverFileIngestModule.DEFAULT_CONFIG_FILE_OPT_OPTIONS,
|
||||
PhotoRecCarverFileIngestModule.DEFAULT_CONFIG_INCLUDE_ELSE_EXCLUDE,
|
||||
PhotoRecCarverFileIngestModule.DEFAULT_CONFIG_EXTENSION_FILTER,
|
||||
null);
|
||||
}
|
||||
|
||||
@ -50,19 +67,16 @@ final class PhotoRecCarverIngestJobSettings implements IngestModuleIngestJobSett
|
||||
*
|
||||
* @param keepCorruptedFiles Whether or not to keep corrupted files.
|
||||
* @param fileOptOption Whether or not the file opt options
|
||||
* should be enabled (whether or not to
|
||||
* include/exclude file extensions).
|
||||
* @param includeElseExclude If file opt options is enabled, whether
|
||||
* to include only the extensions listed or
|
||||
* exclude extensions from output.
|
||||
* @param extensionFilterOption How the includeExcludeExtensions should
|
||||
* be filtered.
|
||||
* @param includeExcludeExtensions The extensions to include or exclude
|
||||
* (i.e. jpg, gif)
|
||||
*/
|
||||
PhotoRecCarverIngestJobSettings(boolean keepCorruptedFiles, boolean fileOptOption, boolean includeElseExclude, List<String> includeExcludeExtensions) {
|
||||
PhotoRecCarverIngestJobSettings(boolean keepCorruptedFiles, ExtensionFilterOption extensionFilterOption, List<String> includeExcludeExtensions) {
|
||||
this.keepCorruptedFiles = keepCorruptedFiles;
|
||||
this.fileOptOption = fileOptOption;
|
||||
this.includeElseExclude = includeElseExclude;
|
||||
setIncludeExcludeExtensions(includeExcludeExtensions);
|
||||
setExtensionFilterOption(extensionFilterOption);
|
||||
setExtensions(includeExcludeExtensions);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,10 +108,10 @@ final class PhotoRecCarverIngestJobSettings implements IngestModuleIngestJobSett
|
||||
*
|
||||
* @return The extension names.
|
||||
*/
|
||||
List<String> getIncludeExcludeExtensions() {
|
||||
return includeExcludeExtensions == null
|
||||
List<String> getExtensions() {
|
||||
return extensions == null
|
||||
? Collections.emptyList()
|
||||
: Collections.unmodifiableList(includeExcludeExtensions);
|
||||
: Collections.unmodifiableList(extensions);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,58 +120,30 @@ final class PhotoRecCarverIngestJobSettings implements IngestModuleIngestJobSett
|
||||
*
|
||||
* @param includeExcludeExtensions The extension names.
|
||||
*/
|
||||
void setIncludeExcludeExtensions(List<String> includeExcludeExtensions) {
|
||||
this.includeExcludeExtensions = new ArrayList<>();
|
||||
void setExtensions(List<String> includeExcludeExtensions) {
|
||||
this.extensions = new ArrayList<>();
|
||||
if (includeExcludeExtensions != null) {
|
||||
this.includeExcludeExtensions.addAll(includeExcludeExtensions);
|
||||
this.extensions.addAll(includeExcludeExtensions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the fileopt option (and subsequent file extension
|
||||
* filtering) should be enabled.
|
||||
*
|
||||
* @return Whether or not the fileopt option (and subsequent file extension
|
||||
* filtering) should be enabled.
|
||||
* How extension filtering should be handled.
|
||||
* @return How extension filtering should be handled.
|
||||
*/
|
||||
boolean hasFileOptOption() {
|
||||
return fileOptOption;
|
||||
ExtensionFilterOption getExtensionFilterOption() {
|
||||
return (this.extensionFilterOption == null) ?
|
||||
ExtensionFilterOption.NO_FILTER :
|
||||
extensionFilterOption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the fileopt option (and subsequent file extension
|
||||
* filtering) should be enabled.
|
||||
*
|
||||
* @param fileOptOption Whether or not the fileopt option (and subsequent
|
||||
* file extension filtering) should be enabled.
|
||||
* Sets how extension filtering should be handled.
|
||||
* @param extensionFilterOption How extension filtering should be handled.
|
||||
*/
|
||||
void setFileOptOption(boolean fileOptOption) {
|
||||
this.fileOptOption = fileOptOption;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the hasFileOptOption is true, this determines whether
|
||||
* includeExcludeExtensions will be included in the results (excluding all
|
||||
* others) or includeExcludeExtensions will be excluded from results
|
||||
* (including all others).
|
||||
*
|
||||
* @return Whether to include or exclude includeExcludeExtensions.
|
||||
*/
|
||||
boolean isIncludeElseExclude() {
|
||||
return includeElseExclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not to include or exclude files. If the hasFileOptOption
|
||||
* is true, this determines whether includeExcludeExtensions will be
|
||||
* included in the results (excluding all others) or
|
||||
* includeExcludeExtensions will be excluded from results (including all
|
||||
* others).
|
||||
*
|
||||
* @param includeElseExclude Whether to include or exclude
|
||||
* includeExcludeExtensions.
|
||||
*/
|
||||
void setIncludeElseExclude(boolean includeElseExclude) {
|
||||
this.includeElseExclude = includeElseExclude;
|
||||
void setExtensionFilterOption(ExtensionFilterOption extensionFilterOption) {
|
||||
this.extensionFilterOption = (extensionFilterOption == null) ?
|
||||
ExtensionFilterOption.NO_FILTER :
|
||||
extensionFilterOption;
|
||||
}
|
||||
}
|
||||
|
@ -62,10 +62,10 @@ final class PhotoRecCarverIngestJobSettingsPanel extends IngestModuleIngestJobSe
|
||||
* @param settings The ingest job settings.
|
||||
*/
|
||||
private void customizeComponents(PhotoRecCarverIngestJobSettings settings) {
|
||||
includeExcludeCheckbox.setSelected(settings.hasFileOptOption());
|
||||
extensionListTextfield.setText(String.join(EXTENSION_LIST_SEPARATOR, settings.getIncludeExcludeExtensions()));
|
||||
includeRadioButton.setSelected(!settings.isIncludeElseExclude());
|
||||
excludeRadioButton.setSelected(!settings.isIncludeElseExclude());
|
||||
includeExcludeCheckbox.setSelected(settings.getExtensionFilterOption() != PhotoRecCarverIngestJobSettings.ExtensionFilterOption.NO_FILTER);
|
||||
extensionListTextfield.setText(String.join(EXTENSION_LIST_SEPARATOR, settings.getExtensions()));
|
||||
includeRadioButton.setSelected(settings.getExtensionFilterOption() == PhotoRecCarverIngestJobSettings.ExtensionFilterOption.INCLUDE);
|
||||
excludeRadioButton.setSelected(settings.getExtensionFilterOption() == PhotoRecCarverIngestJobSettings.ExtensionFilterOption.EXCLUDE);
|
||||
keepCorruptedFilesCheckbox.setSelected(settings.isKeepCorruptedFiles());
|
||||
setupTypesHyperlink();
|
||||
setIncludePanelEnabled();
|
||||
@ -117,12 +117,21 @@ final class PhotoRecCarverIngestJobSettingsPanel extends IngestModuleIngestJobSe
|
||||
|
||||
@Override
|
||||
public IngestModuleIngestJobSettings getSettings() {
|
||||
PhotoRecCarverIngestJobSettings.ExtensionFilterOption filterOption =
|
||||
PhotoRecCarverIngestJobSettings.ExtensionFilterOption.NO_FILTER;
|
||||
|
||||
if (includeExcludeCheckbox.isSelected()) {
|
||||
if (includeRadioButton.isSelected()) {
|
||||
filterOption = PhotoRecCarverIngestJobSettings.ExtensionFilterOption.INCLUDE;
|
||||
} else {
|
||||
filterOption = PhotoRecCarverIngestJobSettings.ExtensionFilterOption.EXCLUDE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new PhotoRecCarverIngestJobSettings(
|
||||
keepCorruptedFilesCheckbox.isSelected(),
|
||||
includeExcludeCheckbox.isSelected(),
|
||||
includeRadioButton.isSelected(),
|
||||
filterOption,
|
||||
getExtensions(extensionListTextfield.getText())
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user