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;
52 File[] directoryListing = dir.listFiles();
53 List<IngestProfile> profileList =
new ArrayList<>();
54 if (directoryListing != null) {
55 for (File child : directoryListing) {
56 String name = FilenameUtils.removeExtension(child.getName());
57 String context = PROFILE_FOLDER + File.separator + name;
60 profileList.add(
new IngestProfile(name, desc, fileIngestFilter));
69 synchronized static void setProfiles(List<IngestProfile> profiles) {
93 IngestProfile(String name, String desc, String selectedFilter) {
95 this.description = desc;
96 this.fileIngestFilter = selectedFilter;
141 synchronized static void deleteProfile(
IngestProfile selectedProfile) {
145 FileUtils.deleteDirectory(
IngestJobSettings.getSavedModuleSettingsFolder(selectedProfile.getName() + File.separator).toFile());
146 }
catch (IOException ex) {
147 logger.log(Level.WARNING,
"Error deleting directory for profile " + selectedProfile.getName(), ex);
157 synchronized static void renameProfile(String oldName, String newName) {
158 if (!oldName.equals(newName)) {
161 oldFile.renameTo(newFile);
162 oldFile = Paths.get(PlatformUtil.getUserConfigDirectory(), oldName +
PROFILE_FILE_EXT).toFile();
163 newFile = Paths.get(PlatformUtil.getUserConfigDirectory(), newName +
PROFILE_FILE_EXT).toFile();
164 oldFile.renameTo(newFile);
165 oldFile = IngestJobSettings.getSavedModuleSettingsFolder(oldName + File.separator).toFile();
166 newFile = IngestJobSettings.getSavedModuleSettingsFolder(newName + File.separator).toFile();
167 oldFile.renameTo(newFile);
176 synchronized static void saveProfile(IngestProfile profile) {
177 String context = PROFILE_FOLDER + File.separator + profile.getName();
178 ModuleSettings.setConfigSetting(context, PROFILE_NAME_KEY, profile.getName());
179 ModuleSettings.setConfigSetting(context, PROFILE_DESC_KEY, profile.getDescription());
180 ModuleSettings.setConfigSetting(context, PROFILE_FILTER_KEY, profile.getFileIngestFilter());
static synchronized String getConfigSetting(String moduleName, String settingName)
static final String PROFILE_NAME_KEY
static final String PROFILE_FILTER_KEY
final String fileIngestFilter
static final String PROFILE_FILE_EXT
static synchronized List< IngestProfile > getIngestProfiles()
static final String PROFILE_FOLDER
String getFileIngestFilter()
synchronized static Logger getLogger(String name)
static final Logger logger
static final String PROFILE_DESC_KEY