<commit_before> /*
 *
 * Autopsy Forensic Browser
 * 
 * Copyright 2013 Basis Technology Corp.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.sleuthkit.autopsy.report;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.filesystems.FileUtil;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.ModuleSettings;

/**
 * Manages settings configured report branding and their defaults.
 *
 * If configured branding is not present on the machine, uses defaults.
 *
 * Uses module settings property files to store customizations.
 */
public final class ReportBranding implements ReportBrandingProviderI {

    //property names
    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";
    //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 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());

    public ReportBranding() {

        //initialize with extracting of resource files if needed, ensure 1 writer at a time
        synchronized (ReportBranding.class) {
            reportsBrandingDir = Case.getCurrentCase().getCaseDirectory() + File.separator + ReportGenerator.REPORTS_DIR + File.separator
                    + "branding";
            File brandingDir = new File(reportsBrandingDir);
            if (!brandingDir.exists()) {
                if (!brandingDir.mkdirs()) {
                    logger.log(Level.SEVERE, "Error creating report branding dir for the case, will use defaults");
                    //TODO use defaults
                }
            }<commit_msg>fix location of report branding folder<commit_after> /*
 *
 * Autopsy Forensic Browser
 * 
 * Copyright 2013 Basis Technology Corp.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.sleuthkit.autopsy.report;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.filesystems.FileUtil;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.autopsy.coreutils.PlatformUtil;

/**
 * Manages settings configured report branding and their defaults.
 *
 * If configured branding is not present on the machine, uses defaults.
 *
 * Uses module settings property files to store customizations.
 */
public final class ReportBranding implements ReportBrandingProviderI {

    //property names
    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";
    //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 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());

    public ReportBranding() {

        //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
                    + "branding";
            File brandingDir = new File(reportsBrandingDir);
            if (!brandingDir.exists()) {
                if (!brandingDir.mkdirs()) {
                    logger.log(Level.SEVERE, "Error creating report branding dir for the case, will use defaults");
                    //TODO use defaults
                }
            }
{'fraction_non_alphanumeric': 0.07571428571428572, 'fraction_numerical': 0.0032142857142857142, 'mean_word_length': 3.516935483870968, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6885984', 'n_tokens_mistral': 1516, 'n_tokens_neox': 1417, 'n_words': 499}