Autopsy  4.19.3
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  */
19 package org.sleuthkit.autopsy.casemodule.events;
20 
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.Optional;
26 import org.sleuthkit.datamodel.Host;
27 import org.sleuthkit.datamodel.Person;
28 import org.sleuthkit.datamodel.SleuthkitCase;
29 import org.sleuthkit.datamodel.TskCoreException;
30 
35 public 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)

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