Added WizardPathValidator interface and service provider lookup

This commit is contained in:
Eugene Livis
2015-05-15 14:56:13 -04:00
parent 399fcb6bd4
commit b2d8c2fc50
2 changed files with 63 additions and 0 deletions
@@ -38,6 +38,7 @@ import javax.swing.event.DocumentEvent;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator;
import org.sleuthkit.autopsy.coreutils.Logger;
/**
@@ -55,6 +56,8 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel {
private Map<String, DataSourceProcessor> datasourceProcessorsMap = new HashMap<>();
List<WizardPathValidator> pathValidatorList = new ArrayList<>();
List<String> coreDSPTypes = new ArrayList<>();
/**
@@ -75,6 +78,8 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel {
typePanel.setLayout(new BorderLayout());
discoverDataSourceProcessors();
discoverWizardPathValidators();
// set up the DSP type combobox
typeComboBox.removeAllItems();
@@ -128,6 +133,12 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel {
}
}
}
private void discoverWizardPathValidators() {
for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) {
pathValidatorList.add(pathValidator);
}
}
private void dspSelectionChanged() {
// update the current panel to selection
@@ -0,0 +1,52 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2014 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.corecomponentinterfaces;
/*
* Defines an interface used by the Add DataSource wizard to validate path for selected
* case and/or data source.
*
* Different Autopsy implementations and modes may have its unique attributes and
* may need to be processed differently.
*
* The WizardPathValidator interface defines a uniform mechanism for the Autopsy UI
* to:
* - Validate path for selected case.
* - Validate path for selected data source.
*/
public interface WizardPathValidator {
/**
* Validates case path.
*
* @param path Absolute path to case file.
* @return String Error message if path is invalid, empty string otherwise.
*
*/
String validateCasePath(String path);
/**
* Validates data source path.
*
* @param path Absolute path to data source file.
* @return String Error message if path is invalid, empty string otherwise.
*
*/
String validateDataSourcePath(String path);
}