Autopsy  4.10.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.Account;
28 import org.sleuthkit.datamodel.AccountDeviceInstance;
29 import org.sleuthkit.datamodel.CommunicationsFilter;
30 import org.sleuthkit.datamodel.CommunicationsManager;
31 import org.sleuthkit.datamodel.TskCoreException;
32 
38 final class AccountDeviceInstanceNodeFactory extends ChildFactory<AccountDeviceInstanceKey> {
39 
40  private static final Logger logger = Logger.getLogger(AccountDeviceInstanceNodeFactory.class.getName());
41 
42  private final CommunicationsManager commsManager;
43  private final CommunicationsFilter commsFilter;
44 
45  AccountDeviceInstanceNodeFactory(CommunicationsManager commsManager, CommunicationsFilter commsFilter) {
46  this.commsManager = commsManager;
47  this.commsFilter = commsFilter;
48  }
49 
50  @Override
51  protected boolean createKeys(List<AccountDeviceInstanceKey> list) {
52  List<AccountDeviceInstanceKey> accountDeviceInstanceKeys = new ArrayList<>();
53  try {
54  final List<AccountDeviceInstance> accountDeviceInstancesWithRelationships =
55  commsManager.getAccountDeviceInstancesWithRelationships(commsFilter);
56  for (AccountDeviceInstance accountDeviceInstance : accountDeviceInstancesWithRelationships) {
57  //Filter out device accounts, in the table.
58  if (Account.Type.DEVICE.equals(accountDeviceInstance.getAccount().getAccountType()) ==false) {
59  long communicationsCount = commsManager.getRelationshipSourcesCount(accountDeviceInstance, commsFilter);
60  accountDeviceInstanceKeys.add(new AccountDeviceInstanceKey(accountDeviceInstance, commsFilter, communicationsCount));
61  }
62  }
63  } catch (TskCoreException tskCoreException) {
64  logger.log(Level.SEVERE, "Error getting filtered account device instances", tskCoreException);
65  }
66  list.addAll(accountDeviceInstanceKeys);
67 
68  return true;
69  }
70 
71  @Override
72  protected Node createNodeForKey(AccountDeviceInstanceKey key) {
73  return new AccountDeviceInstanceNode(key, commsManager);
74  }
75 }

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.