Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AssociatePersonAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2021 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.datamodel.hosts;
20 
21 import java.awt.event.ActionEvent;
22 import java.util.Collections;
23 import java.util.logging.Level;
24 import javax.swing.AbstractAction;
25 import javax.swing.JOptionPane;
26 import org.openide.util.NbBundle.Messages;
27 import org.openide.windows.WindowManager;
31 import org.sleuthkit.datamodel.Host;
32 import org.sleuthkit.datamodel.Person;
33 import org.sleuthkit.datamodel.TskCoreException;
34 
38 @Messages({
39  "AssociatePersonAction_unknownPerson=Unknown Person",
40  "AssociatePersonAction_onError_title=Error Associating Host with Person",
41  "# {0} - hostName",
42  "# {1} - personName",
43  "AssociatePersonAction_onError_description=There was an error associating host {0} with person {1}.",})
44 public class AssociatePersonAction extends AbstractAction {
45 
46  private static final Logger logger = Logger.getLogger(AssociatePersonAction.class.getName());
47 
48  private final Host host;
49  private final Person person;
50 
57  public AssociatePersonAction(Host host, Person person) {
58  super(person == null || person.getName() == null
59  ? Bundle.RemoveParentPersonAction_unknownPerson()
60  : person.getName());
61 
62  this.host = host;
63  this.person = person;
64  }
65 
66  @Override
67  public void actionPerformed(ActionEvent e) {
68  try {
69  Case.getCurrentCaseThrows().getSleuthkitCase().getPersonManager().addHostsToPerson(person, Collections.singletonList(host));
70  } catch (NoCurrentCaseException | TskCoreException ex) {
71  String hostName = this.host == null || this.host.getName() == null ? "" : this.host.getName();
72  String personName = this.person == null || this.person.getName() == null ? "" : this.person.getName();
73  logger.log(Level.WARNING, String.format("Unable to remove parent from host: %s with person: %s", hostName, personName), ex);
74 
75  JOptionPane.showMessageDialog(
76  WindowManager.getDefault().getMainWindow(),
77  Bundle.AssociatePersonAction_onError_description(hostName, personName),
78  Bundle.AssociatePersonAction_onError_title(),
79  JOptionPane.WARNING_MESSAGE);
80  }
81  }
82 
83 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.