Search in sources :

Example 16 with ConfigurationLocator

use of org.mifos.framework.util.ConfigurationLocator in project head by mifos.

the class ViewOrganizationSettingsServiceFacadeWebTier method getGeneralConfig.

private Properties getGeneralConfig() {
    Properties configContent = new Properties();
    MifosConfigurationManager configuration = MifosConfigurationManager.getInstance();
    String maxPointsPerPPISurvey = configuration.getString("GeneralConfig.MaxPointsPerPPISurvey");
    String batchSizeForBatchJobs = configuration.getString("GeneralConfig.BatchSizeForBatchJobs");
    String recordCommittingSizeForBatchJobs = configuration.getString("GeneralConfig.RecordCommittingSizeForBatchJobs");
    String outputIntervalForBatchJobs = configuration.getString("GeneralConfig.OutputIntervalForBatchJobs");
    String allowDataPrefetchingWhenSavingCollectionSheets = configuration.getString("GeneralConfig.allowDataPrefetchingWhenSavingCollectionSheets");
    String shutdownCountdownNotificationThreshold = configuration.getString("GeneralConfig.ShutdownCountdownNotificationThreshold");
    String imageStorageType = configuration.getString("GeneralConfig.ImageStorageType");
    String uploadStorageDirectory = getUploadStorageDirectory();
    String uploadQGDirectory = new ConfigurationLocator().resolvePath(getUploadQGDirectory());
    String imageStorageDirectory = ImageStorageManager.getStorageLocation();
    configContent.put("maxPointsPerPPISurvey", maxPointsPerPPISurvey);
    configContent.put("batchSizeForBatchJobs", batchSizeForBatchJobs);
    configContent.put("recordCommittingSizeForBatchJobs", recordCommittingSizeForBatchJobs);
    configContent.put("outputIntervalForBatchJobs", outputIntervalForBatchJobs);
    configContent.put("allowDataPrefetchingWhenSavingCollectionSheets", allowDataPrefetchingWhenSavingCollectionSheets);
    configContent.put("shutdownCountdownNotificationThreshold", shutdownCountdownNotificationThreshold);
    configContent.put("imageStorageType", imageStorageType);
    configContent.put("uploadStorageDirectory", uploadStorageDirectory);
    configContent.put("uploadQGDirectory", uploadQGDirectory);
    configContent.put("imageStorageDirectory", imageStorageDirectory);
    return configContent;
}
Also used : Properties(java.util.Properties) ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 17 with ConfigurationLocator

use of org.mifos.framework.util.ConfigurationLocator in project head by mifos.

the class ViewOrganizationSettingsServiceFacadeWebTier method getUploadStorageDirectory.

public String getUploadStorageDirectory() {
    ConfigurationLocator configurationLocator = new ConfigurationLocator();
    String reportPath = configurationLocator.getConfigurationDirectory() + "/uploads";
    String uploadsDir = reportPath;
    if (File.separatorChar == '\\') {
        // windows platform
        uploadsDir = uploadsDir.replaceAll("/", "\\\\");
    }
    return uploadsDir;
}
Also used : ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator)

Example 18 with ConfigurationLocator

use of org.mifos.framework.util.ConfigurationLocator in project head by mifos.

the class Log4jConfigListener method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent event) {
    Resource location;
    try {
        location = new ConfigurationLocator().getResource(NAME);
    } catch (IOException e) {
        throw new IllegalArgumentException("Unable to start logging, because " + NAME + " look-up failed: " + e.getMessage(), e);
    }
    // following code due to https://jira.springsource.org/browse/SPR-8254
    try {
        File locationFile = location.getFile();
        // can use refreshInterval here (as opposed to below)
        Log4jConfigurer.initLogging(locationFile.getAbsolutePath(), refreshInterval);
        return;
    } catch (IOException e) {
        try {
            URL locationURL = location.getURL();
            // use method w.o. refreshInterval here (@see https://jira.springsource.org/browse/SPR-707)
            Log4jConfigurer.initLogging(locationURL.toString());
        } catch (IOException e1) {
            throw new IllegalArgumentException("Unable to start logging, because non-File resource " + location.getDescription() + " toURL() failed: " + e.getMessage(), e);
        }
    }
}
Also used : Resource(org.springframework.core.io.Resource) IOException(java.io.IOException) ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator) File(java.io.File) URL(java.net.URL)

Example 19 with ConfigurationLocator

use of org.mifos.framework.util.ConfigurationLocator in project head by mifos.

the class AccountingDataCacheManager method getAccoutingDataCachePath.

private String getAccoutingDataCachePath() {
    if (accountingDataPath == null) {
        ConfigurationLocator configurationLocator = new ConfigurationLocator();
        accountingDataPath = configurationLocator.getConfigurationDirectory() + "/accounting/data/";
    }
    File path = new File(accountingDataPath);
    if (!(path.exists() && path.isDirectory())) {
        path.mkdirs();
    }
    return accountingDataPath;
}
Also used : ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator) File(java.io.File)

Example 20 with ConfigurationLocator

use of org.mifos.framework.util.ConfigurationLocator in project head by mifos.

the class AccountingDataCacheManager method getDigitsAfterDecimal.

private int getDigitsAfterDecimal() {
    if (digitsAfterDecimal != null) {
        // Already read, avoid reading again to reduce processing
        return digitsAfterDecimal;
    }
    ConfigurationLocator configurationLocator = new ConfigurationLocator();
    String customApplicationPropertyFile = configurationLocator.getConfigurationDirectory() + "/applicationConfiguration.custom.properties";
    File appConfigFile = new File(customApplicationPropertyFile);
    Properties properties = new Properties();
    if (appConfigFile.exists() && appConfigFile.isFile()) {
        try {
            properties.load(new FileReader(appConfigFile));
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
    } else {
        // FIXME hardcoded default value, using property file only for custom value
        // There should be a way to read application properties across modules
        digitsAfterDecimal = 1;
    }
    digitsAfterDecimal = Integer.parseInt(properties.getProperty("AccountingRules.DigitsAfterDecimal", "1"));
    return digitsAfterDecimal;
}
Also used : FileReader(java.io.FileReader) ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator) Properties(java.util.Properties) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) AccountingRuntimeException(org.mifos.platform.accounting.AccountingRuntimeException)

Aggregations

ConfigurationLocator (org.mifos.framework.util.ConfigurationLocator)25 File (java.io.File)9 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 URL (java.net.URL)3 ArrayList (java.util.ArrayList)3 MifosScheduler (org.mifos.framework.components.batchjobs.MifosScheduler)3 Resource (org.springframework.core.io.Resource)3 FileInputStream (java.io.FileInputStream)2 Properties (java.util.Properties)2 JarInputStream (java.util.jar.JarInputStream)2 Graphics2D (java.awt.Graphics2D)1 BufferedImage (java.awt.image.BufferedImage)1 BufferedReader (java.io.BufferedReader)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 URLClassLoader (java.net.URLClassLoader)1 SQLException (java.sql.SQLException)1