23 package org.sleuthkit.autopsy.report.modules.bodyfile;
26 import java.io.BufferedWriter;
27 import java.io.FileWriter;
28 import java.io.IOException;
29 import java.util.List;
30 import java.util.logging.Level;
31 import javax.swing.JPanel;
33 import org.openide.util.NbBundle;
50 private static BodyFileReport instance = null;
52 private Case currentCase;
53 private SleuthkitCase skCase;
55 private String reportPath;
58 private BodyFileReport() {
62 public static synchronized BodyFileReport getDefault() {
63 if (instance == null) {
64 instance =
new BodyFileReport();
76 @SuppressWarnings(
"deprecation")
82 logger.log(Level.SEVERE,
"Exception while getting open case.", ex);
86 progressPanel.
start();
87 progressPanel.
updateStatusLabel(NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.querying"));
88 reportPath = baseReportDir + getRelativeFilePath();
95 final String query =
"type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType()
96 +
" AND name != '.' AND name != '..'";
98 progressPanel.
updateStatusLabel(NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.loading"));
99 List<AbstractFile> fs = skCase.findAllFilesWhere(query);
102 String ingestwarning =
"";
104 ingestwarning = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.ingestWarning.text");
107 int size = fs.size();
110 BufferedWriter out = null;
113 out =
new BufferedWriter(
new FileWriter(reportPath,
true));
114 out.write(ingestwarning);
117 for (AbstractFile file : fs) {
121 if (count++ == 100) {
124 NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.processing",
129 if (file.getMd5Hash() != null) {
130 out.write(file.getMd5Hash());
133 if (file.getUniquePath() != null) {
134 out.write(file.getUniquePath());
137 out.write(Long.toString(file.getMetaAddr()));
139 String modeString = file.getModesAsString();
140 if (modeString != null) {
141 out.write(modeString);
144 out.write(Long.toString(file.getUid()));
146 out.write(Long.toString(file.getGid()));
148 out.write(Long.toString(file.getSize()));
150 out.write(Long.toString(file.getAtime()));
152 out.write(Long.toString(file.getMtime()));
154 out.write(Long.toString(file.getCtime()));
156 out.write(Long.toString(file.getCrtime()));
159 }
catch (IOException ex) {
160 logger.log(Level.WARNING,
"Could not write the temp body file report.", ex);
167 NbBundle.getMessage(
this.getClass(),
168 "ReportBodyFile.generateReport.srcModuleName.text"),
"");
171 }
catch (IOException ex) {
172 logger.log(Level.WARNING,
"Could not flush and close the BufferedWriter.", ex);
174 String errorMessage = String.format(
"Error adding %s to case as a report", reportPath);
175 logger.log(Level.SEVERE, errorMessage, ex);
179 }
catch (TskCoreException ex) {
180 logger.log(Level.WARNING,
"Failed to get the unique path.", ex);
185 public String getName() {
186 String name = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getName.text");
191 public String getRelativeFilePath() {
192 return NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getFilePath.text");
196 public String getDescription() {
197 String desc = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getDesc.text");
202 public JPanel getConfigurationPanel() {
static synchronized IngestManager getInstance()
void complete(ReportStatus reportStatus)
boolean isIngestRunning()
void addReport(String localPath, String srcModuleName, String reportName)
void setIndeterminate(boolean indeterminate)
void setMaximumProgress(int max)
SleuthkitCase getSleuthkitCase()
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
void updateStatusLabel(String statusMessage)