Autopsy 4.22.1
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-2020 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 */
19package org.sleuthkit.autopsy.centralrepository;
20
21import java.awt.event.ActionEvent;
22import java.util.List;
23import java.util.logging.Level;
24import javax.swing.AbstractAction;
25import javax.swing.Action;
26import org.apache.commons.lang.StringUtils;
27import org.openide.DialogDisplayer;
28import org.openide.NotifyDescriptor;
29import org.openide.util.NbBundle.Messages;
30import org.sleuthkit.autopsy.casemodule.Case;
31import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
32import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
33import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil;
34import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
35import org.sleuthkit.autopsy.coreutils.Logger;
36import org.sleuthkit.datamodel.AbstractFile;
37import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository;
38
43@Messages({"AddEditCentralRepoCommentAction.menuItemText.addEditCentralRepoCommentEmptyFile=Add/Edit Central Repository Comment (Empty File)",
44 "AddEditCentralRepoCommentAction.menuItemText.addEditCentralRepoCommentNoMD5=Add/Edit Central Repository Comment (No MD5 Hash)",
45 "AddEditCentralRepoCommentAction.menuItemText.addEditCentralRepoComment=Add/Edit Central Repository Comment"})
46public final class AddEditCentralRepoCommentAction extends AbstractAction {
47
48 private static final Logger logger = Logger.getLogger(AddEditCentralRepoCommentAction.class.getName());
49 private static final long serialVersionUID = 1L;
50
51 private boolean addToDatabase;
53 private String comment;
54 private final Long fileId;
55
63 public AddEditCentralRepoCommentAction(AbstractFile file) {
64 fileId = file.getId();
66 if (correlationAttributeInstance == null) {
67 addToDatabase = true;
68 final List<CorrelationAttributeInstance> md5CorrelationAttr = CorrelationAttributeUtil.makeCorrAttrsForSearch(file);
69 if (!md5CorrelationAttr.isEmpty()) {
70 //for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistency with other makeCorrAttrsForSearch methods per 7852
71 correlationAttributeInstance = md5CorrelationAttr.get(0);
72 } else {
74 }
75 }
76 if (file.getSize() == 0) {
77 putValue(Action.NAME, Bundle.AddEditCentralRepoCommentAction_menuItemText_addEditCentralRepoCommentEmptyFile());
78 } else if (StringUtils.isBlank(file.getMd5Hash())) {
79 putValue(Action.NAME, Bundle.AddEditCentralRepoCommentAction_menuItemText_addEditCentralRepoCommentNoMD5());
80 } else {
81 putValue(Action.NAME, Bundle.AddEditCentralRepoCommentAction_menuItemText_addEditCentralRepoComment());
82 }
83 }
84
96 @Override
97 public void actionPerformed(ActionEvent event) {
98 CentralRepoCommentDialog centralRepoCommentDialog = new CentralRepoCommentDialog(correlationAttributeInstance);
99 centralRepoCommentDialog.display();
100
101 comment = null;
102
103 if (centralRepoCommentDialog.isCommentUpdated()) {
104 CentralRepository dbManager;
105
106 try {
107 dbManager = CentralRepository.getInstance();
108
109 if (addToDatabase) {
111 } else {
113 }
114
115 comment = centralRepoCommentDialog.getComment();
116 try {
118 } catch (NoCurrentCaseException ex) {
119 logger.log(Level.WARNING, "Case not open after changing central repository comment", ex);
120 }
121 } catch (CentralRepoException ex) {
122 logger.log(Level.SEVERE, "Error adding comment", ex);
123 NotifyDescriptor notifyDescriptor = new NotifyDescriptor.Message(
124 "An error occurred while trying to save the comment to the central repository.",
125 NotifyDescriptor.ERROR_MESSAGE);
126 DialogDisplayer.getDefault().notify(notifyDescriptor);
127 }
128 }
129 }
130
138 public String getComment() {
139 return comment;
140 }
141
150}
void notifyCentralRepoCommentChanged(long contentId, String newComment)
Definition Case.java:1875
static CorrelationAttributeInstance getCorrAttrForFile(AbstractFile file)
static List< CorrelationAttributeInstance > makeCorrAttrsForSearch(AnalysisResult analysisResult)
synchronized static Logger getLogger(String name)
Definition Logger.java:124
void addArtifactInstance(CorrelationAttributeInstance eamArtifact)
void updateAttributeInstanceComment(CorrelationAttributeInstance eamArtifact)

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.