Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
HostsAddedToPersonEvent.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.casemodule.events;
20
21import java.util.ArrayList;
22import java.util.Collections;
23import java.util.List;
24import java.util.Optional;
25import org.sleuthkit.autopsy.casemodule.Case;
26import org.sleuthkit.datamodel.Host;
27import org.sleuthkit.datamodel.Person;
28import org.sleuthkit.datamodel.SleuthkitCase;
29import org.sleuthkit.datamodel.TskCoreException;
30
35public final class HostsAddedToPersonEvent extends TskDataModelChangedEvent<Person, Host> {
36
37 private static final long serialVersionUID = 1L;
38
46 public HostsAddedToPersonEvent(Person person, List<Host> hosts) {
47 super(Case.Events.HOSTS_ADDED_TO_PERSON.toString(), Collections.singletonList(person), Person::getPersonId, hosts, Host::getHostId);
48 }
49
55 public Person getPerson() {
56 return getOldValue().get(0);
57 }
58
64 public List<Host> getHosts() {
65 return getNewValue();
66 }
67
68 @Override
69 protected List<Person> getOldValueObjects(SleuthkitCase caseDb, List<Long> ids) throws TskCoreException {
70 List<Person> persons = new ArrayList<>();
71 for (Long id : ids) {
72 Optional<Person> person = caseDb.getPersonManager().getPerson(id);
73 if (person.isPresent()) {
74 persons.add(person.get());
75 }
76 }
77 return persons;
78 }
79
80 @Override
81 protected List<Host> getNewValueObjects(SleuthkitCase caseDb, List<Long> ids) throws TskCoreException {
82 List<Host> hosts = new ArrayList<>();
83 for (Long id : ids) {
84 Optional<Host> host = caseDb.getHostManager().getHostById(id);
85 if (host.isPresent()) {
86 hosts.add(host.get());
87 }
88 }
89 return hosts;
90 }
91
92}
List< Person > getOldValueObjects(SleuthkitCase caseDb, List< Long > ids)
List< Host > getNewValueObjects(SleuthkitCase caseDb, List< Long > ids)
TskDataModelChangedEvent(String eventName, List< T > oldValueObjects, Function< T, Long > oldValueGetIdMethod, List< U > newValueObjects, Function< U, Long > newValueGetIdMethod)

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