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 org.apache.commons.io.FileUtils;
28 import org.apache.commons.io.FilenameUtils;
29 import org.openide.util.Exceptions;
51 File[] directoryListing = dir.listFiles();
52 List<IngestProfile> profileList =
new ArrayList<>();
53 if (directoryListing != null) {
54 for (File child : directoryListing) {
55 String name = FilenameUtils.removeExtension(child.getName());
56 String context = PROFILE_FOLDER + File.separator + name;
59 profileList.add(
new IngestProfile(name, desc, fileIngestFilter));
68 synchronized static void setProfiles(List<IngestProfile> profiles) {
92 IngestProfile(String name, String desc, String selectedFilter) {
94 this.description = desc;
95 this.fileIngestFilter = selectedFilter;
140 synchronized static void deleteProfile(
IngestProfile selectedProfile) {
144 FileUtils.deleteDirectory(
IngestJobSettings.getSavedModuleSettingsFolder(selectedProfile.getName() + File.separator).toFile());
145 }
catch (IOException ex) {
146 Exceptions.printStackTrace(ex);
156 synchronized static void renameProfile(String oldName, String newName) {
157 if (!oldName.equals(newName)) {
160 oldFile.renameTo(newFile);
161 oldFile = Paths.get(PlatformUtil.getUserConfigDirectory(), oldName +
PROFILE_FILE_EXT).toFile();
162 newFile = Paths.get(PlatformUtil.getUserConfigDirectory(), newName +
PROFILE_FILE_EXT).toFile();
163 oldFile.renameTo(newFile);
164 oldFile = IngestJobSettings.getSavedModuleSettingsFolder(oldName + File.separator).toFile();
165 newFile = IngestJobSettings.getSavedModuleSettingsFolder(newName + File.separator).toFile();
166 oldFile.renameTo(newFile);
175 synchronized static void saveProfile(IngestProfile profile) {
176 String context = PROFILE_FOLDER + File.separator + profile.getName();
177 ModuleSettings.setConfigSetting(context, PROFILE_NAME_KEY, profile.getName());
178 ModuleSettings.setConfigSetting(context, PROFILE_DESC_KEY, profile.getDescription());
179 ModuleSettings.setConfigSetting(context, PROFILE_FILTER_KEY, profile.getFileIngestFilter());
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
static String getConfigSetting(String moduleName, String settingName)
String getFileIngestFilter()
static final String PROFILE_DESC_KEY