19 package org.sleuthkit.autopsy.datasourcesummary.datamodel;
21 import java.sql.ResultSet;
22 import java.sql.SQLException;
23 import java.text.DecimalFormat;
24 import java.util.ArrayList;
25 import java.util.Comparator;
26 import java.util.Date;
27 import java.util.List;
28 import java.util.SortedMap;
29 import java.util.TreeMap;
32 import org.apache.commons.lang.StringUtils;
48 public static final DecimalFormat
COMMA_FORMATTER =
new DecimalFormat(COMMA_FORMAT_STR);
64 if (currentDataSource != null) {
65 return skCase.countFilesWhere(
66 "data_source_obj_id=" + currentDataSource.getId()
67 + (StringUtils.isBlank(additionalWhere) ?
"" : (
" AND " + additionalWhere)));
84 static Long getCountOfRegularFiles(SleuthkitCase skCase, DataSource currentDataSource, String additionalWhere)
85 throws TskCoreException, SQLException {
86 String whereClause =
"meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue();
88 if (StringUtils.isNotBlank(additionalWhere)) {
89 whereClause +=
" AND " + additionalWhere;
92 return getCountOfTskFiles(skCase, currentDataSource, whereClause);
108 throws TskCoreException, SQLException {
112 if (StringUtils.isNotBlank(additionalWhere)) {
113 whereClause +=
" AND " + additionalWhere;
116 return getCountOfTskFiles(skCase, currentDataSource, whereClause);
124 T
process(ResultSet resultset)
throws SQLException;
141 throws TskCoreException, SQLException {
143 ResultSet resultSet = dbQuery.getResultSet();
144 return processor.process(resultSet);
157 return "meta_flags & " + flag.
getValue() +
" > 0";
189 return getArtifacts(skCase, artifactType, dataSource, attributeType, sortOrder, 0);
216 throw new IllegalArgumentException(
"Invalid maxCount passed to getArtifacts, value must be equal to or greater than 0");
245 SortedMap<BlackboardAttribute, List<BlackboardArtifact>> sortedMap =
new TreeMap<>(
new AttributeComparator(sortOrder));
246 List<BlackboardArtifact> artifactList = skCase.getBlackboard().getArtifacts(artifactType.getTypeID(), dataSource.getId());
250 if (attribute == null) {
254 List<BlackboardArtifact> mapArtifactList = sortedMap.get(attribute);
255 if (mapArtifactList == null) {
256 mapArtifactList =
new ArrayList<>();
257 sortedMap.put(attribute, mapArtifactList);
260 mapArtifactList.add(artifact);
275 List<BlackboardArtifact> artifactList =
new ArrayList<>();
277 for (List<BlackboardArtifact> mapArtifactList : sortedMap.values()) {
279 if (maxCount == 0 || (artifactList.size() + mapArtifactList.size()) <= maxCount) {
280 artifactList.addAll(mapArtifactList);
284 if (maxCount == artifactList.size()) {
289 if (artifactList.size() < maxCount) {
290 artifactList.add(artifact);
319 throw new IllegalArgumentException(
"Unable to compare attributes of different types");
343 switch (type.getValueType()) {
356 throw new IllegalArgumentException(
"Unable to compare attributes of type " + attribute1.
getAttributeType().getTypeName());
373 }
catch (TskCoreException ex) {
432 return (longVal == null || longVal == 0) ? null :
new Date(longVal * 1000);
443 return longVal == null ? 0 : longVal;
455 return longVal == null ?
"0" : COMMA_FORMATTER.format(longVal);
static List< BlackboardArtifact > getArtifacts(SleuthkitCase skCase, BlackboardArtifact.Type artifactType, DataSource dataSource, BlackboardAttribute.Type attributeType, SortOrder sortOrder, int maxCount)
static Long getCountOfRegNonSlackFiles(SleuthkitCase skCase, DataSource currentDataSource, String additionalWhere)
static List< BlackboardArtifact > createListFromMap(SortedMap< BlackboardAttribute, List< BlackboardArtifact >> sortedMap, int maxCount)
static SortedMap< BlackboardAttribute, List< BlackboardArtifact > > getArtifactMap(SleuthkitCase skCase, BlackboardArtifact.Type artifactType, DataSource dataSource, BlackboardAttribute.Type attributeType, SortOrder sortOrder)
static String getMetaFlagsContainsStatement(TSK_FS_META_FLAG_ENUM flag)
static long getLongOrZero(Long longVal)
BlackboardAttribute getAttribute(BlackboardAttribute.Type attributeType)
static List< BlackboardArtifact > getArtifacts(SleuthkitCase skCase, BlackboardArtifact.Type artifactType, DataSource dataSource, BlackboardAttribute.Type attributeType, SortOrder sortOrder)
int compare(BlackboardAttribute attribute1, BlackboardAttribute attribute2)
BlackboardAttribute.Type getAttributeType()
T process(ResultSet resultset)
static Long getLongOrNull(BlackboardArtifact artifact, Type attributeType)
DataSourceInfoUtilities()
static String getStringOrZero(Long longVal)
boolean equals(Object that)
static Integer getIntOrNull(BlackboardArtifact artifact, Type attributeType)
final SortOrder direction
static BlackboardAttribute getAttributeOrNull(BlackboardArtifact artifact, Type attributeType)
static Date getDateOrNull(BlackboardArtifact artifact, Type attributeType)
static String getStringOrNull(BlackboardArtifact artifact, Type attributeType)
static final DecimalFormat COMMA_FORMATTER
int compare(BlackboardAttribute.Type type, BlackboardAttribute attribute1, BlackboardAttribute attribute2)
static final String COMMA_FORMAT_STR