Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
HashDbSearchManager.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 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.modules.hashdatabase;
20 
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.List;
24 import java.util.Map;
25 import javax.swing.JOptionPane;
26 import org.openide.nodes.AbstractNode;
27 import org.openide.nodes.Children;
28 import org.openide.nodes.Node;
29 import org.openide.util.NbBundle;
30 import org.openide.windows.TopComponent;
32 import org.sleuthkit.datamodel.AbstractFile;
33 
39 class HashDbSearchManager {
40 
41  private Map<String, List<AbstractFile>> map;
42  private List<AbstractFile> kvContents;
43 
44  public HashDbSearchManager(Map<String, List<AbstractFile>> map) {
45  this.map = map;
46  init();
47  }
48 
54  private void init() {
55  if (!map.isEmpty()) {
56  kvContents = new ArrayList<AbstractFile>();
57  int id = 0;
58  for (String s : map.keySet()) {
59  for (AbstractFile file : map.get(s)) {
60  kvContents.add(file);
61  }
62  }
63  }
64  }
65 
70  public void execute() {
71  if (!map.isEmpty()) {
72  Collection<AbstractFile> kvCollection = kvContents;
73  Node rootNode = null;
74 
75  if (kvCollection.size() > 0) {
76  Children childKeyValueContentNodes
77  = Children.create(new HashDbSearchResultFactory(kvCollection), true);
78 
79  rootNode = new AbstractNode(childKeyValueContentNodes);
80  } else {
81  rootNode = Node.EMPTY;
82  }
83 
84  final String pathText = NbBundle.getMessage(this.getClass(), "HashDbSearchManager.MD5HashSearch");
85  TopComponent searchResultWin = DataResultTopComponent.createInstance(
86  NbBundle.getMessage(this.getClass(), "HashDbSearchManager.MD5HashSearch"),
87  pathText,
88  rootNode,
89  kvCollection.size());
90 
91  searchResultWin.requestActive();
92  } else {
93  JOptionPane.showMessageDialog(null,
94  NbBundle.getMessage(this.getClass(), "HashDbSearchManager.noResultsFoundMsg"));
95  }
96  }
97 }

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.