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();
 
   86         Files.createDirectories(reportFolderPath);
 
  140         HashMap<String, Object> indexContext = 
new HashMap<>();
 
  141         indexContext.put(
"reportBranding", reportBranding); 
 
  142         indexContext.put(
"reportName", reportName); 
 
  143         Path reportIndexFile = reportFolderPath.resolve(
"index.html"); 
 
  145         fillTemplateAndWrite(
"/org/sleuthkit/autopsy/report/uisnapshot/index_template.html", 
"Index", indexContext, reportIndexFile); 
 
  146         return reportIndexFile;
 
  156         HashMap<String, Object> summaryContext = 
new HashMap<>();
 
  157         summaryContext.put(
"reportName", reportName); 
 
  158         summaryContext.put(
"reportBranding", reportBranding); 
 
  159         summaryContext.put(
"generationDateTime", 
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss").format(generationDate)); 
 
  161         summaryContext.put(
"currentCase", currentCase); 
 
  162         String agencyLogo = 
"agency_logo.png"; 
 
  164             agencyLogo = Paths.get(reportBranding.
getAgencyLogoPath()).getFileName().toString();
 
  166         summaryContext.put(
"agencyLogoFileName", agencyLogo);
 
  167         fillTemplateAndWrite(
"/org/sleuthkit/autopsy/report/uisnapshot/summary_template.html", 
"Summary", summaryContext, reportFolderPath.resolve(
"summary.html")); 
 
  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")); 
 
  236             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()