Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
IngestJobInfoPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2016 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.casemodule;
20 
21 import java.beans.PropertyChangeEvent;
22 import java.text.DateFormat;
23 import java.text.SimpleDateFormat;
24 import java.util.ArrayList;
25 import java.util.Date;
26 import java.util.List;
27 import java.util.logging.Level;
28 import java.util.logging.Logger;
29 import javax.swing.JOptionPane;
30 import javax.swing.event.ListSelectionEvent;
31 import javax.swing.table.AbstractTableModel;
32 import org.openide.util.NbBundle.Messages;
34 import org.sleuthkit.datamodel.IngestJobInfo;
35 import org.sleuthkit.datamodel.IngestModuleInfo;
36 import org.sleuthkit.datamodel.SleuthkitCase;
37 import org.sleuthkit.datamodel.TskCoreException;
38 
42 public final class IngestJobInfoPanel extends javax.swing.JPanel {
43 
44  private static final Logger logger = Logger.getLogger(IngestJobInfoPanel.class.getName());
45  private List<IngestJobInfo> ingestJobs;
48  private final DateFormat datetimeFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
49 
53  public IngestJobInfoPanel() {
56  }
57 
58  @Messages({"IngestJobInfoPanel.loadIngestJob.error.text=Failed to load ingest jobs.",
59  "IngestJobInfoPanel.loadIngestJob.error.title=Load Failure"})
60  private void customizeComponents() {
61  refresh();
62  this.ingestJobTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
63  this.ingestModuleTableModel = new IngestModuleTableModel(this.ingestJobs.get(ingestJobTable.getSelectedRow()));
64  this.ingestModuleTable.setModel(this.ingestModuleTableModel);
65  });
66 
67  IngestManager.getInstance().addIngestJobEventListener((PropertyChangeEvent evt) -> {
68  if (evt.getPropertyName().equals(IngestManager.IngestJobEvent.STARTED.toString())
69  || evt.getPropertyName().equals(IngestManager.IngestJobEvent.CANCELLED.toString())
70  || evt.getPropertyName().equals(IngestManager.IngestJobEvent.COMPLETED.toString())) {
71  refresh();
72  }
73  });
74  }
75 
76  private void refresh() {
77  SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
78  try {
79  List<IngestJobInfo> ingestJobs = skCase.getIngestJobs();
80  this.ingestJobs = ingestJobs;
81  this.repaint();
82  } catch (TskCoreException ex) {
83  logger.log(Level.SEVERE, "Failed to load ingest jobs.", ex);
84  JOptionPane.showMessageDialog(null, Bundle.IngestJobInfoPanel_loadIngestJob_error_text(), Bundle.IngestJobInfoPanel_loadIngestJob_error_title(), JOptionPane.ERROR_MESSAGE);
85  }
86  }
87 
88  @Messages({"IngestJobInfoPanel.IngestJobTableModel.DataSource.header=Data Source",
89  "IngestJobInfoPanel.IngestJobTableModel.StartTime.header=Start Time",
90  "IngestJobInfoPanel.IngestJobTableModel.EndTime.header=End Time",
91  "IngestJobInfoPanel.IngestJobTableModel.IngestStatus.header=Ingest Status"})
92  private class IngestJobTableModel extends AbstractTableModel {
93 
94  private List<String> columnHeaders = new ArrayList<>();
95 
97  columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_DataSource_header());
98  columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_StartTime_header());
99  columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_EndTime_header());
100  columnHeaders.add(Bundle.IngestJobInfoPanel_IngestJobTableModel_IngestStatus_header());
101  }
102 
103  @Override
104  public int getRowCount() {
105  return ingestJobs.size();
106  }
107 
108  @Override
109  public int getColumnCount() {
110  return columnHeaders.size();
111  }
112 
113  @Override
114  public Object getValueAt(int rowIndex, int columnIndex) {
115  IngestJobInfo currIngestJob = ingestJobs.get(rowIndex);
116  SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
117  if (columnIndex == 0) {
118  try {
119  return skCase.getContentById(currIngestJob.getObjectId()).getName();
120  } catch (TskCoreException ex) {
121  logger.log(Level.SEVERE, "Failed to get content from db", ex);
122  return "";
123  }
124  } else if (columnIndex == 1) {
125  return datetimeFormat.format(currIngestJob.getStartDateTime());
126  } else if (columnIndex == 2) {
127  Date endDate = currIngestJob.getEndDateTime();
128  if (endDate.getTime() == 0) {
129  return "N/A";
130  }
131  return datetimeFormat.format(currIngestJob.getEndDateTime());
132  } else if (columnIndex == 3) {
133  return currIngestJob.getStatus().getDisplayName();
134  }
135  return null;
136  }
137 
138  @Override
139  public String getColumnName(int column) {
140  return columnHeaders.get(column);
141  }
142 
143  }
144 
145  @Messages({"IngestJobInfoPanel.IngestModuleTableModel.ModuleName.header=Module Name",
146  "IngestJobInfoPanel.IngestModuleTableModel.ModuleVersion.header=Module Version"})
147  private class IngestModuleTableModel extends AbstractTableModel {
148 
149  private List<String> columnHeaders = new ArrayList<>();
150  private IngestJobInfo currJob;
151 
152  IngestModuleTableModel(IngestJobInfo currJob) {
153  columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleName_header());
154  columnHeaders.add(Bundle.IngestJobInfoPanel_IngestModuleTableModel_ModuleVersion_header());
155  this.currJob = currJob;
156  }
157 
158  @Override
159  public int getRowCount() {
160  if (currJob == null) {
161  return 0;
162  }
163  return currJob.getIngestModuleInfo().size();
164  }
165 
166  @Override
167  public int getColumnCount() {
168  return columnHeaders.size();
169  }
170 
171  @Override
172  public Object getValueAt(int rowIndex, int columnIndex) {
173  if (currJob != null) {
174  IngestModuleInfo currIngestModule = currJob.getIngestModuleInfo().get(rowIndex);
175  if (columnIndex == 0) {
176  return currIngestModule.getDisplayName();
177  } else if (columnIndex == 1) {
178  return currIngestModule.getVersion();
179  }
180  return null;
181  }
182  return null;
183  }
184 
185  @Override
186  public String getColumnName(int column) {
187  return columnHeaders.get(column);
188  }
189 
190  }
191 
197  @SuppressWarnings("unchecked")
198  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
199  private void initComponents() {
200 
201  jScrollPane1 = new javax.swing.JScrollPane();
202  ingestJobTable = new javax.swing.JTable();
203  jLabel1 = new javax.swing.JLabel();
204  jLabel2 = new javax.swing.JLabel();
205  jScrollPane2 = new javax.swing.JScrollPane();
206  ingestModuleTable = new javax.swing.JTable();
207 
208  jScrollPane1.setBorder(null);
209 
210  ingestJobTable.setModel(ingestJobTableModel);
211  ingestJobTable.getTableHeader().setReorderingAllowed(false);
212  jScrollPane1.setViewportView(ingestJobTable);
213  ingestJobTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
214 
215  org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(IngestJobInfoPanel.class, "IngestJobInfoPanel.jLabel1.text")); // NOI18N
216 
217  org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(IngestJobInfoPanel.class, "IngestJobInfoPanel.jLabel2.text")); // NOI18N
218 
219  ingestModuleTable.setModel(ingestModuleTableModel);
220  jScrollPane2.setViewportView(ingestModuleTable);
221 
222  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
223  this.setLayout(layout);
224  layout.setHorizontalGroup(
225  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
226  .addGroup(layout.createSequentialGroup()
227  .addGap(15, 15, 15)
228  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
229  .addComponent(jLabel2)
230  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE))
231  .addGap(8, 8, 8)
232  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
233  .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
234  .addComponent(jLabel1))
235  .addContainerGap())
236  );
237  layout.setVerticalGroup(
238  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
239  .addGroup(layout.createSequentialGroup()
240  .addGap(8, 8, 8)
241  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
242  .addComponent(jLabel1)
243  .addComponent(jLabel2))
244  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
245  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
246  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
247  .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
248  .addGap(10, 10, 10))
249  );
250  }// </editor-fold>//GEN-END:initComponents
251 
252 
253  // Variables declaration - do not modify//GEN-BEGIN:variables
254  private javax.swing.JTable ingestJobTable;
255  private javax.swing.JTable ingestModuleTable;
256  private javax.swing.JLabel jLabel1;
257  private javax.swing.JLabel jLabel2;
258  private javax.swing.JScrollPane jScrollPane1;
259  private javax.swing.JScrollPane jScrollPane2;
260  // End of variables declaration//GEN-END:variables
261 }
static synchronized IngestManager getInstance()
void addIngestJobEventListener(final PropertyChangeListener listener)
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.