19package org.sleuthkit.autopsy.report.uisnapshot;
21import com.github.mustachejava.DefaultMustacheFactory;
22import com.github.mustachejava.Mustache;
23import com.github.mustachejava.MustacheFactory;
24import java.io.IOException;
25import java.io.InputStream;
26import java.io.InputStreamReader;
28import java.nio.charset.Charset;
29import java.nio.file.Files;
30import java.nio.file.Path;
31import java.nio.file.Paths;
32import java.text.SimpleDateFormat;
34import java.util.HashMap;
35import org.apache.commons.lang3.StringUtils;
36import org.sleuthkit.autopsy.casemodule.Case;
37import org.sleuthkit.autopsy.ingest.IngestManager;
38import org.sleuthkit.autopsy.report.ReportBranding;
48 private final static MustacheFactory
mf =
new DefaultMustacheFactory();
140 HashMap<String, Object> indexContext =
new HashMap<>();
145 fillTemplateAndWrite(
"/org/sleuthkit/autopsy/report/uisnapshot/index_template.html",
"Index", indexContext, reportIndexFile);
146 return reportIndexFile;
156 HashMap<String, Object> summaryContext =
new HashMap<>();
159 summaryContext.put(
"generationDateTime",
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss").format(
generationDate));
162 String agencyLogo =
"agency_logo.png";
164 agencyLogo = Paths.get(
reportBranding.getAgencyLogoPath()).getFileName().toString();
166 summaryContext.put(
"agencyLogoFileName", agencyLogo);
186 protected void fillTemplateAndWrite(
final String templateLocation,
final String templateName, Object context,
final Path outPutFile)
throws IOException {
188 Mustache summaryMustache =
mf.compile(
new InputStreamReader(
UiSnapShotReportWriter.class.getResourceAsStream(templateLocation)), templateName);
189 try (Writer writer = Files.newBufferedWriter(outPutFile, Charset.forName(
"UTF-8"))) {
190 summaryMustache.execute(writer, context);
204 if (StringUtils.isNotBlank(generatorLogoPath)) {
205 Files.copy(Files.newInputStream(Paths.get(generatorLogoPath)),
reportFolderPath.resolve(
"generator_logo.png"));
208 if (StringUtils.isNotBlank(agencyLogoPath)) {
209 Files.copy(Files.newInputStream(Paths.get(agencyLogoPath)),
reportFolderPath.resolve(Paths.get(
reportBranding.getAgencyLogoPath()).getFileName()));
213 if (StringUtils.isBlank(agencyLogoPath)) {
216 Files.copy(Files.newInputStream(Paths.get(agencyLogoPath)),
reportFolderPath.resolve(
"favicon.ico"));
static synchronized IngestManager getInstance()
boolean isIngestRunning()
Path getReportFolderPath()
UiSnapShotReportWriter(Case currentCase, Path reportFolderPath, String reportName, Date generationDate)
abstract void writeSnapShotHTMLFile()
final ReportBranding reportBranding
void fillTemplateAndWrite(final String templateLocation, final String templateName, Object context, final Path outPutFile)
static final MustacheFactory mf
final Path reportFolderPath
void copyInternalResource(String internalPath, String fileName)