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 JFileChooser fileChooser = null;
60 private HashDb newHashDb = null;
61 private final static String LAST_FILE_PATH_KEY =
"HashDbCreate_Path";
62 private CentralRepoOrganization selectedOrg = null;
63 private List<CentralRepoOrganization> orgs = null;
64 static final String HASH_DATABASE_DIR_NAME =
"HashDatabases";
71 HashDbCreateDatabaseDialog() {
72 super((JFrame) WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.createHashDbMsg"),
true);
84 HashDb getHashDatabase() {
88 private void initFileChooser() {
89 fileChooser =
new JFileChooser() {
91 public void approveSelection() {
92 File selectedFile = getSelectedFile();
93 if (!FilenameUtils.getExtension(selectedFile.getName()).equalsIgnoreCase(HashDbManager.getHashDatabaseFileExtension())) {
94 if (JOptionPane.showConfirmDialog(
this,
95 NbBundle.getMessage(
this.getClass(),
96 "HashDbCreateDatabaseDialog.hashDbMustHaveFileExtensionMsg",
97 HashDbManager.getHashDatabaseFileExtension()),
98 NbBundle.getMessage(
this.getClass(),
99 "HashDbCreateDatabaseDialog.fileNameErr"),
100 JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) {
105 if (selectedFile.exists()) {
106 if (JOptionPane.showConfirmDialog(
this,
107 NbBundle.getMessage(
this.getClass(),
108 "HashDbCreateDatabaseDialog.fileNameAlreadyExistsMsg"),
109 NbBundle.getMessage(
this.getClass(),
110 "HashDbCreateDatabaseDialog.fileExistsErr"),
111 JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) {
116 super.approveSelection();
119 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
120 fileChooser.setDragEnabled(
false);
121 fileChooser.setMultiSelectionEnabled(
false);
124 private void display() {
125 setLocationRelativeTo(getOwner());
129 private void enableComponents() {
131 if (!CentralRepository.isEnabled() || !FeatureAccessUtils.canAddHashSetsToCentralRepo()) {
132 centralRepoRadioButton.setEnabled(
false);
133 fileTypeRadioButton.setSelected(
true);
138 boolean isFileType = fileTypeRadioButton.isSelected();
141 databasePathLabel.setEnabled(isFileType);
142 databasePathTextField.setEnabled(isFileType);
143 saveAsButton.setEnabled(isFileType);
146 lbOrg.setEnabled(!isFileType);
147 orgButton.setEnabled(!isFileType);
148 orgComboBox.setEnabled(!isFileType);
151 @NbBundle.Messages({
"HashDbCreateDatabaseDialog.populateOrgsError.message=Failure loading organizations."})
152 private void populateCombobox() {
153 orgComboBox.removeAllItems();
155 CentralRepository dbManager = CentralRepository.getInstance();
156 orgs = dbManager.getOrganizations();
157 orgs.forEach((
org) -> {
158 orgComboBox.addItem(
org.getName());
159 if (CentralRepoDbUtil.isDefaultOrg(
org)) {
160 orgComboBox.setSelectedItem(
org.getName());
164 if ((selectedOrg == null) && (!orgs.isEmpty())) {
165 selectedOrg = orgs.get(0);
167 }
catch (CentralRepoException ex) {
168 JOptionPane.showMessageDialog(
this, Bundle.HashDbCreateDatabaseDialog_populateOrgsError_message());
169 Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE,
"Failure loading organizations", ex);
178 @SuppressWarnings(
"unchecked")
180 private
void initComponents() {
182 buttonGroup1 =
new javax.swing.ButtonGroup();
183 storageTypeButtonGroup =
new javax.swing.ButtonGroup();
184 saveAsButton =
new javax.swing.JButton();
185 cancelButton =
new javax.swing.JButton();
186 knownRadioButton =
new javax.swing.JRadioButton();
187 knownBadRadioButton =
new javax.swing.JRadioButton();
188 databasePathLabel =
new javax.swing.JLabel();
189 hashSetNameTextField =
new javax.swing.JTextField();
190 jLabel2 =
new javax.swing.JLabel();
191 sendIngestMessagesCheckbox =
new javax.swing.JCheckBox();
192 jLabel3 =
new javax.swing.JLabel();
193 databasePathTextField =
new javax.swing.JTextField();
194 okButton =
new javax.swing.JButton();
195 jLabel4 =
new javax.swing.JLabel();
196 fileTypeRadioButton =
new javax.swing.JRadioButton();
197 centralRepoRadioButton =
new javax.swing.JRadioButton();
198 lbOrg =
new javax.swing.JLabel();
199 orgComboBox =
new javax.swing.JComboBox<>();
200 orgButton =
new javax.swing.JButton();
201 noChangeRadioButton =
new javax.swing.JRadioButton();
203 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
205 org.openide.awt.Mnemonics.setLocalizedText(saveAsButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.saveAsButton.text"));
206 saveAsButton.addActionListener(
new java.awt.event.ActionListener() {
207 public void actionPerformed(java.awt.event.ActionEvent evt) {
208 saveAsButtonActionPerformed(evt);
212 org.openide.awt.Mnemonics.setLocalizedText(cancelButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.cancelButton.text"));
213 cancelButton.addActionListener(
new java.awt.event.ActionListener() {
214 public void actionPerformed(java.awt.event.ActionEvent evt) {
215 cancelButtonActionPerformed(evt);
219 buttonGroup1.add(knownRadioButton);
220 org.openide.awt.Mnemonics.setLocalizedText(knownRadioButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.knownRadioButton.text"));
221 knownRadioButton.addActionListener(
new java.awt.event.ActionListener() {
222 public void actionPerformed(java.awt.event.ActionEvent evt) {
223 knownRadioButtonActionPerformed(evt);
227 buttonGroup1.add(knownBadRadioButton);
228 knownBadRadioButton.setSelected(
true);
229 org.openide.awt.Mnemonics.setLocalizedText(knownBadRadioButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.knownBadRadioButton.text"));
230 knownBadRadioButton.addActionListener(
new java.awt.event.ActionListener() {
231 public void actionPerformed(java.awt.event.ActionEvent evt) {
232 knownBadRadioButtonActionPerformed(evt);
236 org.openide.awt.Mnemonics.setLocalizedText(databasePathLabel,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.databasePathLabel.text"));
238 hashSetNameTextField.setText(
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.hashSetNameTextField.text"));
240 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.jLabel2.text"));
242 sendIngestMessagesCheckbox.setSelected(
true);
243 org.openide.awt.Mnemonics.setLocalizedText(sendIngestMessagesCheckbox,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.sendIngestMessagesCheckbox.text"));
244 sendIngestMessagesCheckbox.addActionListener(
new java.awt.event.ActionListener() {
245 public void actionPerformed(java.awt.event.ActionEvent evt) {
246 sendIngestMessagesCheckboxActionPerformed(evt);
250 org.openide.awt.Mnemonics.setLocalizedText(jLabel3,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.jLabel3.text"));
252 databasePathTextField.setEditable(
false);
253 databasePathTextField.setText(
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.databasePathTextField.text"));
255 org.openide.awt.Mnemonics.setLocalizedText(okButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.okButton.text"));
256 okButton.addActionListener(
new java.awt.event.ActionListener() {
257 public void actionPerformed(java.awt.event.ActionEvent evt) {
258 okButtonActionPerformed(evt);
262 org.openide.awt.Mnemonics.setLocalizedText(jLabel4,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.jLabel4.text"));
264 storageTypeButtonGroup.add(fileTypeRadioButton);
265 fileTypeRadioButton.setSelected(
true);
266 org.openide.awt.Mnemonics.setLocalizedText(fileTypeRadioButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.fileTypeRadioButton.text"));
267 fileTypeRadioButton.addActionListener(
new java.awt.event.ActionListener() {
268 public void actionPerformed(java.awt.event.ActionEvent evt) {
269 fileTypeRadioButtonActionPerformed(evt);
273 storageTypeButtonGroup.add(centralRepoRadioButton);
274 org.openide.awt.Mnemonics.setLocalizedText(centralRepoRadioButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.centralRepoRadioButton.text"));
275 centralRepoRadioButton.addActionListener(
new java.awt.event.ActionListener() {
276 public void actionPerformed(java.awt.event.ActionEvent evt) {
277 centralRepoRadioButtonActionPerformed(evt);
281 org.openide.awt.Mnemonics.setLocalizedText(lbOrg,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.lbOrg.text"));
283 orgComboBox.addActionListener(
new java.awt.event.ActionListener() {
284 public void actionPerformed(java.awt.event.ActionEvent evt) {
285 orgComboBoxActionPerformed(evt);
289 org.openide.awt.Mnemonics.setLocalizedText(orgButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.orgButton.text"));
290 orgButton.addActionListener(
new java.awt.event.ActionListener() {
291 public void actionPerformed(java.awt.event.ActionEvent evt) {
292 orgButtonActionPerformed(evt);
296 buttonGroup1.add(noChangeRadioButton);
297 org.openide.awt.Mnemonics.setLocalizedText(noChangeRadioButton,
org.openide.util.NbBundle.getMessage(HashDbCreateDatabaseDialog.class,
"HashDbCreateDatabaseDialog.noChangeRadioButton.text"));
298 noChangeRadioButton.addActionListener(
new java.awt.event.ActionListener() {
299 public void actionPerformed(java.awt.event.ActionEvent evt) {
300 noChangeRadioButtonActionPerformed(evt);
304 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
305 getContentPane().setLayout(layout);
306 layout.setHorizontalGroup(
307 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
308 .addGroup(layout.createSequentialGroup()
310 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
311 .addGroup(layout.createSequentialGroup()
312 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
313 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
315 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
316 .addComponent(orgComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
317 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
318 .addComponent(orgButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
319 .addGroup(layout.createSequentialGroup()
320 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
321 .addComponent(jLabel3)
322 .addComponent(jLabel4)
323 .addComponent(databasePathLabel))
324 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
325 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
326 .addGroup(layout.createSequentialGroup()
327 .addComponent(fileTypeRadioButton)
329 .addComponent(centralRepoRadioButton))
330 .addComponent(hashSetNameTextField)
331 .addComponent(databasePathTextField))))
332 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
333 .addComponent(saveAsButton))
334 .addGroup(layout.createSequentialGroup()
335 .addGap(0, 0, Short.MAX_VALUE)
336 .addComponent(okButton)
337 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
338 .addComponent(cancelButton)))
340 .addGroup(layout.createSequentialGroup()
341 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
342 .addGroup(layout.createSequentialGroup()
344 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
345 .addComponent(knownRadioButton)
346 .addComponent(knownBadRadioButton)
347 .addComponent(noChangeRadioButton)))
348 .addGroup(layout.createSequentialGroup()
350 .addComponent(jLabel2))
351 .addGroup(layout.createSequentialGroup()
353 .addComponent(sendIngestMessagesCheckbox)))
354 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
357 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {cancelButton, okButton});
359 layout.setVerticalGroup(
360 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
361 .addGroup(layout.createSequentialGroup()
363 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
364 .addComponent(jLabel4)
365 .addComponent(fileTypeRadioButton)
366 .addComponent(centralRepoRadioButton))
367 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
368 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
369 .addComponent(jLabel3)
370 .addComponent(hashSetNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
371 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
372 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
373 .addComponent(databasePathLabel)
374 .addComponent(databasePathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
375 .addComponent(saveAsButton))
376 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
377 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
379 .addComponent(orgComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
380 .addComponent(orgButton))
381 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
382 .addComponent(jLabel2)
383 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
384 .addComponent(knownRadioButton)
385 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
386 .addComponent(knownBadRadioButton)
387 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
388 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
389 .addGroup(layout.createSequentialGroup()
390 .addGap(0, 0, Short.MAX_VALUE)
391 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
392 .addComponent(cancelButton)
393 .addComponent(okButton)))
394 .addGroup(layout.createSequentialGroup()
395 .addComponent(noChangeRadioButton)
397 .addComponent(sendIngestMessagesCheckbox)
398 .addGap(0, 0, Short.MAX_VALUE)))
405 private void knownRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
406 sendIngestMessagesCheckbox.setSelected(KnownFilesType.KNOWN.isDefaultInboxMessages());
407 sendIngestMessagesCheckbox.setEnabled(KnownFilesType.KNOWN.isInboxMessagesAllowed());
410 private void knownBadRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
411 sendIngestMessagesCheckbox.setSelected(KnownFilesType.KNOWN_BAD.isDefaultInboxMessages());
412 sendIngestMessagesCheckbox.setEnabled(KnownFilesType.KNOWN_BAD.isInboxMessagesAllowed());
415 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
419 private void saveAsButtonActionPerformed(java.awt.event.ActionEvent evt) {
421 String lastBaseDirectory = Paths.get(PlatformUtil.getUserConfigDirectory(), HASH_DATABASE_DIR_NAME).toString();
422 if (ModuleSettings.settingExists(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY)) {
423 lastBaseDirectory = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY);
425 StringBuilder path =
new StringBuilder();
426 path.append(lastBaseDirectory);
427 File hashDbFolder =
new File(path.toString());
429 if (!hashDbFolder.exists()) {
430 hashDbFolder.mkdir();
432 if (!hashSetNameTextField.getText().isEmpty()) {
433 path.append(File.separator).append(hashSetNameTextField.getText());
435 path.append(File.separator).append(DEFAULT_FILE_NAME);
437 path.append(
".").append(HashDbManager.getHashDatabaseFileExtension());
438 fileChooser.setSelectedFile(
new File(path.toString()));
439 if (fileChooser.showSaveDialog(
this) == JFileChooser.APPROVE_OPTION) {
440 File databaseFile = fileChooser.getSelectedFile();
441 databasePathTextField.setText(databaseFile.getCanonicalPath());
442 ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY, databaseFile.getParent());
444 }
catch (IOException ex) {
445 Logger.getLogger(HashDbCreateDatabaseDialog.class.getName()).log(Level.WARNING,
"Couldn't get selected file path.", ex);
449 @NbBundle.Messages({
"HashDbCreateDatabaseDialog.missingOrg=An organization must be selected",
450 "HashDbCreateDatabaseDialog.duplicateName=A hashset with this name already exists",
451 "HashDbCreateDatabaseDialog.databaseLookupError=Error accessing central repository",
452 "HashDbCreateDatabaseDialog.databaseCreationError=Error creating new hash set"
454 private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
458 if (hashSetNameTextField.getText().isEmpty()) {
459 JOptionPane.showMessageDialog(
this,
460 NbBundle.getMessage(
this.getClass(),
461 "HashDbCreateDatabaseDialog.mustEnterHashSetNameMsg"),
462 NbBundle.getMessage(
this.getClass(),
463 "HashDbCreateDatabaseDialog.createHashDbErr"),
464 JOptionPane.ERROR_MESSAGE);
468 if (fileTypeRadioButton.isSelected()) {
469 if (databasePathTextField.getText().isEmpty()) {
470 JOptionPane.showMessageDialog(
this,
471 NbBundle.getMessage(
this.getClass(),
472 "HashDbCreateDatabaseDialog.mustEnterHashDbPathMsg"),
473 NbBundle.getMessage(
this.getClass(),
474 "HashDbCreateDatabaseDialog.createHashDbErr"),
475 JOptionPane.ERROR_MESSAGE);
479 if (selectedOrg == null) {
480 JOptionPane.showMessageDialog(
this,
481 NbBundle.getMessage(
this.getClass(),
482 "HashDbCreateDatabaseDialog.missingOrg"),
483 NbBundle.getMessage(
this.getClass(),
484 "HashDbCreateDatabaseDialog.createHashDbErr"),
485 JOptionPane.ERROR_MESSAGE);
492 if (knownRadioButton.isSelected()) {
493 type = KnownFilesType.KNOWN;
494 }
else if (noChangeRadioButton.isSelected()) {
495 type = KnownFilesType.NO_CHANGE;
497 type = KnownFilesType.KNOWN_BAD;
500 TskData.FileKnown fileKnown = type.getFileKnown();
502 String errorMessage = NbBundle
503 .getMessage(this.getClass(),
"HashDbCreateDatabaseDialog.errMsg.hashDbCreationErr");
505 if (fileTypeRadioButton.isSelected()) {
507 newHashDb = HashDbManager.getInstance().addNewHashDatabaseNoSave(hashSetNameTextField.getText(), fileChooser.getSelectedFile().getCanonicalPath(),
true, sendIngestMessagesCheckbox.isSelected(), type);
508 }
catch (IOException ex) {
509 Logger.getLogger(HashDbCreateDatabaseDialog.class.getName()).log(Level.WARNING, errorMessage, ex);
510 JOptionPane.showMessageDialog(
this,
511 NbBundle.getMessage(
this.getClass(),
512 "HashDbCreateDatabaseDialog.cannotCreateFileAtLocMsg"),
513 NbBundle.getMessage(
this.getClass(),
514 "HashDbCreateDatabaseDialog.createHashDbErr"),
515 JOptionPane.ERROR_MESSAGE);
517 }
catch (HashDbManagerException ex) {
518 Logger.getLogger(HashDbCreateDatabaseDialog.class.getName()).log(Level.WARNING, errorMessage, ex);
519 JOptionPane.showMessageDialog(
this,
521 NbBundle.getMessage(this.getClass(),
522 "HashDbCreateDatabaseDialog.createHashDbErr"),
523 JOptionPane.ERROR_MESSAGE);
529 if (CentralRepository.getInstance().referenceSetExists(hashSetNameTextField.getText(),
"")) {
530 JOptionPane.showMessageDialog(
this,
531 NbBundle.getMessage(
this.getClass(),
532 "HashDbCreateDatabaseDialog.duplicateName"),
533 NbBundle.getMessage(
this.getClass(),
534 "HashDbCreateDatabaseDialog.createHashDbErr"),
535 JOptionPane.ERROR_MESSAGE);
538 }
catch (CentralRepoException ex) {
539 Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.SEVERE,
"Error looking up reference set", ex);
540 JOptionPane.showMessageDialog(
this,
541 NbBundle.getMessage(
this.getClass(),
542 "HashDbCreateDatabaseDialog.databaseLookupError"),
543 NbBundle.getMessage(
this.getClass(),
544 "HashDbCreateDatabaseDialog.createHashDbErr"),
545 JOptionPane.ERROR_MESSAGE);
550 int referenceSetID = CentralRepository.getInstance().newReferenceSet(
new CentralRepoFileSet(selectedOrg.getOrgID(), hashSetNameTextField.getText(),
551 "", fileKnown,
false, CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)));
552 newHashDb = HashDbManager.getInstance().addExistingCentralRepoHashSet(hashSetNameTextField.getText(),
554 true, sendIngestMessagesCheckbox.isSelected(), type,
false);
555 }
catch (CentralRepoException | TskCoreException ex) {
556 Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.SEVERE,
"Error creating new reference set", ex);
557 JOptionPane.showMessageDialog(
this,
558 NbBundle.getMessage(
this.getClass(),
559 "HashDbCreateDatabaseDialog.databaseCreationError"),
560 NbBundle.getMessage(
this.getClass(),
561 "HashDbCreateDatabaseDialog.createHashDbErr"),
562 JOptionPane.ERROR_MESSAGE);
570 private void sendIngestMessagesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
574 private void orgButtonActionPerformed(java.awt.event.ActionEvent evt) {
575 ManageOrganizationsDialog dialog =
new ManageOrganizationsDialog();
577 if (dialog.isChanged()) {
582 private void orgComboBoxActionPerformed(java.awt.event.ActionEvent evt) {
583 if (null == orgComboBox.getSelectedItem()) {
586 String orgName = this.orgComboBox.getSelectedItem().toString();
587 for (CentralRepoOrganization
org : orgs) {
588 if (
org.getName().equals(orgName)) {
595 private void fileTypeRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
599 private void centralRepoRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
603 private void noChangeRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
604 sendIngestMessagesCheckbox.setSelected(KnownFilesType.NO_CHANGE.isDefaultInboxMessages());
605 sendIngestMessagesCheckbox.setEnabled(KnownFilesType.NO_CHANGE.isInboxMessagesAllowed());
609 private javax.swing.ButtonGroup buttonGroup1;
610 private javax.swing.JButton cancelButton;
611 private javax.swing.JRadioButton centralRepoRadioButton;
612 private javax.swing.JLabel databasePathLabel;
613 private javax.swing.JTextField databasePathTextField;
614 private javax.swing.JRadioButton fileTypeRadioButton;
615 private javax.swing.JTextField hashSetNameTextField;
616 private javax.swing.JLabel jLabel2;
617 private javax.swing.JLabel jLabel3;
618 private javax.swing.JLabel jLabel4;
619 private javax.swing.JRadioButton knownBadRadioButton;
620 private javax.swing.JRadioButton knownRadioButton;
621 private javax.swing.JLabel lbOrg;
622 private javax.swing.JRadioButton noChangeRadioButton;
623 private javax.swing.JButton okButton;
624 private javax.swing.JButton orgButton;
625 private javax.swing.JComboBox<String> orgComboBox;
626 private javax.swing.JButton saveAsButton;
627 private javax.swing.JCheckBox sendIngestMessagesCheckbox;
628 private javax.swing.ButtonGroup storageTypeButtonGroup;