diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties
index 4da5e45e93..b0c10ad498 100644
--- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties
+++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties
@@ -21,7 +21,6 @@ ImportHashDatabaseDialog.tfDatabaseName.tooltip=Name for this database
ImportHashDatabaseDialog.tfDatabaseVersion.tooltip.text=Database Version Number
ImportHashDatabaseDialog.tfDatabaseName.tooltip=Name for this database
ImportHashDatabaseDialog.tfDatabaseVersion.tooltip.text=Database Version Number
-GlobalSettingsPanel.bnImportDatabase.actionCommand=
GlobalSettingsPanel.bnManageTags.actionCommand=
GlobalSettingsPanel.bnManageTags.toolTipText=
GlobalSettingsPanel.bnManageTags.text=Manage Tags
diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.form b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.form
index 49d525511b..731c177818 100755
--- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.form
+++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.form
@@ -31,7 +31,6 @@
-
@@ -55,9 +54,7 @@
-
-
-
+
@@ -177,22 +174,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -415,7 +396,7 @@
-
+
diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.java
index de99aff998..37d18036d8 100755
--- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.java
+++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.java
@@ -71,9 +71,6 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
private void customizeComponents() {
setName(Bundle.GlobalSettingsPanel_title());
-
- // The hash set functions of central repo are not being included in the current release.
- bnImportDatabase.setVisible(false);
}
private void addIngestJobEventsListener() {
@@ -99,7 +96,6 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
lbDbNameValue = new javax.swing.JLabel();
lbDbLocationValue = new javax.swing.JLabel();
cbUseCentralRepo = new javax.swing.JCheckBox();
- bnImportDatabase = new javax.swing.JButton();
pnTagManagement = new javax.swing.JPanel();
bnManageTags = new javax.swing.JButton();
manageTagsScrollPane = new javax.swing.JScrollPane();
@@ -180,15 +176,6 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
}
});
- bnImportDatabase.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/centralrepository/images/import16.png"))); // NOI18N
- org.openide.awt.Mnemonics.setLocalizedText(bnImportDatabase, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.bnImportDatabase.label")); // NOI18N
- bnImportDatabase.setActionCommand(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.bnImportDatabase.actionCommand")); // NOI18N
- bnImportDatabase.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- bnImportDatabaseActionPerformed(evt);
- }
- });
-
pnTagManagement.setBorder(javax.swing.BorderFactory.createTitledBorder(null, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.pnTagManagement.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
pnTagManagement.setPreferredSize(new java.awt.Dimension(674, 97));
@@ -353,8 +340,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
.addComponent(pnCorrelationProperties, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnTagManagement, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnDatabaseConfiguration, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(cbUseCentralRepo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(bnImportDatabase, javax.swing.GroupLayout.Alignment.LEADING))
+ .addComponent(cbUseCentralRepo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())))
);
layout.setVerticalGroup(
@@ -373,20 +359,12 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
.addComponent(organizationPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 0, 0)
- .addComponent(bnImportDatabase)
- .addContainerGap())
+ .addGap(36, 36, 36))
);
pnTagManagement.getAccessibleContext().setAccessibleName("");
}// //GEN-END:initComponents
- private void bnImportDatabaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnImportDatabaseActionPerformed
- store();
- //ImportHashDatabaseDialog dialog = new ImportHashDatabaseDialog();
- //firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
- }//GEN-LAST:event_bnImportDatabaseActionPerformed
-
private void bnManageTagsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnManageTagsActionPerformed
store();
ManageTagsDialog dialog = new ManageTagsDialog();
@@ -567,7 +545,6 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
pnCorrelationProperties.setEnabled(enable && !ingestRunning);
pnTagManagement.setEnabled(enable && !ingestRunning);
bnManageTypes.setEnabled(enable && !ingestRunning);
- bnImportDatabase.setEnabled(enable && !ingestRunning);
bnManageTags.setEnabled(enable && !ingestRunning);
manageTagsTextArea.setEnabled(enable && !ingestRunning);
correlationPropertiesTextArea.setEnabled(enable && !ingestRunning);
@@ -579,7 +556,6 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton bnDbConfigure;
- private javax.swing.JButton bnImportDatabase;
private javax.swing.JButton bnManageTags;
private javax.swing.JButton bnManageTypes;
private javax.swing.JCheckBox cbUseCentralRepo;
diff --git a/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchDialog.java b/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchDialog.java
index a66e49aa2a..66cca80df1 100755
--- a/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchDialog.java
+++ b/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchDialog.java
@@ -57,7 +57,7 @@ class FileSearchDialog extends javax.swing.JDialog {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
- }
+ }
});
}
diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/Bundle.properties b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/Bundle.properties
index ff3cf1c7f5..e802f9f9f5 100755
--- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/Bundle.properties
+++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/Bundle.properties
@@ -211,31 +211,6 @@ HashLookupSettingsPanel.hashDatabasesLabel.text=Hash Databases:
HashLookupSettingsPanel.importDatabaseButton.toolTipText=
HashLookupSettingsPanel.importDatabaseButton.text=Import database
HashLookupSettingsPanel.deleteDatabaseButton.text=Delete database
-HashLookupSettingsPanel.hashDbTypeLabel1.text=No database selected
-HashLookupSettingsPanel.importDatabaseButton1.text=Import database
-HashLookupSettingsPanel.jLabel1.text=Version:
-HashLookupSettingsPanel.hashDatabasesLabel1.text=Hash Databases:
-HashLookupSettingsPanel.hashDbNameLabel1.text=No database selected
-HashLookupSettingsPanel.ingestWarningLabel1.text=Ingest is ongoing, some settings will be unavailable until it finishes.
-HashLookupSettingsPanel.informationLabel1.text=Information
-HashLookupSettingsPanel.jLabel3.text=jLabel3
-HashLookupSettingsPanel.optionsLabel1.text=Options
-HashLookupSettingsPanel.nameLabel1.text=Hash Set Name:
-HashLookupSettingsPanel.sendIngestMessagesCheckBox1.text=Send ingest inbox message for each hit
-HashLookupSettingsPanel.importDatabaseButton1.toolTipText=
-HashLookupSettingsPanel.typeLabel1.text=Type:
-ImportCentralRepoDatabaseDialog.cbInboxMessages.text=Send ingest inbox message for each hit
-ImportCentralRepoDatabaseDialog.cancelButton.text=Cancel
-ImportCentralRepoDatabaseDialog.lbDatabaseVersion.text=Hash Set Version:
-ImportCentralRepoDatabaseDialog.okButton.text=OK
-ImportCentralRepoDatabaseDialog.lbDatabaseName.text=Hash Set Name:
-ImportCentralRepoDatabaseDialog.lbSourceOrganization.text=Source Organization:
-ImportCentralRepoDatabaseDialog.lbDatabaseType.text=Type of database:
-ImportCentralRepoDatabaseDialog.knownBadRadioButton.text=Notable
-ImportCentralRepoDatabaseDialog.bnNewOrganization.text=Add New Organization
-ImportCentralRepoDatabaseDialog.knownRadioButton.text=Known (NSRL or other)
-ImportCentralRepoDatabaseDialog.openButton.text=Open...
-ImportCentralRepoDatabaseDialog.tfFilePath.text=
ImportHashDatabaseDialog.lbFilePath.text=Database Path:
ImportHashDatabaseDialog.tfDatabaseName.tooltip=Name for this database
ImportHashDatabaseDialog.tfDatabaseVersion.tooltip.text=Database Version Number
diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/Bundle_ja.properties b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/Bundle_ja.properties
index ebe1466e05..3a1eac32f4 100755
--- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/Bundle_ja.properties
+++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/Bundle_ja.properties
@@ -209,13 +209,3 @@ HashLookupSettingsPanel.hashDbNameLabel.text=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b
HashLookupSettingsPanel.nameLabel.text=\u30cf\u30c3\u30b7\u30e5\u30bb\u30c3\u30c8\u540d\uff1a
HashLookupSettingsPanel.hashDatabasesLabel.text=\u30cf\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\uff1a
HashLookupSettingsPanel.importDatabaseButton.text=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30a4\u30f3\u30dd\u30fc\u30c8
-HashLookupSettingsPanel.typeLabel1.text=\u30bf\u30a4\u30d7\uff1a
-HashLookupSettingsPanel.hashDbTypeLabel1.text=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u9078\u629e\u3055\u308c\u3066\u3044\u307e\u305b\u3093
-HashLookupSettingsPanel.importDatabaseButton1.text=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30a4\u30f3\u30dd\u30fc\u30c8
-HashLookupSettingsPanel.hashDatabasesLabel1.text=\u30cf\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\uff1a
-HashLookupSettingsPanel.hashDbNameLabel1.text=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u9078\u629e\u3055\u308c\u3066\u3044\u307e\u305b\u3093
-HashLookupSettingsPanel.ingestWarningLabel1.text=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8\u4e2d\u3067\u3059\u3002\u5b8c\u4e86\u3059\u308b\u307e\u3067\u4e00\u90e8\u306e\u8a2d\u5b9a\u306f\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002
-HashLookupSettingsPanel.informationLabel1.text=\u60c5\u5831
-HashLookupSettingsPanel.optionsLabel1.text=\u30aa\u30d7\u30b7\u30e7\u30f3
-HashLookupSettingsPanel.nameLabel1.text=\u30cf\u30c3\u30b7\u30e5\u30bb\u30c3\u30c8\u540d\uff1a
-HashLookupSettingsPanel.sendIngestMessagesCheckBox1.text=\u30d2\u30c3\u30c8\u6bce\u306b\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8\u30a4\u30f3\u30dc\u30c3\u30af\u30b9\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u308b
diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/ImportCentralRepoDatabaseDialog.form b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/ImportCentralRepoDatabaseDialog.form
deleted file mode 100644
index 2f42a4ef79..0000000000
--- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/ImportCentralRepoDatabaseDialog.form
+++ /dev/null
@@ -1,290 +0,0 @@
-
-
-
diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/ImportCentralRepoDatabaseDialog.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/ImportCentralRepoDatabaseDialog.java
deleted file mode 100644
index a9a44839a8..0000000000
--- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/ImportCentralRepoDatabaseDialog.java
+++ /dev/null
@@ -1,716 +0,0 @@
-/*
- * Central Repository
- *
- * Copyright 2015-2017 Basis Technology Corp.
- * Contact: carrier sleuthkit 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.modules.hashdatabase;
-
-import java.awt.Dimension;
-import java.awt.Toolkit;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.nio.file.Files;
-import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.logging.Level;
-import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
-import javax.swing.SwingWorker;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import org.netbeans.api.progress.ProgressHandle;
-import org.netbeans.spi.options.OptionsPanelController;
-import org.openide.util.Exceptions;
-import org.openide.util.NbBundle;
-import org.openide.util.NbBundle.Messages;
-import org.openide.windows.WindowManager;
-import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttribute;
-import org.sleuthkit.autopsy.coreutils.Logger;
-import org.sleuthkit.autopsy.coreutils.ModuleSettings;
-import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
-import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
-import org.sleuthkit.autopsy.centralrepository.datamodel.EamGlobalFileInstance;
-import org.sleuthkit.autopsy.centralrepository.datamodel.EamGlobalSet;
-import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization;
-import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
-import org.sleuthkit.autopsy.centralrepository.optionspanel.AddNewOrganizationDialog;
-import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
-import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager;
-import org.sleuthkit.datamodel.TskData;
-
-/**
- * Instances of this class allow a user to select an existing hash database and
- * add it to the set of hash databases used to classify files as unknown, known,
- * or notable.
- */
-final public class ImportCentralRepoDatabaseDialog extends javax.swing.JDialog {
- private static final Logger LOGGER = Logger.getLogger(ImportCentralRepoDatabaseDialog.class.getName());
-
- private final JFileChooser fileChooser = new JFileChooser();
- private final static String LAST_FILE_PATH_KEY = "CentralRepositoryImport_Path"; // NON-NLS
- private final int HASH_IMPORT_THRESHOLD = 10000;
- private EamOrganization selectedOrg = null;
- private List orgs = null;
- private final Collection textBoxes;
- private final TextBoxChangedListener textBoxChangedListener;
- private HashDbManager.HashDatabase selectedHashDb = null;
-
-
- /**
- * Displays a dialog that allows a user to select an existing hash database
- * and add it to the set of hash databases used to classify files as
- * unknown, known, or notable.
- */
- @Messages({"ImportCentralRepoDatabaseDialog.importHashDbMsg=Import Hash Database"})
- public ImportCentralRepoDatabaseDialog() {
- super((JFrame) WindowManager.getDefault().getMainWindow(),
- Bundle.ImportCentralRepoDatabaseDialog_importHashDbMsg(),
- true); // NON-NLS
-
- textBoxes = new ArrayList<>();
- textBoxChangedListener = new TextBoxChangedListener();
- initFileChooser();
- initComponents();
- customizeComponents();
- display();
- }
-
- @Messages({"ImportCentralRepoDatabaseDialog.fileNameExtFilter.text=Hash Database File",})
- private void initFileChooser() {
- fileChooser.setDragEnabled(false);
- fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- String[] EXTENSION = new String[]{"idx"}; //NON-NLS
- FileNameExtensionFilter filter = new FileNameExtensionFilter(
- Bundle.ImportCentralRepoDatabaseDialog_fileNameExtFilter_text(),
- EXTENSION); // NON-NLS
- fileChooser.setFileFilter(filter);
- fileChooser.setMultiSelectionEnabled(false);
-
- if (ModuleSettings.settingExists(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY)) {
- String lastBaseDirectory = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY);
- File hashDbFolder = new File(lastBaseDirectory);
- if(hashDbFolder.exists()){
- fileChooser.setCurrentDirectory(hashDbFolder);
- }
- }
- }
-
- private void customizeComponents() {
- populateCombobox();
- setTextBoxListeners();
- enableOkButton(false);
- }
-
- public HashDbManager.HashDatabase getHashDatabase(){
- return this.selectedHashDb;
- }
-
- /**
- * Register for notifications when the text boxes get updated.
- */
- private void setTextBoxListeners() {
- textBoxes.add(tfFilePath);
- textBoxes.add(tfDatabaseName);
- textBoxes.add(tfDatabaseVersion);
- addDocumentListeners(textBoxes, textBoxChangedListener);
- }
-
- private void populateCombobox() {
- comboboxSourceOrganization.removeAllItems();
- try {
- EamDb dbManager = EamDb.getInstance();
- orgs = dbManager.getOrganizations();
- orgs.forEach((org) -> {
- comboboxSourceOrganization.addItem(org.getName());
- });
- if (!orgs.isEmpty()) {
- selectedOrg = orgs.get(0);
- }
- valid();
- } catch (EamDbException ex) {
- LOGGER.log(Level.SEVERE, "Failure populating combobox with organizations.", ex);
- }
- }
-
- /**
- * Adds a change listener to a collection of text fields.
- *
- * @param textFields The text fields.
- * @param listener The change listener.
- */
- private static void addDocumentListeners(Collection textFields, TextBoxChangedListener listener) {
- textFields.forEach((textField) -> {
- textField.getDocument().addDocumentListener(listener);
- });
- }
-
- /**
- * Tests whether or not values have been entered in all of the required
- * text fields.
- *
- * @return True or false.
- */
- private boolean textFieldsArePopulated() {
- return !tfDatabaseName.getText().trim().isEmpty()
- && !tfDatabaseVersion.getText().trim().isEmpty()
- && !tfFilePath.getText().trim().isEmpty();
- }
-
- /**
- * Tests whether or not all of the settings components are populated.
- *
- * @return True or false.
- */
- @Messages({"ImportHashDatabaseDialog.validation.incompleteFields=Fill in all values"})
- private boolean checkFields() {
- boolean result = true;
-
- boolean allPopulated = textFieldsArePopulated();
-
- if (!allPopulated) {
- // We don't even have everything filled out
- result = false;
- lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_validation_incompleteFields());
- }
- return result;
- }
-
- /**
- * Validates that the form is filled out correctly for our usage.
- *
- * @return true if it's okay, false otherwise.
- */
- @Messages({"ImportHashDatabaseDialog.validation.notEnabled=Central Repository is not enabled."})
- public boolean valid() {
- lbWarningMsg.setText("");
- if (!EamDb.isEnabled()) {
- lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_validation_notEnabled());
- return false;
- }
-
- return enableOkButton(checkFields() && null != selectedOrg);
- }
-
- /**
- * Enables the "OK" button to create the Global File Set and insert the instances.
- *
- * @param enable
- *
- * @return True or False
- */
- private boolean enableOkButton(Boolean enable) {
- okButton.setEnabled(enable);
- return enable;
- }
-
- /**
- * Used to listen for changes in text boxes. It lets the panel know things
- * have been updated and that validation needs to happen.
- */
- private class TextBoxChangedListener implements DocumentListener {
-
- @Override
- public void changedUpdate(DocumentEvent e) {
- firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
- valid();
- }
-
- @Override
- public void insertUpdate(DocumentEvent e) {
- firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
- valid();
- }
-
- @Override
- public void removeUpdate(DocumentEvent e) {
- firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
- valid();
- }
- }
-
- private void display() {
- Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
- setLocation((screenDimension.width - getSize().width) / 2, (screenDimension.height - getSize().height) / 2);
- setVisible(true);
- }
-
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // //GEN-BEGIN:initComponents
- private void initComponents() {
-
- buttonGroup1 = new javax.swing.ButtonGroup();
- okButton = new javax.swing.JButton();
- cancelButton = new javax.swing.JButton();
- tfFilePath = new javax.swing.JTextField();
- openButton = new javax.swing.JButton();
- knownRadioButton = new javax.swing.JRadioButton();
- knownBadRadioButton = new javax.swing.JRadioButton();
- lbDatabaseType = new javax.swing.JLabel();
- lbDatabasePath = new javax.swing.JLabel();
- lbSourceOrganization = new javax.swing.JLabel();
- lbDatabaseName = new javax.swing.JLabel();
- lbDatabaseVersion = new javax.swing.JLabel();
- comboboxSourceOrganization = new javax.swing.JComboBox<>();
- tfDatabaseName = new javax.swing.JTextField();
- tfDatabaseVersion = new javax.swing.JTextField();
- bnNewOrganization = new javax.swing.JButton();
- lbWarningMsg = new javax.swing.JLabel();
- cbInboxMessages = new javax.swing.JCheckBox();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-
- org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.okButton.text")); // NOI18N
- okButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- okButtonActionPerformed(evt);
- }
- });
-
- org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.cancelButton.text")); // NOI18N
- cancelButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- cancelButtonActionPerformed(evt);
- }
- });
-
- tfFilePath.setText(org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.tfFilePath.text")); // NOI18N
-
- org.openide.awt.Mnemonics.setLocalizedText(openButton, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.openButton.text")); // NOI18N
- openButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- openButtonActionPerformed(evt);
- }
- });
-
- buttonGroup1.add(knownRadioButton);
- org.openide.awt.Mnemonics.setLocalizedText(knownRadioButton, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.knownRadioButton.text")); // NOI18N
-
- buttonGroup1.add(knownBadRadioButton);
- knownBadRadioButton.setSelected(true);
- org.openide.awt.Mnemonics.setLocalizedText(knownBadRadioButton, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.knownBadRadioButton.text")); // NOI18N
-
- org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseType, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.lbDatabaseType.text")); // NOI18N
-
- org.openide.awt.Mnemonics.setLocalizedText(lbDatabasePath, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportHashDatabaseDialog.lbFilePath.text")); // NOI18N
-
- org.openide.awt.Mnemonics.setLocalizedText(lbSourceOrganization, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.lbSourceOrganization.text")); // NOI18N
-
- org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseName, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.lbDatabaseName.text")); // NOI18N
-
- org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseVersion, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.lbDatabaseVersion.text")); // NOI18N
-
- comboboxSourceOrganization.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
- comboboxSourceOrganization.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- comboboxSourceOrganizationActionPerformed(evt);
- }
- });
-
- tfDatabaseName.setToolTipText(org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportHashDatabaseDialog.tfDatabaseName.tooltip")); // NOI18N
-
- tfDatabaseVersion.setToolTipText(org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportHashDatabaseDialog.tfDatabaseVersion.tooltip.text")); // NOI18N
-
- org.openide.awt.Mnemonics.setLocalizedText(bnNewOrganization, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.bnNewOrganization.text")); // NOI18N
- bnNewOrganization.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- bnNewOrganizationActionPerformed(evt);
- }
- });
-
- lbWarningMsg.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
- lbWarningMsg.setForeground(new java.awt.Color(255, 0, 0));
-
- cbInboxMessages.setSelected(true);
- org.openide.awt.Mnemonics.setLocalizedText(cbInboxMessages, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.cbInboxMessages.text")); // NOI18N
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(cbInboxMessages)
- .addGap(0, 0, Short.MAX_VALUE))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addGap(0, 0, Short.MAX_VALUE)
- .addComponent(okButton)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(cancelButton))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(lbDatabaseName)
- .addComponent(lbDatabaseVersion)
- .addComponent(lbSourceOrganization))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(comboboxSourceOrganization, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(bnNewOrganization)
- .addGap(0, 0, Short.MAX_VALUE))
- .addComponent(tfDatabaseName)
- .addComponent(tfDatabaseVersion)))
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
- .addComponent(lbDatabasePath)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(tfFilePath, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(lbDatabaseType, javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
- .addGap(19, 19, 19)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(knownRadioButton)
- .addComponent(knownBadRadioButton))))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(openButton)))
- .addGap(6, 6, 6))
- .addComponent(lbWarningMsg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
- );
-
- layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, okButton});
-
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(lbDatabasePath)
- .addComponent(tfFilePath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(openButton))
- .addGap(6, 6, 6)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(lbDatabaseName, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(tfDatabaseName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(lbDatabaseVersion, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(tfDatabaseVersion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(lbSourceOrganization, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(comboboxSourceOrganization, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(bnNewOrganization))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(lbDatabaseType)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(knownRadioButton)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(knownBadRadioButton)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(cbInboxMessages)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(lbWarningMsg, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(okButton)
- .addComponent(cancelButton))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
-
- pack();
- }// //GEN-END:initComponents
-
- @Messages({"ImportHashDatabaseDialog.failedToGetDbPathMsg=Failed to get the path of the selected database.",})
- private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openButtonActionPerformed
- if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
- File databaseFile = fileChooser.getSelectedFile();
- try {
- tfFilePath.setText(databaseFile.getCanonicalPath());
- if (databaseFile.getName().toLowerCase().contains("nsrl")) { //NON-NLS
- knownRadioButton.setSelected(true);
- }
- ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY, databaseFile.getParent());
- } catch (IOException ex) {
- Logger.getLogger(ImportCentralRepoDatabaseDialog.class.getName()).log(Level.SEVERE, "Failed to get path of selected database", ex); // NON-NLS
- lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_failedToGetDbPathMsg());
- }
- }
- valid();
- }//GEN-LAST:event_openButtonActionPerformed
-
- private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
- dispose();
- }//GEN-LAST:event_cancelButtonActionPerformed
-
- /**
- * Create the new global set and return the ID number
- *
- * @return ID number of new global set
- * @throws EamDbException
- */
- private int createGlobalSet() throws EamDbException {
- /*EamDb dbManager = EamDb.getInstance();
- EamGlobalSet eamGlobalSet = new EamGlobalSet(
- selectedOrg.getOrgID(),
- tfDatabaseName.getText().trim(),
- tfDatabaseVersion.getText().trim(),
- LocalDate.now());
- return dbManager.newReferencelSet(eamGlobalSet);*/
- return 0;
- }
-
- @Messages({"ImportHashDatabaseDialog.createGlobalSet.failedMsg.text=Failed to store attribution details.",
- "ImportHashDatabaseDialog.mustSelectHashDbFilePathMsg=Missing hash database file path.",
- "ImportHashDatabaseDialog.hashDbDoesNotExistMsg=The selected hash database does not exist.",
- "# {0} - selected file path",
- "ImportHashDatabaseDialog.errorMessage.failedToOpenHashDbMsg=Failed to open hash database at {0}.",
- "ImportHashDatabaseDialog.dbAlreadyExists=A database with that name and version already exists.",
- "ImportHashDatabaseDialog.centralRepoError=Error accessing the central repository",
-})
- private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
- // Note that the error handlers in this method call return without disposing of the
- // dialog to allow the user to try again, if desired.
- String selectedFilePath = tfFilePath.getText();
-
- // have valid file path
- if (selectedFilePath.isEmpty()) {
- lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_mustSelectHashDbFilePathMsg());
- return;
- }
- File file = new File(selectedFilePath);
- if (!file.exists()) {
- lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_hashDbDoesNotExistMsg());
- return;
- }
-
- String dbName = tfDatabaseName.getText().trim();
- String version = tfDatabaseVersion.getText().trim();
-
- try{
- if(EamDb.getInstance().referenceSetExists(dbName, version)){
- lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_dbAlreadyExists());
- return;
- }
- } catch (EamDbException ex){
- lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_centralRepoError());
- LOGGER.log(Level.SEVERE, "Error searching for reference set in central repo", ex);
- return;
- }
-
- HashDbManager.HashDb.KnownFilesType known;
- if (knownRadioButton.isSelected()) {
- known = HashDbManager.HashDb.KnownFilesType.KNOWN;
- } else{
- known = HashDbManager.HashDb.KnownFilesType.KNOWN_BAD;
- }
-
- boolean sendMessages = this.cbInboxMessages.isSelected();
-
- try{
- ImportCentralRepoDbProgressDialog progressDialog = new ImportCentralRepoDbProgressDialog();
- //progressDialog.importFile(dbName, version,
- // selectedOrg.getOrgID(), true, sendMessages, known, selectedFilePath);
- //HashDbManager.getInstance().importCentralRepoHashSet(dbName, version,
- // selectedOrg.getOrgID(), true, sendMessages, known, selectedFilePath);
- } catch (Exception ex){
- ex.printStackTrace();
- } finally {
- dispose();
- }
- /*
- // create global set
- int globalSetID;
- try {
- globalSetID = createGlobalSet();
- } catch (EamDbException ex) {
- LOGGER.log(Level.SEVERE, "Failed to create global set.", ex);
- lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_createGlobalSet_failedMsg_text());
- return;
- }
-
- // insert hashes
- TskData.FileKnown knownStatus = TskData.FileKnown.UNKNOWN;
- if (knownRadioButton.isSelected()) {
- knownStatus = TskData.FileKnown.KNOWN;
- } else if (knownBadRadioButton.isSelected()) {
- knownStatus = TskData.FileKnown.BAD;
- }
-
- String errorMessage = Bundle.ImportHashDatabaseDialog_errorMessage_failedToOpenHashDbMsg(selectedFilePath);
- // Future, make UI handle more than the "FILES" type.
- try {
- EamDb dbManager = EamDb.getInstance();
- CorrelationAttribute.Type contentType = dbManager.getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID); // get "FILES" type
- // run in the background and close dialog
- SwingUtilities.invokeLater(new ImportHashDatabaseWorker(selectedFilePath, knownStatus, globalSetID, contentType)::execute);
- dispose();
- } catch (EamDbException | UnknownHostException ex) {
- Logger.getLogger(ImportHashDatabaseDialog.class.getName()).log(Level.SEVERE, errorMessage, ex);
- lbWarningMsg.setText(ex.getMessage());
- }*/
-
- }//GEN-LAST:event_okButtonActionPerformed
-
- @SuppressWarnings({"unchecked"})
- private void bnNewOrganizationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnNewOrganizationActionPerformed
- AddNewOrganizationDialog dialogO = new AddNewOrganizationDialog();
- // update the combobox options
- if (dialogO.isChanged()) {
- populateCombobox();
- }
- }//GEN-LAST:event_bnNewOrganizationActionPerformed
-
- @SuppressWarnings({"unchecked"})
- private void comboboxSourceOrganizationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboboxSourceOrganizationActionPerformed
- JComboBox cb = (JComboBox)evt.getSource();
- String orgName = (String)cb.getSelectedItem();
- if (null == orgName) return;
-
- for (EamOrganization org : orgs) {
- if (org.getName().equals(orgName)) {
- selectedOrg = org;
- return;
- }
- }
- valid();
- }//GEN-LAST:event_comboboxSourceOrganizationActionPerformed
-
- @NbBundle.Messages({"ImportHashDatabaseDialog.ImportHashDatabaseWorker.displayName=Importing Hash Database"})
- public class ImportHashDatabaseWorker extends SwingWorker {
-
- private final File file;
- private final TskData.FileKnown knownStatus;
- private final int globalSetID;
- private final ProgressHandle progress;
- private final CorrelationAttribute.Type contentType;
-
- public ImportHashDatabaseWorker(String filename, TskData.FileKnown knownStatus, int globalSetID, CorrelationAttribute.Type contentType) throws EamDbException, UnknownHostException {
- this.file = new File(filename);
- this.knownStatus = knownStatus;
- this.globalSetID = globalSetID;
- this.contentType = contentType;
- this.progress = ProgressHandle.createHandle(Bundle.ImportHashDatabaseDialog_ImportHashDatabaseWorker_displayName());
-
- if (!EamDb.isEnabled()) {
- throw new EamDbException("Central repository database is not enabled."); // NON-NLS
- }
- }
-
- @Override
- protected Void doInBackground() throws Exception {
- importHashDatabase();
- return null;
- }
-
- @Override
- @Messages({"ImportHashDatabaseDialog.ImportHashDatabaseWorker.error=Failed to import hash database."})
- protected void done() {
- progress.finish();
- try {
- get();
- } catch (InterruptedException | ExecutionException ex) {
- Logger.getLogger(ImportCentralRepoDatabaseDialog.class.getName()).log(Level.SEVERE, Bundle.ImportHashDatabaseDialog_ImportHashDatabaseWorker_error(), ex);
- MessageNotifyUtil.Notify.show(Bundle.ImportHashDatabaseDialog_ImportHashDatabaseWorker_error(),
- ex.getMessage(),
- MessageNotifyUtil.MessageType.ERROR);
- }
- }
-
- private long numberOfLinesInFile(File f) throws IOException {
- return Files.lines(f.toPath()).count();
- }
-
- @Messages({"# {0} - value content",
- "ImportHashDatabaseDialog.ImportHashDatabaseWorker.duplicate=Duplicate value {0} found in import file."})
- private void importHashDatabase() throws EamDbException, IOException {
- BufferedReader reader = new BufferedReader(new FileReader(file));
- String line;
- EamDb dbManager = EamDb.getInstance();
- Set globalInstances = new HashSet<>();
-
- long totalLines = numberOfLinesInFile(file);
- if (totalLines <= Integer.MAX_VALUE) {
- progress.start((int) totalLines);
- } else {
- progress.start();
- }
-
- int numLines = 0;
- LOGGER.log(Level.INFO, "Importing hash database {0}", file.getName());
- while ((line = reader.readLine()) != null) {
- progress.progress(++numLines);
-
- String[] parts = line.split("\\|");
-
- // Header lines start with a 41 character dummy hash, 1 character longer than a SHA-1 hash
- if (parts.length != 2 || parts[0].length() == 41) {
- continue;
- }
-
- EamGlobalFileInstance eamGlobalFileInstance = new EamGlobalFileInstance(
- globalSetID,
- parts[0].toLowerCase(),
- knownStatus,
- "");
-
- globalInstances.add(eamGlobalFileInstance);
-
- if(numLines % HASH_IMPORT_THRESHOLD == 0){
- dbManager.bulkInsertReferenceTypeEntries(globalInstances, contentType);
- globalInstances.clear();
- }
- }
-
- dbManager.bulkInsertReferenceTypeEntries(globalInstances, contentType);
- LOGGER.log(Level.INFO, "Finished importing hash database. Total entries: {0}", numLines);
-
- }
- }
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton bnNewOrganization;
- private javax.swing.ButtonGroup buttonGroup1;
- private javax.swing.JButton cancelButton;
- private javax.swing.JCheckBox cbInboxMessages;
- private javax.swing.JComboBox comboboxSourceOrganization;
- private javax.swing.JRadioButton knownBadRadioButton;
- private javax.swing.JRadioButton knownRadioButton;
- private javax.swing.JLabel lbDatabaseName;
- private javax.swing.JLabel lbDatabasePath;
- private javax.swing.JLabel lbDatabaseType;
- private javax.swing.JLabel lbDatabaseVersion;
- private javax.swing.JLabel lbSourceOrganization;
- private javax.swing.JLabel lbWarningMsg;
- private javax.swing.JButton okButton;
- private javax.swing.JButton openButton;
- private javax.swing.JTextField tfDatabaseName;
- private javax.swing.JTextField tfDatabaseVersion;
- private javax.swing.JTextField tfFilePath;
- // End of variables declaration//GEN-END:variables
-}