19 package org.sleuthkit.autopsy.modules.hashdatabase;
22 import java.io.IOException;
23 import java.nio.file.Paths;
24 import java.util.List;
25 import java.util.logging.Level;
26 import javax.swing.JFileChooser;
27 import javax.swing.JFrame;
28 import javax.swing.JOptionPane;
29 import javax.swing.filechooser.FileNameExtensionFilter;
30 import org.apache.commons.io.FilenameUtils;
31 import org.openide.util.NbBundle;
32 import org.openide.windows.WindowManager;
50 final class HashDbImportDatabaseDialog
extends javax.swing.JDialog {
52 private JFileChooser fileChooser =
new JFileChooser();
53 private String selectedFilePath =
"";
54 private HashDb selectedHashDb = null;
55 private final static String LAST_FILE_PATH_KEY =
"HashDbImport_Path";
56 private EamOrganization selectedOrg = null;
57 private List<EamOrganization> orgs = null;
64 HashDbImportDatabaseDialog() {
65 super((JFrame) WindowManager.getDefault().getMainWindow(),
66 NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.importHashDbMsg"),
79 HashDb getHashDatabase() {
80 return selectedHashDb;
83 private void initFileChooser() {
84 fileChooser.setDragEnabled(
false);
85 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
86 String[] EXTENSION =
new String[]{
"txt",
"kdb",
"idx",
"hash",
"Hash",
"hsh"};
87 FileNameExtensionFilter filter =
new FileNameExtensionFilter(
88 NbBundle.getMessage(
this.getClass(),
"HashDbImportDatabaseDialog.fileNameExtFilter.text"), EXTENSION);
89 fileChooser.setFileFilter(filter);
90 fileChooser.setMultiSelectionEnabled(
false);
93 private void display() {
94 setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
98 private static String shortenPath(String path) {
99 String shortenedPath = path;
100 if (shortenedPath.length() > 50) {
101 shortenedPath = shortenedPath.substring(0, 10 + shortenedPath.substring(10).indexOf(File.separator) + 1) +
"..." + shortenedPath.substring((shortenedPath.length() - 20) + shortenedPath.substring(shortenedPath.length() - 20).indexOf(File.separator));
103 return shortenedPath;
106 private void enableComponents(){
109 if(! EamDb.isEnabled()){
110 centralRepoRadioButton.setEnabled(
false);
111 fileTypeRadioButton.setSelected(
true);
116 boolean isFileType = fileTypeRadioButton.isSelected();
119 lbVersion.setEnabled((! isFileType) && (readOnlyCheckbox.isSelected()));
120 versionTextField.setEnabled((! isFileType) && (readOnlyCheckbox.isSelected()));
122 lbOrg.setEnabled(! isFileType);
123 orgButton.setEnabled(! isFileType);
124 orgComboBox.setEnabled(! isFileType);
125 readOnlyCheckbox.setEnabled(! isFileType);
128 @NbBundle.Messages({
"HashDbImportDatabaseDialog.populateOrgsError.message=Failure loading organizations."})
129 private void populateCombobox() {
130 orgComboBox.removeAllItems();
132 EamDb dbManager = EamDb.getInstance();
133 orgs = dbManager.getOrganizations();
134 orgs.forEach((
org) -> {
135 orgComboBox.addItem(
org.getName());
136 if(EamDbUtil.isDefaultOrg(
org)){
137 orgComboBox.setSelectedItem(
org.getName());
141 if ((selectedOrg == null) && (!orgs.isEmpty())) {
142 selectedOrg = orgs.get(0);
144 }
catch (EamDbException ex) {
145 JOptionPane.showMessageDialog(
this, Bundle.HashDbImportDatabaseDialog_populateOrgsError_message());
146 Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE,
"Failure loading organizations", ex);
155 @SuppressWarnings(
"unchecked")
157 private
void initComponents() {
159 buttonGroup1 =
new javax.swing.ButtonGroup();
160 storageTypeButtonGroup =
new javax.swing.ButtonGroup();
161 okButton =
new javax.swing.JButton();
162 cancelButton =
new javax.swing.JButton();
163 databasePathTextField =
new javax.swing.JTextField();
164 openButton =
new javax.swing.JButton();
165 knownRadioButton =
new javax.swing.JRadioButton();
166 knownBadRadioButton =
new javax.swing.JRadioButton();
167 jLabel1 =
new javax.swing.JLabel();
168 hashSetNameTextField =
new javax.swing.JTextField();
169 jLabel2 =
new javax.swing.JLabel();
170 sendIngestMessagesCheckbox =
new javax.swing.JCheckBox();
171 jLabel3 =
new javax.swing.JLabel();
172 lbVersion =
new javax.swing.JLabel();
173 versionTextField =
new javax.swing.JTextField();
174 lbOrg =
new javax.swing.JLabel();
175 orgComboBox =
new javax.swing.JComboBox<>();
176 orgButton =
new javax.swing.JButton();
177 readOnlyCheckbox =
new javax.swing.JCheckBox();
178 fileTypeRadioButton =
new javax.swing.JRadioButton();
179 centralRepoRadioButton =
new javax.swing.JRadioButton();
180 jLabel4 =
new javax.swing.JLabel();
182 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
184 org.openide.awt.Mnemonics.setLocalizedText(okButton,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.okButton.text"));
185 okButton.addActionListener(
new java.awt.event.ActionListener() {
186 public void actionPerformed(java.awt.event.ActionEvent evt) {
187 okButtonActionPerformed(evt);
191 org.openide.awt.Mnemonics.setLocalizedText(cancelButton,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.cancelButton.text"));
192 cancelButton.addActionListener(
new java.awt.event.ActionListener() {
193 public void actionPerformed(java.awt.event.ActionEvent evt) {
194 cancelButtonActionPerformed(evt);
198 databasePathTextField.setEditable(
false);
199 databasePathTextField.setText(
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.databasePathTextField.text"));
201 org.openide.awt.Mnemonics.setLocalizedText(openButton,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.openButton.text"));
202 openButton.addActionListener(
new java.awt.event.ActionListener() {
203 public void actionPerformed(java.awt.event.ActionEvent evt) {
204 openButtonActionPerformed(evt);
208 buttonGroup1.add(knownRadioButton);
209 org.openide.awt.Mnemonics.setLocalizedText(knownRadioButton,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.knownRadioButton.text"));
210 knownRadioButton.addActionListener(
new java.awt.event.ActionListener() {
211 public void actionPerformed(java.awt.event.ActionEvent evt) {
212 knownRadioButtonActionPerformed(evt);
216 buttonGroup1.add(knownBadRadioButton);
217 knownBadRadioButton.setSelected(
true);
218 org.openide.awt.Mnemonics.setLocalizedText(knownBadRadioButton,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.knownBadRadioButton.text"));
219 knownBadRadioButton.addActionListener(
new java.awt.event.ActionListener() {
220 public void actionPerformed(java.awt.event.ActionEvent evt) {
221 knownBadRadioButtonActionPerformed(evt);
225 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.jLabel1.text"));
227 hashSetNameTextField.setText(
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.hashSetNameTextField.text"));
229 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.jLabel2.text"));
231 sendIngestMessagesCheckbox.setSelected(
true);
232 org.openide.awt.Mnemonics.setLocalizedText(sendIngestMessagesCheckbox,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.sendIngestMessagesCheckbox.text"));
233 sendIngestMessagesCheckbox.addActionListener(
new java.awt.event.ActionListener() {
234 public void actionPerformed(java.awt.event.ActionEvent evt) {
235 sendIngestMessagesCheckboxActionPerformed(evt);
239 org.openide.awt.Mnemonics.setLocalizedText(jLabel3,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.jLabel3.text"));
241 org.openide.awt.Mnemonics.setLocalizedText(lbVersion,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.lbVersion.text"));
243 versionTextField.setText(
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.versionTextField.text"));
245 org.openide.awt.Mnemonics.setLocalizedText(lbOrg,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.lbOrg.text"));
247 orgComboBox.addActionListener(
new java.awt.event.ActionListener() {
248 public void actionPerformed(java.awt.event.ActionEvent evt) {
249 orgComboBoxActionPerformed(evt);
253 org.openide.awt.Mnemonics.setLocalizedText(orgButton,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.orgButton.text"));
254 orgButton.addActionListener(
new java.awt.event.ActionListener() {
255 public void actionPerformed(java.awt.event.ActionEvent evt) {
256 orgButtonActionPerformed(evt);
260 readOnlyCheckbox.setSelected(
true);
261 org.openide.awt.Mnemonics.setLocalizedText(readOnlyCheckbox,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.readOnlyCheckbox.text"));
262 readOnlyCheckbox.addActionListener(
new java.awt.event.ActionListener() {
263 public void actionPerformed(java.awt.event.ActionEvent evt) {
264 readOnlyCheckboxActionPerformed(evt);
268 storageTypeButtonGroup.add(fileTypeRadioButton);
269 fileTypeRadioButton.setSelected(
true);
270 org.openide.awt.Mnemonics.setLocalizedText(fileTypeRadioButton,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.fileTypeRadioButton.text"));
271 fileTypeRadioButton.addActionListener(
new java.awt.event.ActionListener() {
272 public void actionPerformed(java.awt.event.ActionEvent evt) {
273 fileTypeRadioButtonActionPerformed(evt);
277 storageTypeButtonGroup.add(centralRepoRadioButton);
278 org.openide.awt.Mnemonics.setLocalizedText(centralRepoRadioButton,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.centralRepoRadioButton.text"));
279 centralRepoRadioButton.addActionListener(
new java.awt.event.ActionListener() {
280 public void actionPerformed(java.awt.event.ActionEvent evt) {
281 centralRepoRadioButtonActionPerformed(evt);
285 org.openide.awt.Mnemonics.setLocalizedText(jLabel4,
org.openide.util.NbBundle.getMessage(HashDbImportDatabaseDialog.class,
"HashDbImportDatabaseDialog.jLabel4.text"));
287 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
288 getContentPane().setLayout(layout);
289 layout.setHorizontalGroup(
290 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
291 .addGroup(layout.createSequentialGroup()
293 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
294 .addGroup(layout.createSequentialGroup()
295 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
296 .addComponent(jLabel3)
297 .addComponent(jLabel4))
298 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
299 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
300 .addGroup(layout.createSequentialGroup()
301 .addComponent(fileTypeRadioButton)
303 .addComponent(centralRepoRadioButton)
304 .addGap(0, 0, Short.MAX_VALUE))
305 .addGroup(layout.createSequentialGroup()
306 .addComponent(databasePathTextField)
307 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
308 .addComponent(openButton))))
309 .addGroup(layout.createSequentialGroup()
310 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
311 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
312 .addComponent(sendIngestMessagesCheckbox)
313 .addGap(0, 0, Short.MAX_VALUE))
314 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
316 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
317 .addComponent(orgComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
318 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
319 .addComponent(orgButton))
320 .addGroup(layout.createSequentialGroup()
321 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
322 .addComponent(jLabel1)
323 .addComponent(lbVersion))
325 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
326 .addComponent(versionTextField)
327 .addComponent(hashSetNameTextField)))
328 .addGroup(layout.createSequentialGroup()
329 .addGap(0, 0, Short.MAX_VALUE)
330 .addComponent(okButton)))
331 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
332 .addComponent(cancelButton))
333 .addGroup(layout.createSequentialGroup()
334 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
335 .addComponent(jLabel2)
336 .addComponent(readOnlyCheckbox)
337 .addGroup(layout.createSequentialGroup()
339 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
340 .addComponent(knownRadioButton)
341 .addComponent(knownBadRadioButton))))
342 .addGap(0, 0, Short.MAX_VALUE)))
346 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {cancelButton, okButton});
348 layout.setVerticalGroup(
349 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
350 .addGroup(layout.createSequentialGroup()
352 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
353 .addComponent(databasePathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
354 .addComponent(jLabel3)
355 .addComponent(openButton))
356 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
357 .addGroup(layout.createSequentialGroup()
358 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
359 .addComponent(fileTypeRadioButton)
360 .addComponent(centralRepoRadioButton)
361 .addComponent(jLabel4))
362 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
363 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
364 .addComponent(jLabel1)
365 .addComponent(hashSetNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
366 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
367 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
368 .addComponent(lbVersion)
369 .addComponent(versionTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
371 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
372 .addComponent(orgButton)
373 .addComponent(orgComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
374 .addComponent(lbOrg))
375 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
376 .addComponent(jLabel2)
377 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
378 .addComponent(knownRadioButton)
379 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
380 .addComponent(knownBadRadioButton)
381 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
382 .addComponent(readOnlyCheckbox)
383 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
384 .addComponent(sendIngestMessagesCheckbox)
385 .addGap(0, 39, Short.MAX_VALUE))
386 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
387 .addGap(0, 0, Short.MAX_VALUE)
388 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
389 .addComponent(cancelButton)
390 .addComponent(okButton))))
397 private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {
398 String lastBaseDirectory = Paths.get(PlatformUtil.getUserConfigDirectory(),
"HashDatabases").toString();
399 if (ModuleSettings.settingExists(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY)) {
400 lastBaseDirectory = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY);
402 File hashDbFolder =
new File(lastBaseDirectory);
404 if (!hashDbFolder.exists()) {
405 hashDbFolder.mkdir();
407 fileChooser.setCurrentDirectory(hashDbFolder);
408 if (fileChooser.showOpenDialog(
this) == JFileChooser.APPROVE_OPTION) {
409 File databaseFile = fileChooser.getSelectedFile();
411 selectedFilePath = databaseFile.getCanonicalPath();
412 databasePathTextField.setText(shortenPath(selectedFilePath));
413 hashSetNameTextField.setText(FilenameUtils.removeExtension(databaseFile.getName()));
414 if (hashSetNameTextField.getText().toLowerCase().contains(
"nsrl")) {
415 knownRadioButton.setSelected(
true);
416 knownRadioButtonActionPerformed(null);
418 ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY, databaseFile.getParent());
419 }
catch (IOException ex) {
420 Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.SEVERE,
"Failed to get path of selected hash set", ex);
421 JOptionPane.showMessageDialog(
this,
422 NbBundle.getMessage(
this.getClass(),
423 "HashDbImportDatabaseDialog.failedToGetDbPathMsg"));
428 private void knownRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
429 sendIngestMessagesCheckbox.setSelected(
false);
430 sendIngestMessagesCheckbox.setEnabled(
false);
433 private void knownBadRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
434 sendIngestMessagesCheckbox.setSelected(
true);
435 sendIngestMessagesCheckbox.setEnabled(
true);
438 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
442 @NbBundle.Messages({
"HashDbImportDatabaseDialog.missingVersion=A version must be entered",
443 "HashDbImportDatabaseDialog.missingOrg=An organization must be selected",
444 "HashDbImportDatabaseDialog.duplicateName=A hashset with this name and version already exists",
445 "HashDbImportDatabaseDialog.databaseLookupError=Error accessing central repository",
446 "HashDbImportDatabaseDialog.mustEnterHashSetNameMsg=A hash set name must be entered."
448 private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
452 if (hashSetNameTextField.getText().isEmpty()) {
453 JOptionPane.showMessageDialog(
this,
454 NbBundle.getMessage(
this.getClass(),
455 "HashDbImportDatabaseDialog.mustEnterHashSetNameMsg"),
456 NbBundle.getMessage(
this.getClass(),
457 "HashDbImportDatabaseDialog.importHashDbErr"),
458 JOptionPane.ERROR_MESSAGE);
462 if(centralRepoRadioButton.isSelected()){
463 if(readOnlyCheckbox.isSelected() && versionTextField.getText().isEmpty()){
464 JOptionPane.showMessageDialog(
this,
465 NbBundle.getMessage(
this.getClass(),
466 "HashDbImportDatabaseDialog.missingVersion"),
467 NbBundle.getMessage(
this.getClass(),
468 "HashDbImportDatabaseDialog.importHashDbErr"),
469 JOptionPane.ERROR_MESSAGE);
473 if(selectedOrg == null){
474 JOptionPane.showMessageDialog(
this,
475 NbBundle.getMessage(
this.getClass(),
476 "HashDbImportDatabaseDialog.missingOrg"),
477 NbBundle.getMessage(
this.getClass(),
478 "HashDbImportDatabaseDialog.importHashDbErr"),
479 JOptionPane.ERROR_MESSAGE);
484 if (selectedFilePath.isEmpty()) {
485 JOptionPane.showMessageDialog(
this,
486 NbBundle.getMessage(
this.getClass(),
487 "HashDbImportDatabaseDialog.mustSelectHashDbFilePathMsg"),
488 NbBundle.getMessage(
this.getClass(),
489 "HashDbImportDatabaseDialog.importHashDbErr"),
490 JOptionPane.ERROR_MESSAGE);
493 File file =
new File(selectedFilePath);
494 if (!file.exists()) {
495 JOptionPane.showMessageDialog(
this,
496 NbBundle.getMessage(
this.getClass(),
497 "HashDbImportDatabaseDialog.hashDbDoesNotExistMsg"),
498 NbBundle.getMessage(
this.getClass(),
499 "HashDbImportDatabaseDialog.importHashDbErr"),
500 JOptionPane.ERROR_MESSAGE);
505 if (knownRadioButton.isSelected()) {
506 type = KnownFilesType.KNOWN;
508 type = KnownFilesType.KNOWN_BAD;
511 String errorMessage = NbBundle.getMessage(this.getClass(),
512 "HashDbImportDatabaseDialog.errorMessage.failedToOpenHashDbMsg",
514 if(fileTypeRadioButton.isSelected()){
517 selectedHashDb = HashDbManager.getInstance().addExistingHashDatabaseNoSave(hashSetNameTextField.getText(), selectedFilePath,
true, sendIngestMessagesCheckbox.isSelected(), type);
518 }
catch (HashDbManagerException ex) {
519 Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.WARNING, errorMessage, ex);
520 JOptionPane.showMessageDialog(
this,
522 NbBundle.getMessage(this.getClass(),
523 "HashDbImportDatabaseDialog.importHashDbErr"),
524 JOptionPane.ERROR_MESSAGE);
531 if(EamDb.getInstance().referenceSetExists(hashSetNameTextField.getText(), versionTextField.getText())){
532 JOptionPane.showMessageDialog(
this,
533 NbBundle.getMessage(
this.getClass(),
534 "HashDbImportDatabaseDialog.duplicateName"),
535 NbBundle.getMessage(
this.getClass(),
536 "HashDbImportDatabaseDialog.importHashDbErr"),
537 JOptionPane.ERROR_MESSAGE);
540 }
catch (EamDbException ex){
541 Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.SEVERE,
"Error looking up reference set", ex);
542 JOptionPane.showMessageDialog(
this,
543 NbBundle.getMessage(
this.getClass(),
544 "HashDbImportDatabaseDialog.databaseLookupError"),
545 NbBundle.getMessage(
this.getClass(),
546 "HashDbImportDatabaseDialog.importHashDbErr"),
547 JOptionPane.ERROR_MESSAGE);
552 if(readOnlyCheckbox.isSelected()){
553 version = versionTextField.getText();
558 ImportCentralRepoDbProgressDialog progressDialog =
new ImportCentralRepoDbProgressDialog();
559 progressDialog.importFile(hashSetNameTextField.getText(), version,
560 selectedOrg.getOrgID(),
true, sendIngestMessagesCheckbox.isSelected(), type,
561 readOnlyCheckbox.isSelected(), selectedFilePath);
562 selectedHashDb = progressDialog.getDatabase();
568 private void sendIngestMessagesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
572 private void fileTypeRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
576 private void centralRepoRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
580 private void orgButtonActionPerformed(java.awt.event.ActionEvent evt) {
581 ManageOrganizationsDialog dialog =
new ManageOrganizationsDialog();
583 if (dialog.isChanged()) {
588 private void orgComboBoxActionPerformed(java.awt.event.ActionEvent evt) {
589 if (null == orgComboBox.getSelectedItem())
return;
590 String orgName = this.orgComboBox.getSelectedItem().toString();
591 for (EamOrganization
org : orgs) {
592 if (
org.getName().equals(orgName)) {
599 private void readOnlyCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
604 private javax.swing.ButtonGroup buttonGroup1;
605 private javax.swing.JButton cancelButton;
606 private javax.swing.JRadioButton centralRepoRadioButton;
607 private javax.swing.JTextField databasePathTextField;
608 private javax.swing.JRadioButton fileTypeRadioButton;
609 private javax.swing.JTextField hashSetNameTextField;
610 private javax.swing.JLabel jLabel1;
611 private javax.swing.JLabel jLabel2;
612 private javax.swing.JLabel jLabel3;
613 private javax.swing.JLabel jLabel4;
614 private javax.swing.JRadioButton knownBadRadioButton;
615 private javax.swing.JRadioButton knownRadioButton;
616 private javax.swing.JLabel lbOrg;
617 private javax.swing.JLabel lbVersion;
618 private javax.swing.JButton okButton;
619 private javax.swing.JButton openButton;
620 private javax.swing.JButton orgButton;
621 private javax.swing.JComboBox<String> orgComboBox;
622 private javax.swing.JCheckBox readOnlyCheckbox;
623 private javax.swing.JCheckBox sendIngestMessagesCheckbox;
624 private javax.swing.ButtonGroup storageTypeButtonGroup;
625 private javax.swing.JTextField versionTextField;