From 8d2f2fd21ec54e074b5abca3e14fea5abd424d0a Mon Sep 17 00:00:00 2001 From: Karl Mortensen Date: Tue, 12 May 2015 17:01:47 -0400 Subject: [PATCH 1/6] update paths for collab --- .../autopsy/actions/Bundle.properties | 3 + .../actions/OpenOutputFolderAction.java | 68 ++++++ .../autopsy/casemodule/Bundle.properties | 1 + .../sleuthkit/autopsy/casemodule/Case.java | 130 +++++++++-- .../casemodule/NewCaseWizardPanel1.java | 10 +- .../autopsy/casemodule/XMLCaseManagement.java | 220 +++++++++++------- .../directorytree/ExtractUnallocAction.java | 6 +- ...ampleExecutableDataSourceIngestModule.java | 2 +- .../ExternalResultsImporter.java | 2 +- .../autopsy/modules/iOS/ContactAnalyzer.java | 2 +- .../PhotoRecCarverFileIngestModule.java | 6 +- .../sevenzip/SevenZipIngestModule.java | 4 +- .../autopsy/report/ReportGenerator.java | 2 +- .../autopsy/report/ReportWizardAction.java | 11 - .../timeline/actions/SaveSnapshot.java | 2 +- .../timeline/events/db/EventsRepository.java | 2 +- .../imagegallery/PerCaseProperties.java | 4 +- .../autopsy/keywordsearch/Server.java | 6 +- .../recentactivity/RAImageIngestModule.java | 2 +- .../scalpel/ScalpelCarverIngestModule.java | 2 +- .../netbeans/core/startup/Bundle.properties | 2 +- .../core/windows/view/ui/Bundle.properties | 2 +- .../ThunderbirdMboxFileIngestModule.java | 8 +- 23 files changed, 354 insertions(+), 143 deletions(-) create mode 100644 Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java diff --git a/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties b/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties index ca5c8b3174..ad546159c7 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties @@ -50,6 +50,9 @@ GetTagNameDialog.tagNameAlreadyDef.msg=A {0} tag name has already been defined. GetTagNameDialog.dupTagErr=Duplicate Tag Error OpenLogFolder.error1=Log File Not Found: {0} CTL_OpenLogFolder=Open Log Folder +CTL_OpenOutputFolder=Open Output Folder +OpenOutputFolder.error1=Output Folder Not Found: {0} +OpenOutputFolder.noCaseOpen=No open case, therefore no current output folder available. ShowIngestProgressSnapshotAction.actionName.text=Get Ingest Progress Snapshot OpenPythonModulesFolderAction.actionName.text=Python Plugins OpenPythonModulesFolderAction.errorMsg.folderNotFound=Python plugins folder not found: {0} diff --git a/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java b/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java new file mode 100644 index 0000000000..668cc30473 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java @@ -0,0 +1,68 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2015 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.actions; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.Desktop; +import java.io.File; +import java.io.IOException; +import javax.swing.JOptionPane; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionRegistration; +import org.openide.util.Exceptions; +import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.casemodule.Case; + +/** + * Action in menu to open the folder containing the output files + */ +@ActionRegistration( + displayName = "#CTL_OpenOutputFolder", iconInMenu = true) +@ActionReference(path = "Menu/Help", position = 1850) +@ActionID(id = "org.sleuthkit.autopsy.actions.OpenOutputFolderAction", category = "Help") +public final class OpenOutputFolderAction implements ActionListener { + + @Override + public void actionPerformed(ActionEvent e) { + + try { + File outputDir; + if (Case.isCaseOpen()) { + outputDir = new File(Case.getCurrentCase().getHostDirectory()); + if (outputDir.exists() == false) { + NotifyDescriptor d + = new NotifyDescriptor.Message(NbBundle.getMessage(this.getClass(), + "OpenOutputFolder.error1", outputDir.getAbsolutePath()), + NotifyDescriptor.ERROR_MESSAGE); + DialogDisplayer.getDefault().notify(d); + } else { + Desktop.getDesktop().open(outputDir); + } + } else { + JOptionPane.showMessageDialog(null, NbBundle.getMessage(this.getClass(), "OpenOutputFolder.noCaseOpen")); + } + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } +} diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index 906c3c2f4f..e6e04b7a6c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -133,6 +133,7 @@ Case.createCaseDir.exception.existCantRW=Cannot create case dir, already exists Case.createCaseDir.exception.cantCreate=Cannot create case dir\: {0} Case.createCaseDir.exception.cantCreateCaseDir=Could not create case directory\: {0} Case.createCaseDir.exception.cantCreateModDir=Could not create modules output directory\: {0} +Case.createCaseDir.exception.cantCreateReportsDir=Could not create reports output directory\: {0} Case.createCaseDir.exception.gen=Could not create case directory\: {0} Case.OpenEventChannel.ErrMsg=Case opening process failed to connect to nodes collaborating on case {0}. CaseDeleteAction.closeConfMsg.text=Are you sure want to close and delete this case? \n\ diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 4a61b1ae5f..c41c3d156d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -25,6 +25,9 @@ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.net.UnknownHostException; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -188,6 +191,9 @@ public class Case implements SleuthkitCase.ErrorObserver { private static final Logger logger = Logger.getLogger(Case.class.getName()); static final String CASE_EXTENSION = "aut"; //NON-NLS static final String CASE_DOT_EXTENSION = "." + CASE_EXTENSION; + private static String HOSTNAME; + private static String REPORTOUTPUT = "Reports"; + private static String MODULEOUTPUT = "ModuleOutput"; // we cache if the case has data in it yet since a few places ask for it and we dont' need to keep going to DB private boolean hasData = false; @@ -204,6 +210,7 @@ public class Case implements SleuthkitCase.ErrorObserver { this.caseType = type; this.db = db; this.services = new Services(db); + setHostName(); } /** @@ -315,7 +322,7 @@ public class Case implements SleuthkitCase.ErrorObserver { // create case directory if it doesn't already exist. if (new File(caseDir).exists() == false) { - Case.createCaseDirectory(caseDir); + Case.createCaseDirectory(caseDir, caseType); } String configFilePath = caseDir + File.separator + caseName + CASE_DOT_EXTENSION; @@ -738,7 +745,7 @@ public class Case implements SleuthkitCase.ErrorObserver { if (xmlcm == null) { return ""; } else { - return xmlcm.getTempDir(); + return xmlcm.getTempDir(HOSTNAME, caseType); } } @@ -751,7 +758,7 @@ public class Case implements SleuthkitCase.ErrorObserver { if (xmlcm == null) { return ""; } else { - return xmlcm.getCacheDir(); + return xmlcm.getCacheDir(HOSTNAME, caseType); } } @@ -764,7 +771,7 @@ public class Case implements SleuthkitCase.ErrorObserver { if (xmlcm == null) { return ""; } else { - return xmlcm.getExportDir(); + return xmlcm.getExportDir(HOSTNAME, caseType); } } @@ -777,7 +784,7 @@ public class Case implements SleuthkitCase.ErrorObserver { if (xmlcm == null) { return ""; } else { - return xmlcm.getLogDir(); + return xmlcm.getLogDir(HOSTNAME, caseType); } } @@ -808,24 +815,65 @@ public class Case implements SleuthkitCase.ErrorObserver { } /** - * Get absolute module output directory path where modules should save their - * permanent data The directory is a subdirectory of this case dir. + * Get the host output directory path where modules should save their + * permanent data. If single-user case, the directory is a subdirectory of + * the case directory. If multi-user case, the directory is a subdirectory + * of HOSTNAME, which is a subdirectory of the case directory. + * + * @return the path to the host output directory + */ + public String getHostDirectory() { + if (xmlcm == null) { + return ""; + } else { + return xmlcm.getHostPath(HOSTNAME, this.getCaseType()); + } + } + + /** + * Get the reports directory path where modules should save their reports. + * + * @return absolute path to the report output directory + */ + public String getReportDirectory() { + Path thePath = Paths.get(this.getHostDirectory(), REPORTOUTPUT); + if (!thePath.toFile().exists()) { + thePath.toFile().mkdirs(); + } + return thePath.toString(); + } + + /** + * Get module output directory path where modules should save their + * permanent data. * * @return absolute path to the module output dir */ - public String getModulesOutputDirAbsPath() { - return this.getCaseDirectory() + File.separator + getModulesOutputDirRelPath(); + public String getModulesDirectory() { + Path thePath = Paths.get(this.getHostDirectory(), MODULEOUTPUT); + if (!thePath.toFile().exists()) { + thePath.toFile().mkdirs(); + } + return thePath.toString(); } /** * Get relative (with respect to case dir) module output directory path - * where modules should save their permanent data The directory is a + * where modules should save their permanent data. The directory is a * subdirectory of this case dir. * * @return relative path to the module output dir */ - public static String getModulesOutputDirRelPath() { - return "ModuleOutput"; //NON-NLS + public String getModuleOutputDirectoryRelativePath() { + Path thePath; + if (getCaseType() == CaseType.MULTI_USER_CASE) { + thePath = Paths.get(HOSTNAME, MODULEOUTPUT); + } else { + thePath = Paths.get(MODULEOUTPUT); + } + // Do not autocreate this relative path. It will have already been + // created when the case was made. + return thePath.toString(); } /** @@ -1046,8 +1094,8 @@ public class Case implements SleuthkitCase.ErrorObserver { * @throws CaseActionException throw if could not create the case dir * @Deprecated */ - static void createCaseDirectory(String caseDir, String caseName) throws CaseActionException { - createCaseDirectory(caseDir); + static void createCaseDirectory(String caseDir, String caseName, CaseType caseType) throws CaseActionException { + createCaseDirectory(caseDir, caseType); } @@ -1055,10 +1103,10 @@ public class Case implements SleuthkitCase.ErrorObserver { * Create the case directory and its needed subfolders. * * @param caseDir Path to the case directory (typically base + case name) - * + * @param caseType The type of case, single-user or multi-user * @throws CaseActionException throw if could not create the case dir */ - static void createCaseDirectory(String caseDir) throws CaseActionException { + static void createCaseDirectory(String caseDir, CaseType caseType) throws CaseActionException { File caseDirF = new File(caseDir); if (caseDirF.exists()) { @@ -1079,17 +1127,25 @@ public class Case implements SleuthkitCase.ErrorObserver { } // create the folders inside the case directory - result = result && (new File(caseDir + File.separator + XMLCaseManagement.EXPORT_FOLDER_RELPATH)).mkdir() - && (new File(caseDir + File.separator + XMLCaseManagement.LOG_FOLDER_RELPATH)).mkdir() - && (new File(caseDir + File.separator + XMLCaseManagement.TEMP_FOLDER_RELPATH)).mkdir() - && (new File(caseDir + File.separator + XMLCaseManagement.CACHE_FOLDER_RELPATH)).mkdir(); + String hostClause = ""; + if (HOSTNAME == null || HOSTNAME.isEmpty()) { + setHostName(); + } + + if (caseType == CaseType.MULTI_USER_CASE) { + hostClause = File.separator + HOSTNAME; + } + result = result && (new File(caseDir + hostClause + File.separator + XMLCaseManagement.EXPORT_FOLDER_RELPATH)).mkdirs() + && (new File(caseDir + hostClause + File.separator + XMLCaseManagement.LOG_FOLDER_RELPATH)).mkdirs() + && (new File(caseDir + hostClause + File.separator + XMLCaseManagement.TEMP_FOLDER_RELPATH)).mkdirs() + && (new File(caseDir + hostClause + File.separator + XMLCaseManagement.CACHE_FOLDER_RELPATH)).mkdirs(); if (result == false) { throw new CaseActionException( NbBundle.getMessage(Case.class, "Case.createCaseDir.exception.cantCreateCaseDir", caseDir)); } - final String modulesOutDir = caseDir + File.separator + getModulesOutputDirRelPath(); + final String modulesOutDir = caseDir + hostClause + File.separator + MODULEOUTPUT; result = new File(modulesOutDir).mkdir(); if (result == false) { throw new CaseActionException( @@ -1097,6 +1153,14 @@ public class Case implements SleuthkitCase.ErrorObserver { modulesOutDir)); } + final String reportsOutDir = caseDir + hostClause + File.separator + REPORTOUTPUT; + result = new File(reportsOutDir).mkdir(); + if (result == false) { + throw new CaseActionException( + NbBundle.getMessage(Case.class, "Case.createCaseDir.exception.cantCreateReportsDir", + modulesOutDir)); + } + } catch (Exception e) { throw new CaseActionException( NbBundle.getMessage(Case.class, "Case.createCaseDir.exception.gen", caseDir), e); @@ -1171,7 +1235,7 @@ public class Case implements SleuthkitCase.ErrorObserver { * @param openedCase */ private static void checkSubFolders(Case openedCase) { - String modulesOutputDir = openedCase.getModulesOutputDirAbsPath(); + String modulesOutputDir = openedCase.getModulesDirectory(); File modulesOutputDirF = new File(modulesOutputDir); if (!modulesOutputDirF.exists()) { logger.log(Level.INFO, "Creating modules output dir for the case."); //NON-NLS @@ -1283,5 +1347,25 @@ public class Case implements SleuthkitCase.ErrorObserver { } return hasData; } - + + /** + * Set the host name variable. Sometimes the network can be finicky, so the + * answer returned by getHostName() could throw an exception or be null. + * Have it read the environment variable if getHostName() is unsuccessful. + * Also note that some calls into the Case class are static via Case.*, so + * anywhere we use HOSTNAME prior to a Case class being instantiated, we + * must call setHostName() first. + */ + private static void setHostName() { + try { + HOSTNAME = java.net.InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException ex) { + // getLocalHost().getHostName() can fail in some situations. + // Use environment variable if so. + HOSTNAME = System.getenv("COMPUTERNAME"); + } + if (HOSTNAME == null || HOSTNAME.isEmpty()) { + HOSTNAME = System.getenv("COMPUTERNAME"); + } + } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java index cda7baa037..c7cd604622 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java @@ -242,7 +242,7 @@ class NewCaseWizardPanel1 implements WizardDescriptor.ValidatingPanel absFiles; try { SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase(); - absFiles = skCase.findAllFilesWhere("LOWER(name) LIKE '%call_history%' "); //NON-NLS //get exact file names + absFiles = skCase.findAllFilesWhere("LOWER(name) LIKE LOWER('%call_history%') "); //NON-NLS //get exact file names if (absFiles.isEmpty()) { return; } diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java index 1bcd4791c7..b178a11b24 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java @@ -142,8 +142,10 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule { } // Check that we have roughly enough disk space left to complete the operation + // Some network drives always return -1 for free disk space. + // In this case, expect enough space and move on. long freeDiskSpace = IngestServices.getInstance().getFreeDiskSpace(); - if ((file.getSize() * 2) > freeDiskSpace) { + if ((freeDiskSpace!=-1) && ((file.getSize() * 2) > freeDiskSpace)) { logger.log(Level.SEVERE, "PhotoRec error processing {0} with {1} Not enough space on primary disk to carve unallocated space.", // NON-NLS new Object[]{file.getName(), PhotoRecCarverIngestModuleFactory.getModuleName()}); // NON-NLS return IngestModule.ProcessResult.ERROR; @@ -278,7 +280,7 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule { * @throws org.sleuthkit.autopsy.ingest.IngestModule.IngestModuleException */ synchronized static Path createModuleOutputDirectoryForCase() throws IngestModule.IngestModuleException { - Path path = Paths.get(Case.getCurrentCase().getModulesOutputDirAbsPath(), PhotoRecCarverIngestModuleFactory.getModuleName()); + Path path = Paths.get(Case.getCurrentCase().getModulesDirectory(), PhotoRecCarverIngestModuleFactory.getModuleName()); try { Files.createDirectory(path); } diff --git a/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java index 9ccb53ae17..5acbb1dec4 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java @@ -105,8 +105,8 @@ public final class SevenZipIngestModule implements FileIngestModule { final Case currentCase = Case.getCurrentCase(); - moduleDirRelative = Case.getModulesOutputDirRelPath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); - moduleDirAbsolute = currentCase.getModulesOutputDirAbsPath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); + moduleDirRelative = currentCase.getModuleOutputDirectoryRelativePath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); + moduleDirAbsolute = currentCase.getModulesDirectory() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); File unpackDirPathFile = new File(moduleDirAbsolute); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java b/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java index 5099519499..9220227c0d 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java @@ -110,7 +110,7 @@ import org.sleuthkit.datamodel.TskData; DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss"); Date date = new Date(); String dateNoTime = dateFormat.format(date); - this.reportPath = currentCase.getCaseDirectory() + File.separator + REPORTS_DIR + File.separator + currentCase.getName() + " " + dateNoTime + File.separator; + this.reportPath = currentCase.getReportDirectory()+ File.separator + currentCase.getName() + " " + dateNoTime + File.separator; this.errorList = new ArrayList(); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java b/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java index fcabfca3f2..b28539e7ac 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java @@ -89,17 +89,6 @@ public final class ReportWizardAction extends CallableSystemAction implements P if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) { Case newCase = (Case) evt.getNewValue(); setEnabled(newCase != null); - - // Make the cases' Reoports folder, if it doesn't exist - if (newCase != null) { - boolean exists = (new File(newCase.getCaseDirectory() + File.separator + "Reports")).exists(); - if (!exists) { - boolean reportCreate = (new File(newCase.getCaseDirectory() + File.separator + "Reports")).mkdirs(); - if (!reportCreate) { - logger.log(Level.WARNING, "Could not create Reports directory for case. It does not exist."); //NON-NLS - } - } - } } } }); diff --git a/Core/src/org/sleuthkit/autopsy/timeline/actions/SaveSnapshot.java b/Core/src/org/sleuthkit/autopsy/timeline/actions/SaveSnapshot.java index 528a44bacf..7aa0f16eb3 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/actions/SaveSnapshot.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/actions/SaveSnapshot.java @@ -69,7 +69,7 @@ public class SaveSnapshot extends Action { //choose location/name DirectoryChooser fileChooser = new DirectoryChooser(); fileChooser.setTitle(NbBundle.getMessage(this.getClass(), "SaveSnapshot.fileChoose.title.text")); - fileChooser.setInitialDirectory(new File(Case.getCurrentCase().getCaseDirectory() + File.separator + "Reports")); // NON-NLS + fileChooser.setInitialDirectory(new File(Case.getCurrentCase().getReportDirectory())); File outFolder = fileChooser.showDialog(null); if (outFolder == null) { return; diff --git a/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java b/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java index 52af156e35..1595d3808f 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java @@ -107,7 +107,7 @@ public class EventsRepository { public EventsRepository(ReadOnlyObjectProperty currentStateProperty) { //TODO: we should check that case is open, or get passed a case object/directory -jm - this.eventDB = EventDB.getEventDB(Case.getCurrentCase().getCaseDirectory()); + this.eventDB = EventDB.getEventDB(Case.getCurrentCase().getHostDirectory()); idToEventCache = CacheBuilder.newBuilder().maximumSize(5000L).expireAfterAccess(10, TimeUnit.MINUTES).removalListener((RemovalNotification rn) -> { //LOGGER.log(Level.INFO, "evicting event: {0}", rn.toString()); diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java index 03448b3bd4..f73c72a49b 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java @@ -88,7 +88,7 @@ class PerCaseProperties { * @return true if the config exists, false otherwise. */ public synchronized boolean configExists(String moduleName) { - File f = new File(c.getCaseDirectory() + File.separator + moduleName + ".properties"); + File f = new File(c.getHostDirectory() + File.separator + moduleName + ".properties"); // NON-NLS return f.exists(); } @@ -114,7 +114,7 @@ class PerCaseProperties { * file doesn't exist. */ private synchronized String getPropertyPath(String moduleName) { - return c.getCaseDirectory() + File.separator + moduleName + ".properties"; //NON-NLS + return c.getHostDirectory() + File.separator + moduleName + ".properties"; //NON-NLS } /** diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java index 01a87bd7eb..cf2748b729 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java @@ -639,7 +639,7 @@ public class Server { logger.log(Level.INFO, "Validating keyword search index location"); //NON-NLS String properIndexPath = getIndexDirPath(theCase); - String legacyIndexPath = theCase.getCaseDirectory() + String legacyIndexPath = theCase.getHostDirectory() + File.separator + "keywordsearch" + File.separator + "data"; //NON-NLS @@ -680,8 +680,8 @@ public class Server { * @return absolute path to index dir */ String getIndexDirPath(Case theCase) { - String indexDir = theCase.getModulesOutputDirAbsPath() - + File.separator + "keywordsearch" + File.separator + "data"; //NON-NLS + String indexDir = theCase.getModulesDirectory() + + File.separator + "keywordsearch" + File.separator + "data"; //NON-NLS return indexDir; } diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java index 1600472f43..fac78fd3aa 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java @@ -209,7 +209,7 @@ public final class RAImageIngestModule implements DataSourceIngestModule { * @return Path to directory */ protected static String getRAOutputPath(Case a_case, String mod) { - String tmpDir = a_case.getModulesOutputDirAbsPath() + File.separator + "RecentActivity" + File.separator + mod; //NON-NLS + String tmpDir = a_case.getModulesDirectory()+ File.separator + "RecentActivity" + File.separator + mod; //NON-NLS File dir = new File(tmpDir); if (dir.exists() == false) { dir.mkdirs(); diff --git a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java index 7101c71dc4..b3400ec623 100644 --- a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java +++ b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java @@ -83,7 +83,7 @@ class ScalpelCarverIngestModule implements FileIngestModule { } // make sure module output directory exists; create it if it doesn't - moduleOutputDirPath = Case.getCurrentCase().getModulesOutputDirAbsPath() + moduleOutputDirPath = Case.getCurrentCase().getModulesDirectory() + File.separator + MODULE_OUTPUT_DIR_NAME; File moduleOutputDir = new File(moduleOutputDirPath); if (!moduleOutputDir.exists()) { diff --git a/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties b/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties index 256e682850..079b38ebea 100644 --- a/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties +++ b/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties @@ -1,5 +1,5 @@ #Updated by build script -#Tue, 28 Apr 2015 18:19:58 -0400 +#Tue, 12 May 2015 16:43:39 -0400 LBL_splash_window_title=Starting Autopsy SPLASH_HEIGHT=314 SPLASH_WIDTH=538 diff --git a/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties b/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties index b8a2cebc1c..1619ec9c99 100644 --- a/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties +++ b/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties @@ -1,5 +1,5 @@ #Updated by build script -#Tue, 28 Apr 2015 18:19:58 -0400 +#Tue, 12 May 2015 16:43:39 -0400 CTL_MainWindow_Title=Autopsy 3.1.2 CTL_MainWindow_Title_No_Project=Autopsy 3.1.2 diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java index 790b395c75..08e353896b 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java @@ -252,8 +252,8 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { } public static String getModuleOutputPath() { - String outDir = Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator - + EmailParserModuleFactory.getModuleName(); + String outDir = Case.getCurrentCase().getModulesDirectory() + + File.separator + EmailParserModuleFactory.getModuleName(); File dir = new File(outDir); if (dir.exists() == false) { dir.mkdirs(); @@ -262,8 +262,8 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { } public static String getRelModuleOutputPath() { - return Case.getModulesOutputDirRelPath() + File.separator - + EmailParserModuleFactory.getModuleName(); + return Case.getCurrentCase().getModuleOutputDirectoryRelativePath() + + File.separator + EmailParserModuleFactory.getModuleName(); } /** From 94600895d706d312ee9700b76b7c2fd2254bce0e Mon Sep 17 00:00:00 2001 From: Karl Mortensen Date: Thu, 14 May 2015 16:21:40 -0400 Subject: [PATCH 2/6] code review update --- .../actions/OpenOutputFolderAction.java | 2 +- .../sleuthkit/autopsy/casemodule/Case.java | 140 ++++++----- .../autopsy/casemodule/XMLCaseManagement.java | 220 +++++++----------- ...ampleExecutableDataSourceIngestModule.java | 2 +- .../ExternalResultsImporter.java | 2 +- .../PhotoRecCarverFileIngestModule.java | 2 +- .../sevenzip/SevenZipIngestModule.java | 2 +- .../timeline/events/db/EventsRepository.java | 9 +- .../imagegallery/ImageGalleryController.java | 5 +- .../imagegallery/PerCaseProperties.java | 4 +- .../autopsy/keywordsearch/Server.java | 32 +-- .../recentactivity/RAImageIngestModule.java | 2 +- .../netbeans/core/startup/Bundle.properties | 2 +- .../core/windows/view/ui/Bundle.properties | 2 +- .../ThunderbirdMboxFileIngestModule.java | 2 +- 15 files changed, 180 insertions(+), 248 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java b/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java index 668cc30473..9a90fb6c71 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java @@ -48,7 +48,7 @@ public final class OpenOutputFolderAction implements ActionListener { try { File outputDir; if (Case.isCaseOpen()) { - outputDir = new File(Case.getCurrentCase().getHostDirectory()); + outputDir = new File(Case.getCurrentCase().getOutputDirectory()); if (outputDir.exists() == false) { NotifyDescriptor d = new NotifyDescriptor.Message(NbBundle.getMessage(this.getClass(), diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 6946d17405..46bce9d07d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -75,7 +75,7 @@ public class Case implements SleuthkitCase.ErrorObserver { private static final String autopsyVer = Version.getVersion(); // current version of autopsy. Change it when the version is changed private static final String EVENT_CHANNEL_NAME = "%s-Case-Events"; private static String appName = null; - + /** * Name for the property that determines whether to show the dialog at * startup @@ -192,10 +192,15 @@ public class Case implements SleuthkitCase.ErrorObserver { private static final Logger logger = Logger.getLogger(Case.class.getName()); static final String CASE_EXTENSION = "aut"; //NON-NLS static final String CASE_DOT_EXTENSION = "." + CASE_EXTENSION; - private static String HOSTNAME; - private static String REPORTOUTPUT = "Reports"; - private static String MODULEOUTPUT = "ModuleOutput"; + private static String HostName; + private final static String CACHE_FOLDER = "Cache"; //NON-NLS + private final static String EXPORT_FOLDER = "Export"; //NON-NLS + private final static String LOG_FOLDER = "Log"; //NON-NLS + private final static String MODULE_FOLDER = "ModuleOutput"; //NON-NLS + private final static String REPORTS_FOLDER = "Reports"; //NON-NLS + private final static String TEMP_FOLDER = "Temp"; //NON-NLS + // we cache if the case has data in it yet since a few places ask for it and we dont' need to keep going to DB private boolean hasData = false; @@ -744,55 +749,59 @@ public class Case implements SleuthkitCase.ErrorObserver { } /** - * Gets the full path to the temp directory of this case + * Gets the full path to the temp directory of this case. Will create it if + * it does not already exist. * * @return tempDirectoryPath */ public String getTempDirectory() { - if (xmlcm == null) { - return ""; - } else { - return xmlcm.getTempDir(HOSTNAME, caseType); + File tempPath = new File(getHostDirectory() + File.separator + TEMP_FOLDER); + if (!tempPath.exists()) { + tempPath.mkdirs(); } + return tempPath.toString(); } /** - * Gets the full path to the cache directory of this case + * Gets the full path to the cache directory of this case. Will create it if + * it does not already exist. * * @return cacheDirectoryPath */ public String getCacheDirectory() { - if (xmlcm == null) { - return ""; - } else { - return xmlcm.getCacheDir(HOSTNAME, caseType); + File cachePath = new File(getHostDirectory() + File.separator + CACHE_FOLDER); + if (!cachePath.exists()) { + cachePath.mkdirs(); } + return cachePath.toString(); } /** - * Gets the full path to the export directory of this case + * Gets the full path to the export directory of this case. Will create it + * if it does not already exist. * - * @return export DirectoryPath + * @return exportDirectoryPath */ public String getExportDirectory() { - if (xmlcm == null) { - return ""; - } else { - return xmlcm.getExportDir(HOSTNAME, caseType); + File exportPath = new File(getHostDirectory() + File.separator + EXPORT_FOLDER); + if (!exportPath.exists()) { + exportPath.mkdirs(); } + return exportPath.toString(); } /** - * Gets the full path to the log directory for this case. + * Gets the full path to the log directory of this case. Will create it if + * it does not already exist. * - * @return The log directory path. + * @return logDirectoryPath */ public String getLogDirectoryPath() { - if (xmlcm == null) { - return ""; - } else { - return xmlcm.getLogDir(HOSTNAME, caseType); + File logPath = new File(getHostDirectory() + File.separator + LOG_FOLDER); + if (!logPath.exists()) { + logPath.mkdirs(); } + return logPath.toString(); } /** @@ -823,31 +832,51 @@ public class Case implements SleuthkitCase.ErrorObserver { /** * Get the host output directory path where modules should save their - * permanent data. If single-user case, the directory is a subdirectory of - * the case directory. If multi-user case, the directory is a subdirectory - * of HOSTNAME, which is a subdirectory of the case directory. + * permanent data. If single-user case, the directory is a subdirectory of + * the case directory. If multi-user case, the directory is a subdirectory + * of HostName, which is a subdirectory of the case directory. * * @return the path to the host output directory */ public String getHostDirectory() { - if (xmlcm == null) { - return ""; + String caseDirectory = getCaseDirectory(); + Path hostPath; + if (caseType == CaseType.MULTI_USER_CASE) { + hostPath = Paths.get(caseDirectory, HostName); } else { - return xmlcm.getHostPath(HOSTNAME, this.getCaseType()); + hostPath = Paths.get(caseDirectory); } + if (!hostPath.toFile().exists()) { + hostPath.toFile().mkdirs(); + } + return hostPath.toString(); } + /** + * Get the output directory path where modules should save their + * permanent data. If single-user case, the directory is a subdirectory of + * the case directory. If multi-user case, the directory is a subdirectory + * of HostName, which is a subdirectory of the case directory. + * + * @return the path to the host output directory + */ + public String getOutputDirectory() { + return getHostDirectory(); + } + + /** * Get the reports directory path where modules should save their reports. + * Will create it if it does not already exist. * * @return absolute path to the report output directory */ public String getReportDirectory() { - Path thePath = Paths.get(this.getHostDirectory(), REPORTOUTPUT); - if (!thePath.toFile().exists()) { - thePath.toFile().mkdirs(); + File reportPath = new File(getHostDirectory() + File.separator + REPORTS_FOLDER); + if (!reportPath.exists()) { + reportPath.mkdirs(); } - return thePath.toString(); + return reportPath.toString(); } /** @@ -856,8 +885,8 @@ public class Case implements SleuthkitCase.ErrorObserver { * * @return absolute path to the module output dir */ - public String getModulesDirectory() { - Path thePath = Paths.get(this.getHostDirectory(), MODULEOUTPUT); + public String getModulesOutputDirAbsPath() { + Path thePath = Paths.get(this.getHostDirectory(), MODULE_FOLDER); if (!thePath.toFile().exists()) { thePath.toFile().mkdirs(); } @@ -874,9 +903,9 @@ public class Case implements SleuthkitCase.ErrorObserver { public String getModuleOutputDirectoryRelativePath() { Path thePath; if (getCaseType() == CaseType.MULTI_USER_CASE) { - thePath = Paths.get(HOSTNAME, MODULEOUTPUT); + thePath = Paths.get(HostName, MODULE_FOLDER); } else { - thePath = Paths.get(MODULEOUTPUT); + thePath = Paths.get(MODULE_FOLDER); } // Do not autocreate this relative path. It will have already been // created when the case was made. @@ -1092,19 +1121,6 @@ public class Case implements SleuthkitCase.ErrorObserver { * The methods below are used to manage the case directories (creating, * checking, deleting, etc) */ - /** - * to create the case directory - * - * @param caseDir Path to the case directory (typically base + case name) - * @param caseName the case name (used only for error messages) - * - * @throws CaseActionException throw if could not create the case dir - * @Deprecated - */ - static void createCaseDirectory(String caseDir, String caseName, CaseType caseType) throws CaseActionException { - createCaseDirectory(caseDir, caseType); - - } /** * Create the case directory and its needed subfolders. @@ -1135,12 +1151,12 @@ public class Case implements SleuthkitCase.ErrorObserver { // create the folders inside the case directory String hostClause = ""; - if (HOSTNAME == null || HOSTNAME.isEmpty()) { + if (HostName == null || HostName.isEmpty()) { setHostName(); } if (caseType == CaseType.MULTI_USER_CASE) { - hostClause = File.separator + HOSTNAME; + hostClause = File.separator + HostName; } result = result && (new File(caseDir + hostClause + File.separator + XMLCaseManagement.EXPORT_FOLDER_RELPATH)).mkdirs() && (new File(caseDir + hostClause + File.separator + XMLCaseManagement.LOG_FOLDER_RELPATH)).mkdirs() @@ -1152,7 +1168,7 @@ public class Case implements SleuthkitCase.ErrorObserver { NbBundle.getMessage(Case.class, "Case.createCaseDir.exception.cantCreateCaseDir", caseDir)); } - final String modulesOutDir = caseDir + hostClause + File.separator + MODULEOUTPUT; + final String modulesOutDir = caseDir + hostClause + File.separator + MODULE_FOLDER; result = new File(modulesOutDir).mkdir(); if (result == false) { throw new CaseActionException( @@ -1160,7 +1176,7 @@ public class Case implements SleuthkitCase.ErrorObserver { modulesOutDir)); } - final String reportsOutDir = caseDir + hostClause + File.separator + REPORTOUTPUT; + final String reportsOutDir = caseDir + hostClause + File.separator + REPORTS_FOLDER; result = new File(reportsOutDir).mkdir(); if (result == false) { throw new CaseActionException( @@ -1242,7 +1258,7 @@ public class Case implements SleuthkitCase.ErrorObserver { * @param openedCase */ private static void checkSubFolders(Case openedCase) { - String modulesOutputDir = openedCase.getModulesDirectory(); + String modulesOutputDir = openedCase.getModulesOutputDirAbsPath(); File modulesOutputDirF = new File(modulesOutputDir); if (!modulesOutputDirF.exists()) { logger.log(Level.INFO, "Creating modules output dir for the case."); //NON-NLS @@ -1365,14 +1381,14 @@ public class Case implements SleuthkitCase.ErrorObserver { */ private static void setHostName() { try { - HOSTNAME = java.net.InetAddress.getLocalHost().getHostName(); + HostName = java.net.InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException ex) { // getLocalHost().getHostName() can fail in some situations. // Use environment variable if so. - HOSTNAME = System.getenv("COMPUTERNAME"); + HostName = System.getenv("COMPUTERNAME"); } - if (HOSTNAME == null || HOSTNAME.isEmpty()) { - HOSTNAME = System.getenv("COMPUTERNAME"); + if (HostName == null || HostName.isEmpty()) { + HostName = System.getenv("COMPUTERNAME"); } } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/XMLCaseManagement.java b/Core/src/org/sleuthkit/autopsy/casemodule/XMLCaseManagement.java index c0d3b26329..86b9ddc770 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/XMLCaseManagement.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/XMLCaseManagement.java @@ -19,8 +19,6 @@ package org.sleuthkit.autopsy.casemodule; import java.io.*; -import java.nio.file.Path; -import java.nio.file.Paths; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -87,7 +85,7 @@ import org.xml.sax.SAXException; private String caseName; // case name private String caseNumber; // case number private String examiner; // examiner name - private String schemaVersion = "2.0"; + private String schemaVersion = "1.0"; private String autopsySavedVersion; private CaseType caseType; // The type of case: local or shared private String dbName; // The name of the database @@ -346,17 +344,13 @@ import org.xml.sax.SAXException; * * @return caseDirPath the case directory path */ - public String getCaseDirectory() { - if (doc == null) { - return ""; - } else { - File casePath = new File(caseDirPath); - if (!casePath.exists()) { - casePath.mkdirs(); - } - return caseDirPath; - } - // Note: change this to get the case name from the xml file if needed + public String getCaseDirectory() { + if (doc == null) { + return ""; + } else { + return caseDirPath; + } + // Note: change this to get the case name from the xml file if needed } /** @@ -455,140 +449,82 @@ import org.xml.sax.SAXException; return null; // should throw error or exception } } - - /** - * Get the path to the case, with the host name in it if it's a multi-user - * case, without the host name if it's a single-user case. - * - * @param hostname The host name - * @param caseType The case type - * @return - */ - public String getHostPath(String hostname, CaseType caseType) { - Path thePath; - if (caseType == CaseType.MULTI_USER_CASE) { - thePath = Paths.get(caseDirPath, hostname); - } else { - thePath = Paths.get(caseDirPath); - } - - if (!thePath.toFile().exists()) { - thePath.toFile().mkdirs(); - } - return thePath.toString(); - } - /** - * Gets the full path to the log directory - * - * @param hostname The hostname of this machine - * @param caseType The type of the case. - * @return logDir the full path of the "Log" directory - */ - protected String getLogDir(String hostname, CaseType caseType) { - String thePath = getHostPath(hostname, caseType); - if (doc != null) { - Element logElement = (Element) getCaseElement().getElementsByTagName(LOG_FOLDER_NAME).item(0); - if (logElement.getAttribute(RELATIVE_NAME).equals(RELATIVE_TRUE)) { - thePath += File.separator + logElement.getTextContent(); - } else { - thePath = logElement.getTextContent(); - } - } else { - thePath += File.separator + LOG_FOLDER_RELPATH; - } + /** + * Gets the full path to the log directory + * + * @return logDir the full path of the "Log" directory + */ + protected String getLogDir() { + if (doc != null) { + Element logElement = (Element) getCaseElement().getElementsByTagName(LOG_FOLDER_NAME).item(0); + if (logElement.getAttribute(RELATIVE_NAME).equals(RELATIVE_TRUE)) { + return caseDirPath + File.separator + logElement.getTextContent(); + } else { + return logElement.getTextContent(); + } + } else { + return ""; // should throw error or exception + } + } - File logPath = new File(thePath); - if (!logPath.exists()) { - logPath.mkdirs(); - } - return thePath; - } + /** + * Gets the full path to the temp directory + * + * @return tempDir the full path of the "Temp" directory + */ + protected String getTempDir() { + if (doc != null) { + Element tempElement = (Element) getCaseElement().getElementsByTagName(TEMP_FOLDER_NAME).item(0); + if (tempElement.getAttribute(RELATIVE_NAME).equals(RELATIVE_TRUE)) { + return caseDirPath + File.separator + tempElement.getTextContent(); + } else { + return tempElement.getTextContent(); + } + } else { + return ""; // should throw error or exception + } + } - /** - * Gets the full path to the temp directory - * - * @param hostname The hostname of this machine - * @param caseType The type of the case. - * @return tempDir the full path of the "Temp" directory - */ - protected String getTempDir(String hostname, CaseType caseType) { - String thePath = getHostPath(hostname, caseType); - if (doc != null) { - Element tempElement = (Element) getCaseElement().getElementsByTagName(TEMP_FOLDER_NAME).item(0); - if (tempElement.getAttribute(RELATIVE_NAME).equals(RELATIVE_TRUE)) { - thePath += File.separator + tempElement.getTextContent(); - } else { - thePath = tempElement.getTextContent(); - } - } else { - thePath += File.separator + TEMP_FOLDER_RELPATH; - } + /** + * Gets the full path to the Export directory + * + * @return exportDir the full path of the "Export" directory + */ + protected String getExportDir() { + if (doc != null) { + Element exportElement = (Element) getCaseElement().getElementsByTagName(EXPORT_FOLDER_NAME).item(0); + if (exportElement.getAttribute(RELATIVE_NAME).equals(RELATIVE_TRUE)) { + return caseDirPath + File.separator + exportElement.getTextContent(); + } else { + return exportElement.getTextContent(); + } + } else { + return ""; // should throw error or exception + } + } - File tempPath = new File(thePath); - if (!tempPath.exists()) { - tempPath.mkdirs(); - } - return thePath; - } - - /** - * Gets the full path to the Export directory - * - * @param hostname The hostname of this machine - * @param caseType The type of the case. - * @return exportDir the full path of the "Export" directory - */ - protected String getExportDir(String hostname, CaseType caseType) { - String thePath = getHostPath(hostname, caseType); - if (doc != null) { - Element exportElement = (Element) getCaseElement().getElementsByTagName(EXPORT_FOLDER_NAME).item(0); - if (exportElement.getAttribute(RELATIVE_NAME).equals(RELATIVE_TRUE)) { - thePath += File.separator + exportElement.getTextContent(); - } else { - thePath = exportElement.getTextContent(); - } - } else { - thePath += File.separator + EXPORT_FOLDER_RELPATH; - } - - File exportPath = new File(thePath); - if (!exportPath.exists()) { - exportPath.mkdirs(); - } - return thePath; - } - - /** - * Gets the full path to the Cache directory - * - * @param hostname The hostname of this machine - * @param caseType The type of the case. - * @return cacheDir the full path of the "Cache" directory - */ - protected String getCacheDir(String hostname, CaseType caseType) { - String thePath = getHostPath(hostname, caseType); - if (doc != null) { - Element cacheElement = (Element) getCaseElement().getElementsByTagName(CACHE_FOLDER_NAME).item(0); - if (cacheElement.getAttribute(RELATIVE_NAME).equals(RELATIVE_TRUE)) { - thePath += File.separator + cacheElement.getTextContent(); - } else { - thePath = cacheElement.getTextContent(); - } - } else { - thePath += File.separator + CACHE_FOLDER_RELPATH; - } - - File cachePath = new File(thePath); - if (!cachePath.exists()) { - cachePath.mkdirs(); - } - return thePath; - } + /** + * Gets the full path to the Cache directory + * + * @return cacheDir the full path of the "Cache" directory + */ + protected String getCacheDir() { + if (doc != null) { + Element cacheElement = (Element) getCaseElement().getElementsByTagName(CACHE_FOLDER_NAME).item(0); + if (cacheElement.getAttribute(RELATIVE_NAME).equals(RELATIVE_TRUE)) { + return caseDirPath + File.separator + cacheElement.getTextContent(); + } else { + return cacheElement.getTextContent(); + } + } else { + return ""; // should throw error or exception + } + } /** * Initialize the basic values for a new case management file. Note: this is - * the schema version 2.0 + * the schema version 1.0 * * @param dirPath case directory path * @param caseName the name of the config file to be located in the case @@ -596,7 +532,7 @@ import org.xml.sax.SAXException; * @param examiner examiner for the case (optional, can be empty string * @param caseNumber case number (optional), can be empty * @param dbName the name of the database. Could be a local path, could be - * a Postgres db name. + * a Postgre db name. * @param textIndexName The name of the index where extracted text is stored. */ protected void create(String dirPath, String caseName, String examiner, String caseNumber, CaseType caseType, String dbName, String textIndexName) throws CaseActionException { diff --git a/Core/src/org/sleuthkit/autopsy/examples/SampleExecutableDataSourceIngestModule.java b/Core/src/org/sleuthkit/autopsy/examples/SampleExecutableDataSourceIngestModule.java index 6ce92e6c71..338e881398 100755 --- a/Core/src/org/sleuthkit/autopsy/examples/SampleExecutableDataSourceIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/examples/SampleExecutableDataSourceIngestModule.java @@ -84,7 +84,7 @@ public class SampleExecutableDataSourceIngestModule implements DataSourceIngestM this.context = context; if (refCounter.incrementAndGet(context.getJobId()) == 1) { // Create an output directory for this job. - outputDirPath = Case.getCurrentCase().getModulesDirectory() + File.separator + moduleName; //NON-NLS + outputDirPath = Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator + moduleName; //NON-NLS File outputDir = new File(outputDirPath); if (outputDir.exists() == false) { outputDir.mkdirs(); diff --git a/Core/src/org/sleuthkit/autopsy/externalresults/ExternalResultsImporter.java b/Core/src/org/sleuthkit/autopsy/externalresults/ExternalResultsImporter.java index 1720744ae3..6a1b8b8699 100644 --- a/Core/src/org/sleuthkit/autopsy/externalresults/ExternalResultsImporter.java +++ b/Core/src/org/sleuthkit/autopsy/externalresults/ExternalResultsImporter.java @@ -234,7 +234,7 @@ public final class ExternalResultsImporter { private String getPathRelativeToCaseFolder(String localPath) { String relativePath = ""; - String caseDirectoryPath = Case.getCurrentCase().getHostDirectory(); + String caseDirectoryPath = Case.getCurrentCase().getCaseDirectory(); Path path = Paths.get(localPath); if (path.isAbsolute()) { Path pathBase = Paths.get(caseDirectoryPath); diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java index b178a11b24..a899e8338f 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java @@ -280,7 +280,7 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule { * @throws org.sleuthkit.autopsy.ingest.IngestModule.IngestModuleException */ synchronized static Path createModuleOutputDirectoryForCase() throws IngestModule.IngestModuleException { - Path path = Paths.get(Case.getCurrentCase().getModulesDirectory(), PhotoRecCarverIngestModuleFactory.getModuleName()); + Path path = Paths.get(Case.getCurrentCase().getModulesOutputDirAbsPath(), PhotoRecCarverIngestModuleFactory.getModuleName()); try { Files.createDirectory(path); } diff --git a/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java index 5acbb1dec4..227e545e79 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java @@ -106,7 +106,7 @@ public final class SevenZipIngestModule implements FileIngestModule { final Case currentCase = Case.getCurrentCase(); moduleDirRelative = currentCase.getModuleOutputDirectoryRelativePath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); - moduleDirAbsolute = currentCase.getModulesDirectory() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); + moduleDirAbsolute = currentCase.getModulesOutputDirAbsPath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); File unpackDirPathFile = new File(moduleDirAbsolute); diff --git a/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java b/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java index 1595d3808f..5152962448 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java @@ -22,6 +22,7 @@ import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.cache.RemovalNotification; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -93,6 +94,8 @@ public class EventsRepository { private final LoadingCache> aggregateEventsCache; + private static final String TIMELINE = "Timeline"; + public Interval getBoundingEventsInterval(Interval timeRange, Filter filter) { return eventDB.getBoundingEventsInterval(timeRange, filter); } @@ -107,7 +110,11 @@ public class EventsRepository { public EventsRepository(ReadOnlyObjectProperty currentStateProperty) { //TODO: we should check that case is open, or get passed a case object/directory -jm - this.eventDB = EventDB.getEventDB(Case.getCurrentCase().getHostDirectory()); + File thePath = new File(Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator + TIMELINE); + if (!thePath.exists()) { + thePath.mkdirs(); + } + this.eventDB = EventDB.getEventDB(thePath.toString()); idToEventCache = CacheBuilder.newBuilder().maximumSize(5000L).expireAfterAccess(10, TimeUnit.MINUTES).removalListener((RemovalNotification rn) -> { //LOGGER.log(Level.INFO, "evicting event: {0}", rn.toString()); diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java index 3701e1b228..51acd19ced 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java @@ -19,6 +19,7 @@ package org.sleuthkit.autopsy.imagegallery; import java.beans.PropertyChangeEvent; +import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -84,6 +85,8 @@ public final class ImageGalleryController { private static final Logger LOGGER = Logger.getLogger(ImageGalleryController.class.getName()); + private static final String TIMELINE = "Timeline"; + private final Region infoOverLayBackground = new Region() { { setBackground(new Background(new BackgroundFill(Color.GREY, CornerRadii.EMPTY, Insets.EMPTY))); @@ -332,7 +335,7 @@ public final class ImageGalleryController { */ public synchronized void setCase(Case c) { - this.db = DrawableDB.getDrawableDB(c.getCaseDirectory(), this); + this.db = DrawableDB.getDrawableDB(c.getModulesOutputDirAbsPath() + File.separator + TIMELINE, this); setListeningEnabled(ImageGalleryModule.isEnabledforCase(c)); setStale(ImageGalleryModule.isCaseStale(c)); diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java index f73c72a49b..a6871d1df3 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java @@ -88,7 +88,7 @@ class PerCaseProperties { * @return true if the config exists, false otherwise. */ public synchronized boolean configExists(String moduleName) { - File f = new File(c.getHostDirectory() + File.separator + moduleName + ".properties"); // NON-NLS + File f = new File(getPropertyPath(moduleName)); // NON-NLS return f.exists(); } @@ -114,7 +114,7 @@ class PerCaseProperties { * file doesn't exist. */ private synchronized String getPropertyPath(String moduleName) { - return c.getHostDirectory() + File.separator + moduleName + ".properties"; //NON-NLS + return c.getModulesOutputDirAbsPath() + File.separator + moduleName + File.separator + moduleName + ".properties"; //NON-NLS } /** diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java index cf2748b729..b05d671a1a 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java @@ -625,40 +625,10 @@ public class Server { Case currentCase = Case.getCurrentCase(); - validateIndexLocation(currentCase); - currentCore = openCore(currentCase); serverAction.putValue(CORE_EVT, CORE_EVT_STATES.STARTED); } - /** - * Checks if index dir exists, and moves it to new location if needed (for - * backwards compatibility with older cases) - */ - private void validateIndexLocation(Case theCase) { - logger.log(Level.INFO, "Validating keyword search index location"); //NON-NLS - String properIndexPath = getIndexDirPath(theCase); - - String legacyIndexPath = theCase.getHostDirectory() - + File.separator + "keywordsearch" + File.separator + "data"; //NON-NLS - - - File properIndexDir = new File(properIndexPath); - File legacyIndexDir = new File(legacyIndexPath); - if (!properIndexDir.exists() - && legacyIndexDir.exists() && legacyIndexDir.isDirectory()) { - logger.log(Level.INFO, "Moving keyword search index location from: " //NON-NLS - + legacyIndexPath + " to: " + properIndexPath); //NON-NLS - try { - Files.move(Paths.get(legacyIndexDir.getParent()), Paths.get(properIndexDir.getParent())); - } catch (IOException | SecurityException ex) { - logger.log(Level.WARNING, "Error moving keyword search index folder from: " //NON-NLS - + legacyIndexPath + " to: " + properIndexPath //NON-NLS - + " will recreate a new index.", ex); //NON-NLS - } - } - } - synchronized void closeCore() throws KeywordSearchModuleException { if (currentCore == null) { return; @@ -680,7 +650,7 @@ public class Server { * @return absolute path to index dir */ String getIndexDirPath(Case theCase) { - String indexDir = theCase.getModulesDirectory() + + String indexDir = theCase.getModulesOutputDirAbsPath() + File.separator + "keywordsearch" + File.separator + "data"; //NON-NLS return indexDir; } diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java index fac78fd3aa..6f469e7e9f 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java @@ -209,7 +209,7 @@ public final class RAImageIngestModule implements DataSourceIngestModule { * @return Path to directory */ protected static String getRAOutputPath(Case a_case, String mod) { - String tmpDir = a_case.getModulesDirectory()+ File.separator + "RecentActivity" + File.separator + mod; //NON-NLS + String tmpDir = a_case.getModulesOutputDirAbsPath()+ File.separator + "RecentActivity" + File.separator + mod; //NON-NLS File dir = new File(tmpDir); if (dir.exists() == false) { dir.mkdirs(); diff --git a/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties b/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties index 079b38ebea..4908072385 100644 --- a/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties +++ b/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties @@ -1,5 +1,5 @@ #Updated by build script -#Tue, 12 May 2015 16:43:39 -0400 +#Thu, 14 May 2015 16:14:51 -0400 LBL_splash_window_title=Starting Autopsy SPLASH_HEIGHT=314 SPLASH_WIDTH=538 diff --git a/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties b/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties index 1619ec9c99..5f6cddfc29 100644 --- a/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties +++ b/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties @@ -1,5 +1,5 @@ #Updated by build script -#Tue, 12 May 2015 16:43:39 -0400 +#Thu, 14 May 2015 16:14:51 -0400 CTL_MainWindow_Title=Autopsy 3.1.2 CTL_MainWindow_Title_No_Project=Autopsy 3.1.2 diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java index 08e353896b..6cda07bab1 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java @@ -252,7 +252,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { } public static String getModuleOutputPath() { - String outDir = Case.getCurrentCase().getModulesDirectory() + + String outDir = Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator + EmailParserModuleFactory.getModuleName(); File dir = new File(outDir); if (dir.exists() == false) { From 13acb13ee9b353c1fc61cb665af686398528658e Mon Sep 17 00:00:00 2001 From: Karl Mortensen Date: Thu, 14 May 2015 16:50:35 -0400 Subject: [PATCH 3/6] code review comments --- Core/src/org/sleuthkit/autopsy/casemodule/Case.java | 12 ++++++------ .../modules/sevenzip/SevenZipIngestModule.java | 2 +- .../autopsy/recentactivity/RAImageIngestModule.java | 2 +- .../org/netbeans/core/startup/Bundle.properties | 2 +- .../netbeans/core/windows/view/ui/Bundle.properties | 2 +- .../ThunderbirdMboxFileIngestModule.java | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 46bce9d07d..79c8238bfb 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -75,7 +75,7 @@ public class Case implements SleuthkitCase.ErrorObserver { private static final String autopsyVer = Version.getVersion(); // current version of autopsy. Change it when the version is changed private static final String EVENT_CHANNEL_NAME = "%s-Case-Events"; private static String appName = null; - + /** * Name for the property that determines whether to show the dialog at * startup @@ -886,11 +886,11 @@ public class Case implements SleuthkitCase.ErrorObserver { * @return absolute path to the module output dir */ public String getModulesOutputDirAbsPath() { - Path thePath = Paths.get(this.getHostDirectory(), MODULE_FOLDER); - if (!thePath.toFile().exists()) { - thePath.toFile().mkdirs(); + File modulePath = new File(this.getHostDirectory() + File.separator + MODULE_FOLDER); + if (!modulePath.exists()) { + modulePath.mkdirs(); } - return thePath.toString(); + return modulePath.toString(); } /** @@ -900,7 +900,7 @@ public class Case implements SleuthkitCase.ErrorObserver { * * @return relative path to the module output dir */ - public String getModuleOutputDirectoryRelativePath() { + public String getModulesOutputDirRelPath() { Path thePath; if (getCaseType() == CaseType.MULTI_USER_CASE) { thePath = Paths.get(HostName, MODULE_FOLDER); diff --git a/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java index 227e545e79..ca9bec8d7b 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java @@ -105,7 +105,7 @@ public final class SevenZipIngestModule implements FileIngestModule { final Case currentCase = Case.getCurrentCase(); - moduleDirRelative = currentCase.getModuleOutputDirectoryRelativePath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); + moduleDirRelative = currentCase.getModulesOutputDirRelPath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); moduleDirAbsolute = currentCase.getModulesOutputDirAbsPath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java index 6f469e7e9f..1600472f43 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java @@ -209,7 +209,7 @@ public final class RAImageIngestModule implements DataSourceIngestModule { * @return Path to directory */ protected static String getRAOutputPath(Case a_case, String mod) { - String tmpDir = a_case.getModulesOutputDirAbsPath()+ File.separator + "RecentActivity" + File.separator + mod; //NON-NLS + String tmpDir = a_case.getModulesOutputDirAbsPath() + File.separator + "RecentActivity" + File.separator + mod; //NON-NLS File dir = new File(tmpDir); if (dir.exists() == false) { dir.mkdirs(); diff --git a/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties b/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties index 4908072385..256e682850 100644 --- a/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties +++ b/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties @@ -1,5 +1,5 @@ #Updated by build script -#Thu, 14 May 2015 16:14:51 -0400 +#Tue, 28 Apr 2015 18:19:58 -0400 LBL_splash_window_title=Starting Autopsy SPLASH_HEIGHT=314 SPLASH_WIDTH=538 diff --git a/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties b/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties index 5f6cddfc29..b8a2cebc1c 100644 --- a/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties +++ b/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties @@ -1,5 +1,5 @@ #Updated by build script -#Thu, 14 May 2015 16:14:51 -0400 +#Tue, 28 Apr 2015 18:19:58 -0400 CTL_MainWindow_Title=Autopsy 3.1.2 CTL_MainWindow_Title_No_Project=Autopsy 3.1.2 diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java index 6cda07bab1..c3e2803982 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java @@ -252,8 +252,8 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { } public static String getModuleOutputPath() { - String outDir = Case.getCurrentCase().getModulesOutputDirAbsPath() + - File.separator + EmailParserModuleFactory.getModuleName(); + String outDir = Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator + + EmailParserModuleFactory.getModuleName(); File dir = new File(outDir); if (dir.exists() == false) { dir.mkdirs(); @@ -262,8 +262,8 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { } public static String getRelModuleOutputPath() { - return Case.getCurrentCase().getModuleOutputDirectoryRelativePath() + - File.separator + EmailParserModuleFactory.getModuleName(); + return Case.getCurrentCase().getModulesOutputDirRelPath() + File.separator + + EmailParserModuleFactory.getModuleName(); } /** From 9917381b92c6922c6fe3c733684e2f4fac3aba01 Mon Sep 17 00:00:00 2001 From: Karl Mortensen Date: Thu, 14 May 2015 16:58:20 -0400 Subject: [PATCH 4/6] code review updates --- Core/src/org/sleuthkit/autopsy/casemodule/Case.java | 2 +- .../sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 79c8238bfb..e4bef0cb3f 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -838,7 +838,7 @@ public class Case implements SleuthkitCase.ErrorObserver { * * @return the path to the host output directory */ - public String getHostDirectory() { + private String getHostDirectory() { String caseDirectory = getCaseDirectory(); Path hostPath; if (caseType == CaseType.MULTI_USER_CASE) { diff --git a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java index b3400ec623..7101c71dc4 100644 --- a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java +++ b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java @@ -83,7 +83,7 @@ class ScalpelCarverIngestModule implements FileIngestModule { } // make sure module output directory exists; create it if it doesn't - moduleOutputDirPath = Case.getCurrentCase().getModulesDirectory() + moduleOutputDirPath = Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator + MODULE_OUTPUT_DIR_NAME; File moduleOutputDir = new File(moduleOutputDirPath); if (!moduleOutputDir.exists()) { From 7dff89d8fb4e200efacfd6d9d27580ea088e2b94 Mon Sep 17 00:00:00 2001 From: Karl Mortensen Date: Tue, 19 May 2015 14:57:30 -0400 Subject: [PATCH 5/6] code review comments --- .../autopsy/actions/Bundle.properties | 2 + .../autopsy/actions/OpenLogFolderAction.java | 16 +- .../actions/OpenOutputFolderAction.java | 9 +- .../sleuthkit/autopsy/casemodule/Case.java | 308 +++++++++--------- ...ampleExecutableDataSourceIngestModule.java | 2 +- .../PhotoRecCarverFileIngestModule.java | 2 +- .../sevenzip/SevenZipIngestModule.java | 4 +- .../timeline/events/db/EventsRepository.java | 2 +- .../imagegallery/ImageGalleryController.java | 4 +- .../imagegallery/datamodel/DrawableDB.java | 4 + .../ThunderbirdMboxFileIngestModule.java | 2 +- 11 files changed, 189 insertions(+), 166 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties b/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties index ad546159c7..832079a515 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties @@ -49,10 +49,12 @@ GetTagNameDialog.taggingErr=Tagging Error GetTagNameDialog.tagNameAlreadyDef.msg=A {0} tag name has already been defined. GetTagNameDialog.dupTagErr=Duplicate Tag Error OpenLogFolder.error1=Log File Not Found: {0} +OpenLogFolder.CouldNotOpenLogFolder=Could not open log folder CTL_OpenLogFolder=Open Log Folder CTL_OpenOutputFolder=Open Output Folder OpenOutputFolder.error1=Output Folder Not Found: {0} OpenOutputFolder.noCaseOpen=No open case, therefore no current output folder available. +OpenOutputFolder.CouldNotOpenOutputFolder=Could not open output folder ShowIngestProgressSnapshotAction.actionName.text=Get Ingest Progress Snapshot OpenPythonModulesFolderAction.actionName.text=Python Plugins OpenPythonModulesFolderAction.errorMsg.folderNotFound=Python plugins folder not found: {0} diff --git a/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java b/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java index a1edbe0bd7..9795537f08 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java @@ -23,16 +23,16 @@ import java.awt.event.ActionListener; import java.awt.Desktop; import java.io.File; import java.io.IOException; +import java.util.logging.Level; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; import org.openide.awt.ActionRegistration; import org.openide.modules.Places; -import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; - +import org.sleuthkit.autopsy.coreutils.Logger; /** * Action in menu to open the folder containing the log files @@ -43,19 +43,20 @@ import org.sleuthkit.autopsy.casemodule.Case; @ActionID(id = "org.sleuthkit.autopsy.actions.OpenLogFolderAction", category = "Help") public final class OpenLogFolderAction implements ActionListener { + private static final Logger logger = Logger.getLogger(OpenLogFolderAction.class.getName()); + @Override public void actionPerformed(ActionEvent e) { try { File logDir; if (Case.isCaseOpen()) { logDir = new File(Case.getCurrentCase().getLogDirectoryPath()); - } - else { + } else { logDir = new File(Places.getUserDirectory().getAbsolutePath() + File.separator + "var" + File.separator + "log"); } if (logDir.exists() == false) { - NotifyDescriptor d = - new NotifyDescriptor.Message( + NotifyDescriptor d + = new NotifyDescriptor.Message( NbBundle.getMessage(this.getClass(), "OpenLogFolder.error1", logDir.getAbsolutePath()), NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notify(d); @@ -63,7 +64,8 @@ public final class OpenLogFolderAction implements ActionListener { Desktop.getDesktop().open(logDir); } } catch (IOException ex) { - Exceptions.printStackTrace(ex); + logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "OpenLogFolder.CouldNotOpenLogFolder"), ex); //NON-NLS + } } } diff --git a/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java b/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java index 9a90fb6c71..7152884bbf 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java @@ -23,15 +23,16 @@ import java.awt.event.ActionListener; import java.awt.Desktop; import java.io.File; import java.io.IOException; +import java.util.logging.Level; import javax.swing.JOptionPane; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; import org.openide.awt.ActionRegistration; -import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; +import org.sleuthkit.autopsy.coreutils.Logger; /** * Action in menu to open the folder containing the output files @@ -42,6 +43,8 @@ import org.sleuthkit.autopsy.casemodule.Case; @ActionID(id = "org.sleuthkit.autopsy.actions.OpenOutputFolderAction", category = "Help") public final class OpenOutputFolderAction implements ActionListener { + private static final Logger logger = Logger.getLogger(OpenOutputFolderAction.class.getName()); + @Override public void actionPerformed(ActionEvent e) { @@ -52,7 +55,7 @@ public final class OpenOutputFolderAction implements ActionListener { if (outputDir.exists() == false) { NotifyDescriptor d = new NotifyDescriptor.Message(NbBundle.getMessage(this.getClass(), - "OpenOutputFolder.error1", outputDir.getAbsolutePath()), + "OpenOutputFolder.error1", outputDir.getAbsolutePath()), NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notify(d); } else { @@ -62,7 +65,7 @@ public final class OpenOutputFolderAction implements ActionListener { JOptionPane.showMessageDialog(null, NbBundle.getMessage(this.getClass(), "OpenOutputFolder.noCaseOpen")); } } catch (IOException ex) { - Exceptions.printStackTrace(ex); + logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(),"OpenOutputFolder.CouldNotOpenOutputFolder") , ex); //NON-NLS } } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index e4bef0cb3f..33a2b00386 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -216,7 +216,6 @@ public class Case implements SleuthkitCase.ErrorObserver { this.caseType = type; this.db = db; this.services = new Services(db); - setHostName(); } /** @@ -755,11 +754,7 @@ public class Case implements SleuthkitCase.ErrorObserver { * @return tempDirectoryPath */ public String getTempDirectory() { - File tempPath = new File(getHostDirectory() + File.separator + TEMP_FOLDER); - if (!tempPath.exists()) { - tempPath.mkdirs(); - } - return tempPath.toString(); + return getDirectory(TEMP_FOLDER); } /** @@ -769,11 +764,7 @@ public class Case implements SleuthkitCase.ErrorObserver { * @return cacheDirectoryPath */ public String getCacheDirectory() { - File cachePath = new File(getHostDirectory() + File.separator + CACHE_FOLDER); - if (!cachePath.exists()) { - cachePath.mkdirs(); - } - return cachePath.toString(); + return getDirectory(CACHE_FOLDER); } /** @@ -783,11 +774,7 @@ public class Case implements SleuthkitCase.ErrorObserver { * @return exportDirectoryPath */ public String getExportDirectory() { - File exportPath = new File(getHostDirectory() + File.separator + EXPORT_FOLDER); - if (!exportPath.exists()) { - exportPath.mkdirs(); - } - return exportPath.toString(); + return getDirectory(EXPORT_FOLDER); } /** @@ -797,11 +784,143 @@ public class Case implements SleuthkitCase.ErrorObserver { * @return logDirectoryPath */ public String getLogDirectoryPath() { - File logPath = new File(getHostDirectory() + File.separator + LOG_FOLDER); - if (!logPath.exists()) { - logPath.mkdirs(); + return getDirectory(LOG_FOLDER); + } + + /** + * Get the reports directory path where modules should save their reports. + * Will create it if it does not already exist. + * + * @return absolute path to the report output directory + */ + public String getReportDirectory() { + return getDirectory(REPORTS_FOLDER); + } + + /** + * Get module output directory path where modules should save their + * permanent data. + * + * @return absolute path to the module output directory + */ + public String getModuleDirectory() { + return getDirectory(MODULE_FOLDER); + } + + /** + * Get the output directory path where modules should save their permanent + * data. If single-user case, the directory is a subdirectory of the case + * directory. If multi-user case, the directory is a subdirectory of + * HostName, which is a subdirectory of the case directory. + * + * @return the path to the host output directory + */ + public String getOutputDirectory() { + return getHostDirectory(); + } + + /** + * Get the specified directory path, create it if it does not already exist. + * + * @return absolute path to the directory + */ + private String getDirectory(String input) { + File theDirectory = new File(getHostDirectory() + File.separator + input); + if (!theDirectory.exists()) { // Create it if it doesn't exist already. + theDirectory.mkdirs(); } - return logPath.toString(); + return theDirectory.toString(); + } + + /** + * Get relative (with respect to case dir) module output directory path + * where modules should save their permanent data. The directory is a + * subdirectory of this case dir. + * + * @return relative path to the module output dir + */ + public String getModuleOutputDirectoryRelativePath() { + Path thePath; + if (getCaseType() == CaseType.MULTI_USER_CASE) { + thePath = Paths.get(getLocalHostName(), MODULE_FOLDER); + } else { + thePath = Paths.get(MODULE_FOLDER); + } + // Do not autocreate this relative path. It will have already been + // created when the case was made. + return thePath.toString(); + } + + /** + * Get the host output directory path where modules should save their + * permanent data. If single-user case, the directory is a subdirectory of + * the case directory. If multi-user case, the directory is a subdirectory + * of HostName, which is a subdirectory of the case directory. + * + * @return the path to the host output directory + */ + private String getHostDirectory() { + String caseDirectory = getCaseDirectory(); + Path hostPath; + if (caseType == CaseType.MULTI_USER_CASE) { + hostPath = Paths.get(caseDirectory, getLocalHostName()); + } else { + hostPath = Paths.get(caseDirectory); + } + if (!hostPath.toFile().exists()) { + hostPath.toFile().mkdirs(); + } + return hostPath.toString(); + } + + /** + * Get module output directory path where modules should save their + * permanent data. + * + * @return absolute path to the module output directory + * @deprecated Use getModuleDirectory() instead. + */ + @Deprecated + public String getModulesOutputDirAbsPath() { + return getModuleDirectory(); + } + + /** + * Get relative (with respect to case dir) module output directory path + * where modules should save their permanent data. The directory is a + * subdirectory of this case dir. + * + * @return relative path to the module output dir + * @deprecated Use getModuleOutputDirectoryRelativePath() instead + */ + @Deprecated + public static String getModulesOutputDirRelPath() { + return "ModuleOutput"; //NON-NLS + } + + /** + * Gets a PropertyChangeSupport object. The PropertyChangeSupport object + * returned is not used by instances of this class and does not have any + * PropertyChangeListeners. + * + * @return A new PropertyChangeSupport object. + * @deprecated Do not use. + */ + @Deprecated + public static PropertyChangeSupport getPropertyChangeSupport() { + return new PropertyChangeSupport(Case.class); + } + + /** + * Get the data model Content objects in the root of this case's hierarchy. + * + * @return a list of the root objects + * @throws org.sleuthkit.datamodel.TskCoreException + */ + public List getDataSources() throws TskCoreException { + List list = db.getRootObjects(); + hasData = (list.size() > 0); + return list; } /** @@ -830,113 +949,6 @@ public class Case implements SleuthkitCase.ErrorObserver { } } - /** - * Get the host output directory path where modules should save their - * permanent data. If single-user case, the directory is a subdirectory of - * the case directory. If multi-user case, the directory is a subdirectory - * of HostName, which is a subdirectory of the case directory. - * - * @return the path to the host output directory - */ - private String getHostDirectory() { - String caseDirectory = getCaseDirectory(); - Path hostPath; - if (caseType == CaseType.MULTI_USER_CASE) { - hostPath = Paths.get(caseDirectory, HostName); - } else { - hostPath = Paths.get(caseDirectory); - } - if (!hostPath.toFile().exists()) { - hostPath.toFile().mkdirs(); - } - return hostPath.toString(); - } - - /** - * Get the output directory path where modules should save their - * permanent data. If single-user case, the directory is a subdirectory of - * the case directory. If multi-user case, the directory is a subdirectory - * of HostName, which is a subdirectory of the case directory. - * - * @return the path to the host output directory - */ - public String getOutputDirectory() { - return getHostDirectory(); - } - - - /** - * Get the reports directory path where modules should save their reports. - * Will create it if it does not already exist. - * - * @return absolute path to the report output directory - */ - public String getReportDirectory() { - File reportPath = new File(getHostDirectory() + File.separator + REPORTS_FOLDER); - if (!reportPath.exists()) { - reportPath.mkdirs(); - } - return reportPath.toString(); - } - - /** - * Get module output directory path where modules should save their - * permanent data. - * - * @return absolute path to the module output dir - */ - public String getModulesOutputDirAbsPath() { - File modulePath = new File(this.getHostDirectory() + File.separator + MODULE_FOLDER); - if (!modulePath.exists()) { - modulePath.mkdirs(); - } - return modulePath.toString(); - } - - /** - * Get relative (with respect to case dir) module output directory path - * where modules should save their permanent data. The directory is a - * subdirectory of this case dir. - * - * @return relative path to the module output dir - */ - public String getModulesOutputDirRelPath() { - Path thePath; - if (getCaseType() == CaseType.MULTI_USER_CASE) { - thePath = Paths.get(HostName, MODULE_FOLDER); - } else { - thePath = Paths.get(MODULE_FOLDER); - } - // Do not autocreate this relative path. It will have already been - // created when the case was made. - return thePath.toString(); - } - - /** - * Gets a PropertyChangeSupport object. The PropertyChangeSupport object - * returned is not used by instances of this class and does not have any - * PropertyChangeListeners. - * - * @return A new PropertyChangeSupport object. - * @deprecated Do not use. - */ - @Deprecated - public static PropertyChangeSupport getPropertyChangeSupport() { - return new PropertyChangeSupport(Case.class); - } - - /** - * Get the data model Content objects in the root of this case's hierarchy. - * - * @return a list of the root objects - * @throws org.sleuthkit.datamodel.TskCoreException - */ - public List getDataSources() throws TskCoreException { - List list = db.getRootObjects(); - hasData = (list.size() > 0); - return list; - } - /** * Gets the time zone(s) of the image(s) in this case. * @@ -1150,18 +1162,15 @@ public class Case implements SleuthkitCase.ErrorObserver { } // create the folders inside the case directory - String hostClause = ""; - if (HostName == null || HostName.isEmpty()) { - setHostName(); - } - + String hostClause=""; + if (caseType == CaseType.MULTI_USER_CASE) { - hostClause = File.separator + HostName; + hostClause = File.separator + getLocalHostName(); } - result = result && (new File(caseDir + hostClause + File.separator + XMLCaseManagement.EXPORT_FOLDER_RELPATH)).mkdirs() - && (new File(caseDir + hostClause + File.separator + XMLCaseManagement.LOG_FOLDER_RELPATH)).mkdirs() - && (new File(caseDir + hostClause + File.separator + XMLCaseManagement.TEMP_FOLDER_RELPATH)).mkdirs() - && (new File(caseDir + hostClause + File.separator + XMLCaseManagement.CACHE_FOLDER_RELPATH)).mkdirs(); + result = result && (new File(caseDir + hostClause + File.separator + EXPORT_FOLDER)).mkdirs() + && (new File(caseDir + hostClause + File.separator + LOG_FOLDER)).mkdirs() + && (new File(caseDir + hostClause + File.separator + TEMP_FOLDER)).mkdirs() + && (new File(caseDir + hostClause + File.separator + CACHE_FOLDER)).mkdirs(); if (result == false) { throw new CaseActionException( @@ -1258,7 +1267,7 @@ public class Case implements SleuthkitCase.ErrorObserver { * @param openedCase */ private static void checkSubFolders(Case openedCase) { - String modulesOutputDir = openedCase.getModulesOutputDirAbsPath(); + String modulesOutputDir = openedCase.getModuleDirectory(); File modulesOutputDirF = new File(modulesOutputDir); if (!modulesOutputDirF.exists()) { logger.log(Level.INFO, "Creating modules output dir for the case."); //NON-NLS @@ -1377,18 +1386,21 @@ public class Case implements SleuthkitCase.ErrorObserver { * Have it read the environment variable if getHostName() is unsuccessful. * Also note that some calls into the Case class are static via Case.*, so * anywhere we use HOSTNAME prior to a Case class being instantiated, we - * must call setHostName() first. + * must call getLocalHostName() first. */ - private static void setHostName() { - try { - HostName = java.net.InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException ex) { - // getLocalHost().getHostName() can fail in some situations. - // Use environment variable if so. - HostName = System.getenv("COMPUTERNAME"); - } + private static String getLocalHostName() { if (HostName == null || HostName.isEmpty()) { - HostName = System.getenv("COMPUTERNAME"); + try { + HostName = java.net.InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException ex) { + // getLocalHost().getHostName() can fail in some situations. + // Use environment variable if so. + HostName = System.getenv("COMPUTERNAME"); + } + if (HostName == null || HostName.isEmpty()) { + HostName = System.getenv("COMPUTERNAME"); + } } + return HostName; } } diff --git a/Core/src/org/sleuthkit/autopsy/examples/SampleExecutableDataSourceIngestModule.java b/Core/src/org/sleuthkit/autopsy/examples/SampleExecutableDataSourceIngestModule.java index 338e881398..662dbbfd86 100755 --- a/Core/src/org/sleuthkit/autopsy/examples/SampleExecutableDataSourceIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/examples/SampleExecutableDataSourceIngestModule.java @@ -84,7 +84,7 @@ public class SampleExecutableDataSourceIngestModule implements DataSourceIngestM this.context = context; if (refCounter.incrementAndGet(context.getJobId()) == 1) { // Create an output directory for this job. - outputDirPath = Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator + moduleName; //NON-NLS + outputDirPath = Case.getCurrentCase().getModuleDirectory() + File.separator + moduleName; //NON-NLS File outputDir = new File(outputDirPath); if (outputDir.exists() == false) { outputDir.mkdirs(); diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java index a899e8338f..3e0b096c55 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java @@ -280,7 +280,7 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule { * @throws org.sleuthkit.autopsy.ingest.IngestModule.IngestModuleException */ synchronized static Path createModuleOutputDirectoryForCase() throws IngestModule.IngestModuleException { - Path path = Paths.get(Case.getCurrentCase().getModulesOutputDirAbsPath(), PhotoRecCarverIngestModuleFactory.getModuleName()); + Path path = Paths.get(Case.getCurrentCase().getModuleDirectory(), PhotoRecCarverIngestModuleFactory.getModuleName()); try { Files.createDirectory(path); } diff --git a/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java index ca9bec8d7b..16739e0f8a 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/sevenzip/SevenZipIngestModule.java @@ -105,8 +105,8 @@ public final class SevenZipIngestModule implements FileIngestModule { final Case currentCase = Case.getCurrentCase(); - moduleDirRelative = currentCase.getModulesOutputDirRelPath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); - moduleDirAbsolute = currentCase.getModulesOutputDirAbsPath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); + moduleDirRelative = currentCase.getModuleOutputDirectoryRelativePath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); + moduleDirAbsolute = currentCase.getModuleDirectory() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); File unpackDirPathFile = new File(moduleDirAbsolute); diff --git a/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java b/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java index 5152962448..2d2ec777d9 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/events/db/EventsRepository.java @@ -110,7 +110,7 @@ public class EventsRepository { public EventsRepository(ReadOnlyObjectProperty currentStateProperty) { //TODO: we should check that case is open, or get passed a case object/directory -jm - File thePath = new File(Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator + TIMELINE); + File thePath = new File(Case.getCurrentCase().getModuleDirectory() + File.separator + TIMELINE); if (!thePath.exists()) { thePath.mkdirs(); } diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java index 51acd19ced..0d74a7d2a1 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java @@ -85,7 +85,7 @@ public final class ImageGalleryController { private static final Logger LOGGER = Logger.getLogger(ImageGalleryController.class.getName()); - private static final String TIMELINE = "Timeline"; + private static final String IMAGEGALLERY = "ImageGallery"; private final Region infoOverLayBackground = new Region() { { @@ -335,7 +335,7 @@ public final class ImageGalleryController { */ public synchronized void setCase(Case c) { - this.db = DrawableDB.getDrawableDB(c.getModulesOutputDirAbsPath() + File.separator + TIMELINE, this); + this.db = DrawableDB.getDrawableDB(c.getModulesOutputDirAbsPath() + File.separator + IMAGEGALLERY, this); setListeningEnabled(ImageGalleryModule.isEnabledforCase(c)); setStale(ImageGalleryModule.isCaseStale(c)); diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableDB.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableDB.java index a6762734cc..b77d65f710 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableDB.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableDB.java @@ -278,6 +278,10 @@ public class DrawableDB { public static DrawableDB getDrawableDB(String dbPath, ImageGalleryController controller) { try { + File db = new File(dbPath); + if (!db.exists()) { + db.mkdirs(); + } DrawableDB drawableDB = new DrawableDB(dbPath + File.separator + "drawable.db"); drawableDB.controller = controller; return drawableDB; diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java index c3e2803982..922033f3a1 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java @@ -262,7 +262,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { } public static String getRelModuleOutputPath() { - return Case.getCurrentCase().getModulesOutputDirRelPath() + File.separator + return Case.getCurrentCase().getModuleOutputDirectoryRelativePath() + File.separator + EmailParserModuleFactory.getModuleName(); } From 844e8b0e928cefe018225f3604f996fa66446b6e Mon Sep 17 00:00:00 2001 From: Karl Mortensen Date: Tue, 19 May 2015 15:34:48 -0400 Subject: [PATCH 6/6] code review updates --- .../sleuthkit/autopsy/imagegallery/ImageGalleryController.java | 2 +- .../org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java | 2 +- .../src/org/sleuthkit/autopsy/keywordsearch/Server.java | 2 +- .../sleuthkit/autopsy/recentactivity/RAImageIngestModule.java | 2 +- .../sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java | 2 +- .../thunderbirdparser/ThunderbirdMboxFileIngestModule.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java index 0d74a7d2a1..fb1825605f 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java @@ -335,7 +335,7 @@ public final class ImageGalleryController { */ public synchronized void setCase(Case c) { - this.db = DrawableDB.getDrawableDB(c.getModulesOutputDirAbsPath() + File.separator + IMAGEGALLERY, this); + this.db = DrawableDB.getDrawableDB(c.getModuleDirectory() + File.separator + IMAGEGALLERY, this); setListeningEnabled(ImageGalleryModule.isEnabledforCase(c)); setStale(ImageGalleryModule.isCaseStale(c)); diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java index a6871d1df3..9c709b975c 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/PerCaseProperties.java @@ -114,7 +114,7 @@ class PerCaseProperties { * file doesn't exist. */ private synchronized String getPropertyPath(String moduleName) { - return c.getModulesOutputDirAbsPath() + File.separator + moduleName + File.separator + moduleName + ".properties"; //NON-NLS + return c.getModuleDirectory() + File.separator + moduleName + File.separator + moduleName + ".properties"; //NON-NLS } /** diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java index b05d671a1a..2f6997be76 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java @@ -650,7 +650,7 @@ public class Server { * @return absolute path to index dir */ String getIndexDirPath(Case theCase) { - String indexDir = theCase.getModulesOutputDirAbsPath() + + String indexDir = theCase.getModuleDirectory() + File.separator + "keywordsearch" + File.separator + "data"; //NON-NLS return indexDir; } diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java index 1600472f43..5af9fa15ae 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java @@ -209,7 +209,7 @@ public final class RAImageIngestModule implements DataSourceIngestModule { * @return Path to directory */ protected static String getRAOutputPath(Case a_case, String mod) { - String tmpDir = a_case.getModulesOutputDirAbsPath() + File.separator + "RecentActivity" + File.separator + mod; //NON-NLS + String tmpDir = a_case.getModuleDirectory() + File.separator + "RecentActivity" + File.separator + mod; //NON-NLS File dir = new File(tmpDir); if (dir.exists() == false) { dir.mkdirs(); diff --git a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java index 7101c71dc4..d6318a02de 100644 --- a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java +++ b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/ScalpelCarverIngestModule.java @@ -83,7 +83,7 @@ class ScalpelCarverIngestModule implements FileIngestModule { } // make sure module output directory exists; create it if it doesn't - moduleOutputDirPath = Case.getCurrentCase().getModulesOutputDirAbsPath() + moduleOutputDirPath = Case.getCurrentCase().getModuleDirectory() + File.separator + MODULE_OUTPUT_DIR_NAME; File moduleOutputDir = new File(moduleOutputDirPath); if (!moduleOutputDir.exists()) { diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java index 922033f3a1..aea6a8356a 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java @@ -252,7 +252,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { } public static String getModuleOutputPath() { - String outDir = Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator + String outDir = Case.getCurrentCase().getModuleDirectory() + File.separator + EmailParserModuleFactory.getModuleName(); File dir = new File(outDir); if (dir.exists() == false) {