Autopsy  3.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;
33 
38  class HashDbSearchManager {
39  private Map<String, List<AbstractFile>> map;
40  private List<AbstractFile> kvContents;
41 
42  public HashDbSearchManager(Map<String, List<AbstractFile>> map) {
43  this.map = map;
44  init();
45  }
46 
52  private void init() {
53  if(!map.isEmpty()) {
54  kvContents = new ArrayList<AbstractFile>();
55  int id = 0;
56  for(String s : map.keySet()) {
57  for(AbstractFile file : map.get(s)) {
58  kvContents.add(file);
59  }
60  }
61  }
62  }
63 
68  public void execute() {
69  if(!map.isEmpty()) {
70  Collection<AbstractFile> kvCollection = kvContents;
71  Node rootNode = null;
72 
73  if (kvCollection.size() > 0) {
74  Children childKeyValueContentNodes =
75  Children.create(new HashDbSearchResultFactory(kvCollection), true);
76 
77  rootNode = new AbstractNode(childKeyValueContentNodes);
78  } else {
79  rootNode = Node.EMPTY;
80  }
81 
82  final String pathText = NbBundle.getMessage(this.getClass(), "HashDbSearchManager.MD5HashSearch");
83  TopComponent searchResultWin = DataResultTopComponent.createInstance(
84  NbBundle.getMessage(this.getClass(), "HashDbSearchManager.MD5HashSearch"),
85  pathText,
86  rootNode,
87  kvCollection.size());
88 
89  searchResultWin.requestActive();
90  } else {
91  JOptionPane.showMessageDialog(null,
92  NbBundle.getMessage(this.getClass(), "HashDbSearchManager.noResultsFoundMsg"));
93  }
94  }
95 }

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