Autopsy  4.7.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddEditCentralRepoCommentAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.centralrepository;
20 
21 import java.awt.event.ActionEvent;
22 import java.util.logging.Level;
23 import javax.swing.AbstractAction;
24 import org.openide.util.NbBundle.Messages;
31 import org.sleuthkit.datamodel.AbstractFile;
32 import org.sleuthkit.datamodel.TskCoreException;
33 
38 public final class AddEditCentralRepoCommentAction extends AbstractAction {
39 
40  private static final Logger logger = Logger.getLogger(AddEditCentralRepoCommentAction.class.getName());
41 
42  private boolean addToDatabase;
44  String title;
45 
52  private AddEditCentralRepoCommentAction(CorrelationAttribute correlationAttribute, String title) {
53  super(title);
54  this.title = title;
55  this.correlationAttribute = correlationAttribute;
56  }
57 
65  private AddEditCentralRepoCommentAction(AbstractFile file, String title) {
66 
67  super(title);
68  this.title = title;
69  correlationAttribute = EamArtifactUtil.getCorrelationAttributeFromContent(file);
70  if (correlationAttribute == null) {
71  addToDatabase = true;
72  correlationAttribute = EamArtifactUtil.makeCorrelationAttributeFromContent(file);
73  }
74  }
75 
76  @Override
77  public void actionPerformed(ActionEvent event) {
79  }
80 
87  public void addEditCentralRepoComment() {
88  CentralRepoCommentDialog centralRepoCommentDialog = new CentralRepoCommentDialog(correlationAttribute, title);
89  centralRepoCommentDialog.display();
90 
91  if (centralRepoCommentDialog.isCommentUpdated()) {
92  EamDb dbManager;
93 
94  try {
95  dbManager = EamDb.getInstance();
96 
97  if (addToDatabase) {
98  dbManager.addArtifact(correlationAttribute);
99  } else {
100  dbManager.updateAttributeInstanceComment(correlationAttribute);
101  }
102  } catch (EamDbException ex) {
103  logger.log(Level.SEVERE, "Error connecting to Central Repository database.", ex);
104  }
105  }
106  }
107 
121  @Messages({"AddEditCentralRepoCommentAction.menuItemText.addEditCentralRepoComment=Add/Edit Central Repository Comment"})
123 
124  return new AddEditCentralRepoCommentAction(file,
125  Bundle.AddEditCentralRepoCommentAction_menuItemText_addEditCentralRepoComment());
126  }
127 
136  @Messages({"AddEditCentralRepoCommentAction.menuItemText.addEditComment=Add/Edit Comment"})
138 
139  return new AddEditCentralRepoCommentAction(correlationAttribute,
140  Bundle.AddEditCentralRepoCommentAction_menuItemText_addEditComment());
141  }
142 }
AddEditCentralRepoCommentAction(CorrelationAttribute correlationAttribute, String title)
void updateAttributeInstanceComment(CorrelationAttribute eamArtifact)
void addArtifact(CorrelationAttribute eamArtifact)
static CorrelationAttribute makeCorrelationAttributeFromContent(Content content)
static AddEditCentralRepoCommentAction createAddEditCommentAction(CorrelationAttribute correlationAttribute)
static AddEditCentralRepoCommentAction createAddEditCentralRepoCommentAction(AbstractFile file)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static CorrelationAttribute getCorrelationAttributeFromContent(Content content)

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.