Merge pull request #1245 from karlmortensen/output_paths

update paths for collab
This commit is contained in:
Richard Cordovano 2015-05-19 16:07:30 -04:00
commit 0ce75e3e8b
22 changed files with 311 additions and 145 deletions

View File

@ -49,7 +49,12 @@ GetTagNameDialog.taggingErr=Tagging Error
GetTagNameDialog.tagNameAlreadyDef.msg=A {0} tag name has already been defined. GetTagNameDialog.tagNameAlreadyDef.msg=A {0} tag name has already been defined.
GetTagNameDialog.dupTagErr=Duplicate Tag Error GetTagNameDialog.dupTagErr=Duplicate Tag Error
OpenLogFolder.error1=Log File Not Found: {0} OpenLogFolder.error1=Log File Not Found: {0}
OpenLogFolder.CouldNotOpenLogFolder=Could not open log folder
CTL_OpenLogFolder=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 ShowIngestProgressSnapshotAction.actionName.text=Get Ingest Progress Snapshot
OpenPythonModulesFolderAction.actionName.text=Python Plugins OpenPythonModulesFolderAction.actionName.text=Python Plugins
OpenPythonModulesFolderAction.errorMsg.folderNotFound=Python plugins folder not found: {0} OpenPythonModulesFolderAction.errorMsg.folderNotFound=Python plugins folder not found: {0}

View File

