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;
43 class ReportBodyFile
implements GeneralReportModule {
44 private static final Logger logger = Logger.getLogger(ReportBodyFile.class.getName());
45 private static ReportBodyFile instance = null;
47 private Case currentCase;
50 private String reportPath;
53 private ReportBodyFile() {
57 public static synchronized ReportBodyFile getDefault() {
58 if (instance == null) {
59 instance =
new ReportBodyFile();
70 @SuppressWarnings(
"deprecation")
71 public
void generateReport(String baseReportDir, ReportProgressPanel progressPanel) {
73 progressPanel.setIndeterminate(
false);
74 progressPanel.start();
75 progressPanel.updateStatusLabel(NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.querying"));
76 reportPath = baseReportDir +
"BodyFile.txt";
77 currentCase = Case.getCurrentCase();
78 skCase = currentCase.getSleuthkitCase();
85 +
" AND name != '.' AND name != '..'";
87 progressPanel.updateStatusLabel(NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.loading"));
91 String ingestwarning =
"";
92 if (IngestManager.getInstance().isIngestRunning()) {
93 ingestwarning = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.ingestWarning.text");
97 progressPanel.setMaximumProgress(size/100);
99 BufferedWriter out = null;
102 out =
new BufferedWriter(
new FileWriter(reportPath,
true));
103 out.write(ingestwarning);
107 if (progressPanel.getStatus() == ReportStatus.CANCELED) {
111 progressPanel.increment();
112 progressPanel.updateStatusLabel(
113 NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.processing",
118 if(file.getMd5Hash()!=null) {
119 out.write(file.getMd5Hash());
122 if(file.getUniquePath()!=null) {
123 out.write(file.getUniquePath());
126 out.write(Long.toString(file.getMetaAddr()));
128 String modeString = file.getModesAsString();
129 if(modeString != null) {
130 out.write(modeString);
133 out.write(Long.toString(file.getUid()));
135 out.write(Long.toString(file.getGid()));
137 out.write(Long.toString(file.getSize()));
139 out.write(Long.toString(file.getAtime()));
141 out.write(Long.toString(file.getMtime()));
143 out.write(Long.toString(file.getCtime()));
145 out.write(Long.toString(file.getCrtime()));
148 }
catch (IOException ex) {
149 logger.log(Level.WARNING,
"Could not write the temp body file report.", ex);
155 Case.getCurrentCase().addReport(reportPath,
156 NbBundle.getMessage(
this.getClass(),
157 "ReportBodyFile.generateReport.srcModuleName.text"),
"");
160 }
catch (IOException ex) {
161 logger.log(Level.WARNING,
"Could not flush and close the BufferedWriter.", ex);
163 String errorMessage = String.format(
"Error adding %s to case as a report", reportPath);
164 logger.log(Level.SEVERE, errorMessage, ex);
167 progressPanel.complete();
169 logger.log(Level.WARNING,
"Failed to get the unique path.", ex);
174 public String getName() {
175 String name = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getName.text");
180 public String getRelativeFilePath() {
181 return NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getFilePath.text");
185 public String getDescription() {
186 String desc = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getDesc.text");
191 public JPanel getConfigurationPanel() {
List< FsContent > findFilesWhere(String sqlWhereClause)