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 org.apache.commons.io.FilenameUtils;
30 import org.openide.util.NbBundle;
31 import org.openide.windows.WindowManager;
54 @SuppressWarnings(
"PMD.SingularField")
55 final class HashDbCreateDatabaseDialog extends javax.swing.JDialog {
57 private static final String DEFAULT_FILE_NAME = NbBundle
58 .getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.defaultFileName");
59 private static final long serialVersionUID = 1L;
60 private JFileChooser fileChooser = null;
61 private HashDb newHashDb = null;
62 private final static String LAST_FILE_PATH_KEY =
"HashDbCreate_Path";
63 private CentralRepoOrganization selectedOrg = null;
64 private List<CentralRepoOrganization> orgs = null;
65 static final String HASH_DATABASE_DIR_NAME =
"HashDatabases";
66 private final JFileChooserFactory chooserFactory;
73 HashDbCreateDatabaseDialog() {
74 super((JFrame) WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.createHashDbMsg"),
true);
76 chooserFactory =
new JFileChooserFactory(CustomFileChooser.class);
87 HashDb getHashDatabase() {
91 private void display() {
92 setLocationRelativeTo(getOwner());
96 private void enableComponents() {
98 if (!CentralRepository.isEnabled() || !FeatureAccessUtils.canAddHashSetsToCentralRepo()) {
99 centralRepoRadioButton.setEnabled(
false);
100 fileTypeRadioButton.setSelected(
true);
105 boolean isFileType = fileTypeRadioButton.isSelected();
108 databasePathLabel.setEnabled(isFileType);
109 databasePathTextField.setEnabled(isFileType);
110 saveAsButton.setEnabled(isFileType);
113 lbOrg.setEnabled(!isFileType);
114 orgButton.setEnabled(!isFileType);
115 orgComboBox.setEnabled(!isFileType);
118 @NbBundle.Messages({
"HashDbCreateDatabaseDialog.populateOrgsError.message=Failure loading organizations."})
119 private void populateCombobox() {
120 orgComboBox.removeAllItems();
122 CentralRepository dbManager = CentralRepository.getInstance();
123 orgs = dbManager.getOrganizations();
124 orgs.forEach((
org) -> {
125 orgComboBox.addItem(
org.getName());
126 if (CentralRepoDbUtil.isDefaultOrg(
org)) {
127 orgComboBox.setSelectedItem(
org.getName());
131 if ((selectedOrg == null) && (!orgs.isEmpty())) {
132 selectedOrg = orgs.get(0);
134 }
catch (CentralRepoException ex) {
135 JOptionPane.showMessageDialog(
this, Bundle.HashDbCreateDatabaseDialog_populateOrgsError_message());
136 Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE,
"Failure loading organizations", ex);
145 private static final long serialVersionUID = 1L;
149 File selectedFile = getSelectedFile();
150 if (!FilenameUtils.getExtension(selectedFile.getName()).equalsIgnoreCase(
HashDbManager.getHashDatabaseFileExtension())) {
151 if (JOptionPane.showConfirmDialog(
this,
152 NbBundle.getMessage(
this.getClass(),
153 "HashDbCreateDatabaseDialog.hashDbMustHaveFileExtensionMsg",
155 NbBundle.getMessage(
this.getClass(),
156 "HashDbCreateDatabaseDialog.fileNameErr"),
157 JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) {
162 if (selectedFile.exists()) {
163 if (JOptionPane.showConfirmDialog(
this,
164 NbBundle.getMessage(
this.getClass(),
165 "HashDbCreateDatabaseDialog.fileNameAlreadyExistsMsg"),
166 NbBundle.getMessage(
this.getClass(),
167 "HashDbCreateDatabaseDialog.fileExistsErr"),
168 JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) {
173 super.approveSelection();
182 @SuppressWarnings(
"unchecked")
184 private
void initComponents() {
186 buttonGroup1 =
new javax.swing.ButtonGroup();
187 storageTypeButtonGroup =
new javax.swing.ButtonGroup();
188 saveAsButton =
new javax.swing.JButton();
189 cancelButton =
new javax.swing.JButton();
190 knownRadioButton =
new javax.swing.JRadioButton();
191 knownBadRadioButton =
new javax.swing.JRadioButton();
192 databasePathLabel =
new javax.swing.JLabel();
193 hashSetNameTextField =
new javax.swing.JTextField();
194 jLabel2 =
new javax.swing.JLabel();
195 sendIngestMessagesCheckbox =
new javax.swing.JCheckBox();
196 jLabel3 =
new javax.swing.JLabel();
197 databasePathTextField =
new javax.swing.JTextField();
198 okButton =
new javax.swing.JButton();
199 jLabel4 =
new javax.swing.JLabel();
200 fileTypeRadioButton =
new javax.swing.JRadioButton();
201 centralRepoRadioButton =
new javax.swing.JRadioButton();
202 lbOrg =
new javax.swing.JLabel();
203 orgComboBox =
new javax.swing.JComboBox<>();
204 orgButton =
new javax.swing.JButton();
205 noChangeRadioButton =
new javax.swing.JRadioButton();
207 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
209 org.openide.awt.Mnemonics.setLocalizedText(saveAsButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.saveAsButton.text"));
210 saveAsButton.addActionListener(
new java.awt.event.ActionListener() {
211 public void actionPerformed(java.awt.event.ActionEvent evt) {
212 saveAsButtonActionPerformed(evt);
216 org.openide.awt.Mnemonics.setLocalizedText(cancelButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.cancelButton.text"));
217 cancelButton.addActionListener(
new java.awt.event.ActionListener() {
218 public void actionPerformed(java.awt.event.ActionEvent evt) {
219 cancelButtonActionPerformed(evt);
223 buttonGroup1.add(knownRadioButton);
224 org.openide.awt.Mnemonics.setLocalizedText(knownRadioButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.knownRadioButton.text"));
225 knownRadioButton.addActionListener(
new java.awt.event.ActionListener() {
226 public void actionPerformed(java.awt.event.ActionEvent evt) {
227 knownRadioButtonActionPerformed(evt);
231 buttonGroup1.add(knownBadRadioButton);
232 knownBadRadioButton.setSelected(
true);
233 org.openide.awt.Mnemonics.setLocalizedText(knownBadRadioButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.knownBadRadioButton.text"));
234 knownBadRadioButton.addActionListener(
new java.awt.event.ActionListener() {
235 public void actionPerformed(java.awt.event.ActionEvent evt) {
236 knownBadRadioButtonActionPerformed(evt);
240 org.openide.awt.Mnemonics.setLocalizedText(databasePathLabel,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.databasePathLabel.text"));
242 hashSetNameTextField.setText(
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.hashSetNameTextField.text"));
244 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.jLabel2.text"));
246 sendIngestMessagesCheckbox.setSelected(
true);
247 org.openide.awt.Mnemonics.setLocalizedText(sendIngestMessagesCheckbox,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.sendIngestMessagesCheckbox.text"));
248 sendIngestMessagesCheckbox.addActionListener(
new java.awt.event.ActionListener() {
249 public void actionPerformed(java.awt.event.ActionEvent evt) {
250 sendIngestMessagesCheckboxActionPerformed(evt);
254 org.openide.awt.Mnemonics.setLocalizedText(jLabel3,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.jLabel3.text"));
256 databasePathTextField.setEditable(
false);
257 databasePathTextField.setText(
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.databasePathTextField.text"));
259 org.openide.awt.Mnemonics.setLocalizedText(okButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.okButton.text"));
260 okButton.addActionListener(
new java.awt.event.ActionListener() {
261 public void actionPerformed(java.awt.event.ActionEvent evt) {
262 okButtonActionPerformed(evt);
266 org.openide.awt.Mnemonics.setLocalizedText(jLabel4,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.jLabel4.text"));
268 storageTypeButtonGroup.add(fileTypeRadioButton);
269 fileTypeRadioButton.setSelected(
true);
270 org.openide.awt.Mnemonics.setLocalizedText(fileTypeRadioButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.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(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.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(lbOrg,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.lbOrg.text"));
287 orgComboBox.addActionListener(
new java.awt.event.ActionListener() {
288 public void actionPerformed(java.awt.event.ActionEvent evt) {
289 orgComboBoxActionPerformed(evt);
293 org.openide.awt.Mnemonics.setLocalizedText(orgButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.orgButton.text"));
294 orgButton.addActionListener(
new java.awt.event.ActionListener() {
295 public void actionPerformed(java.awt.event.ActionEvent evt) {
296 orgButtonActionPerformed(evt);
300 buttonGroup1.add(noChangeRadioButton);
301 org.openide.awt.Mnemonics.setLocalizedText(noChangeRadioButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.noChangeRadioButton.text"));
302 noChangeRadioButton.addActionListener(
new java.awt.event.ActionListener() {
303 public void actionPerformed(java.awt.event.ActionEvent evt) {
304 noChangeRadioButtonActionPerformed(evt);
308 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
309 getContentPane().setLayout(layout);
310 layout.setHorizontalGroup(
311 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
312 .addGroup(layout.createSequentialGroup()
314 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
315 .addGroup(layout.createSequentialGroup()
316 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
317 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
319 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
320 .addComponent(orgComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
321 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
322 .addComponent(orgButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
323 .addGroup(layout.createSequentialGroup()
324 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
325 .addComponent(jLabel3)
326 .addComponent(jLabel4)
327 .addComponent(databasePathLabel))
328 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
329 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
330 .addGroup(layout.createSequentialGroup()
331 .addComponent(fileTypeRadioButton)
333 .addComponent(centralRepoRadioButton))
334 .addComponent(hashSetNameTextField)
335 .addComponent(databasePathTextField))))
336 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
337 .addComponent(saveAsButton))
338 .addGroup(layout.createSequentialGroup()
339 .addGap(0, 0, Short.MAX_VALUE)
340 .addComponent(okButton)
341 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
342 .addComponent(cancelButton)))
344 .addGroup(layout.createSequentialGroup()
345 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
346 .addGroup(layout.createSequentialGroup()
348 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
349 .addComponent(knownRadioButton)
350 .addComponent(knownBadRadioButton)
351 .addComponent(noChangeRadioButton)))
352 .addGroup(layout.createSequentialGroup()
354 .addComponent(jLabel2))
355 .addGroup(layout.createSequentialGroup()
357 .addComponent(sendIngestMessagesCheckbox)))
358 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
361 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {cancelButton, okButton});
363 layout.setVerticalGroup(
364 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
365 .addGroup(layout.createSequentialGroup()
367 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
368 .addComponent(jLabel4)
369 .addComponent(fileTypeRadioButton)
370 .addComponent(centralRepoRadioButton))
371 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
372 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
373 .addComponent(jLabel3)
374 .addComponent(hashSetNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
375 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
376 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
377 .addComponent(databasePathLabel)
378 .addComponent(databasePathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
379 .addComponent(saveAsButton))
380 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
381 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
383 .addComponent(orgComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
384 .addComponent(orgButton))
385 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
386 .addComponent(jLabel2)
387 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
388 .addComponent(knownRadioButton)
389 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
390 .addComponent(knownBadRadioButton)
391 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
392 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
393 .addGroup(layout.createSequentialGroup()
394 .addGap(0, 0, Short.MAX_VALUE)
395 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
396 .addComponent(cancelButton)
397 .addComponent(okButton)))
398 .addGroup(layout.createSequentialGroup()
399 .addComponent(noChangeRadioButton)
401 .addComponent(sendIngestMessagesCheckbox)
402 .addGap(0, 0, Short.MAX_VALUE)))
409 private void knownRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
410 sendIngestMessagesCheckbox.setSelected(KnownFilesType.KNOWN.isDefaultInboxMessages());
411 sendIngestMessagesCheckbox.setEnabled(KnownFilesType.KNOWN.isInboxMessagesAllowed());
414 private void knownBadRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
415 sendIngestMessagesCheckbox.setSelected(KnownFilesType.KNOWN_BAD.isDefaultInboxMessages());
416 sendIngestMessagesCheckbox.setEnabled(KnownFilesType.KNOWN_BAD.isInboxMessagesAllowed());
419 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
423 private void saveAsButtonActionPerformed(java.awt.event.ActionEvent evt) {
425 String lastBaseDirectory = HashLookupSettings.getDefaultDbPath();
426 if (ModuleSettings.settingExists(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY)) {
427 lastBaseDirectory = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY);
429 StringBuilder path =
new StringBuilder();
430 path.append(lastBaseDirectory);
431 File hashDbFolder =
new File(path.toString());
433 if (!hashDbFolder.exists()) {
434 hashDbFolder.mkdirs();
436 if (!hashSetNameTextField.getText().isEmpty()) {
437 path.append(File.separator).append(hashSetNameTextField.getText());
439 path.append(File.separator).append(DEFAULT_FILE_NAME);
441 path.append(
".").append(HashDbManager.getHashDatabaseFileExtension());
443 if(fileChooser == null) {
444 fileChooser = chooserFactory.getChooser();
446 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
447 fileChooser.setDragEnabled(
false);
448 fileChooser.setMultiSelectionEnabled(
false);
452 fileChooser.setSelectedFile(
new File(path.toString()));
453 if (fileChooser.showSaveDialog(
this) == JFileChooser.APPROVE_OPTION) {
454 File databaseFile = fileChooser.getSelectedFile();
455 databasePathTextField.setText(databaseFile.getCanonicalPath());
456 ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY, databaseFile.getParent());
458 }
catch (IOException ex) {
459 Logger.getLogger(HashDbCreateDatabaseDialog.class.getName()).log(Level.WARNING,
"Couldn't get selected file path.", ex);
463 @NbBundle.Messages({
"HashDbCreateDatabaseDialog.missingOrg=An organization must be selected",
464 "HashDbCreateDatabaseDialog.duplicateName=A hashset with this name already exists",
465 "HashDbCreateDatabaseDialog.databaseLookupError=Error accessing central repository",
466 "HashDbCreateDatabaseDialog.databaseCreationError=Error creating new hash set"
468 private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
472 if (hashSetNameTextField.getText().isEmpty()) {
473 JOptionPane.showMessageDialog(
this,
474 NbBundle.getMessage(
this.getClass(),
475 "HashDbCreateDatabaseDialog.mustEnterHashSetNameMsg"),
476 NbBundle.getMessage(
this.getClass(),
477 "HashDbCreateDatabaseDialog.createHashDbErr"),
478 JOptionPane.ERROR_MESSAGE);
482 if (fileTypeRadioButton.isSelected()) {
483 if (databasePathTextField.getText().isEmpty()) {
484 JOptionPane.showMessageDialog(
this,
485 NbBundle.getMessage(
this.getClass(),
486 "HashDbCreateDatabaseDialog.mustEnterHashDbPathMsg"),
487 NbBundle.getMessage(
this.getClass(),
488 "HashDbCreateDatabaseDialog.createHashDbErr"),
489 JOptionPane.ERROR_MESSAGE);
493 if (selectedOrg == null) {
494 JOptionPane.showMessageDialog(
this,
495 NbBundle.getMessage(
this.getClass(),
496 "HashDbCreateDatabaseDialog.missingOrg"),
497 NbBundle.getMessage(
this.getClass(),
498 "HashDbCreateDatabaseDialog.createHashDbErr"),
499 JOptionPane.ERROR_MESSAGE);
506 if (knownRadioButton.isSelected()) {
507 type = KnownFilesType.KNOWN;
508 }
else if (noChangeRadioButton.isSelected()) {
509 type = KnownFilesType.NO_CHANGE;
511 type = KnownFilesType.KNOWN_BAD;
514 TskData.FileKnown fileKnown = type.getFileKnown();
516 String errorMessage = NbBundle
517 .getMessage(this.getClass(),
"HashDbCreateDatabaseDialog.errMsg.hashDbCreationErr");
519 if (fileTypeRadioButton.isSelected()) {
521 newHashDb = HashDbManager.getInstance().addNewHashDatabaseNoSave(hashSetNameTextField.getText(), fileChooser.getSelectedFile().getCanonicalPath(),
true, sendIngestMessagesCheckbox.isSelected(), type);
522 }
catch (IOException ex) {
523 Logger.getLogger(HashDbCreateDatabaseDialog.class.getName()).log(Level.WARNING, errorMessage, ex);
524 JOptionPane.showMessageDialog(
this,
525 NbBundle.getMessage(
this.getClass(),
526 "HashDbCreateDatabaseDialog.cannotCreateFileAtLocMsg"),
527 NbBundle.getMessage(
this.getClass(),
528 "HashDbCreateDatabaseDialog.createHashDbErr"),
529 JOptionPane.ERROR_MESSAGE);
531 }
catch (HashDbManagerException ex) {
532 Logger.getLogger(HashDbCreateDatabaseDialog.class.getName()).log(Level.WARNING, errorMessage, ex);
533 JOptionPane.showMessageDialog(
this,
535 NbBundle.getMessage(this.getClass(),
536 "HashDbCreateDatabaseDialog.createHashDbErr"),
537 JOptionPane.ERROR_MESSAGE);
543 if (CentralRepository.getInstance().referenceSetExists(hashSetNameTextField.getText(),
"")) {
544 JOptionPane.showMessageDialog(
this,
545 NbBundle.getMessage(
this.getClass(),
546 "HashDbCreateDatabaseDialog.duplicateName"),
547 NbBundle.getMessage(
this.getClass(),
548 "HashDbCreateDatabaseDialog.createHashDbErr"),
549 JOptionPane.ERROR_MESSAGE);
552 }
catch (CentralRepoException ex) {
553 Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.SEVERE,
"Error looking up reference set", ex);
554 JOptionPane.showMessageDialog(
this,
555 NbBundle.getMessage(
this.getClass(),
556 "HashDbCreateDatabaseDialog.databaseLookupError"),
557 NbBundle.getMessage(
this.getClass(),
558 "HashDbCreateDatabaseDialog.createHashDbErr"),
559 JOptionPane.ERROR_MESSAGE);
564 int referenceSetID = CentralRepository.getInstance().newReferenceSet(
new CentralRepoFileSet(selectedOrg.getOrgID(), hashSetNameTextField.getText(),
565 "", fileKnown,
false, CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)));
566 newHashDb = HashDbManager.getInstance().addExistingCentralRepoHashSet(hashSetNameTextField.getText(),
568 true, sendIngestMessagesCheckbox.isSelected(), type,
false);
569 }
catch (CentralRepoException | TskCoreException ex) {
570 Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.SEVERE,
"Error creating new reference set", ex);
571 JOptionPane.showMessageDialog(
this,
572 NbBundle.getMessage(
this.getClass(),
573 "HashDbCreateDatabaseDialog.databaseCreationError"),
574 NbBundle.getMessage(
this.getClass(),
575 "HashDbCreateDatabaseDialog.createHashDbErr"),
576 JOptionPane.ERROR_MESSAGE);
584 private void sendIngestMessagesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
588 private void orgButtonActionPerformed(java.awt.event.ActionEvent evt) {
589 ManageOrganizationsDialog dialog =
new ManageOrganizationsDialog();
591 if (dialog.isChanged()) {
596 private void orgComboBoxActionPerformed(java.awt.event.ActionEvent evt) {
597 if (null == orgComboBox.getSelectedItem()) {
600 String orgName = this.orgComboBox.getSelectedItem().toString();
601 for (CentralRepoOrganization
org : orgs) {
602 if (
org.getName().equals(orgName)) {
609 private void fileTypeRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
613 private void centralRepoRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
617 private void noChangeRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
618 sendIngestMessagesCheckbox.setSelected(KnownFilesType.NO_CHANGE.isDefaultInboxMessages());
619 sendIngestMessagesCheckbox.setEnabled(KnownFilesType.NO_CHANGE.isInboxMessagesAllowed());
623 private javax.swing.ButtonGroup buttonGroup1;
624 private javax.swing.JButton cancelButton;
625 private javax.swing.JRadioButton centralRepoRadioButton;
626 private javax.swing.JLabel databasePathLabel;
627 private javax.swing.JTextField databasePathTextField;
628 private javax.swing.JRadioButton fileTypeRadioButton;
629 private javax.swing.JTextField hashSetNameTextField;
630 private javax.swing.JLabel jLabel2;
631 private javax.swing.JLabel jLabel3;
632 private javax.swing.JLabel jLabel4;
633 private javax.swing.JRadioButton knownBadRadioButton;
634 private javax.swing.JRadioButton knownRadioButton;
635 private javax.swing.JLabel lbOrg;
636 private javax.swing.JRadioButton noChangeRadioButton;
637 private javax.swing.JButton okButton;
638 private javax.swing.JButton orgButton;
639 private javax.swing.JComboBox<String> orgComboBox;
640 private javax.swing.JButton saveAsButton;
641 private javax.swing.JCheckBox sendIngestMessagesCheckbox;
642 private javax.swing.ButtonGroup storageTypeButtonGroup;