Search in sources :

Example 6 with MotechSettings

use of org.motechproject.config.domain.MotechSettings in project motech by motech.

the class SettingServiceImpl method getFailureLoginLimit.

@Override
public int getFailureLoginLimit() {
    MotechSettings motechSettings = configurationService.getPlatformSettings();
    Integer failureLoginLimit = motechSettings.getFailureLoginLimit();
    return failureLoginLimit == null ? 0 : failureLoginLimit;
}
Also used : MotechSettings(org.motechproject.config.domain.MotechSettings)

Example 7 with MotechSettings

use of org.motechproject.config.domain.MotechSettings in project motech by motech.

the class SettingsServiceImpl method getSettings.

@Override
public AdminSettings getSettings() {
    MotechSettings motechSettings = configurationService.getPlatformSettings();
    List<Settings> settingsList = new ArrayList<>();
    AdminSettings adminSettings = new AdminSettings(settingsList, false);
    if (motechSettings != null) {
        List<SettingsOption> generalOptions = new ArrayList<>();
        List<SettingsOption> securityOptions = new ArrayList<>();
        List<SettingsOption> jmxOptions = new ArrayList<>();
        SettingsOption languageOption = ParamParser.parseParam(ConfigurationConstants.LANGUAGE, motechSettings.getLanguage());
        generalOptions.add(languageOption);
        SettingsOption msgOption = ParamParser.parseParam(ConfigurationConstants.STATUS_MSG_TIMEOUT, motechSettings.getStatusMsgTimeout());
        generalOptions.add(msgOption);
        SettingsOption serverUrlOption = ParamParser.parseParam(ConfigurationConstants.SERVER_URL, motechSettings.getServerUrl());
        generalOptions.add(serverUrlOption);
        SettingsOption uploadSizeOption = ParamParser.parseParam(ConfigurationConstants.UPLOAD_SIZE, motechSettings.getUploadSize());
        generalOptions.add(uploadSizeOption);
        SettingsOption emailRequiredOption = ParamParser.parseParam(ConfigurationConstants.EMAIL_REQUIRED, motechSettings.getEmailRequired());
        securityOptions.add(emailRequiredOption);
        SettingsOption sessionTimeoutOption = ParamParser.parseParam(ConfigurationConstants.SESSION_TIMEOUT, motechSettings.getSessionTimeout());
        securityOptions.add(sessionTimeoutOption);
        SettingsOption failureLoginLimit = ParamParser.parseParam(ConfigurationConstants.FAILURE_LOGIN_LIMIT, motechSettings.getFailureLoginLimit());
        securityOptions.add(failureLoginLimit);
        SettingsOption minPasswordLengthOption = ParamParser.parseParam(ConfigurationConstants.MIN_PASSWORD_LENGTH, motechSettings.getMinPasswordLength());
        securityOptions.add(minPasswordLengthOption);
        SettingsOption passwordValidatorOption = ParamParser.parseParam(ConfigurationConstants.PASSWORD_VALIDATOR, motechSettings.getPasswordValidator());
        securityOptions.add(passwordValidatorOption);
        SettingsOption passwordResetOption = ParamParser.parseParam(ConfigurationConstants.PASSWORD_RESET_DAYS, motechSettings.getNumberOfDaysToChangePassword());
        securityOptions.add(passwordResetOption);
        SettingsOption passwordReminderOption = ParamParser.parseParam(ConfigurationConstants.PASSWORD_REMINDER, motechSettings.isPasswordResetReminderEnabled());
        securityOptions.add(passwordReminderOption);
        SettingsOption passwordRemindDaysOption = ParamParser.parseParam(ConfigurationConstants.PASSWORD_REMINDER_DAYS, motechSettings.getNumberOfDaysForReminder());
        securityOptions.add(passwordRemindDaysOption);
        SettingsOption jmxUrlOption = ParamParser.parseParam(ConfigurationConstants.JMX_HOST, motechSettings.getJmxHost());
        jmxOptions.add(jmxUrlOption);
        SettingsOption jmxBrokerOption = ParamParser.parseParam(ConfigurationConstants.JMX_BROKER, motechSettings.getJmxBroker());
        jmxOptions.add(jmxBrokerOption);
        Settings generalSettings = new Settings("general", generalOptions);
        Settings securitySettings = new Settings("security", securityOptions);
        Settings jmxSettings = new Settings("jmx", jmxOptions);
        settingsList.add(generalSettings);
        settingsList.add(securitySettings);
        settingsList.add(jmxSettings);
        if (ConfigSource.FILE.equals(configurationService.getConfigSource())) {
            adminSettings = new AdminSettings(settingsList, true);
        } else {
            adminSettings = new AdminSettings(settingsList, false);
        }
    }
    return adminSettings;
}
Also used : MotechSettings(org.motechproject.config.domain.MotechSettings) ArrayList(java.util.ArrayList) AdminSettings(org.motechproject.admin.settings.AdminSettings) Settings(org.motechproject.admin.settings.Settings) MotechSettings(org.motechproject.config.domain.MotechSettings) SettingsOption(org.motechproject.admin.settings.SettingsOption) AdminSettings(org.motechproject.admin.settings.AdminSettings)

