19 package org.sleuthkit.autopsy.datasourcesummary.datamodel;
21 import java.nio.file.Paths;
22 import java.text.DateFormat;
23 import java.text.SimpleDateFormat;
24 import java.util.ArrayList;
25 import java.util.Collections;
26 import java.util.List;
27 import java.util.Locale;
29 import java.util.Objects;
30 import java.util.stream.Collectors;
31 import org.apache.commons.lang.StringUtils;
55 private static final DateFormat
DATETIME_FORMAT =
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss", Locale.getDefault());
72 if (provider == null) {
73 throw new IllegalArgumentException(
"Unable to construct RecentFileSummary object. SleuthkitCaseProvider cannot be null");
87 private static <T extends RecentFileDetails> List<T>
getSortedLimited(List<T> fileDetails,
int limit) {
88 Map<String, T> fileDetailsMap = fileDetails.stream()
89 .filter(details -> details != null)
90 .collect(Collectors.toMap(
91 d -> d.getPath().toUpperCase(),
93 (d1, d2) -> Long.compare(d1.getDateAsLong(), d2.getDateAsLong()) > 0 ? d1 : d2));
95 return fileDetailsMap.values().stream()
96 .sorted((a, b) -> -Long.compare(a.getDateAsLong(), b.getDateAsLong()))
98 .collect(Collectors.toList());
112 if (StringUtils.isBlank(path) || lastOpened == null || lastOpened == 0) {
134 if (dataSource == null) {
135 return Collections.emptyList();
143 .filter(d -> d != null)
144 .collect(Collectors.toList());
161 if (StringUtils.isBlank(path) || accessedTime == null || accessedTime == 0) {
175 throw new IllegalArgumentException(
"Invalid count: value must be greater than 0.");
194 if (dataSource == null) {
195 return Collections.emptyList();
203 .filter(d -> d != null)
204 .collect(Collectors.toList());
222 if (dataSource == null) {
223 return Collections.emptyList();
230 List<BlackboardArtifact> associatedArtifacts = skCase.
getBlackboard()
233 List<RecentAttachmentDetails> details =
new ArrayList<>();
237 if (thisDetails != null) {
238 details.add(thisDetails);
257 if (attribute == null) {
273 AbstractFile abstractFile = (AbstractFile) content;
280 if (date == null || date == 0 || StringUtils.isBlank(path)) {
331 return DATETIME_FORMAT.format(date * 1000);
376 super(artifact, path, date);
409 super(artifact, path, date);
428 RecentAttachmentDetails compareObj = (RecentAttachmentDetails) obj;
430 return compareObj.
getSender().equals(this.sender)
438 hash = 73 * hash + Objects.hashCode(this.sender);
static boolean isMessageArtifact(BlackboardArtifact nodeArtifact)
static RecentDownloadDetails getRecentDownload(BlackboardArtifact artifact)
SleuthkitCaseProvider DEFAULT
Blackboard getBlackboard()
List< RecentFileDetails > getRecentlyOpenedDocuments(DataSource dataSource, int maxCount)
static< TextendsRecentFileDetails > List< T > getSortedLimited(List< T > fileDetails, int limit)
static void throwOnNonPositiveCount(int count)
BlackboardArtifact getArtifact()
static final DateFormat DATETIME_FORMAT
List< RecentDownloadDetails > getRecentDownloads(DataSource dataSource, int maxCount)
static final BlackboardAttribute.Type DOMAIN_ATT
final BlackboardArtifact artifact
static final BlackboardArtifact.Type ASSOCATED_OBJ_ART
List< BlackboardArtifact > getArtifacts(int artifactTypeID, long dataSourceObjId)
List< RecentAttachmentDetails > getRecentAttachments(DataSource dataSource, int maxCount)
RecentFilesSummary(SleuthkitCaseProvider provider)
static RecentAttachmentDetails getRecentAttachment(BlackboardArtifact artifact, SleuthkitCase skCase)
static final BlackboardAttribute.Type ASSOCATED_ATT
static Long getLongOrNull(BlackboardArtifact artifact, Type attributeType)
final SleuthkitCaseProvider provider
static final BlackboardAttribute.Type MSG_DATEIME_SENT_ATT
boolean equals(Object obj)
static final BlackboardAttribute.Type DATETIME_ACCESSED_ATT
static RecentFileDetails getRecentlyOpenedDocument(BlackboardArtifact artifact)
static String getStringOrNull(BlackboardArtifact artifact, Type attributeType)
static final BlackboardAttribute.Type PATH_ATT
static final BlackboardAttribute.Type EMAIL_FROM_ATT