Import updates

This commit is contained in:
Karl Mortensen 2015-08-04 17:55:46 -04:00
parent 60d291a185
commit 1f93a32f55
3 changed files with 68 additions and 54 deletions

View File

@ -45,7 +45,9 @@ import javax.swing.JOptionPane;
import static javax.swing.JOptionPane.OK_CANCEL_OPTION; import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case.CaseType; import org.sleuthkit.autopsy.casemodule.Case.CaseType;
@ -73,7 +75,8 @@ public class SingleUserCaseImporter implements Runnable {
private final static String AIM_LOG_FILE_NAME = "auto_ingest_log.txt"; //NON-NLS private final static String AIM_LOG_FILE_NAME = "auto_ingest_log.txt"; //NON-NLS
private static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(logDateFormat); private static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(logDateFormat);
private static final int MAX_DB_NAME_LENGTH = 63; private static final int MAX_DB_NAME_LENGTH = 63;
final String SEP = System.getProperty("line.separator"); private final String SEP = System.getProperty("line.separator");
private final Object threadWaitNotifyLock = new Object();
private final Path caseInputFolder; private final Path caseInputFolder;
private final String caseOutputFolder; private final String caseOutputFolder;
@ -88,6 +91,7 @@ public class SingleUserCaseImporter implements Runnable {
private XMLCaseManagement oldXmlCaseManagement; private XMLCaseManagement oldXmlCaseManagement;
private XMLCaseManagement newXmlCaseManagement; private XMLCaseManagement newXmlCaseManagement;
private boolean addTimestamp; private boolean addTimestamp;
private int userAnswer = 0;
/** /**
* SingleUserCaseImporter constructor * SingleUserCaseImporter constructor
@ -119,6 +123,45 @@ public class SingleUserCaseImporter implements Runnable {
this.addTimestamp = addTimestamp; this.addTimestamp = addTimestamp;
} }
/**
* Tests if the input path has a corresponding image input folder and no
* repeated case names in the path. If both of these conditions are true, we
* can process this case, otherwise we can not.
*
* @param icd the import case data for the current case
* @return true if we can process it, false if not
*/
private boolean canProcess(ImportCaseData icd) {
try {
String relativeCaseName = TimeStampUtils.removeTimeStamp(icd.getRelativeCaseName());
String caseName = TimeStampUtils.removeTimeStamp(icd.getOldCaseName());
// check for image folder
Path testImageInputsFromOldCase = Paths.get(imageInputFolder, relativeCaseName);
if (!testImageInputsFromOldCase.toFile().isDirectory()) {
log(testImageInputsFromOldCase.toString() + " has no corresponding images folder. Not able to process.");
return false;
} else {
icd.setSpecificImageInputFolder(testImageInputsFromOldCase);
}
Path imagePath = Paths.get(imageInputFolder);
// see if case name is in the image path. This causes bad things to happen with the parsing.
for (int x = 0; x < imagePath.getNameCount(); ++x) {
if (caseName.toLowerCase().equals(imagePath.getName(x).toString().toLowerCase())) {
log(imagePath.toString() + " has case name \"" + caseName + "\" within path. Not able to process.");
return false;
}
}
} catch (Exception ex) {
log(ex.getMessage());
return false; // anything goes wrong, bail.
}
return true;
}
/** /**
* Handles most of the heavy lifting for importing cases from single-user to * Handles most of the heavy lifting for importing cases from single-user to
* multi-user. Creates new .aut file, moves folders to the right place, * multi-user. Creates new .aut file, moves folders to the right place,
@ -1192,49 +1235,6 @@ public class SingleUserCaseImporter implements Runnable {
} }
} }
/**
* Tests if the input path has a corresponding image input folder and no
* repeated case names in the path. If both of these conditions are true, we
* can process this case, otherwise we can not.
*
* @param icd the import case data for the current case
* @return true if we can process it, false if not
*/
private boolean canProcess(ImportCaseData icd) {
try {
String relativeCaseName = TimeStampUtils.removeTimeStamp(icd.getRelativeCaseName());
String caseName = TimeStampUtils.removeTimeStamp(icd.getOldCaseName());
// check for image folder
Path testImageInputsFromOldCase = Paths.get(imageInputFolder, relativeCaseName);
if (!testImageInputsFromOldCase.toFile().isDirectory()) {
log(testImageInputsFromOldCase.toString() + " has no corresponding images folder. Not able to process.");
return false;
} else {
icd.setSpecificImageInputFolder(testImageInputsFromOldCase);
}
// see if case name is repeated in the path. This causes bad things to happen with the parsing.
int hits = 0;
for (int x = 0; x < testImageInputsFromOldCase.getNameCount(); ++x) {
if (caseName.toLowerCase().equals(testImageInputsFromOldCase.getName(x).toString().toLowerCase())) {
++hits;
}
}
if (hits > 1) {
log(testImageInputsFromOldCase.toString() + " has case name \"" + caseName + "\" repeated within path. Not able to process.");
return false;
}
} catch (Exception ex) {
log(ex.getMessage());
return false; // anything goes wrong, bail.
}
return true;
}
private class ImportCaseData { private class ImportCaseData {
private Path specificCaseInputFolder; private Path specificCaseInputFolder;
@ -1372,11 +1372,25 @@ public class SingleUserCaseImporter implements Runnable {
} }
}; };
int answer = JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(), SwingUtilities.invokeLater(() -> {
jsp, userAnswer = JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(),
NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.ContinueWithImport"), // NON-NLS jsp,
OK_CANCEL_OPTION); NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.ContinueWithImport"), // NON-NLS
if (answer == JOptionPane.OK_OPTION) { OK_CANCEL_OPTION);
synchronized (threadWaitNotifyLock) {
threadWaitNotifyLock.notify();
}
});
synchronized (threadWaitNotifyLock) {
try {
threadWaitNotifyLock.wait();
} catch (InterruptedException ex) {
log("Unable to wait for user input");
}
}
if (userAnswer == JOptionPane.OK_OPTION) {
// feed .aut files in one by one for processing // feed .aut files in one by one for processing
for (ImportCaseData icd : ableToProcess) { for (ImportCaseData icd : ableToProcess) {
if (false == processCase(icd)) { if (false == processCase(icd)) {

View File

@ -1,5 +1,5 @@
#Updated by build script #Updated by build script
#Thu, 25 Jun 2015 13:09:21 -0400 #Tue, 04 Aug 2015 17:44:38 -0400
LBL_splash_window_title=Starting Autopsy LBL_splash_window_title=Starting Autopsy
SPLASH_HEIGHT=314 SPLASH_HEIGHT=314
SPLASH_WIDTH=538 SPLASH_WIDTH=538
@ -8,4 +8,4 @@ SplashRunningTextBounds=0,289,538,18
SplashRunningTextColor=0x0 SplashRunningTextColor=0x0
SplashRunningTextFontSize=19 SplashRunningTextFontSize=19
currentVersion=Autopsy 3.1.2 currentVersion=Autopsy 3.1.3

View File

@ -1,5 +1,5 @@
#Updated by build script #Updated by build script
#Thu, 25 Jun 2015 13:09:21 -0400 #Tue, 04 Aug 2015 17:44:38 -0400
CTL_MainWindow_Title=Autopsy 3.1.2 CTL_MainWindow_Title=Autopsy 3.1.3
CTL_MainWindow_Title_No_Project=Autopsy 3.1.2 CTL_MainWindow_Title_No_Project=Autopsy 3.1.3