Example 8 with MotechSettings

use of org.motechproject.config.domain.MotechSettings in project motech by motech.

the class ConfigLoaderTest method testMotechSettingsLoading.

@Test
public void testMotechSettingsLoading() {
    final String dirPath = FileHelper.getResourceFile("config/").getAbsolutePath();
    ConfigLocation configLocation = new ConfigLocation(dirPath);
    when(coreConfigurationService.getConfigLocation()).thenReturn(configLocation);
    MotechSettings settings = configLoader.loadMotechSettings();
    assertNotNull(settings);
    assertEquals(settings.getLanguage(), "en");
}
Also used : MotechSettings(org.motechproject.config.domain.MotechSettings) ConfigLocation(org.motechproject.config.core.domain.ConfigLocation) Test(org.junit.Test)

Example 9 with MotechSettings

use of org.motechproject.config.domain.MotechSettings in project motech by motech.

the class SettingServiceImpl method getMinPasswordLength.

@Override
public int getMinPasswordLength() {
    MotechSettings motechSettings = configurationService.getPlatformSettings();
    Integer minLength = motechSettings.getMinPasswordLength();
    return minLength == null ? 0 : minLength;
}
Also used : MotechSettings(org.motechproject.config.domain.MotechSettings)

Example 10 with MotechSettings

use of org.motechproject.config.domain.MotechSettings in project motech by motech.

the class SettingServiceImpl method getSessionTimeout.

@Override
public int getSessionTimeout() {
    MotechSettings motechSettings = configurationService.getPlatformSettings();
    Integer sessionTimeout = motechSettings.getSessionTimeout();
    return sessionTimeout == null || sessionTimeout == 0 ? DEFAULT_SESSION_TIMEOUT : sessionTimeout;
}
Also used : MotechSettings(org.motechproject.config.domain.MotechSettings)

Aggregations

MotechSettings (org.motechproject.config.domain.MotechSettings)13 Test (org.junit.Test)5 Matchers.anyString (org.mockito.Matchers.anyString)2 StartupForm (org.motechproject.server.web.form.StartupForm)2 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 AdminSettings (org.motechproject.admin.settings.AdminSettings)1 Settings (org.motechproject.admin.settings.Settings)1 SettingsOption (org.motechproject.admin.settings.SettingsOption)1 ConfigLocation (org.motechproject.config.core.domain.ConfigLocation)1 ConfigSource (org.motechproject.config.core.domain.ConfigSource)1 PasswordRecovery (org.motechproject.security.domain.PasswordRecovery)1 PasswordValidator (org.motechproject.security.validator.PasswordValidator)1 MinLengthValidatorDecorator (org.motechproject.security.validator.impl.MinLengthValidatorDecorator)1 StartupFormValidator (org.motechproject.server.web.validator.StartupFormValidator)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1