Autopsy  4.10.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 
49  public static Map<AutoIngestDataSourceProcessor, Integer> getDataSourceProcessorForFile(Path dataSourcePath, Collection<? extends AutoIngestDataSourceProcessor> processorCandidates) throws AutoIngestDataSourceProcessorException {
50  Map<AutoIngestDataSourceProcessor, Integer> validDataSourceProcessorsMap = new HashMap<>();
51  for (AutoIngestDataSourceProcessor processor : processorCandidates) {
52  int confidence = processor.canProcess(dataSourcePath);
53  if (confidence > 0) {
54  validDataSourceProcessorsMap.put(processor, confidence);
55  }
56  }
57 
58  return validDataSourceProcessorsMap;
59  }
60 
76  public static List<AutoIngestDataSourceProcessor> getOrderedListOfDataSourceProcessors(Path dataSourcePath) throws AutoIngestDataSourceProcessorException {
77  // lookup all AutomatedIngestDataSourceProcessors
78  Collection<? extends AutoIngestDataSourceProcessor> processorCandidates = Lookup.getDefault().lookupAll(AutoIngestDataSourceProcessor.class);
79  return getOrderedListOfDataSourceProcessors(dataSourcePath, processorCandidates);
80  }
81 
98  public static List<AutoIngestDataSourceProcessor> getOrderedListOfDataSourceProcessors(Path dataSourcePath, Collection<? extends AutoIngestDataSourceProcessor> processorCandidates) throws AutoIngestDataSourceProcessorException {
99  Map<AutoIngestDataSourceProcessor, Integer> validDataSourceProcessorsMap = getDataSourceProcessorForFile(dataSourcePath, processorCandidates);
100  return orderDataSourceProcessorsByConfidence(validDataSourceProcessorsMap);
101  }
102 
103 
112  public static List<AutoIngestDataSourceProcessor> orderDataSourceProcessorsByConfidence(Map<AutoIngestDataSourceProcessor, Integer> validDataSourceProcessorsMap) {
113  List<AutoIngestDataSourceProcessor> validDataSourceProcessors = validDataSourceProcessorsMap.entrySet().stream()
114  .sorted(Map.Entry.<AutoIngestDataSourceProcessor, Integer>comparingByValue().reversed())
115  .map(Map.Entry::getKey)
116  .collect(Collectors.toList());
117 
118  return validDataSourceProcessors;
119  }
120 }
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-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.