mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Better handle default reporting branding
This commit is contained in:
parent
f563eb2e38
commit
c4090f7ecd
@ -79,26 +79,21 @@ public final class ReportBranding implements ReportBrandingProviderI {
|
||||
@Override
|
||||
public String getGeneratorLogoPath() {
|
||||
String curPath = null;
|
||||
// try {
|
||||
// curPath = ModuleSettings.getConfigSetting(MODULE_NAME, GENERATOR_LOGO_PATH_PROP);
|
||||
// if (curPath == null || curPath.isEmpty() || new File(curPath).canRead() == false) {
|
||||
// //use default
|
||||
// logger.log(Level.INFO, "Using default report branding for generator logo");
|
||||
// curPath = reportsBrandingDir + File.separator + "logo.png";
|
||||
// InputStream in = getClass().getResourceAsStream(DEFAULT_GENERATOR_LOGO);
|
||||
// OutputStream output = new FileOutputStream(new File(curPath));
|
||||
// FileUtil.copy(in, output);
|
||||
// ModuleSettings.setConfigSetting(MODULE_NAME, GENERATOR_LOGO_PATH_PROP, curPath);
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// logger.log(Level.SEVERE, "Error extracting report branding resources for generator logo", e);
|
||||
// }
|
||||
curPath = ModuleSettings.getConfigSetting(MODULE_NAME, GENERATOR_LOGO_PATH_PROP);
|
||||
if (curPath != null && new File(curPath).canRead() == false) {
|
||||
//use default
|
||||
logger.log(Level.INFO, "Custom report branding for generator logo is not valid: " + curPath);
|
||||
curPath = null;
|
||||
try {
|
||||
curPath = ModuleSettings.getConfigSetting(MODULE_NAME, GENERATOR_LOGO_PATH_PROP);
|
||||
if (curPath == null || (!curPath.isEmpty() && !new File(curPath).canRead() ) ) {
|
||||
//use default
|
||||
logger.log(Level.INFO, "Using default report branding for generator logo");
|
||||
curPath = reportsBrandingDir + File.separator + "logo.png";
|
||||
InputStream in = getClass().getResourceAsStream(DEFAULT_GENERATOR_LOGO);
|
||||
OutputStream output = new FileOutputStream(new File(curPath));
|
||||
FileUtil.copy(in, output);
|
||||
ModuleSettings.setConfigSetting(MODULE_NAME, GENERATOR_LOGO_PATH_PROP, curPath);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "Error extracting report branding resources for generator logo", e);
|
||||
}
|
||||
|
||||
return curPath;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public interface ReportBrandingProviderI {
|
||||
/**
|
||||
* Sets custom generator logo path
|
||||
*
|
||||
* @param path path to set
|
||||
* @param path path to set, use empty string to disable
|
||||
*/
|
||||
public void setGeneratorLogoPath(String path);
|
||||
|
||||
@ -51,7 +51,7 @@ public interface ReportBrandingProviderI {
|
||||
/**
|
||||
* Sets custom agency logo path
|
||||
*
|
||||
* @param path path to set
|
||||
* @param path path to set, use empty string to disable
|
||||
*/
|
||||
public void setAgencyLogoPath(String path);
|
||||
|
||||
|
@ -459,14 +459,14 @@ public class ReportHTML implements TableReportModule {
|
||||
|
||||
//pull generator and agency logo from branding, and the remaining resources from the core jar
|
||||
String generatorLogoPath = reportBranding.getGeneratorLogoPath();
|
||||
if (generatorLogoPath != null) {
|
||||
if (generatorLogoPath != null && ! generatorLogoPath.isEmpty()) {
|
||||
File from = new File(generatorLogoPath);
|
||||
File to = new File(path);
|
||||
FileUtil.copyFile(FileUtil.toFileObject(from), FileUtil.toFileObject(to), "generator_logo");
|
||||
}
|
||||
|
||||
String agencyLogoPath = reportBranding.getAgencyLogoPath();
|
||||
if (agencyLogoPath != null) {
|
||||
if (agencyLogoPath != null && ! agencyLogoPath.isEmpty() ) {
|
||||
File from = new File(agencyLogoPath);
|
||||
File to = new File(path);
|
||||
FileUtil.copyFile(FileUtil.toFileObject(from), FileUtil.toFileObject(to), "agency_logo");
|
||||
@ -624,8 +624,8 @@ public class ReportHTML implements TableReportModule {
|
||||
|
||||
final String reportTitle = reportBranding.getReportTitle();
|
||||
final String reportFooter = reportBranding.getReportFooter();
|
||||
final boolean agencyLogoSet = reportBranding.getAgencyLogoPath() != null;
|
||||
final boolean generatorLogoSet = reportBranding.getGeneratorLogoPath() != null;
|
||||
final boolean agencyLogoSet = reportBranding.getAgencyLogoPath() != null && !reportBranding.getAgencyLogoPath().isEmpty();
|
||||
final boolean generatorLogoSet = reportBranding.getGeneratorLogoPath() != null && !reportBranding.getGeneratorLogoPath().isEmpty();
|
||||
|
||||
summary.append("<div id=\"wrapper\">\n");
|
||||
summary.append("<h1>").append(reportTitle).append(running ? "<span>Warning, this report was run before ingest services completed!</span>" : "").append("</h1>\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user