From efe98d59d2ca57edb9b5472d08a2ee0fbd5fc187 Mon Sep 17 00:00:00 2001 From: adam-m Date: Tue, 30 Apr 2013 13:19:35 -0400 Subject: [PATCH 1/5] Abstracts out startup window, added StartupWindowProvider doing runtime discovery and choosing the right window to use --- .../sleuthkit/autopsy/casemodule/Case.java | 2 +- .../autopsy/casemodule/CaseCloseAction.java | 2 +- .../autopsy/casemodule/CaseOpenAction.java | 4 +- .../casemodule/NewCaseWizardPanel1.java | 2 +- .../casemodule/OpenRecentCasePanel.java | 4 +- .../autopsy/casemodule/RecentItems.java | 2 +- .../autopsy/casemodule/StartupWindow.java | 28 ++--- .../casemodule/StartupWindowInterface.java | 35 ++++++ .../casemodule/StartupWindowProvider.java | 103 ++++++++++++++++++ 9 files changed, 155 insertions(+), 27 deletions(-) create mode 100644 Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowInterface.java create mode 100644 Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index c39f10d476..af9b1f214e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -816,7 +816,7 @@ public class Case { * Invoke the creation of startup dialog window. */ static public void invokeStartupDialog() { - StartupWindow.getInstance().open(); + StartupWindowProvider.getInstance().open(); } /** diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CaseCloseAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/CaseCloseAction.java index 64e34e7f40..1a3eacffb4 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/CaseCloseAction.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/CaseCloseAction.java @@ -86,7 +86,7 @@ public final class CaseCloseAction extends CallableSystemAction implements Prese EventQueue.invokeLater(new Runnable() { @Override public void run() { - StartupWindow.getInstance().open(); + StartupWindowProvider.getInstance().open(); } }); } catch (Exception ex) { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CaseOpenAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/CaseOpenAction.java index 41b1d8eb24..26dfb3b821 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/CaseOpenAction.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/CaseOpenAction.java @@ -85,7 +85,7 @@ public final class CaseOpenAction implements ActionListener { } else { // try to close Startup window if there's one try { - StartupWindow.getInstance().close(); + StartupWindowProvider.getInstance().close(); } catch (Exception ex) { // no need to show the error message to the user. logger.log(Level.WARNING, "Error closing startup window.", ex); @@ -97,7 +97,7 @@ public final class CaseOpenAction implements ActionListener { + ": " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); logger.log(Level.WARNING, "Error opening case in folder " + path, ex); - StartupWindow.getInstance().open(); + StartupWindowProvider.getInstance().open(); } } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java index ab9af0ed5e..73a9ae671b 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java @@ -291,7 +291,7 @@ class NewCaseWizardPanel1 implements WizardDescriptor.ValidatingPanel sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.casemodule; + +/** + * Interface for startup window implementations + */ +public interface StartupWindowInterface { + + /** + * Shows and makes active the startup window + */ + public void open(); + + /** + * Closes the startup window + */ + public void close(); +} diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java b/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java new file mode 100644 index 0000000000..4cfa6f3b1c --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java @@ -0,0 +1,103 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2013 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.casemodule; + +import java.util.Collection; +import java.util.Iterator; +import java.util.logging.Level; +import org.openide.util.Lookup; +import org.sleuthkit.autopsy.coreutils.Logger; + +/** + * Provides the start up window to rest of the application. It may return the + * main / default startup window, or a custom one if it has been discovered. + * + * All that is required to create a custom startup window in a module and active it, + * is to implement StartupWindowInterface and register it with lookup as a ServiceProvider. + * The custom startup window is automatically chosen over the default one, given it is the only external module custom startup window. + */ +public class StartupWindowProvider implements StartupWindowInterface { + + private static volatile StartupWindowProvider instance; + private static final Logger logger = Logger.getLogger(StartupWindowProvider.class.getName()); + private volatile StartupWindowInterface startupWindowToUse; + + public static StartupWindowProvider getInstance() { + if (instance == null) { + synchronized (StartupWindowProvider.class) { + if (instance == null) { + instance = new StartupWindowProvider(); + instance.init(); + } + } + } + + return instance; + } + + private void init() { + if (startupWindowToUse == null) { + //discover the registered windows + Collection startupWindows = + Lookup.getDefault().lookupAll(StartupWindowInterface.class); + + int windowsCount = startupWindows.size(); + if (windowsCount > 2) { + logger.log(Level.WARNING, "More than 2 (" + windowsCount + ") start up windows discovered, will use the first custom one"); + } else if (windowsCount == 1) { + startupWindowToUse = startupWindows.iterator().next(); + logger.log(Level.INFO, "Will use the default startup window: " + startupWindowToUse.toString()); + } else { + //pick the non default one + Iterator it = startupWindows.iterator(); + while (it.hasNext()) { + StartupWindowInterface window = it.next(); + if (!org.sleuthkit.autopsy.casemodule.StartupWindow.class.isInstance(window)) { + startupWindowToUse = window; + logger.log(Level.INFO, "Will use the custom startup window: " + startupWindowToUse.toString()); + break; + + } + } + + if (startupWindowToUse == null) { + logger.log(Level.SEVERE, "Unexpected error, no custom startup window found, using the default"); + startupWindowToUse = new org.sleuthkit.autopsy.casemodule.StartupWindow(); + } + + } + + + } + } + + @Override + public void open() { + if (startupWindowToUse != null) { + startupWindowToUse.open(); + } + } + + @Override + public void close() { + if (startupWindowToUse != null) { + startupWindowToUse.close(); + } + } +} From f4d0a48ccfbd2b0c6dbea113269496cb5fee8220 Mon Sep 17 00:00:00 2001 From: adam-m Date: Wed, 1 May 2013 14:48:09 -0400 Subject: [PATCH 2/5] fixes AUT-945 "Process Unallocated Space" option doesn't do anything --- Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java index a9698df5ed..11d377eefa 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java @@ -583,7 +583,9 @@ class IngestScheduler { //if it's unalloc file, skip if so scheduled if (processTask.context.isProcessUnalloc() == false) { - if (aFile.isVirtual() == true) { + if (aFile.isVirtual() == true //virtual dir + || aFile.getType().equals(TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS //unalloc files + ) ) { return false; } } From d3f7b481bd41073b013ab605e574c246e93d04d0 Mon Sep 17 00:00:00 2001 From: adam-m Date: Wed, 1 May 2013 14:50:07 -0400 Subject: [PATCH 3/5] update news --- NEWS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.txt b/NEWS.txt index 8c3785a29a..757ef95b35 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -7,6 +7,7 @@ Improvements: Bugfixes: - Keyword Search: fix when Solr does not cleanly shutdown +- fix for "Process Unallocated Space" option doesn't do anything From b64089fc7f32011551c26c7c30c165d282256917 Mon Sep 17 00:00:00 2001 From: adam-m Date: Thu, 2 May 2013 09:32:57 -0400 Subject: [PATCH 4/5] change error msg from Sun to Oracle --- Core/src/org/sleuthkit/autopsy/core/Installer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/core/Installer.java b/Core/src/org/sleuthkit/autopsy/core/Installer.java index fc791743fc..218c00c3aa 100644 --- a/Core/src/org/sleuthkit/autopsy/core/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/core/Installer.java @@ -124,7 +124,7 @@ public class Installer extends ModuleInstall { javaFxInit = false; final String msg = "Error initializing JavaFX. "; final String details = " Some features will not be available. " - + " Check that you have the right JRE installed (Sun JRE > 1.7.10). "; + + " Check that you have the right JRE installed (Oracle JRE > 1.7.10). "; logger.log(Level.SEVERE, msg + details, e); From b641b543942922faf60792590412e557e4fd5ba5 Mon Sep 17 00:00:00 2001 From: adam-m Date: Thu, 2 May 2013 11:28:39 -0400 Subject: [PATCH 5/5] Better logic in ingest scheduler for not processing unalloc blocks --- .../org/sleuthkit/autopsy/ingest/IngestScheduler.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java index 11d377eefa..b8519b9878 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java @@ -578,24 +578,21 @@ class IngestScheduler { * of skipped * @return true if should be enqueued, false otherwise */ - private static boolean shouldEnqueueTask(ProcessTask processTask) { + private static boolean shouldEnqueueTask(final ProcessTask processTask) { final AbstractFile aFile = processTask.file; //if it's unalloc file, skip if so scheduled - if (processTask.context.isProcessUnalloc() == false) { - if (aFile.isVirtual() == true //virtual dir - || aFile.getType().equals(TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS //unalloc files + if (processTask.context.isProcessUnalloc() == false + && aFile.getType().equals(TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS //unalloc files ) ) { return false; - } } String fileName = aFile.getName(); if (fileName.equals(".") || fileName.equals("..")) { return false; } - if (aFile.isVirtual() == false && aFile.isFile() == true - && aFile.getType() == TSK_DB_FILES_TYPE_ENUM.FS) { + else if (aFile instanceof org.sleuthkit.datamodel.File ) { final org.sleuthkit.datamodel.File f = (File) aFile; //skip files in root dir, starting with $, containing : (not default attributes)