Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
RemoveParentPersonAction.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 */
19package org.sleuthkit.autopsy.datamodel.hosts;
20
21import java.awt.event.ActionEvent;
22import java.util.Collections;
23import java.util.logging.Level;
24import javax.swing.AbstractAction;
25import javax.swing.JOptionPane;
26import org.openide.util.NbBundle.Messages;
27import org.openide.windows.WindowManager;
28import org.sleuthkit.autopsy.casemodule.Case;
29import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
30import org.sleuthkit.datamodel.TskCoreException;
31import org.sleuthkit.autopsy.coreutils.Logger;
32import org.sleuthkit.datamodel.Host;
33import org.sleuthkit.datamodel.Person;
34import org.sleuthkit.datamodel.TskCoreException;
35
39@Messages({
40 "# {0} - personName",
41 "RemoveParentPersonAction_menuTitle=Remove from Person ({0})",
42 "RemoveParentPersonAction_unknownPerson=Unknown Person",
43 "RemoveParentPersonAction_onError_title=Error Removing Host from Person",
44 "# {0} - hostName",
45 "RemoveParentPersonAction_onError_description=There was an error removing person from host: {0}.",})
46public class RemoveParentPersonAction extends AbstractAction {
47
48 private static final Logger logger = Logger.getLogger(RemoveParentPersonAction.class.getName());
49
50 private final Person person;
51 private final Host host;
52
59 public RemoveParentPersonAction(Host host, Person person) {
60 super(Bundle.RemoveParentPersonAction_menuTitle(
61 person == null || person.getName() == null
62 ? Bundle.RemoveParentPersonAction_unknownPerson() : person.getName()));
63 this.host = host;
64 this.person = person;
65 }
66
67 @Override
68 public void actionPerformed(ActionEvent e) {
69 try {
70 Case.getCurrentCaseThrows().getSleuthkitCase().getPersonManager().removeHostsFromPerson(person, Collections.singletonList(host));
71 } catch (NoCurrentCaseException | TskCoreException ex) {
72 String hostName = this.host == null || this.host.getName() == null ? "" : this.host.getName();
73 logger.log(Level.WARNING, String.format("Unable to remove parent from host: %s", hostName), ex);
74
75 JOptionPane.showMessageDialog(
76 WindowManager.getDefault().getMainWindow(),
77 Bundle.RemoveParentPersonAction_onError_description(hostName),
78 Bundle.RemoveParentPersonAction_onError_title(),
79 JOptionPane.WARNING_MESSAGE);
80 }
81 }
82
83}
synchronized static Logger getLogger(String name)
Definition Logger.java:124

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