Autopsy  4.20.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AccountDeviceInstanceNodeFactory.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017-2018 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.communications;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.logging.Level;
24 import org.openide.nodes.ChildFactory;
25 import org.openide.nodes.Node;
27 import org.sleuthkit.datamodel.AccountDeviceInstance;
28 import org.sleuthkit.datamodel.CommunicationsFilter;
29 import org.sleuthkit.datamodel.CommunicationsManager;
30 import org.sleuthkit.datamodel.TskCoreException;
31 
37 final class AccountDeviceInstanceNodeFactory extends ChildFactory<AccountDeviceInstanceKey> {
38 
39  private static final Logger logger = Logger.getLogger(AccountDeviceInstanceNodeFactory.class.getName());
40 
41  private final CommunicationsManager commsManager;
42  private final CommunicationsFilter commsFilter;
43 
44  AccountDeviceInstanceNodeFactory(CommunicationsManager commsManager, CommunicationsFilter commsFilter) {
45  this.commsManager = commsManager;
46  this.commsFilter = commsFilter;
47  }
48 
49  @Override
50  protected boolean createKeys(List<AccountDeviceInstanceKey> list) {
51  List<AccountDeviceInstanceKey> accountDeviceInstanceKeys = new ArrayList<>();
52  try {
53  final List<AccountDeviceInstance> accountDeviceInstancesWithRelationships =
54  commsManager.getAccountDeviceInstancesWithRelationships(commsFilter);
55  for (AccountDeviceInstance accountDeviceInstance : accountDeviceInstancesWithRelationships) {
56  long communicationsCount = commsManager.getRelationshipSourcesCount(accountDeviceInstance, commsFilter);
57  accountDeviceInstanceKeys.add(new AccountDeviceInstanceKey(accountDeviceInstance, commsFilter, communicationsCount));
58 
59  }
60  } catch (TskCoreException tskCoreException) {
61  logger.log(Level.SEVERE, "Error getting filtered account device instances", tskCoreException);
62  }
63  list.addAll(accountDeviceInstanceKeys);
64 
65  return true;
66  }
67 
68  @Override
69  protected Node createNodeForKey(AccountDeviceInstanceKey key) {
70  return new AccountDeviceInstanceNode(key, commsManager);
71  }
72 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Aug 1 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.