mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Class name change: UserDefinedFileTypesManager to CustomFileTypesManager
This commit is contained in:
parent
38f98f2100
commit
4ea7eb11f8
@ -43,7 +43,7 @@ import org.xml.sax.SAXException;
|
|||||||
* A singleton manager for the custom file types defined by Autopsy and by
|
* A singleton manager for the custom file types defined by Autopsy and by
|
||||||
* users.
|
* users.
|
||||||
*/
|
*/
|
||||||
final class UserDefinedFileTypesManager {
|
final class CustomFileTypesManager {
|
||||||
|
|
||||||
private static final String XML_SETTINGS_FILE = "UserFileTypeDefinitions.xml"; //NON-NLS
|
private static final String XML_SETTINGS_FILE = "UserFileTypeDefinitions.xml"; //NON-NLS
|
||||||
private static final String SERIALIZED_SETTINGS_FILE = "UserFileTypeDefinitions.settings"; //NON-NLS
|
private static final String SERIALIZED_SETTINGS_FILE = "UserFileTypeDefinitions.settings"; //NON-NLS
|
||||||
@ -55,7 +55,7 @@ final class UserDefinedFileTypesManager {
|
|||||||
private static final String BYTES_TAG_NAME = "Bytes"; //NON-NLS
|
private static final String BYTES_TAG_NAME = "Bytes"; //NON-NLS
|
||||||
private static final String OFFSET_TAG_NAME = "Offset"; //NON-NLS
|
private static final String OFFSET_TAG_NAME = "Offset"; //NON-NLS
|
||||||
private static final String RELATIVE_ATTRIBUTE = "RelativeToStart"; //NON-NLS
|
private static final String RELATIVE_ATTRIBUTE = "RelativeToStart"; //NON-NLS
|
||||||
private static UserDefinedFileTypesManager instance;
|
private static CustomFileTypesManager instance;
|
||||||
private final List<FileType> userDefinedFileTypes = new ArrayList<>();
|
private final List<FileType> userDefinedFileTypes = new ArrayList<>();
|
||||||
private final List<FileType> allFileTypes = new ArrayList<>();
|
private final List<FileType> allFileTypes = new ArrayList<>();
|
||||||
|
|
||||||
@ -65,9 +65,9 @@ final class UserDefinedFileTypesManager {
|
|||||||
*
|
*
|
||||||
* @return The custom file types manager singleton.
|
* @return The custom file types manager singleton.
|
||||||
*/
|
*/
|
||||||
synchronized static UserDefinedFileTypesManager getInstance() {
|
synchronized static CustomFileTypesManager getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new UserDefinedFileTypesManager();
|
instance = new CustomFileTypesManager();
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ final class UserDefinedFileTypesManager {
|
|||||||
* Constructs a manager for the custom file types defined by Autopsy and by
|
* Constructs a manager for the custom file types defined by Autopsy and by
|
||||||
* users.
|
* users.
|
||||||
*/
|
*/
|
||||||
private UserDefinedFileTypesManager() {
|
private CustomFileTypesManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,10 +84,10 @@ final class UserDefinedFileTypesManager {
|
|||||||
*
|
*
|
||||||
* @return A list of file types, possibly empty.
|
* @return A list of file types, possibly empty.
|
||||||
*
|
*
|
||||||
* @throws UserDefinedFileTypesException if there is a problem accessing the
|
* @throws CustomFileTypesException if there is a problem accessing the
|
||||||
* file types.
|
* file types.
|
||||||
*/
|
*/
|
||||||
synchronized List<FileType> getFileTypes() throws UserDefinedFileTypesException {
|
synchronized List<FileType> getFileTypes() throws CustomFileTypesException {
|
||||||
loadFileTypes();
|
loadFileTypes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,10 +104,10 @@ final class UserDefinedFileTypesManager {
|
|||||||
*
|
*
|
||||||
* @return A list of file types, possibly empty.
|
* @return A list of file types, possibly empty.
|
||||||
*
|
*
|
||||||
* @throws UserDefinedFileTypesException if there is a problem accessing the
|
* @throws CustomFileTypesException if there is a problem accessing the
|
||||||
* file types.
|
* file types.
|
||||||
*/
|
*/
|
||||||
synchronized List<FileType> getUserDefinedFileTypes() throws UserDefinedFileTypesException {
|
synchronized List<FileType> getUserDefinedFileTypes() throws CustomFileTypesException {
|
||||||
loadFileTypes();
|
loadFileTypes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,10 +122,10 @@ final class UserDefinedFileTypesManager {
|
|||||||
/**
|
/**
|
||||||
* Loads or re-loads the custom file types defined by Autopsy and by users.
|
* Loads or re-loads the custom file types defined by Autopsy and by users.
|
||||||
*
|
*
|
||||||
* @throws UserDefinedFileTypesException if there is a problem loading the
|
* @throws CustomFileTypesException if there is a problem loading the
|
||||||
* file types.
|
* file types.
|
||||||
*/
|
*/
|
||||||
private void loadFileTypes() throws UserDefinedFileTypesException {
|
private void loadFileTypes() throws CustomFileTypesException {
|
||||||
allFileTypes.clear();
|
allFileTypes.clear();
|
||||||
userDefinedFileTypes.clear();
|
userDefinedFileTypes.clear();
|
||||||
|
|
||||||
@ -140,10 +140,10 @@ final class UserDefinedFileTypesManager {
|
|||||||
/**
|
/**
|
||||||
* Loads or re-loads the custom file types defined by Autopsy.
|
* Loads or re-loads the custom file types defined by Autopsy.
|
||||||
*
|
*
|
||||||
* @throws UserDefinedFileTypesException if there is a problem loading the
|
* @throws CustomFileTypesException if there is a problem loading the
|
||||||
* file types.
|
* file types.
|
||||||
*/
|
*/
|
||||||
private void loadPredefinedFileTypes() throws UserDefinedFileTypesException {
|
private void loadPredefinedFileTypes() throws CustomFileTypesException {
|
||||||
byte[] byteArray;
|
byte[] byteArray;
|
||||||
FileType fileType;
|
FileType fileType;
|
||||||
|
|
||||||
@ -298,17 +298,17 @@ final class UserDefinedFileTypesManager {
|
|||||||
/*
|
/*
|
||||||
* parseHexBinary() throws this if the argument passed in is not hex
|
* parseHexBinary() throws this if the argument passed in is not hex
|
||||||
*/
|
*/
|
||||||
throw new UserDefinedFileTypesException("Error creating predefined file types", ex); //
|
throw new CustomFileTypesException("Error creating predefined file types", ex); //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads or re-loads the custom file types defined by users.
|
* Loads or re-loads the custom file types defined by users.
|
||||||
*
|
*
|
||||||
* @throws UserDefinedFileTypesException if there is a problem loading the
|
* @throws CustomFileTypesException if there is a problem loading the
|
||||||
* file types.
|
* file types.
|
||||||
*/
|
*/
|
||||||
private void loadUserDefinedFileTypes() throws UserDefinedFileTypesException {
|
private void loadUserDefinedFileTypes() throws CustomFileTypesException {
|
||||||
try {
|
try {
|
||||||
File serialized = new File(getFileTypeDefinitionsFilePath(SERIALIZED_SETTINGS_FILE));
|
File serialized = new File(getFileTypeDefinitionsFilePath(SERIALIZED_SETTINGS_FILE));
|
||||||
if (serialized.exists()) {
|
if (serialized.exists()) {
|
||||||
@ -331,7 +331,7 @@ final class UserDefinedFileTypesManager {
|
|||||||
*/
|
*/
|
||||||
allFileTypes.clear();
|
allFileTypes.clear();
|
||||||
userDefinedFileTypes.clear();
|
userDefinedFileTypes.clear();
|
||||||
throw new UserDefinedFileTypesException("UserDefinedFileTypesManager.loadFileTypes.errorMessage", ex);
|
throw new CustomFileTypesException("UserDefinedFileTypesManager.loadFileTypes.errorMessage", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ final class UserDefinedFileTypesManager {
|
|||||||
*
|
*
|
||||||
* @param newFileTypes A list of user-defined file types.
|
* @param newFileTypes A list of user-defined file types.
|
||||||
*/
|
*/
|
||||||
synchronized void setUserDefinedFileTypes(List<FileType> newFileTypes) throws UserDefinedFileTypesException {
|
synchronized void setUserDefinedFileTypes(List<FileType> newFileTypes) throws CustomFileTypesException {
|
||||||
String filePath = getFileTypeDefinitionsFilePath(SERIALIZED_SETTINGS_FILE);
|
String filePath = getFileTypeDefinitionsFilePath(SERIALIZED_SETTINGS_FILE);
|
||||||
writeFileTypes(newFileTypes, filePath);
|
writeFileTypes(newFileTypes, filePath);
|
||||||
}
|
}
|
||||||
@ -373,15 +373,15 @@ final class UserDefinedFileTypesManager {
|
|||||||
* @param fileTypes A collection of file types.
|
* @param fileTypes A collection of file types.
|
||||||
* @param filePath The path to the destination file.
|
* @param filePath The path to the destination file.
|
||||||
*
|
*
|
||||||
* @throws UserDefinedFileTypesException if there is a problem writing the
|
* @throws CustomFileTypesException if there is a problem writing the
|
||||||
* file types.
|
* file types.
|
||||||
*/
|
*/
|
||||||
private static void writeFileTypes(List<FileType> fileTypes, String filePath) throws UserDefinedFileTypesException {
|
private static void writeFileTypes(List<FileType> fileTypes, String filePath) throws CustomFileTypesException {
|
||||||
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) {
|
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) {
|
||||||
UserDefinedFileTypesSettings settings = new UserDefinedFileTypesSettings(fileTypes);
|
UserDefinedFileTypesSettings settings = new UserDefinedFileTypesSettings(fileTypes);
|
||||||
out.writeObject(settings);
|
out.writeObject(settings);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new UserDefinedFileTypesException(String.format("Failed to write settings to %s", filePath), ex); //NON-NLS
|
throw new CustomFileTypesException(String.format("Failed to write settings to %s", filePath), ex); //NON-NLS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,10 +393,10 @@ final class UserDefinedFileTypesManager {
|
|||||||
*
|
*
|
||||||
* @return The custom file types.
|
* @return The custom file types.
|
||||||
*
|
*
|
||||||
* @throws UserDefinedFileTypesException if there is a problem reading the
|
* @throws CustomFileTypesException if there is a problem reading the
|
||||||
* file types.
|
* file types.
|
||||||
*/
|
*/
|
||||||
private static List<FileType> readSerializedFileTypes() throws UserDefinedFileTypesException {
|
private static List<FileType> readSerializedFileTypes() throws CustomFileTypesException {
|
||||||
File serializedDefs = new File(getFileTypeDefinitionsFilePath(SERIALIZED_SETTINGS_FILE));
|
File serializedDefs = new File(getFileTypeDefinitionsFilePath(SERIALIZED_SETTINGS_FILE));
|
||||||
try {
|
try {
|
||||||
try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(serializedDefs))) {
|
try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(serializedDefs))) {
|
||||||
@ -404,7 +404,7 @@ final class UserDefinedFileTypesManager {
|
|||||||
return filesSetsSettings.getUserDefinedFileTypes();
|
return filesSetsSettings.getUserDefinedFileTypes();
|
||||||
}
|
}
|
||||||
} catch (IOException | ClassNotFoundException ex) {
|
} catch (IOException | ClassNotFoundException ex) {
|
||||||
throw new UserDefinedFileTypesException("Couldn't read serialized settings.", ex); //NON-NLS
|
throw new CustomFileTypesException("Couldn't read serialized settings.", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,15 +540,15 @@ final class UserDefinedFileTypesManager {
|
|||||||
/**
|
/**
|
||||||
* .An exception thrown by the custom file types manager.
|
* .An exception thrown by the custom file types manager.
|
||||||
*/
|
*/
|
||||||
static class UserDefinedFileTypesException extends Exception {
|
static class CustomFileTypesException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
UserDefinedFileTypesException(String message) {
|
CustomFileTypesException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDefinedFileTypesException(String message, Throwable throwable) {
|
CustomFileTypesException(String message, Throwable throwable) {
|
||||||
super(message, throwable);
|
super(message, throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -60,8 +60,8 @@ public class FileTypeDetector {
|
|||||||
*/
|
*/
|
||||||
public FileTypeDetector() throws FileTypeDetectorInitException {
|
public FileTypeDetector() throws FileTypeDetectorInitException {
|
||||||
try {
|
try {
|
||||||
userDefinedFileTypes = UserDefinedFileTypesManager.getInstance().getFileTypes();
|
userDefinedFileTypes = CustomFileTypesManager.getInstance().getFileTypes();
|
||||||
} catch (UserDefinedFileTypesManager.UserDefinedFileTypesException ex) {
|
} catch (CustomFileTypesManager.CustomFileTypesException ex) {
|
||||||
throw new FileTypeDetectorInitException(Bundle.CouldNotInitializeFileTypeDetector(), ex);
|
throw new FileTypeDetectorInitException(Bundle.CouldNotInitializeFileTypeDetector(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
|
|||||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestModuleGlobalSettingsPanel;
|
import org.sleuthkit.autopsy.ingest.IngestModuleGlobalSettingsPanel;
|
||||||
import org.sleuthkit.autopsy.modules.filetypeid.FileType.Signature;
|
import org.sleuthkit.autopsy.modules.filetypeid.FileType.Signature;
|
||||||
import org.sleuthkit.autopsy.modules.filetypeid.UserDefinedFileTypesManager.UserDefinedFileTypesException;
|
import org.sleuthkit.autopsy.modules.filetypeid.CustomFileTypesManager.CustomFileTypesException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A panel to allow a user to make custom file type definitions. In addition to
|
* A panel to allow a user to make custom file type definitions. In addition to
|
||||||
@ -207,12 +207,12 @@ final class FileTypeIdGlobalSettingsPanel extends IngestModuleGlobalSettingsPane
|
|||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
try {
|
try {
|
||||||
fileTypes = UserDefinedFileTypesManager.getInstance().getUserDefinedFileTypes();
|
fileTypes = CustomFileTypesManager.getInstance().getUserDefinedFileTypes();
|
||||||
updateFileTypesListModel();
|
updateFileTypesListModel();
|
||||||
if (!typesListModel.isEmpty()) {
|
if (!typesListModel.isEmpty()) {
|
||||||
typesList.setSelectedIndex(0);
|
typesList.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
} catch (UserDefinedFileTypesException ex) {
|
} catch (CustomFileTypesException ex) {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
ex.getLocalizedMessage(),
|
ex.getLocalizedMessage(),
|
||||||
NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.JOptionPane.loadFailed.title"),
|
NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.JOptionPane.loadFailed.title"),
|
||||||
@ -266,8 +266,8 @@ final class FileTypeIdGlobalSettingsPanel extends IngestModuleGlobalSettingsPane
|
|||||||
@Override
|
@Override
|
||||||
public void store() {
|
public void store() {
|
||||||
try {
|
try {
|
||||||
UserDefinedFileTypesManager.getInstance().setUserDefinedFileTypes(fileTypes);
|
CustomFileTypesManager.getInstance().setUserDefinedFileTypes(fileTypes);
|
||||||
} catch (UserDefinedFileTypesManager.UserDefinedFileTypesException ex) {
|
} catch (CustomFileTypesManager.CustomFileTypesException ex) {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
ex.getLocalizedMessage(),
|
ex.getLocalizedMessage(),
|
||||||
NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.JOptionPane.storeFailed.title"),
|
NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.JOptionPane.storeFailed.title"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user