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;
|
import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides summary information about top domains in a datasource. At this time,
|
* Provides summary information about user activity in a datasource. At this
|
||||||
* the data being provided is fictitious and is done as a placeholder.
|
* time, the data being provided for domains is fictitious and is done as a
|
||||||
|
* placeholder.
|
||||||
*/
|
*/
|
||||||
public class DataSourceUserActivitySummary {
|
public class DataSourceUserActivitySummary {
|
||||||
|
|
||||||
@ -161,17 +162,12 @@ public class DataSourceUserActivitySummary {
|
|||||||
.map(artifact -> {
|
.map(artifact -> {
|
||||||
String searchString = DataSourceInfoUtilities.getStringOrNull(artifact, TYPE_TEXT);
|
String searchString = DataSourceInfoUtilities.getStringOrNull(artifact, TYPE_TEXT);
|
||||||
Date dateAccessed = DataSourceInfoUtilities.getDateOrNull(artifact, TYPE_DATETIME_ACCESSED);
|
Date dateAccessed = DataSourceInfoUtilities.getDateOrNull(artifact, TYPE_DATETIME_ACCESSED);
|
||||||
if (StringUtils.isBlank(searchString) || dateAccessed == null) {
|
return (StringUtils.isNotBlank(searchString) && dateAccessed != null)
|
||||||
return null;
|
? new TopWebSearchResult(searchString, dateAccessed)
|
||||||
}
|
: null;
|
||||||
|
|
||||||
return new TopWebSearchResult(
|
|
||||||
searchString,
|
|
||||||
dateAccessed
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
// remove null records
|
// remove null records
|
||||||
.filter(result -> result != null && StringUtils.isNotBlank(result.getSearchString()))
|
.filter(result -> result != null)
|
||||||
// get these messages grouped by search to string
|
// get these messages grouped by search to string
|
||||||
.collect(Collectors.groupingBy((result) -> result.getSearchString().toUpperCase()))
|
.collect(Collectors.groupingBy((result) -> result.getSearchString().toUpperCase()))
|
||||||
.entrySet()
|
.entrySet()
|
||||||
@ -184,24 +180,37 @@ public class DataSourceUserActivitySummary {
|
|||||||
// get as list
|
// get as list
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// get translation if possible
|
retrieveTranslations(results);
|
||||||
for (TopWebSearchResult result : results) {
|
|
||||||
if (StringUtils.isNotBlank(result.getSearchString()) && translationService.hasProvider()) {
|
|
||||||
String translated = null;
|
|
||||||
try {
|
|
||||||
translated = translationService.translate(result.getSearchString());
|
|
||||||
} catch (NoServiceProviderException | TranslationException ex) {
|
|
||||||
logger.log(Level.WARNING, String.format("There was an error translating text: '%s'", result.getSearchString()), ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set translation if there is a translation and that value differs from original
|
return results;
|
||||||
if (StringUtils.isNotBlank(translated) && !translated.toUpperCase().trim().equals(result.getSearchString().toUpperCase())) {
|
}
|
||||||
result.setTranslatedResult(translated);
|
|
||||||
|
/**
|
||||||
|
* 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())) {
|
||||||
|
String translated = null;
|
||||||
|
try {
|
||||||
|
translated = translationService.translate(result.getSearchString());
|
||||||
|
} catch (NoServiceProviderException | TranslationException ex) {
|
||||||
|
logger.log(Level.WARNING, String.format("There was an error translating text: '%s'", result.getSearchString()), ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set translation if there is a translation and that value differs from original
|
||||||
|
if (StringUtils.isNotBlank(translated) && !translated.toUpperCase().trim().equals(result.getSearchString().toUpperCase())) {
|
||||||
|
result.setTranslatedResult(translated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -232,8 +241,10 @@ public class DataSourceUserActivitySummary {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
// remove Root Hub identifier
|
// remove Root Hub identifier
|
||||||
.filter(result -> result.getDeviceModel() == null
|
.filter(result -> {
|
||||||
|| !result.getDeviceModel().trim().toUpperCase().equals(ROOT_HUB_IDENTIFIER))
|
return result.getDeviceModel() == null
|
||||||
|
|| !result.getDeviceModel().trim().toUpperCase().equals(ROOT_HUB_IDENTIFIER);
|
||||||
|
})
|
||||||
.limit(count)
|
.limit(count)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -262,7 +273,9 @@ public class DataSourceUserActivitySummary {
|
|||||||
.map(artifact -> {
|
.map(artifact -> {
|
||||||
String type = DataSourceInfoUtilities.getStringOrNull(artifact, TYPE_MESSAGE_TYPE);
|
String type = DataSourceInfoUtilities.getStringOrNull(artifact, TYPE_MESSAGE_TYPE);
|
||||||
Date date = DataSourceInfoUtilities.getDateOrNull(artifact, TYPE_DATETIME);
|
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
|
// remove null records
|
||||||
.filter(result -> result != null)
|
.filter(result -> result != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user