19 package org.sleuthkit.autopsy.report.uisnapshot;
21 import com.github.mustachejava.DefaultMustacheFactory;
22 import com.github.mustachejava.Mustache;
23 import com.github.mustachejava.MustacheFactory;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.io.InputStreamReader;
27 import java.io.Writer;
28 import java.nio.charset.Charset;
29 import java.nio.file.Files;
30 import java.nio.file.Path;
31 import java.nio.file.Paths;
32 import java.text.SimpleDateFormat;
33 import java.util.Date;
34 import java.util.HashMap;
35 import org.apache.commons.lang3.StringUtils;
48 private final static MustacheFactory
mf =
new DefaultMustacheFactory();
88 Files.createDirectories(reportFolderPath);
142 HashMap<String, Object> indexContext =
new HashMap<>();
143 indexContext.put(
"reportBranding", reportBranding);
144 indexContext.put(
"reportName", reportName);
145 Path reportIndexFile = reportFolderPath.resolve(
"index.html");
147 fillTemplateAndWrite(
"/org/sleuthkit/autopsy/report/uisnapshot/index_template.html",
"Index", indexContext, reportIndexFile);
148 return reportIndexFile;
158 HashMap<String, Object> summaryContext =
new HashMap<>();
159 summaryContext.put(
"reportName", reportName);
160 summaryContext.put(
"reportBranding", reportBranding);
161 summaryContext.put(
"generationDateTime",
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss").format(generationDate));
163 summaryContext.put(
"currentCase", currentCase);
164 String agencyLogo =
"agency_logo.png";
166 agencyLogo = Paths.get(reportBranding.
getAgencyLogoPath()).getFileName().toString();
168 summaryContext.put(
"agencyLogoFileName", agencyLogo);
169 fillTemplateAndWrite(
"/org/sleuthkit/autopsy/report/uisnapshot/summary_template.html",
"Summary", summaryContext, reportFolderPath.resolve(
"summary.html"));
188 protected void fillTemplateAndWrite(
final String templateLocation,
final String templateName, Object context,
final Path outPutFile)
throws IOException {
190 Mustache summaryMustache = mf.compile(
new InputStreamReader(
UiSnapShotReportWriter.class.getResourceAsStream(templateLocation)), templateName);
191 try (Writer writer = Files.newBufferedWriter(outPutFile, Charset.forName(
"UTF-8"))) {
192 summaryMustache.execute(writer, context);
206 if (StringUtils.isNotBlank(generatorLogoPath)) {
207 Files.copy(Files.newInputStream(Paths.get(generatorLogoPath)), reportFolderPath.resolve(
"generator_logo.png"));
210 if (StringUtils.isNotBlank(agencyLogoPath)) {
211 Files.copy(Files.newInputStream(Paths.get(agencyLogoPath)), reportFolderPath.resolve(Paths.get(reportBranding.
getAgencyLogoPath()).getFileName()));
215 if (StringUtils.isBlank(agencyLogoPath)) {
218 Files.copy(Files.newInputStream(Paths.get(agencyLogoPath)), reportFolderPath.resolve(
"favicon.ico"));
238 Files.copy(resource, reportFolderPath.resolve(fileName));
String getAgencyLogoPath()
String getGeneratorLogoPath()
static synchronized IngestManager getInstance()
Path getReportFolderPath()
boolean isIngestRunning()
final ReportBranding reportBranding
UiSnapShotReportWriter(Case currentCase, Path reportFolderPath, String reportName, Date generationDate)
void copyInternalResource(String internalPath, String fileName)
void fillTemplateAndWrite(final String templateLocation, final String templateName, Object context, final Path outPutFile)
final Path reportFolderPath
static final MustacheFactory mf
abstract void writeSnapShotHTMLFile()