Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AccountSourceContentChildNodeFactory.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2019 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.communications.relationships;
20
21import java.util.List;
22import java.util.Set;
23import java.util.logging.Level;
24import org.openide.nodes.AbstractNode;
25import org.openide.nodes.ChildFactory;
26import org.openide.nodes.Children;
27import org.openide.nodes.Node;
28import org.sleuthkit.autopsy.casemodule.Case;
29import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
30import org.sleuthkit.autopsy.coreutils.Logger;
31import org.sleuthkit.datamodel.Account;
32import org.sleuthkit.datamodel.AccountFileInstance;
33import org.sleuthkit.datamodel.CommunicationsManager;
34import org.sleuthkit.datamodel.Content;
35import org.sleuthkit.datamodel.TskCoreException;
36
41final class AccountSourceContentChildNodeFactory extends ChildFactory<Content> {
42
43 private static final Logger logger = Logger.getLogger(AccountSourceContentChildNodeFactory.class.getName());
44
45 private final Set<Account> accounts;
46
47 AccountSourceContentChildNodeFactory(Set<Account> accounts) {
48 this.accounts = accounts;
49 }
50
51 @Override
52 protected boolean createKeys(List<Content> list) {
53 if (accounts == null || accounts.isEmpty()) {
54 return true;
55 }
56
57 CommunicationsManager communicationManager;
58 try {
59 communicationManager = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager();
60 } catch (NoCurrentCaseException | TskCoreException ex) {
61 logger.log(Level.WARNING, "Failed to get communications manager from case.", ex); //NON-NLS
62 return false;
63 }
64
65 accounts.forEach((account) -> {
66 try {
67 List<AccountFileInstance> accountFileInstanceList = communicationManager.getAccountFileInstances(account);
68
69 for (AccountFileInstance fileInstance : accountFileInstanceList) {
70 list.add(fileInstance.getFile());
71 }
72
73 } catch (TskCoreException ex) {
74 logger.log(Level.WARNING, String.format("Failed to getAccountFileInstances for account: %d", account.getAccountID()), ex); //NON-NLS
75 }
76 });
77
78 return true;
79 }
80
81 @Override
82 protected Node createNodeForKey(Content content) {
83 return new ContentNode(content);
84 }
85
89 final class ContentNode extends AbstractNode {
90
91 private final Content content;
92
93 ContentNode(Content content) {
94 super(Children.LEAF);
95 this.content = content;
96
97 try {
98 setDisplayName(content.getUniquePath());
99 } catch (TskCoreException ex) {
100 logger.log(Level.WARNING, String.format("Unable to getUniquePath for Content: %d", content.getId()), ex); //NON-NLS
101 setDisplayName(content.getName());
102 }
103
104 setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon.png"); //NON-NLS
105 }
106 }
107
108}

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