mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
refactoring
This commit is contained in:
parent
10faa7d8ef
commit
0f225c5514
@ -46,8 +46,9 @@ import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_MES
|
||||
import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT;
|
||||
|
||||
/**
|
||||
* Provides summary information about top domains in a datasource. At this time,
|
||||
* the data being provided is fictitious and is done as a placeholder.
|
||||
* Provides summary information about user activity in a datasource. At this
|
||||
* time, the data being provided for domains is fictitious and is done as a
|
||||
* placeholder.
|
||||
*/
|
||||
public class DataSourceUserActivitySummary {
|
||||
|
||||
@ -161,17 +162,12 @@ public class DataSourceUserActivitySummary {
|
||||
.map(artifact -> {
|
||||
String searchString = DataSourceInfoUtilities.getStringOrNull(artifact, TYPE_TEXT);
|
||||
Date dateAccessed = DataSourceInfoUtilities.getDateOrNull(artifact, TYPE_DATETIME_ACCESSED);
|
||||
if (StringUtils.isBlank(searchString) || dateAccessed == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TopWebSearchResult(
|
||||
searchString,
|
||||
dateAccessed
|
||||
);
|
||||
return (StringUtils.isNotBlank(searchString) && dateAccessed != null)
|
||||
? new TopWebSearchResult(searchString, dateAccessed)
|
||||
: null;
|
||||
})
|
||||
// remove null records
|
||||
.filter(result -> result != null && StringUtils.isNotBlank(result.getSearchString()))
|
||||
.filter(result -> result != null)
|
||||
// get these messages grouped by search to string
|
||||
.collect(Collectors.groupingBy((result) -> result.getSearchString().toUpperCase()))
|
||||
.entrySet()
|
||||
@ -184,9 +180,23 @@ public class DataSourceUserActivitySummary {
|
||||
// get as list
|
||||
.collect(Collectors.toList());
|
||||
|
||||
retrieveTranslations(results);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve translations for each of the TopWebSearchResult items and sets
|
||||
* each object's translation if a translation that differs from the original
|
||||
* text exists.
|
||||
*
|
||||
* @param results The results.
|
||||
*/
|
||||
private void retrieveTranslations(List<TopWebSearchResult> results) {
|
||||
// get translation if possible
|
||||
if (translationService.hasProvider() && results != null) {
|
||||
for (TopWebSearchResult result : results) {
|
||||
if (StringUtils.isNotBlank(result.getSearchString()) && translationService.hasProvider()) {
|
||||
if (StringUtils.isNotBlank(result.getSearchString())) {
|
||||
String translated = null;
|
||||
try {
|
||||
translated = translationService.translate(result.getSearchString());
|
||||
@ -200,8 +210,7 @@ public class DataSourceUserActivitySummary {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -232,8 +241,10 @@ public class DataSourceUserActivitySummary {
|
||||
);
|
||||
})
|
||||
// remove Root Hub identifier
|
||||
.filter(result -> result.getDeviceModel() == null
|
||||
|| !result.getDeviceModel().trim().toUpperCase().equals(ROOT_HUB_IDENTIFIER))
|
||||
.filter(result -> {
|
||||
return result.getDeviceModel() == null
|
||||
|| !result.getDeviceModel().trim().toUpperCase().equals(ROOT_HUB_IDENTIFIER);
|
||||
})
|
||||
.limit(count)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@ -262,7 +273,9 @@ public class DataSourceUserActivitySummary {
|
||||
.map(artifact -> {
|
||||
String type = DataSourceInfoUtilities.getStringOrNull(artifact, TYPE_MESSAGE_TYPE);
|
||||
Date date = DataSourceInfoUtilities.getDateOrNull(artifact, TYPE_DATETIME);
|
||||
return (StringUtils.isNotBlank(type) && date != null) ? new TopAccountResult(type, date) : null;
|
||||
return (StringUtils.isNotBlank(type) && date != null)
|
||||
? new TopAccountResult(type, date)
|
||||
: null;
|
||||
})
|
||||
// remove null records
|
||||
.filter(result -> result != null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user