19 package org.sleuthkit.autopsy.discovery.search;
21 import com.google.common.cache.CacheLoader;
22 import java.awt.Image;
23 import java.util.List;
24 import java.util.ArrayList;
25 import java.util.Collections;
29 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_CACHE;
30 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD;
32 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
38 import org.openide.util.ImageUtilities;
49 private static final String
UNSUPPORTED_IMAGE =
"org/sleuthkit/autopsy/images/image-extraction-not-supported.png";
74 final SleuthkitCase caseDb = thumbnailRequest.getSleuthkitCase();
76 caseDb, thumbnailRequest.getDomain(), TSK_WEB_DOWNLOAD);
77 final List<BlackboardArtifact> webDownloads = artifactsCache.
get(webDownloadsRequest);
79 Collections.sort(webDownloadPictures, (file1, file2) -> Long.compare(file1.getCrtime(), file2.getCrtime()));
80 for (
int i = webDownloadPictures.size() - 1; i >= 0; i--) {
82 final AbstractFile mostRecent = webDownloadPictures.get(i);
86 return candidateThumbnail;
90 caseDb, thumbnailRequest.getDomain(), TSK_WEB_CACHE);
91 final List<BlackboardArtifact> webCacheArtifacts = artifactsCache.
get(webCacheRequest);
93 Collections.sort(webCachePictures, (file1, file2) -> Long.compare(file1.getSize(), file2.getSize()));
94 for (
int i = webCachePictures.size() - 1; i >= 0; i--) {
96 final AbstractFile largest = webCachePictures.get(i);
99 return candidateThumbnail;
102 return ImageUtilities.loadImage(UNSUPPORTED_IMAGE,
false);
116 private List<AbstractFile>
getJpegsFromWebDownload(SleuthkitCase caseDb, List<BlackboardArtifact> artifacts)
throws TskCoreException {
117 final List<AbstractFile> jpegs =
new ArrayList<>();
118 for (BlackboardArtifact artifact : artifacts) {
119 final Content sourceContent = caseDb.getContentById(artifact.getObjectID());
134 private List<AbstractFile>
getJpegsFromWebCache(SleuthkitCase caseDb, List<BlackboardArtifact> artifacts)
throws TskCoreException {
135 final BlackboardAttribute.Type TSK_PATH_ID =
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_PATH_ID);
136 final List<AbstractFile> jpegs =
new ArrayList<>();
137 for (BlackboardArtifact artifact : artifacts) {
138 final BlackboardAttribute tskPathId = artifact.getAttribute(TSK_PATH_ID);
139 if (tskPathId != null) {
140 final Content sourceContent = caseDb.getContentById(tskPathId.getValueLong());
154 private void addIfJpeg(List<AbstractFile> files, Content sourceContent) {
155 if ((sourceContent instanceof AbstractFile) && !(sourceContent instanceof DataSource)) {
156 final AbstractFile file = (AbstractFile) sourceContent;
157 if (JPG_EXTENSION.equals(file.getNameExtension())
158 || JPG_MIME_TYPE.equals(file.getMIMEType())) {
List< BlackboardArtifact > get(DomainSearchArtifactsRequest request)
DomainSearchThumbnailLoader()
List< AbstractFile > getJpegsFromWebDownload(SleuthkitCase caseDb, List< BlackboardArtifact > artifacts)
static final String JPG_EXTENSION
Image load(DomainSearchThumbnailRequest thumbnailRequest)
void addIfJpeg(List< AbstractFile > files, Content sourceContent)
static Image getDefaultThumbnail()
final DomainSearchArtifactsCache artifactsCache
static BufferedImage getThumbnail(Content content, int iconSize)
List< AbstractFile > getJpegsFromWebCache(SleuthkitCase caseDb, List< BlackboardArtifact > artifacts)
static final String UNSUPPORTED_IMAGE
static final String JPG_MIME_TYPE