@ -23,16 +23,16 @@ import java.awt.event.ActionListener;
import java.awt.Desktop; import java.awt.Desktop;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level;
import org.openide.DialogDisplayer; import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor; import org.openide.NotifyDescriptor;
import org.openide.awt.ActionID; import org.openide.awt.ActionID;
import org.openide.awt.ActionReference; import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration; import org.openide.awt.ActionRegistration;
import org.openide.modules.Places; import org.openide.modules.Places;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.Logger;
/** /**
* Action in menu to open the folder containing the log files * 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") @ActionID(id = "org.sleuthkit.autopsy.actions.OpenLogFolderAction", category = "Help")
public final class OpenLogFolderAction implements ActionListener { public final class OpenLogFolderAction implements ActionListener {
private static final Logger logger = Logger.getLogger(OpenLogFolderAction.class.getName());
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try { try {
File logDir; File logDir;
if (Case.isCaseOpen()) { if (Case.isCaseOpen()) {
logDir = new File(Case.getCurrentCase().getLogDirectoryPath()); logDir = new File(Case.getCurrentCase().getLogDirectoryPath());
} } else {
else {
logDir = new File(Places.getUserDirectory().getAbsolutePath() + File.separator + "var" + File.separator + "log"); logDir = new File(Places.getUserDirectory().getAbsolutePath() + File.separator + "var" + File.separator + "log");
} }
if (logDir.exists() == false) { if (logDir.exists() == false) {
NotifyDescriptor d = NotifyDescriptor d
new NotifyDescriptor.Message( = new NotifyDescriptor.Message(
NbBundle.getMessage(this.getClass(), "OpenLogFolder.error1", logDir.getAbsolutePath()), NbBundle.getMessage(this.getClass(), "OpenLogFolder.error1", logDir.getAbsolutePath()),
NotifyDescriptor.ERROR_MESSAGE); NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(d); DialogDisplayer.getDefault().notify(d);
@ -63,7 +64,8 @@ public final class OpenLogFolderAction implements ActionListener {
Desktop.getDesktop().open(logDir); Desktop.getDesktop().open(logDir);
} }
} catch (IOException ex) { } catch (IOException ex) {
Exceptions.printStackTrace(ex); logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "OpenLogFolder.CouldNotOpenLogFolder"), ex); //NON-NLS
} }
} }
} }

View File

@ -0,0 +1,71 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2015 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> 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 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.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.Logger;
/**
* 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 {
private static final Logger logger = Logger.getLogger(OpenOutputFolderAction.class.getName());
@Override
public void actionPerformed(ActionEvent e) {
try {
File outputDir;
if (Case.isCaseOpen()) {
outputDir = new File(Case.getCurrentCase().getOutputDirectory());
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) {
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(),"OpenOutputFolder.CouldNotOpenOutputFolder") , ex); //NON-NLS
}
}
}

View File

@ -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.cantCreate=Cannot create case dir\: {0}
Case.createCaseDir.exception.cantCreateCaseDir=Could not create case directory\: {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.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.createCaseDir.exception.gen=Could not create case directory\: {0}
Case.OpenEventChannel.FailPopup.ErrMsg=Failed to connect to any other nodes that may be collaborating on this case. Case.OpenEventChannel.FailPopup.ErrMsg=Failed to connect to any other nodes that may be collaborating on this case.
Case.OpenEventChannel.FailPopup.Title=Connection Failure Case.OpenEventChannel.FailPopup.Title=Connection Failure

View File

@ -25,6 +25,9 @@ import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; 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.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -189,7 +192,15 @@ public class Case implements SleuthkitCase.ErrorObserver {
private static final Logger logger = Logger.getLogger(Case.class.getName()); private static final Logger logger = Logger.getLogger(Case.class.getName());
static final String CASE_EXTENSION = "aut"; //NON-NLS static final String CASE_EXTENSION = "aut"; //NON-NLS
static final String CASE_DOT_EXTENSION = "." + CASE_EXTENSION; static final String CASE_DOT_EXTENSION = "." + CASE_EXTENSION;
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 // 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; private boolean hasData = false;
@ -322,7 +333,7 @@ public class Case implements SleuthkitCase.ErrorObserver {
// create case directory if it doesn't already exist. // create case directory if it doesn't already exist.
if (new File(caseDir).exists() == false) { if (new File(caseDir).exists() == false) {
Case.createCaseDirectory(caseDir); Case.createCaseDirectory(caseDir, caseType);
} }
String configFilePath = caseDir + File.separator + caseName + CASE_DOT_EXTENSION; String configFilePath = caseDir + File.separator + caseName + CASE_DOT_EXTENSION;
@ -737,100 +748,152 @@ 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 * @return tempDirectoryPath
*/ */
public String getTempDirectory() { public String getTempDirectory() {
if (xmlcm == null) { return getDirectory(TEMP_FOLDER);
return "";
} else {
return xmlcm.getTempDir();
}
} }
/** /**
* 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 * @return cacheDirectoryPath
*/ */
public String getCacheDirectory() { public String getCacheDirectory() {
if (xmlcm == null) { return getDirectory(CACHE_FOLDER);
return "";
} else {
return xmlcm.getCacheDir();
}
} }
/** /**
* 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() { public String getExportDirectory() {
if (xmlcm == null) { return getDirectory(EXPORT_FOLDER);
return "";
} else {
return xmlcm.getExportDir();
}
} }
/** /**
* 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() { public String getLogDirectoryPath() {
if (xmlcm == null) { return getDirectory(LOG_FOLDER);
return "";
} else {
return xmlcm.getLogDir();
}
} }
/** /**
* get the created date of this case * Get the reports directory path where modules should save their reports.
* Will create it if it does not already exist.
* *
* @return case creation date * @return absolute path to the report output directory
*/ */
public String getCreatedDate() { public String getReportDirectory() {
if (xmlcm == null) { return getDirectory(REPORTS_FOLDER);
return "";
} else {
return xmlcm.getCreatedDate();
}
} }
/** /**
* Get the name of the index where extracted text is stored for the case. * Get module output directory path where modules should save their
* permanent data.
* *
* @return Index name. * @return absolute path to the module output directory
*/ */
public String getTextIndexName() { public String getModuleDirectory() {
if (xmlcm == null) { return getDirectory(MODULE_FOLDER);
return "";
} else {
return xmlcm.getTextIndexName();
}
} }
/** /**
* Get absolute module output directory path where modules should save their * Get the output directory path where modules should save their permanent
* permanent data The directory is a subdirectory of this case dir. * 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 absolute path to the module output dir * @return the path to the host output directory
*/ */
public String getModulesOutputDirAbsPath() { public String getOutputDirectory() {
return this.getCaseDirectory() + File.separator + getModulesOutputDirRelPath(); 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 theDirectory.toString();
} }
/** /**
* Get relative (with respect to case dir) module output directory path * 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. * subdirectory of this case dir.
* *
* @return relative path to the module output 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() { public static String getModulesOutputDirRelPath() {
return "ModuleOutput"; //NON-NLS return "ModuleOutput"; //NON-NLS
} }
@ -860,6 +923,32 @@ public class Case implements SleuthkitCase.ErrorObserver {
return list; return list;
} }
/**
* get the created date of this case
*
* @return case creation date
*/
public String getCreatedDate() {
if (xmlcm == null) {
return "";
} else {
return xmlcm.getCreatedDate();
}
}
/**
* Get the name of the index where extracted text is stored for the case.
*
* @return Index name.
*/
public String getTextIndexName() {
if (xmlcm == null) {
return "";
} else {
return xmlcm.getTextIndexName();
}
}
/** /**
* Gets the time zone(s) of the image(s) in this case. * Gets the time zone(s) of the image(s) in this case.
* *
@ -1044,28 +1133,15 @@ public class Case implements SleuthkitCase.ErrorObserver {
* The methods below are used to manage the case directories (creating, * The methods below are used to manage the case directories (creating,
* checking, deleting, etc) * 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) throws CaseActionException {
createCaseDirectory(caseDir);
}
/** /**
* Create the case directory and its needed subfolders. * Create the case directory and its needed subfolders.
* *
* @param caseDir Path to the case directory (typically base + case name) * @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 * @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); File caseDirF = new File(caseDir);
if (caseDirF.exists()) { if (caseDirF.exists()) {
@ -1086,17 +1162,22 @@ public class Case implements SleuthkitCase.ErrorObserver {
} }
// create the folders inside the case directory // create the folders inside the case directory
result = result && (new File(caseDir + File.separator + XMLCaseManagement.EXPORT_FOLDER_RELPATH)).mkdir() String hostClause="";
&& (new File(caseDir + File.separator + XMLCaseManagement.LOG_FOLDER_RELPATH)).mkdir()
&& (new File(caseDir + File.separator + XMLCaseManagement.TEMP_FOLDER_RELPATH)).mkdir() if (caseType == CaseType.MULTI_USER_CASE) {
&& (new File(caseDir + File.separator + XMLCaseManagement.CACHE_FOLDER_RELPATH)).mkdir(); hostClause = File.separator + getLocalHostName();
}
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) { if (result == false) {
throw new CaseActionException( throw new CaseActionException(
NbBundle.getMessage(Case.class, "Case.createCaseDir.exception.cantCreateCaseDir", caseDir)); NbBundle.getMessage(Case.class, "Case.createCaseDir.exception.cantCreateCaseDir", caseDir));
} }
final String modulesOutDir = caseDir + File.separator + getModulesOutputDirRelPath(); final String modulesOutDir = caseDir + hostClause + File.separator + MODULE_FOLDER;
result = new File(modulesOutDir).mkdir(); result = new File(modulesOutDir).mkdir();
if (result == false) { if (result == false) {
throw new CaseActionException( throw new CaseActionException(
@ -1104,6 +1185,14 @@ public class Case implements SleuthkitCase.ErrorObserver {
modulesOutDir)); modulesOutDir));
} }
final String reportsOutDir = caseDir + hostClause + File.separator + REPORTS_FOLDER;
result = new File(reportsOutDir).mkdir();
if (result == false) {
throw new CaseActionException(
NbBundle.getMessage(Case.class, "Case.createCaseDir.exception.cantCreateReportsDir",
modulesOutDir));
}
} catch (Exception e) { } catch (Exception e) {
throw new CaseActionException( throw new CaseActionException(
NbBundle.getMessage(Case.class, "Case.createCaseDir.exception.gen", caseDir), e); NbBundle.getMessage(Case.class, "Case.createCaseDir.exception.gen", caseDir), e);
@ -1178,7 +1267,7 @@ public class Case implements SleuthkitCase.ErrorObserver {
* @param openedCase * @param openedCase
*/ */
private static void checkSubFolders(Case openedCase) { private static void checkSubFolders(Case openedCase) {
String modulesOutputDir = openedCase.getModulesOutputDirAbsPath(); String modulesOutputDir = openedCase.getModuleDirectory();
File modulesOutputDirF = new File(modulesOutputDir); File modulesOutputDirF = new File(modulesOutputDir);
if (!modulesOutputDirF.exists()) { if (!modulesOutputDirF.exists()) {
logger.log(Level.INFO, "Creating modules output dir for the case."); //NON-NLS logger.log(Level.INFO, "Creating modules output dir for the case."); //NON-NLS
@ -1290,5 +1379,28 @@ public class Case implements SleuthkitCase.ErrorObserver {
} }
return hasData; 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 getLocalHostName() first.
*/
private static String getLocalHostName() {
if (HostName == null || HostName.isEmpty()) {
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;
}
} }

View File

@ -241,7 +241,7 @@ class NewCaseWizardPanel1 implements WizardDescriptor.ValidatingPanel<WizardDesc
if (res2 != null && res2 == DialogDescriptor.YES_OPTION) { if (res2 != null && res2 == DialogDescriptor.YES_OPTION) {
// if user say yes // if user say yes
try { try {
createDirectory(caseDirPath); createDirectory(caseDirPath, getComponent().getCaseType());
} catch (Exception ex) { } catch (Exception ex) {
String errorMsg = NbBundle.getMessage(this.getClass(), String errorMsg = NbBundle.getMessage(this.getClass(),
"NewCaseWizardPanel1.validate.errMsg.cantCreateParDir.msg", "NewCaseWizardPanel1.validate.errMsg.cantCreateParDir.msg",
@ -258,7 +258,7 @@ class NewCaseWizardPanel1 implements WizardDescriptor.ValidatingPanel<WizardDesc
} }
} else { } else {
try { try {
createDirectory(caseDirPath); createDirectory(caseDirPath, getComponent().getCaseType());
} catch (Exception ex) { } catch (Exception ex) {
String errorMsg = NbBundle String errorMsg = NbBundle
.getMessage(this.getClass(), "NewCaseWizardPanel1.validate.errMsg.cantCreateDir"); .getMessage(this.getClass(), "NewCaseWizardPanel1.validate.errMsg.cantCreateDir");
@ -283,11 +283,11 @@ class NewCaseWizardPanel1 implements WizardDescriptor.ValidatingPanel<WizardDesc
/* /*
* create the directory and create a new case * create the directory and create a new case
*/ */
private void createDirectory(final String caseDirPath) throws WizardValidationException { private void createDirectory(final String caseDirPath, CaseType caseType) throws WizardValidationException {
// try to create the directory with the case name in the choosen parent directory // try to create the directory with the case name in the chosen parent directory
boolean success = false; boolean success = false;
try { try {
Case.createCaseDirectory(caseDirPath); Case.createCaseDirectory(caseDirPath, caseType);
success = true; success = true;
} catch (CaseActionException ex) { } catch (CaseActionException ex) {
logger.log(Level.SEVERE, "Could not createDirectory for the case, ", ex); //NON-NLS logger.log(Level.SEVERE, "Could not createDirectory for the case, ", ex); //NON-NLS

View File

@ -122,7 +122,7 @@ import org.sleuthkit.datamodel.VolumeSystem;
} }
}; };
fc.setCurrentDirectory(new File(Case.getCurrentCase().getCaseDirectory() + File.separator + "Export")); fc.setCurrentDirectory(new File(Case.getCurrentCase().getExportDirectory()));
fc.setDialogTitle( fc.setDialogTitle(
NbBundle.getMessage(this.getClass(), "ExtractUnallocAction.dlgTitle.selectDirToSaveTo.msg")); NbBundle.getMessage(this.getClass(), "ExtractUnallocAction.dlgTitle.selectDirToSaveTo.msg"));
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@ -500,7 +500,7 @@ import org.sleuthkit.datamodel.VolumeSystem;
this.ImageId = img.getId(); this.ImageId = img.getId();
this.ImageName = img.getName(); this.ImageName = img.getName();
this.FileName = this.ImageName + "-Unalloc-" + this.ImageId + "-" + 0 + ".dat"; //NON-NLS this.FileName = this.ImageName + "-Unalloc-" + this.ImageId + "-" + 0 + ".dat"; //NON-NLS
this.FileInstance = new File(Case.getCurrentCase().getCaseDirectory() + File.separator + "Export" + File.separator + this.FileName); this.FileInstance = new File(Case.getCurrentCase().getExportDirectory() + File.separator + this.FileName);
this.SizeInBytes = calcSizeInBytes(); this.SizeInBytes = calcSizeInBytes();
} }
@ -520,7 +520,7 @@ import org.sleuthkit.datamodel.VolumeSystem;
this.ImageId = 0; this.ImageId = 0;
} }
this.FileName = this.ImageName + "-Unalloc-" + this.ImageId + "-" + VolumeId + ".dat"; //NON-NLS this.FileName = this.ImageName + "-Unalloc-" + this.ImageId + "-" + VolumeId + ".dat"; //NON-NLS
this.FileInstance = new File(Case.getCurrentCase().getCaseDirectory() + File.separator + "Export" + File.separator + this.FileName); this.FileInstance = new File(Case.getCurrentCase().getExportDirectory() + File.separator + this.FileName);
this.llf = getUnallocFiles(volu); this.llf = getUnallocFiles(volu);
Collections.sort(llf, new SortObjId()); Collections.sort(llf, new SortObjId());
this.SizeInBytes = calcSizeInBytes(); this.SizeInBytes = calcSizeInBytes();

View File

@ -84,7 +84,7 @@ public class SampleExecutableDataSourceIngestModule implements DataSourceIngestM
this.context = context; this.context = context;
if (refCounter.incrementAndGet(context.getJobId()) == 1) { if (refCounter.incrementAndGet(context.getJobId()) == 1) {
// Create an output directory for this job. // 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); File outputDir = new File(outputDirPath);
if (outputDir.exists() == false) { if (outputDir.exists() == false) {
outputDir.mkdirs(); outputDir.mkdirs();

View File

@ -56,7 +56,7 @@ class ContactAnalyzer {
List<AbstractFile> absFiles; List<AbstractFile> absFiles;
try { try {
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase(); 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()) { if (absFiles.isEmpty()) {
return; return;
} }

View File

@ -142,8 +142,10 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule {
} }
// Check that we have roughly enough disk space left to complete the operation // 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(); 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 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 new Object[]{file.getName(), PhotoRecCarverIngestModuleFactory.getModuleName()}); // NON-NLS
return IngestModule.ProcessResult.ERROR; return IngestModule.ProcessResult.ERROR;
@ -278,7 +280,7 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule {
* @throws org.sleuthkit.autopsy.ingest.IngestModule.IngestModuleException * @throws org.sleuthkit.autopsy.ingest.IngestModule.IngestModuleException
*/ */
synchronized static Path createModuleOutputDirectoryForCase() throws 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 { try {
Files.createDirectory(path); Files.createDirectory(path);
} }

View File

@ -105,8 +105,8 @@ public final class SevenZipIngestModule implements FileIngestModule {
final Case currentCase = Case.getCurrentCase(); final Case currentCase = Case.getCurrentCase();
moduleDirRelative = Case.getModulesOutputDirRelPath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); moduleDirRelative = currentCase.getModuleOutputDirectoryRelativePath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName();
moduleDirAbsolute = currentCase.getModulesOutputDirAbsPath() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName(); moduleDirAbsolute = currentCase.getModuleDirectory() + File.separator + ArchiveFileExtractorModuleFactory.getModuleName();
File unpackDirPathFile = new File(moduleDirAbsolute); File unpackDirPathFile = new File(moduleDirAbsolute);

View File

@ -110,7 +110,7 @@ import org.sleuthkit.datamodel.TskData;
DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss"); DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss");
Date date = new Date(); Date date = new Date();
String dateNoTime = dateFormat.format(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<String>(); this.errorList = new ArrayList<String>();

View File

@ -89,17 +89,6 @@ public final class ReportWizardAction extends CallableSystemAction implements P
if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) { if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
Case newCase = (Case) evt.getNewValue(); Case newCase = (Case) evt.getNewValue();
setEnabled(newCase != null); 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
}
}
}
} }
} }
}); });

