Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
MimeTypeSummary.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020-2021 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.datasourcesummary.datamodel;
20 
21 import java.sql.SQLException;
22 import java.util.List;
23 import java.util.Set;
24 import java.util.stream.Collectors;
26 import org.sleuthkit.datamodel.DataSource;
27 import org.sleuthkit.datamodel.TskCoreException;
28 
33 public class MimeTypeSummary {
34 
36 
40  public MimeTypeSummary() {
42  }
43 
50  this.provider = provider;
51  }
52 
71  public Long getCountOfFilesForMimeTypes(DataSource currentDataSource, Set<String> setOfMimeTypes)
72  throws SleuthkitCaseProvider.SleuthkitCaseProviderException, TskCoreException, SQLException {
73  return DataSourceInfoUtilities.getCountOfRegNonSlackFiles(provider.get(), currentDataSource, "mime_type IN " + getSqlSet(setOfMimeTypes));
74  }
75 
92  public Long getCountOfFilesNotInMimeTypes(DataSource currentDataSource, Set<String> setOfMimeTypes)
93  throws SleuthkitCaseProvider.SleuthkitCaseProviderException, TskCoreException, SQLException {
94  return DataSourceInfoUtilities.getCountOfRegNonSlackFiles(provider.get(), currentDataSource,
95  "mime_type NOT IN " + getSqlSet(setOfMimeTypes)
96  + " AND mime_type IS NOT NULL AND mime_type <> '' ");
97  }
98 
110  public Long getCountOfAllRegularFiles(DataSource dataSource)
111  throws SleuthkitCaseProvider.SleuthkitCaseProviderException, TskCoreException, SQLException {
112  return DataSourceInfoUtilities.getCountOfRegNonSlackFiles(provider.get(), dataSource, null);
113  }
114 
127  public Long getCountOfFilesWithNoMimeType(DataSource currentDataSource)
128  throws SleuthkitCaseProvider.SleuthkitCaseProviderException, TskCoreException, SQLException {
129  return DataSourceInfoUtilities.getCountOfRegNonSlackFiles(provider.get(), currentDataSource, "(mime_type IS NULL OR mime_type = '') ");
130  }
131 
142  private String getSqlSet(Set<String> setValues) {
143  List<String> quotedValues = setValues
144  .stream()
145  .map(str -> String.format("'%s'", str.replace("'", "")))
146  .collect(Collectors.toList());
147 
148  String commaSeparatedQuoted = String.join(", ", quotedValues);
149  return String.format("(%s) ", commaSeparatedQuoted);
150  }
151 }
static Long getCountOfRegNonSlackFiles(SleuthkitCase skCase, DataSource currentDataSource, String additionalWhere)
Long getCountOfFilesNotInMimeTypes(DataSource currentDataSource, Set< String > setOfMimeTypes)
Long getCountOfFilesForMimeTypes(DataSource currentDataSource, Set< String > setOfMimeTypes)

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