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