23 package org.sleuthkit.autopsy.report;
 
   25 import java.io.BufferedWriter;
 
   26 import java.io.FileWriter;
 
   27 import java.io.IOException;
 
   28 import java.util.List;
 
   29 import java.util.logging.Level;
 
   30 import javax.swing.JPanel;
 
   32 import org.openide.util.NbBundle;
 
   44 class ReportBodyFile 
implements GeneralReportModule {
 
   46     private static final Logger logger = Logger.getLogger(ReportBodyFile.class.getName());
 
   47     private static ReportBodyFile instance = null;
 
   49     private Case currentCase;
 
   52     private String reportPath;
 
   55     private ReportBodyFile() {
 
   59     public static synchronized ReportBodyFile getDefault() {
 
   60         if (instance == null) {
 
   61             instance = 
new ReportBodyFile();
 
   73     @SuppressWarnings(
"deprecation")
 
   74     public 
void generateReport(String baseReportDir, ReportProgressPanel progressPanel) {
 
   76         progressPanel.setIndeterminate(
false);
 
   77         progressPanel.start();
 
   78         progressPanel.updateStatusLabel(NbBundle.getMessage(
this.getClass(), 
"ReportBodyFile.progress.querying"));
 
   79         reportPath = baseReportDir + 
"BodyFile.txt"; 
 
   80         currentCase = Case.getCurrentCase();
 
   81         skCase = currentCase.getSleuthkitCase();
 
   87                     + 
" AND name != '.' AND name != '..'"; 
 
   89             progressPanel.updateStatusLabel(NbBundle.getMessage(
this.getClass(), 
"ReportBodyFile.progress.loading"));
 
   93             String ingestwarning = 
"";
 
   94             if (IngestManager.getInstance().isIngestRunning()) {
 
   95                 ingestwarning = NbBundle.getMessage(this.getClass(), 
"ReportBodyFile.ingestWarning.text");
 
   99             progressPanel.setMaximumProgress(size / 100);
 
  101             BufferedWriter out = null;
 
  104                 out = 
new BufferedWriter(
new FileWriter(reportPath, 
true));
 
  105                 out.write(ingestwarning);
 
  109                     if (progressPanel.getStatus() == ReportStatus.CANCELED) {
 
  112                     if (count++ == 100) {
 
  113                         progressPanel.increment();
 
  114                         progressPanel.updateStatusLabel(
 
  115                                 NbBundle.getMessage(
this.getClass(), 
"ReportBodyFile.progress.processing",
 
  120                     if (file.getMd5Hash() != null) {
 
  121                         out.write(file.getMd5Hash());
 
  124                     if (file.getUniquePath() != null) {
 
  125                         out.write(file.getUniquePath());
 
  128                     out.write(Long.toString(file.getMetaAddr()));
 
  130                     String modeString = file.getModesAsString();
 
  131                     if (modeString != null) {
 
  132                         out.write(modeString);
 
  135                     out.write(Long.toString(file.getUid()));
 
  137                     out.write(Long.toString(file.getGid()));
 
  139                     out.write(Long.toString(file.getSize()));
 
  141                     out.write(Long.toString(file.getAtime()));
 
  143                     out.write(Long.toString(file.getMtime()));
 
  145                     out.write(Long.toString(file.getCtime()));
 
  147                     out.write(Long.toString(file.getCrtime()));
 
  150             } 
catch (IOException ex) {
 
  151                 logger.log(Level.WARNING, 
"Could not write the temp body file report.", ex); 
 
  157                         Case.getCurrentCase().addReport(reportPath,
 
  158                                 NbBundle.getMessage(
this.getClass(),
 
  159                                         "ReportBodyFile.generateReport.srcModuleName.text"), 
"");
 
  162                 } 
catch (IOException ex) {
 
  163                     logger.log(Level.WARNING, 
"Could not flush and close the BufferedWriter.", ex); 
 
  165                     String errorMessage = String.format(
"Error adding %s to case as a report", reportPath); 
 
  166                     logger.log(Level.SEVERE, errorMessage, ex);
 
  169             progressPanel.complete(ReportStatus.COMPLETE);
 
  171             logger.log(Level.WARNING, 
"Failed to get the unique path.", ex); 
 
  176     public String getName() {
 
  177         String name = NbBundle.getMessage(this.getClass(), 
"ReportBodyFile.getName.text");
 
  182     public String getRelativeFilePath() {
 
  183         return NbBundle.getMessage(this.getClass(), 
"ReportBodyFile.getFilePath.text");
 
  187     public String getDescription() {
 
  188         String desc = NbBundle.getMessage(this.getClass(), 
"ReportBodyFile.getDesc.text");
 
  193     public JPanel getConfigurationPanel() {
 
List< AbstractFile > findAllFilesWhere(String sqlWhereClause)