From 1a0001c9114662b409e5f0534e259b434982a668 Mon Sep 17 00:00:00 2001 From: jmillman Date: Tue, 12 Jan 2016 14:13:39 -0500 Subject: [PATCH 1/4] Log eventbus unregistration error --- .../imagegallery/datamodel/CategoryManager.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/CategoryManager.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/CategoryManager.java index 8972e192b0..ab92d6d862 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/CategoryManager.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/CategoryManager.java @@ -204,7 +204,16 @@ public class CategoryManager { * @param listener */ public void unregisterListener(Object listener) { - categoryEventBus.unregister(listener); + + try { + categoryEventBus.unregister(listener); + } catch (IllegalArgumentException e) { + if (e.getMessage().contains("missing event subscriber for an annotated method. Is " + listener + " registered?")) { + LOGGER.log(Level.WARNING, "Attempted to unregister {0} for category change events, but it was not registered.", listener.toString()); + } else { + throw e; + } + } } /** From 55381fd9be1be5529203d0f59717bb127940d75c Mon Sep 17 00:00:00 2001 From: jmillman Date: Tue, 12 Jan 2016 16:29:11 -0500 Subject: [PATCH 2/4] fix some image reading bugs, to preserve animated gifs, and contain failure to read swf files. --- .../autopsy/coreutils/ImageUtils.java | 24 +++++++++++++------ .../autopsy/coreutils/VideoUtils.java | 8 +++---- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java b/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java index dffa245f48..33817636cd 100755 --- a/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java @@ -429,6 +429,7 @@ public class ImageUtils { String cacheDirectory = Case.getCurrentCase().getCacheDirectory(); return Paths.get(cacheDirectory, "thumbnails", fileID + ".png").toFile(); //NOI18N } catch (IllegalStateException e) { + LOGGER.log(Level.WARNING, "Could not get cached thumbnail location. No case is open."); return null; } @@ -656,6 +657,10 @@ public class ImageUtils { @Override protected javafx.scene.image.Image call() throws Exception { + if (isGIF(file)) { + return readImage(); + } + // If a thumbnail file is already saved locally, just read that. if (cacheFile != null && cacheFile.exists()) { try { @@ -670,18 +675,21 @@ public class ImageUtils { //There was no correctly-sized cached thumbnail so make one. BufferedImage thumbnail = null; + if (VideoUtils.isVideoThumbnailSupported(file)) { if (openCVLoaded) { updateMessage(Bundle.GetOrGenerateThumbnailTask_generatingPreviewFor(file.getName())); thumbnail = VideoUtils.generateVideoThumbnail(file, iconSize); - } else if (defaultOnFailure) { - thumbnail = DEFAULT_THUMBNAIL; - } else { - throw new IIOException("Failed to read image for thumbnail generation."); } - + if (null == thumbnail) { + if (defaultOnFailure) { + thumbnail = DEFAULT_THUMBNAIL; + } else { + throw new IIOException("Failed to read image for thumbnail generation."); + } + } } else { - //read the image into abuffered image. + //read the image into a buffered image. BufferedImage bufferedImage = SwingFXUtils.fromFXImage(readImage(), null); if (null == bufferedImage) { LOGGER.log(Level.WARNING, FAILED_TO_READ_IMAGE_FOR_THUMBNAIL_GENERATION); @@ -717,9 +725,10 @@ public class ImageUtils { updateProgress(-1, 1); //if we got a valid thumbnail save it - if (cacheFile != null && nonNull(thumbnail) && DEFAULT_THUMBNAIL != thumbnail) { + if ((cacheFile != null) && nonNull(thumbnail) && DEFAULT_THUMBNAIL != thumbnail) { saveThumbnail(thumbnail); } + return SwingFXUtils.toFXImage(thumbnail, null); } @@ -875,6 +884,7 @@ public class ImageUtils { protected void failed() { super.failed(); LOGGER.log(Level.WARNING, IMAGE_IO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + ObjectUtils.toString(getException()), ImageUtils.getContentPathSafe(file)); +// Exceptions.printStackTrace(getException()); } @Override diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/VideoUtils.java b/Core/src/org/sleuthkit/autopsy/coreutils/VideoUtils.java index 40569e8ec0..eeedf64915 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/VideoUtils.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/VideoUtils.java @@ -43,8 +43,8 @@ import org.sleuthkit.datamodel.AbstractFile; */ public class VideoUtils { - private static final List SUPPORTED_VIDEO_EXTENSIONS - = Arrays.asList("mov", "m4v", "flv", "mp4", "3gp", "avi", "mpg", + private static final List SUPPORTED_VIDEO_EXTENSIONS = + Arrays.asList("mov", "m4v", "flv", "mp4", "3gp", "avi", "mpg", "mpeg", "asf", "divx", "rm", "moov", "wmv", "vob", "dat", "m1v", "m2v", "m4v", "mkv", "mpe", "yop", "vqa", "xmv", "mve", "wtv", "webm", "vivo", "vc1", "seq", "thp", "san", @@ -58,7 +58,7 @@ public class VideoUtils { "flm", "tmv", "4xm"); //NON-NLS private static final SortedSet SUPPORTED_VIDEO_MIME_TYPES = new TreeSet<>( - Arrays.asList("application/x-shockwave-flash", "video/x-m4v", "video/quicktime", "video/avi", "video/msvideo", "video/x-msvideo", + Arrays.asList("application/x-shockwave-flash", "video/x-m4v", "video/x-flv", "video/quicktime", "video/avi", "video/msvideo", "video/x-msvideo", "video/mp4", "video/x-ms-wmv", "video/mpeg", "video/asf")); //NON-NLS private static final List CONDITIONAL_MIME_TYPES = Arrays.asList("application/octet-stream"); @@ -160,6 +160,6 @@ public class VideoUtils { videoFile.release(); // close the file - return bufferedImage == null ? bufferedImage : ScalrWrapper.resizeFast(bufferedImage, iconSize); + return bufferedImage == null ? null : ScalrWrapper.resizeFast(bufferedImage, iconSize); } } From ce199ecf5b409039b5805d82191b87107dafc7a0 Mon Sep 17 00:00:00 2001 From: jmillman Date: Tue, 12 Jan 2016 16:44:11 -0500 Subject: [PATCH 3/4] clarify log messages --- .../org/sleuthkit/autopsy/coreutils/ImageUtils.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java b/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java index 33817636cd..5cbb3239cf 100755 --- a/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java @@ -685,7 +685,7 @@ public class ImageUtils { if (defaultOnFailure) { thumbnail = DEFAULT_THUMBNAIL; } else { - throw new IIOException("Failed to read image for thumbnail generation."); + throw new IIOException("Failed to generate thumbnail for video file."); } } } else { @@ -792,7 +792,7 @@ public class ImageUtils { */ static private abstract class ReadImageTaskBase extends Task implements IIOReadProgressListener { - private static final String IMAGE_IO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT = "ImageIO could not read {0}. It may be unsupported or corrupt"; //NOI18N + private static final String IMAGE_UTILS_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT = "ImageUtils could not read {0}. It may be unsupported or corrupt"; //NOI18N final AbstractFile file; private ImageReader reader; @@ -839,7 +839,7 @@ public class ImageUtils { } } catch (IOException iOException) { // Ignore this exception or display a warning or similar, for exceptions happening during decoding - LOGGER.log(Level.WARNING, IMAGE_IO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + iOException.toString(), ImageUtils.getContentPathSafe(file)); //NOI18N + LOGGER.log(Level.WARNING, IMAGE_UTILS_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + iOException.toString(), ImageUtils.getContentPathSafe(file)); //NOI18N } finally { reader.removeIIOReadProgressListener(this); reader.dispose(); @@ -868,11 +868,11 @@ public class ImageUtils { try { javafx.scene.image.Image fxImage = get(); if (fxImage == null) { - LOGGER.log(Level.WARNING, IMAGE_IO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT, ImageUtils.getContentPathSafe(file)); + LOGGER.log(Level.WARNING, IMAGE_UTILS_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT, ImageUtils.getContentPathSafe(file)); } else { if (fxImage.isError()) { //if there was somekind of error, log it - LOGGER.log(Level.WARNING, IMAGE_IO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + ObjectUtils.toString(fxImage.getException()), ImageUtils.getContentPathSafe(file)); + LOGGER.log(Level.WARNING, IMAGE_UTILS_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + ObjectUtils.toString(fxImage.getException()), ImageUtils.getContentPathSafe(file)); } } } catch (InterruptedException | ExecutionException ex) { @@ -883,8 +883,7 @@ public class ImageUtils { @Override protected void failed() { super.failed(); - LOGGER.log(Level.WARNING, IMAGE_IO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + ObjectUtils.toString(getException()), ImageUtils.getContentPathSafe(file)); -// Exceptions.printStackTrace(getException()); + LOGGER.log(Level.WARNING, IMAGE_UTILS_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + ObjectUtils.toString(getException()), ImageUtils.getContentPathSafe(file)); } @Override From 4f8316a8cf639dbfbfdfacd458aef9c2f1dfdd45 Mon Sep 17 00:00:00 2001 From: jmillman Date: Wed, 13 Jan 2016 11:36:58 -0500 Subject: [PATCH 4/4] fix OpenExternalViewerAction and usage in IG --- .../imagegallery/actions/OpenExternalViewerAction.java | 6 +++--- .../imagegallery/gui/drawableviews/DrawableTileBase.java | 2 +- .../imagegallery/gui/drawableviews/DrawableUIBase.java | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/OpenExternalViewerAction.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/OpenExternalViewerAction.java index c132a8789f..ba33d077ba 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/OpenExternalViewerAction.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/OpenExternalViewerAction.java @@ -26,7 +26,7 @@ import org.controlsfx.control.action.Action; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.datamodel.FileNode; import org.sleuthkit.autopsy.directorytree.ExternalViewerAction; -import org.sleuthkit.datamodel.AbstractFile; +import org.sleuthkit.autopsy.imagegallery.datamodel.DrawableFile; /** * Wraps {@link ExternalViewerAction} in a ControlsFX {@link Action} with @@ -38,14 +38,14 @@ public class OpenExternalViewerAction extends Action { private static final Image EXTERNAL = new Image(OpenExternalViewerAction.class.getResource("/org/sleuthkit/autopsy/imagegallery/images/external.png").toExternalForm()); private static final ActionEvent ACTION_EVENT = new ActionEvent(OpenExternalViewerAction.class, ActionEvent.ACTION_PERFORMED, ""); //Swing ActionEvent //NOI18N - public OpenExternalViewerAction(AbstractFile file) { + public OpenExternalViewerAction(DrawableFile file) { super("External Viewer"); /** * TODO: why is the name passed to the action? it means we duplicate * this string all over the place -jm */ - ExternalViewerAction externalViewerAction = new ExternalViewerAction(Bundle.MediaViewImagePanel_externalViewerButton_text(), new FileNode(file)); + ExternalViewerAction externalViewerAction = new ExternalViewerAction(Bundle.MediaViewImagePanel_externalViewerButton_text(), new FileNode(file.getAbstractFile())); setLongText(Bundle.MediaViewImagePanel_externalViewerButton_text()); setEventHandler(actionEvent -> //fx ActionEvent diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableTileBase.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableTileBase.java index 809f268902..6a7bcd9f17 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableTileBase.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableTileBase.java @@ -220,7 +220,7 @@ public abstract class DrawableTileBase extends DrawableUIBase { }); menuItems.add(contentViewer); - OpenExternalViewerAction openExternalViewerAction = new OpenExternalViewerAction(file.getAbstractFile()); + OpenExternalViewerAction openExternalViewerAction = new OpenExternalViewerAction(file); MenuItem externalViewer = ActionUtils.createMenuItem(openExternalViewerAction); externalViewer.textProperty().unbind(); externalViewer.textProperty().bind(openExternalViewerAction.longTextProperty()); diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableUIBase.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableUIBase.java index 7169593db1..aa143d805f 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableUIBase.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableUIBase.java @@ -46,7 +46,6 @@ import org.sleuthkit.autopsy.coreutils.ThreadConfined; import org.sleuthkit.autopsy.imagegallery.ImageGalleryController; import org.sleuthkit.autopsy.imagegallery.actions.OpenExternalViewerAction; import org.sleuthkit.autopsy.imagegallery.datamodel.DrawableFile; -import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; /** @@ -207,7 +206,7 @@ abstract public class DrawableUIBase extends AnchorPane implements DrawableView } @ThreadConfined(type = ThreadConfined.ThreadType.JFX) - void showErrorNode(String errorMessage, AbstractFile file) { + void showErrorNode(String errorMessage, DrawableFile file) { Button createButton = ActionUtils.createButton(new OpenExternalViewerAction(file)); VBox vBox = new VBox(10, new Label(errorMessage), createButton);