From 94458fb0128481022698d290e7b7a75c6b7870d7 Mon Sep 17 00:00:00 2001 From: "U-BASIS\\dsmyda" Date: Wed, 26 Jun 2019 17:47:59 -0400 Subject: [PATCH] Made error messages in UI and log straight forward in the event of an OpenCV loading error or non windows user --- .../objectdetection/Bundle.properties-MERGED | 2 ++ .../ObjectDetectectionFileIngestModule.java | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/objectdetection/Bundle.properties-MERGED b/Experimental/src/org/sleuthkit/autopsy/experimental/objectdetection/Bundle.properties-MERGED index 4256a2a349..9b2baa6467 100755 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/objectdetection/Bundle.properties-MERGED +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/objectdetection/Bundle.properties-MERGED @@ -3,5 +3,7 @@ ObjectDetectionFileIngestModule.classifierDetection.text=Classifier detected {0} # {0} - classifierDir ObjectDetectionFileIngestModule.noClassifiersFound.message=No classifiers were found in {0}, object detection will not be executed. ObjectDetectionFileIngestModule.noClassifiersFound.subject=No classifiers found. +ObjectDetectionFileIngestModule.notWindowsError=This module is only available on Windows. +ObjectDetectionFileIngestModule.openCVNotLoaded=OpenCV was not loaded, but is required to run. ObjectDetectionModuleFactory.moduleDescription.text=Use object classifiers to identify objects in pictures. ObjectDetectionModuleFactory.moduleName.text=Object Detection diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/objectdetection/ObjectDetectectionFileIngestModule.java b/Experimental/src/org/sleuthkit/autopsy/experimental/objectdetection/ObjectDetectectionFileIngestModule.java index 4ad9a79165..e5d342aef8 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/objectdetection/ObjectDetectectionFileIngestModule.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/objectdetection/ObjectDetectectionFileIngestModule.java @@ -65,14 +65,32 @@ public class ObjectDetectectionFileIngestModule extends FileIngestModuleAdapter private Blackboard blackboard; @Messages({"ObjectDetectionFileIngestModule.noClassifiersFound.subject=No classifiers found.", - "# {0} - classifierDir", "ObjectDetectionFileIngestModule.noClassifiersFound.message=No classifiers were found in {0}, object detection will not be executed."}) + "# {0} - classifierDir", "ObjectDetectionFileIngestModule.noClassifiersFound.message=No classifiers were found in {0}, object detection will not be executed.", + "ObjectDetectionFileIngestModule.openCVNotLoaded=OpenCV was not loaded, but is required to run.", + "ObjectDetectionFileIngestModule.notWindowsError=This module is only available on Windows." + }) @Override public void startUp(IngestJobContext context) throws IngestModule.IngestModuleException { jobId = context.getJobId(); File classifierDir = new File(PlatformUtil.getObjectDetectionClassifierPath()); classifiers = new HashMap<>(); + + if(!PlatformUtil.isWindowsOS()) { + //Pop-up that catches IngestModuleException will automatically indicate + //the name of the module before the message. + String errorMsg = Bundle.ObjectDetectionFileIngestModule_notWindowsError(); + logger.log(Level.SEVERE, errorMsg); + throw new IngestModule.IngestModuleException(errorMsg); + } + + if(!OpenCvLoader.hasOpenCvLoaded()) { + String errorMsg = Bundle.ObjectDetectionFileIngestModule_openCVNotLoaded(); + logger.log(Level.SEVERE, errorMsg); + throw new IngestModule.IngestModuleException(errorMsg); + } + //Load all classifiers found in PlatformUtil.getObjectDetectionClassifierPath() - if (OpenCvLoader.hasOpenCvLoaded() && classifierDir.exists() && classifierDir.isDirectory()) { + if (classifierDir.exists() && classifierDir.isDirectory()) { for (File classifier : classifierDir.listFiles()) { if (classifier.isFile() && FilenameUtils.getExtension(classifier.getName()).equalsIgnoreCase("xml")) { classifiers.put(classifier.getName(), new CascadeClassifier(classifier.getAbsolutePath()));