Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataContentViewerOtherCases.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2017-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.centralrepository.contentviewer;
20 
21 import java.awt.Component;
22 import java.awt.Cursor;
23 import java.util.concurrent.ExecutionException;
24 import java.util.logging.Level;
26 import javax.swing.JPanel;
27 import org.openide.nodes.Node;
28 import org.openide.util.NbBundle.Messages;
29 import org.openide.util.lookup.ServiceProvider;
32 import org.sleuthkit.datamodel.AbstractFile;
34 import org.sleuthkit.datamodel.OsAccount;
35 
39 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
40 @ServiceProvider(service = DataContentViewer.class, position = 10)
41 @Messages({"DataContentViewerOtherCases.title=Other Occurrences",
42  "DataContentViewerOtherCases.toolTip=Displays instances of the selected file/artifact from other occurrences."})
43 public final class DataContentViewerOtherCases extends JPanel implements DataContentViewer {
44 
45  private static final long serialVersionUID = -1L;
46  private static final Logger logger = Logger.getLogger(DataContentViewerOtherCases.class.getName());
47  private final OtherOccurrencesPanel otherOccurrencesPanel = new OtherOccurrencesPanel();
48 
49  private OtherOccurrencesNodeWorker worker = null;
50 
55  initComponents();
56  add(otherOccurrencesPanel);
57  }
58 
59  @Override
60  public String getTitle() {
61  return Bundle.DataContentViewerOtherCases_title();
62  }
63 
64  @Override
65  public String getToolTip() {
66  return Bundle.DataContentViewerOtherCases_toolTip();
67  }
68 
69  @Override
71  return new DataContentViewerOtherCases();
72  }
73 
74  @Override
75  public Component getComponent() {
76  return this;
77  }
78 
79  @Override
80  public void resetComponent() {
81  otherOccurrencesPanel.reset();
82  }
83 
84  @Override
85  public int isPreferred(Node node) {
86  return 1;
87 
88  }
89 
90  @Override
91  public boolean isSupported(Node node) {
92 
93  // Is supported if one of the following is true:
94  // - The central repo is enabled and the node is not null
95  // - The central repo is disabled and the backing file has a valid MD5 hash
96  // And the node has information which could be correlated on.
97  if (CentralRepository.isEnabled() && node != null) {
98  return OtherOccurrences.getAbstractFileFromNode(node) != null || OtherOccurrences.getBlackboardArtifactFromNode(node) != null || node.getLookup().lookup(OsAccount.class) != null;
99  } else if (node != null) {
100  AbstractFile file = OtherOccurrences.getAbstractFileFromNode(node);
101  return file != null
102  && file.getSize() > 0
103  && ((file.getMd5Hash() != null) && (!file.getMd5Hash().isEmpty()));
104  }
105  return false;
106  }
107 
108  @Override
109  public void setNode(Node node) {
110  otherOccurrencesPanel.reset(); // reset the table to empty.
111  otherOccurrencesPanel.showPanelLoadingMessage();
112 
113  if (node == null) {
114  return;
115  }
116 
117  if (worker != null) {
118  worker.cancel(true);
119  }
120  worker = new OtherOccurrencesNodeWorker(node) {
121  @Override
122  public void done() {
123  try {
124  if (!isCancelled()) {
125  OtherOccurrencesData data = get();
126  otherOccurrencesPanel.populateTable(data);
127  otherOccurrencesPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
128  }
129  } catch (InterruptedException | ExecutionException ex) {
130  DataContentViewerOtherCases.logger.log(Level.SEVERE, "Failed to update OtherOccurrencesPanel", ex);
131  }
132  }
133  };
134  otherOccurrencesPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
135  worker.execute();
136  }
137 
143  @SuppressWarnings("unchecked")
144  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
145  private void initComponents() {
146  java.awt.GridBagConstraints gridBagConstraints;
147 
148  setMinimumSize(new java.awt.Dimension(1000, 10));
149  setOpaque(false);
150  setPreferredSize(new java.awt.Dimension(1000, 63));
151  setLayout(new java.awt.BorderLayout());
152  }// </editor-fold>//GEN-END:initComponents
153 
154  // Variables declaration - do not modify//GEN-BEGIN:variables
155  // End of variables declaration//GEN-END:variables
156 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.