Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceProcessorUtility.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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  */
19 package org.sleuthkit.autopsy.datasourceprocessors;
20 
21 import java.nio.file.Path;
22 import java.util.Collection;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.stream.Collectors;
27 import org.openide.util.Lookup;
29 
34 
36  }
37 
51  public static Map<AutoIngestDataSourceProcessor, Integer> getDataSourceProcessorForFile(Path dataSourcePath, Collection<? extends AutoIngestDataSourceProcessor> processorCandidates) throws AutoIngestDataSourceProcessorException {
52  Map<AutoIngestDataSourceProcessor, Integer> validDataSourceProcessorsMap = new HashMap<>();
53  for (AutoIngestDataSourceProcessor processor : processorCandidates) {
54  int confidence = processor.canProcess(dataSourcePath);
55  if (confidence > 0) {
56  validDataSourceProcessorsMap.put(processor, confidence);
57  }
58  }
59 
60  return validDataSourceProcessorsMap;
61  }
62 
78  public static List<AutoIngestDataSourceProcessor> getOrderedListOfDataSourceProcessors(Path dataSourcePath) throws AutoIngestDataSourceProcessorException {
79  // lookup all AutomatedIngestDataSourceProcessors
80  Collection<? extends AutoIngestDataSourceProcessor> processorCandidates = Lookup.getDefault().lookupAll(AutoIngestDataSourceProcessor.class);
81  return getOrderedListOfDataSourceProcessors(dataSourcePath, processorCandidates);
82  }
83 
100  public static List<AutoIngestDataSourceProcessor> getOrderedListOfDataSourceProcessors(Path dataSourcePath, Collection<? extends AutoIngestDataSourceProcessor> processorCandidates) throws AutoIngestDataSourceProcessorException {
101  Map<AutoIngestDataSourceProcessor, Integer> validDataSourceProcessorsMap = getDataSourceProcessorForFile(dataSourcePath, processorCandidates);
102  return orderDataSourceProcessorsByConfidence(validDataSourceProcessorsMap);
103  }
104 
105 
114  public static List<AutoIngestDataSourceProcessor> orderDataSourceProcessorsByConfidence(Map<AutoIngestDataSourceProcessor, Integer> validDataSourceProcessorsMap) {
115  List<AutoIngestDataSourceProcessor> validDataSourceProcessors = validDataSourceProcessorsMap.entrySet().stream()
116  .sorted(Map.Entry.<AutoIngestDataSourceProcessor, Integer>comparingByValue().reversed())
117  .map(Map.Entry::getKey)
118  .collect(Collectors.toList());
119 
120  return validDataSourceProcessors;
121  }
122 }
static List< AutoIngestDataSourceProcessor > getOrderedListOfDataSourceProcessors(Path dataSourcePath)
static List< AutoIngestDataSourceProcessor > orderDataSourceProcessorsByConfidence(Map< AutoIngestDataSourceProcessor, Integer > validDataSourceProcessorsMap)
static Map< AutoIngestDataSourceProcessor, Integer > getDataSourceProcessorForFile(Path dataSourcePath, Collection<?extends AutoIngestDataSourceProcessor > processorCandidates)
static List< AutoIngestDataSourceProcessor > getOrderedListOfDataSourceProcessors(Path dataSourcePath, Collection<?extends AutoIngestDataSourceProcessor > processorCandidates)

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.