Text FileReport added to databse. Logger format changed

This commit is contained in:
sidheshenator 2015-06-24 15:30:11 -04:00
parent 52c9e16f5a
commit 67ff3ee7cd
3 changed files with 18 additions and 2 deletions

View File

@ -25,6 +25,8 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.InvalidPathException;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
@ -1163,7 +1165,14 @@ public class Case implements SleuthkitCase.ErrorObserver {
* @throws TskCoreException
*/
public void addReport(String localPath, String srcModuleName, String reportName) throws TskCoreException {
Report report = this.db.addReport(localPath, srcModuleName, reportName);
String normalizedLocalPath;
try {
normalizedLocalPath = Paths.get(localPath).normalize().toString();
} catch (InvalidPathException ex) {
logger.log(Level.WARNING, "Invalid local path provided: " + localPath, ex);
normalizedLocalPath = localPath;
}
Report report = this.db.addReport(normalizedLocalPath, srcModuleName, reportName);
try {
Case.pcs.firePropertyChange(Events.REPORT_ADDED.toString(), null, report);
} catch (Exception ex) {

View File

@ -79,7 +79,7 @@ public final class Logger extends java.util.logging.Logger {
+ record.getSourceMethodName() + "\n"
+ record.getLevel() + ": "
+ this.formatMessage(record) + "\n"
+ record.getThrown().toString() + ": "
+ record.getThrown().toString() + ":\n"
+ StackTrace
+ "\n";
} else {

View File

@ -30,7 +30,9 @@ import java.util.logging.Level;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.TskCoreException;
/**
* A Tab-delimited text report of the files in the case.
@ -68,8 +70,13 @@ import org.sleuthkit.datamodel.AbstractFile;
if (out != null) {
try {
out.close();
Case.getCurrentCase().addReport(reportPath, NbBundle.getMessage(this.getClass(),
"FileReportText.getName.text"), "");
} catch (IOException ex) {
logger.log(Level.WARNING, "Could not close output writer when ending report.", ex); //NON-NLS
} catch (TskCoreException ex) {
String errorMessage = String.format("Error adding %s to case as a report", reportPath); //NON-NLS
logger.log(Level.SEVERE, errorMessage, ex);
}
}
}