19 package org.sleuthkit.autopsy.ingest;
22 import java.io.IOException;
23 import java.nio.file.Files;
24 import java.nio.file.Paths;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.logging.Level;
28 import org.apache.commons.io.FileUtils;
29 import org.apache.commons.io.FilenameUtils;
50 static String getIngestProfilePrefix() {
61 static String getExecutionContext(String profileName) {
62 return SETTINGS_FILE_PREFIX + profileName;
73 return (executionContext != null && executionContext.startsWith(getIngestProfilePrefix()))
74 ? executionContext.substring(getIngestProfilePrefix().length())
114 File[] directoryListing = dir.listFiles((file) -> file.getName() != null && file.getName().startsWith(getIngestProfilePrefix()) && file.isFile());
115 List<IngestProfile> profileList =
new ArrayList<>();
116 if (directoryListing != null) {
117 for (File child : directoryListing) {
118 String resourceName = FilenameUtils.removeExtension(child.getName());
120 String moduleSettingsResource =
IngestJobSettings.getModuleSettingsResource(resourceName);
123 profileList.add(
new IngestProfile(profileName, desc, fileIngestFilter));
132 synchronized static void setProfiles(List<IngestProfile> profiles) {
156 IngestProfile(String name, String desc, String selectedFilter) {
158 this.description = desc;
159 this.fileIngestFilter = selectedFilter;
204 synchronized static void deleteProfile(
IngestProfile selectedProfile) {
205 deleteProfile(selectedProfile.getName());
213 synchronized static void deleteProfile(String profileName) {
217 Files.deleteIfExists(rootSettingsFile.toPath());
218 FileUtils.deleteDirectory(settingsDirectory);
219 }
catch (IOException ex) {
220 logger.log(Level.WARNING,
"Error deleting directory for profile " + profileName, ex);
230 synchronized static void renameProfile(String oldName, String newName) {
231 if (!oldName.equals(newName)) {
234 oldRootSettings.renameTo(newRootSettings);
238 oldSettingsFolder.renameTo(newSettingsFolder);
247 synchronized static void saveProfile(IngestProfile profile) {
248 String context = IngestJobSettings.getModuleSettingsResource(getExecutionContext(profile.getName()));
249 ModuleSettings.setConfigSetting(context, PROFILE_NAME_KEY, profile.getName());
250 ModuleSettings.setConfigSetting(context, PROFILE_DESC_KEY, profile.getDescription());
251 ModuleSettings.setConfigSetting(context, PROFILE_FILTER_KEY, profile.getFileIngestFilter());
static synchronized String getConfigSetting(String moduleName, String settingName)
static String getSanitizedProfile(String executionContext)
static final String PROFILE_NAME_KEY
static final String PROFILE_FILTER_KEY
final String fileIngestFilter
static File getRootSettingsFile(String profileName)
String getIngestProfilePrefix()
static IngestProfilePaths getInstance()
static synchronized List< IngestProfile > getIngestProfiles()
String getFileIngestFilter()
static File getSettingsDirectory(String profileName)
synchronized static Logger getLogger(String name)
static final String SETTINGS_FILE_PREFIX
static final Logger logger
static final String PROFILE_DESC_KEY