View File

@ -69,7 +69,7 @@ public class SaveSnapshot extends Action {
//choose location/name //choose location/name
DirectoryChooser fileChooser = new DirectoryChooser(); DirectoryChooser fileChooser = new DirectoryChooser();
fileChooser.setTitle(NbBundle.getMessage(this.getClass(), "SaveSnapshot.fileChoose.title.text")); 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); File outFolder = fileChooser.showDialog(null);
if (outFolder == null) { if (outFolder == null) {
return; return;

View File

@ -22,6 +22,7 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.cache.RemovalNotification; import com.google.common.cache.RemovalNotification;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -93,6 +94,8 @@ public class EventsRepository {
private final LoadingCache<ZoomParams, List<AggregateEvent>> aggregateEventsCache; private final LoadingCache<ZoomParams, List<AggregateEvent>> aggregateEventsCache;
private static final String TIMELINE = "Timeline";
public Interval getBoundingEventsInterval(Interval timeRange, Filter filter) { public Interval getBoundingEventsInterval(Interval timeRange, Filter filter) {
return eventDB.getBoundingEventsInterval(timeRange, filter); return eventDB.getBoundingEventsInterval(timeRange, filter);
} }
@ -107,7 +110,11 @@ public class EventsRepository {
public EventsRepository(ReadOnlyObjectProperty<ZoomParams> currentStateProperty) { public EventsRepository(ReadOnlyObjectProperty<ZoomParams> currentStateProperty) {
//TODO: we should check that case is open, or get passed a case object/directory -jm //TODO: we should check that case is open, or get passed a case object/directory -jm
this.eventDB = EventDB.getEventDB(Case.getCurrentCase().getCaseDirectory()); File thePath = new File(Case.getCurrentCase().getModuleDirectory() + 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<Long, TimeLineEvent> rn) -> { idToEventCache = CacheBuilder.newBuilder().maximumSize(5000L).expireAfterAccess(10, TimeUnit.MINUTES).removalListener((RemovalNotification<Long, TimeLineEvent> rn) -> {
//LOGGER.log(Level.INFO, "evicting event: {0}", rn.toString()); //LOGGER.log(Level.INFO, "evicting event: {0}", rn.toString());

View File

@ -19,6 +19,7 @@
package org.sleuthkit.autopsy.imagegallery; package org.sleuthkit.autopsy.imagegallery;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; 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 Logger LOGGER = Logger.getLogger(ImageGalleryController.class.getName());
private static final String IMAGEGALLERY = "ImageGallery";
private final Region infoOverLayBackground = new Region() { private final Region infoOverLayBackground = new Region() {
{ {
setBackground(new Background(new BackgroundFill(Color.GREY, CornerRadii.EMPTY, Insets.EMPTY))); 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) { public synchronized void setCase(Case c) {
this.db = DrawableDB.getDrawableDB(c.getCaseDirectory(), this); this.db = DrawableDB.getDrawableDB(c.getModuleDirectory() + File.separator + IMAGEGALLERY, this);
setListeningEnabled(ImageGalleryModule.isEnabledforCase(c)); setListeningEnabled(ImageGalleryModule.isEnabledforCase(c));
setStale(ImageGalleryModule.isCaseStale(c)); setStale(ImageGalleryModule.isCaseStale(c));

View File

@ -88,7 +88,7 @@ class PerCaseProperties {
* @return true if the config exists, false otherwise. * @return true if the config exists, false otherwise.
*/ */
public synchronized boolean configExists(String moduleName) { public synchronized boolean configExists(String moduleName) {
File f = new File(c.getCaseDirectory() + File.separator + moduleName + ".properties"); File f = new File(getPropertyPath(moduleName)); // NON-NLS
return f.exists(); return f.exists();
} }
@ -114,7 +114,7 @@ class PerCaseProperties {
* file doesn't exist. * file doesn't exist.
*/ */
private synchronized String getPropertyPath(String moduleName) { private synchronized String getPropertyPath(String moduleName) {
return c.getCaseDirectory() + File.separator + moduleName + ".properties"; //NON-NLS return c.getModuleDirectory() + File.separator + moduleName + File.separator + moduleName + ".properties"; //NON-NLS
} }
/** /**

View File

@ -278,6 +278,10 @@ public class DrawableDB {
public static DrawableDB getDrawableDB(String dbPath, ImageGalleryController controller) { public static DrawableDB getDrawableDB(String dbPath, ImageGalleryController controller) {
try { try {
File db = new File(dbPath);
if (!db.exists()) {
db.mkdirs();
}
DrawableDB drawableDB = new DrawableDB(dbPath + File.separator + "drawable.db"); DrawableDB drawableDB = new DrawableDB(dbPath + File.separator + "drawable.db");
drawableDB.controller = controller; drawableDB.controller = controller;
return drawableDB; return drawableDB;

View File

@ -625,40 +625,10 @@ public class Server {
Case currentCase = Case.getCurrentCase(); Case currentCase = Case.getCurrentCase();
validateIndexLocation(currentCase);
currentCore = openCore(currentCase); currentCore = openCore(currentCase);
serverAction.putValue(CORE_EVT, CORE_EVT_STATES.STARTED); 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.getCaseDirectory()
+ 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 { synchronized void closeCore() throws KeywordSearchModuleException {
if (currentCore == null) { if (currentCore == null) {
return; return;
@ -680,8 +650,8 @@ public class Server {
* @return absolute path to index dir * @return absolute path to index dir
*/ */
String getIndexDirPath(Case theCase) { String getIndexDirPath(Case theCase) {
String indexDir = theCase.getModulesOutputDirAbsPath() String indexDir = theCase.getModuleDirectory() +
+ File.separator + "keywordsearch" + File.separator + "data"; //NON-NLS File.separator + "keywordsearch" + File.separator + "data"; //NON-NLS
return indexDir; return indexDir;
} }

View File

@ -209,7 +209,7 @@ public final class RAImageIngestModule implements DataSourceIngestModule {
* @return Path to directory * @return Path to directory
*/ */
protected static String getRAOutputPath(Case a_case, String mod) { 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); File dir = new File(tmpDir);
if (dir.exists() == false) { if (dir.exists() == false) {
dir.mkdirs(); dir.mkdirs();

View File

@ -83,7 +83,7 @@ class ScalpelCarverIngestModule implements FileIngestModule {
} }
// make sure module output directory exists; create it if it doesn't // 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.separator + MODULE_OUTPUT_DIR_NAME;
File moduleOutputDir = new File(moduleOutputDirPath); File moduleOutputDir = new File(moduleOutputDirPath);
if (!moduleOutputDir.exists()) { if (!moduleOutputDir.exists()) {

View File

@ -252,7 +252,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
} }
public static String getModuleOutputPath() { public static String getModuleOutputPath() {
String outDir = Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator String outDir = Case.getCurrentCase().getModuleDirectory() + File.separator
+ EmailParserModuleFactory.getModuleName(); + EmailParserModuleFactory.getModuleName();
File dir = new File(outDir); File dir = new File(outDir);
if (dir.exists() == false) { if (dir.exists() == false) {
@ -262,7 +262,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
} }
public static String getRelModuleOutputPath() { public static String getRelModuleOutputPath() {
return Case.getModulesOutputDirRelPath() + File.separator return Case.getCurrentCase().getModuleOutputDirectoryRelativePath() + File.separator
+ EmailParserModuleFactory.getModuleName(); + EmailParserModuleFactory.getModuleName();
} }