Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
OtherOccurrencesFilesTableModel.java
Go to the documentation of this file.
1/*
2 * Central Repository
3 *
4 * Copyright 2015-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.centralrepository.contentviewer;
20
21import org.sleuthkit.autopsy.centralrepository.application.NodeData;
22import java.util.ArrayList;
23import java.util.HashMap;
24import java.util.List;
25import java.util.Map;
26import java.util.logging.Level;
27import javax.swing.table.AbstractTableModel;
28import org.openide.util.NbBundle.Messages;
29import org.apache.commons.io.FilenameUtils;
30import org.sleuthkit.autopsy.casemodule.Case;
31import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
32import org.sleuthkit.autopsy.centralrepository.application.OtherOccurrences;
33import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
34import org.sleuthkit.autopsy.coreutils.Logger;
35
40public class OtherOccurrencesFilesTableModel extends AbstractTableModel {
41
42 private static final long serialVersionUID = 1L;
43 private static final Logger logger = Logger.getLogger(OtherOccurrencesFilesTableModel.class.getName());
44 private final List<String> nodeKeys = new ArrayList<>();
45 private final Map<String, List<NodeData>> nodeMap = new HashMap<>();
46
50 OtherOccurrencesFilesTableModel() {
51 // This constructor is intentionally empty.
52 }
53
54 @Override
55 public int getColumnCount() {
56 return 1;
57 }
58
59 @Override
60 public int getRowCount() {
61 return nodeKeys.size();
62 }
63
64 @Messages({"OtherOccurrencesFilesTableModel.fileName=File Name",
65 "OtherOccurrencesFilesTableModel.noData=No Data."})
66 @Override
67 public String getColumnName(int colIdx) {
68 return Bundle.OtherOccurrencesFilesTableModel_fileName();
69 }
70
71 @Override
72 public Object getValueAt(int rowIdx, int colIdx) {
73 //if anything would prevent this from working we will consider it no data for the sake of simplicity
74 if (nodeMap.isEmpty() || nodeKeys.isEmpty() || rowIdx < 0
75 || rowIdx >= nodeKeys.size() || nodeKeys.get(rowIdx) == null
76 || nodeMap.get(nodeKeys.get(rowIdx)) == null
77 || nodeMap.get(nodeKeys.get(rowIdx)).isEmpty()) {
78 return Bundle.OtherOccurrencesFilesTableModel_noData();
79 }
80 return FilenameUtils.getName( nodeMap.get(nodeKeys.get(rowIdx)).get(0).getFilePath());
81 }
82
92 List<NodeData> getListOfNodesForFile(int rowIdx) {
93 //if anything would prevent this from working return an empty list
94 if (nodeMap.isEmpty() || nodeKeys.isEmpty() || rowIdx < 0
95 || rowIdx >= nodeKeys.size() || nodeKeys.get(rowIdx) == null
96 || nodeMap.get(nodeKeys.get(rowIdx)) == null) {
97 return new ArrayList<>();
98 }
99 return nodeMap.get(nodeKeys.get(rowIdx));
100 }
101
102 @Override
103 public Class<String> getColumnClass(int colIdx) {
104 return String.class;
105 }
106
112 void addNodeData(NodeData newNodeData) {
113 String newNodeKey = createNodeKey(newNodeData);
114 List<NodeData> nodeList = nodeMap.get(newNodeKey);
115 if (nodeList == null) {
116 nodeKeys.add(newNodeKey);
117 nodeList = new ArrayList<>();
118 }
119 nodeList.add(newNodeData);
120 nodeMap.put(newNodeKey, nodeList);
121 fireTableDataChanged();
122 }
123
124 private String createNodeKey(NodeData nodeData) {
125 String caseUUID;
126 try {
128 } catch (CentralRepoException ignored) {
129 //non central repo nodeData won't have a correlation case
130 try {
131 caseUUID = Case.getCurrentCaseThrows().getName();
132 //place holder value will be used since correlation attribute was unavailble
133 } catch (NoCurrentCaseException ex) {
134 logger.log(Level.WARNING, "Unable to get current case", ex);
136 }
137 }
138 return nodeData.getCaseName() + nodeData.getDataSourceName() + nodeData.getDeviceID() + nodeData.getFilePath() + caseUUID;
139 }
140
144 void clearTable() {
145 nodeKeys.clear();
146 nodeMap.clear();
147 fireTableDataChanged();
148 }
149
150}
CorrelationAttributeInstance getCorrelationAttributeInstance()
synchronized static Logger getLogger(String name)
Definition Logger.java:124

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