add footer support to report branding

This commit is contained in:
adam-m 2013-06-25 16:17:27 -04:00
parent f39a9e89c6
commit 8a4d73cc56
2 changed files with 50 additions and 8 deletions

View File

@ -43,9 +43,11 @@ public final class ReportBranding implements ReportBrandingProviderI {
private static final String GENERATOR_LOGO_PATH_PROP = "GeneratorLogoPath";
private static final String AGENCY_LOGO_PATH_PROP = "AgencyLogoPath";
private static final String REPORT_TITLE_PROP = "ReportTitle";
private static final String REPORT_FOOTER_PROP = "ReportFooter";
//default settings
private static final String DEFAULT_GENERATOR_LOGO = "/org/sleuthkit/autopsy/report/images/default_generator_logo.png";
private static final String DEFAULT_REPORT_TITLE = "Autopsy Forensic Report";
private static final String DEFAULT_REPORT_FOOTER = "Powered by Autopsy Open Source Digital Forensics Platform - www.sleuthkit.org";
private String reportsBrandingDir; //dir with extracted reports branding resources
private static final String MODULE_NAME = ReportBranding.class.getSimpleName();
private static final Logger logger = Logger.getLogger(ReportBranding.class.getName());
@ -55,7 +57,7 @@ public final class ReportBranding implements ReportBrandingProviderI {
//initialize with extracting of resource files if needed, ensure 1 writer at a time
synchronized (ReportBranding.class) {
reportsBrandingDir = PlatformUtil.getUserConfigDirectory() + File.separator + ReportGenerator.REPORTS_DIR + File.separator
reportsBrandingDir = PlatformUtil.getUserConfigDirectory() + File.separator + ReportGenerator.REPORTS_DIR + File.separator
+ "branding";
File brandingDir = new File(reportsBrandingDir);
if (!brandingDir.exists()) {
@ -134,4 +136,24 @@ public final class ReportBranding implements ReportBrandingProviderI {
public void setReportTitle(String title) {
ModuleSettings.setConfigSetting(MODULE_NAME, REPORT_TITLE_PROP, title);
}
@Override
public String getReportFooter() {
String curFooter = null;
curFooter = ModuleSettings.getConfigSetting(MODULE_NAME, REPORT_FOOTER_PROP);
if (curFooter == null) {
//use default
logger.log(Level.INFO, "Using default report branding for report footer");
curFooter = DEFAULT_REPORT_FOOTER;
ModuleSettings.setConfigSetting(MODULE_NAME, REPORT_FOOTER_PROP, curFooter);
}
return curFooter;
}
@Override
public void setReportFooter(String footer) {
ModuleSettings.setConfigSetting(MODULE_NAME, REPORT_FOOTER_PROP, footer);
}
}

View File

@ -24,29 +24,34 @@ package org.sleuthkit.autopsy.report;
public interface ReportBrandingProviderI {
/**
* Get the generator logo path on the local disk (previously set or default).
* The file pointed by the path should exist.
* Get the generator logo path on the local disk (previously set or
* default). The file pointed by the path should exist.
*
* @return the generator logo path, or null if error occurred and path is not valid
* @return the generator logo path, or null if error occurred and path is
* not valid
*/
public String getGeneratorLogoPath();
/**
* Sets custom generator logo path
*
* @param path path to set
*/
public void setGeneratorLogoPath(String path);
/**
* Get the agency logo path on the local disk (previously set or default), or NULL if unused
* (Note, this is optional, as opposed to the generator logo path)
* Get the agency logo path on the local disk (previously set or default),
* or NULL if unused (Note, this is optional, as opposed to the generator
* logo path)
*
* @return the agency logo path, or null if not provided or error occurred and path is not valid
* @return the agency logo path, or null if not provided or error occurred
* and path is not valid
*/
public String getAgencyLogoPath();
/**
* Sets custom agency logo path
*
* @param path path to set
*/
public void setAgencyLogoPath(String path);
@ -60,7 +65,22 @@ public interface ReportBrandingProviderI {
/**
* Sets custom report title
*
* @param title title to set
*/
public void setReportTitle(String title);
/**
* Get the report footer (previously set or default)
*
* @return the report footer
*/
public String getReportFooter();
/**
* Sets custom report footer
*
* @param footer footer to set
*/
public void setReportFooter(String footer);
}