mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Add module reload listener to dialog panel, add API to reorder modules to loader
This commit is contained in:
parent
f50b7da833
commit
4e50fafe28
@ -24,11 +24,14 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTable;
|
||||
@ -38,6 +41,7 @@ import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.sleuthkit.autopsy.casemodule.IngestConfigurator;
|
||||
import org.sleuthkit.autopsy.corecomponents.AdvancedConfigurationDialog;
|
||||
import org.sleuthkit.datamodel.Image;
|
||||
@ -73,9 +77,9 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void customizeComponents() {
|
||||
modulesTable.setModel(tableModel);
|
||||
this.manager = IngestManager.getDefault();
|
||||
private void loadModules() {
|
||||
this.modules.clear();
|
||||
//this.moduleStates.clear(); maintain the state
|
||||
Collection<IngestModuleImage> imageModules = manager.enumerateImageModules();
|
||||
for (final IngestModuleImage module : imageModules) {
|
||||
addModule(module);
|
||||
@ -84,6 +88,27 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi
|
||||
for (final IngestModuleAbstractFile module : fsModules) {
|
||||
addModule(module);
|
||||
}
|
||||
}
|
||||
|
||||
private void customizeComponents() {
|
||||
modulesTable.setModel(tableModel);
|
||||
this.manager = IngestManager.getDefault();
|
||||
|
||||
loadModules();
|
||||
try {
|
||||
IngestModuleLoader.getDefault().addModulesReloadedListener(new PropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (evt.getPropertyName().equals(IngestModuleLoader.Event.ModulesReloaded.toString())) {
|
||||
loadModules();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (IngestModuleLoaderException ex) {
|
||||
logger.log(Level.SEVERE, "Could not initialize ingest module loader to listen for module config changes", ex);
|
||||
}
|
||||
|
||||
modulesTable.setTableHeader(null);
|
||||
modulesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
@ -59,6 +59,7 @@ import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.openide.filesystems.FileSystem;
|
||||
import org.openide.modules.ModuleInfo;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.Lookup;
|
||||
@ -76,6 +77,7 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.openide.filesystems.Repository;
|
||||
|
||||
/**
|
||||
* Class responsible for discovery and loading ingest modules specified in
|
||||
@ -83,11 +85,16 @@ import org.xml.sax.SAXException;
|
||||
* application for changes in XML to take effect.
|
||||
*
|
||||
* Supports module auto-discovery from system-wide and user-dir wide jar files.
|
||||
* Discovered modules are validated, and if valid, they are added to end of configuration
|
||||
* and saved in the XML.
|
||||
* Discovered modules are validated, and if valid, they are added to end of
|
||||
* configuration and saved in the XML.
|
||||
*
|
||||
* If module is removed/uninstalled, it will remain in the XML file, but it will
|
||||
* not load because it will fail the validation.
|
||||
*
|
||||
* Get a handle to the object by calling static getDefault() method. The
|
||||
* singleton instance will initialize itself the first time - it will load XML
|
||||
* and autodiscover currently present ingest modules in the jar classpath..
|
||||
*
|
||||
* If module is removed/uninstalled, it will remain in the XML file, but it will not load
|
||||
* because it will fail the validation.
|
||||
*
|
||||
* Refer to
|
||||
* http://sleuthkit.org/sleuthkit/docs/framework-docs/pipeline_config_page.html
|
||||
@ -336,6 +343,18 @@ public final class IngestModuleLoader {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* netbeans way, but not public API
|
||||
org.openide.filesystems.Repository defaultRepository = Repository.getDefault();
|
||||
FileSystem masterFilesystem = defaultRepository.getDefaultFileSystem();
|
||||
org.netbeans.core.startup.ModuleSystem moduleSystem = new org.netbeans.core.startup.ModuleSystem(masterFilesystem);
|
||||
List<File> jars = moduleSystem.getModuleJars();
|
||||
for (File jar : jars) {
|
||||
logger.log(Level.INFO, " JAR2: " + jar.getAbsolutePath());
|
||||
}
|
||||
//org.netbeans.ModuleManager moduleManager = moduleSystem.getManager();
|
||||
*/
|
||||
|
||||
return urls;
|
||||
}
|
||||
|
||||
@ -559,6 +578,16 @@ public final class IngestModuleLoader {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new order of the module
|
||||
* @param pipeLineType pipeline type where the module to reorder is present
|
||||
* @param moduleLocation loaded module name (location), fully qualified class path
|
||||
* @param newOrder new order to set
|
||||
*/
|
||||
void setModuleOrder(XmlPipelineRaw.PIPELINE_TYPE pipeLineType, String moduleLocation, int newOrder) throws IngestModuleLoaderException{
|
||||
throw new IngestModuleLoaderException("Not yet implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* add autodiscovered module to raw pipeline to be validated and
|
||||
* instantiated
|
||||
@ -588,12 +617,13 @@ public final class IngestModuleLoader {
|
||||
throw new IngestModuleLoaderException("Could not find expected pipeline of type: " + pipelineType.toString() + ", cannot add autodiscovered module: " + moduleLocation);
|
||||
} else {
|
||||
pipeline.modules.add(modRaw);
|
||||
logger.log(Level.INFO, "Added a new module " + moduleClass.getName() + " to pipeline " + pipelineType.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a listener for module install/uninstall
|
||||
* //TODO ensure that module is actually loadable when Lookup event is fired
|
||||
* Register a listener for module install/uninstall //TODO ensure that
|
||||
* module is actually loadable when Lookup event is fired
|
||||
*/
|
||||
private void registerModulesChange() {
|
||||
final Lookup.Result<ModuleInfo> result =
|
||||
@ -656,7 +686,7 @@ public final class IngestModuleLoader {
|
||||
|
||||
}
|
||||
|
||||
private boolean saveDoc(final Document doc) {
|
||||
private boolean saveDoc(final Document doc) {
|
||||
TransformerFactory xf = TransformerFactory.newInstance();
|
||||
xf.setAttribute("indent-number", new Integer(1));
|
||||
boolean success = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user