dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40487
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20536: Using Setting in SystemSettingManager.
------------------------------------------------------------
revno: 20536
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-06 19:18:17 +0200
message:
Using Setting in SystemSettingManager.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/Setting.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/Setting.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/Setting.java 2015-10-06 16:57:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/Setting.java 2015-10-06 17:18:17 +0000
@@ -56,7 +56,7 @@
EMAIL_PORT( "keyEmailPort", 587, Integer.class ),
EMAIL_USERNAME( "keyEmailUsername" ),
EMAIL_PASSWORD( "keyEmailPassword" ),
- EMAIL_TLS( "keyEmailTls", Boolean.class ),
+ EMAIL_TLS( "keyEmailTls", Boolean.TRUE, Boolean.class ),
EMAIL_SENDER( "keyEmailSender" ),
INSTANCE_BASE_URL( "keyInstanceBaseUrl", ListMap.class ),
SMS_CONFIG( "keySmsConfig", SmsConfiguration.class ),
@@ -65,21 +65,21 @@
SEND_MESSAGE_SCHEDULED_TASKS( "sendMessageScheduled" ),
SCHEDULE_MESSAGE_TASKS( "scheduleMessage" ),
PHONE_NUMBER_AREA_CODE( "phoneNumberAreaCode" ),
- MULTI_ORGANISATION_UNIT_FORMS( "multiOrganisationUnitForms", Boolean.class ),
+ MULTI_ORGANISATION_UNIT_FORMS( "multiOrganisationUnitForms", Boolean.FALSE, Boolean.class ),
SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS( "scheduleAggregateQueryBuilder", Map.class ),
SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY( "scheduleAggregateQueryBuilderTackStrategy", "lastMonth", String.class ),
CONFIGURATION( "keyConfig", Configuration.class ),
- ACCOUNT_RECOVERY( "keyAccountRecovery", Boolean.class ),
+ ACCOUNT_RECOVERY( "keyAccountRecovery", Boolean.FALSE, Boolean.class ),
GOOGLE_ANALYTICS_UA( "googleAnalyticsUA" ),
- CREDENTIALS_EXPIRES( "credentialsExpires", Integer.class ),
- SELF_REGISTRATION_NO_RECAPTCHA( "keySelfRegistrationNoRecaptcha", Boolean.class ),
+ CREDENTIALS_EXPIRES( "credentialsExpires", 0, Integer.class ),
+ SELF_REGISTRATION_NO_RECAPTCHA( "keySelfRegistrationNoRecaptcha", Boolean.FALSE, Boolean.class ),
OPENID_PROVIDER( "keyOpenIdProvider" ),
OPENID_PROVIDER_LABEL( "keyOpenIdProviderLabel" ),
- CAN_GRANT_OWN_USER_AUTHORITY_GROUPS( "keyCanGrantOwnUserAuthorityGroups", Boolean.class ),
- HIDE_UNAPPROVED_DATA_IN_ANALYTICS( "keyHideUnapprovedDataInAnalytics", Boolean.class ),
+ CAN_GRANT_OWN_USER_AUTHORITY_GROUPS( "keyCanGrantOwnUserAuthorityGroups", Boolean.FALSE, Boolean.class ),
+ HIDE_UNAPPROVED_DATA_IN_ANALYTICS( "keyHideUnapprovedDataInAnalytics", Boolean.FALSE, Boolean.class ),
ANALYTICS_MAX_LIMIT( "keyAnalyticsMaxLimit", 50000, Integer.class ),
- CUSTOM_LOGIN_PAGE_LOGO( "keyCustomLoginPageLogo", Boolean.class ),
- CUSTOM_TOP_MENU_LOGO( "keyCustomTopMenuLogo", Boolean.class ),
+ CUSTOM_LOGIN_PAGE_LOGO( "keyCustomLoginPageLogo", Boolean.FALSE, Boolean.class ),
+ CUSTOM_TOP_MENU_LOGO( "keyCustomTopMenuLogo", Boolean.FALSE, Boolean.class ),
ANALYTICS_MAINTENANCE_MODE( "keyAnalyticsMaintenanceMode", Boolean.FALSE, Boolean.class ),
DATABASE_SERVER_CPUS( "keyDatabaseServerCpus", 0, Integer.class ),
LAST_SUCCESSFUL_ANALYTICS_TABLES_RUNTIME( "keyLastSuccessfulAnalyticsTablesRuntime" ),
@@ -89,21 +89,21 @@
LAST_SUCCESSFUL_RESOURCE_TABLES_UPDATE( "keyLastSuccessfulResourceTablesUpdate", Date.class ),
LAST_SUCCESSFUL_MONITORING( "keyLastSuccessfulMonitoring", Date.class ),
HELP_PAGE_LINK( "helpPageLink", "../dhis-web-commons-about/help.action", String.class ),
- ACCEPTANCE_REQUIRED_FOR_APPROVAL( "keyAcceptanceRequiredForApproval", Boolean.class ),
+ ACCEPTANCE_REQUIRED_FOR_APPROVAL( "keyAcceptanceRequiredForApproval", Boolean.FALSE, Boolean.class ),
SYSTEM_NOTIFICATIONS_EMAIL( "keySystemNotificationsEmail" ),
ANALYSIS_RELATIVE_PERIOD( "keyAnalysisRelativePeriod", "LAST_12_MONTHS", String.class ),
CORS_WHITELIST( "keyCorsWhitelist", List.class ),
- REQUIRE_ADD_TO_VIEW( "keyRequireAddToView", Boolean.class ),
- ALLOW_OBJECT_ASSIGNMENT( "keyAllowObjectAssignment", Boolean.class ),
- USE_CUSTOM_LOGO_FRONT( "keyUseCustomLogoFront", Boolean.class ),
- USE_CUSTOM_LOGO_BANNER( "keyUseCustomLogoBanner", Boolean.class ),
+ REQUIRE_ADD_TO_VIEW( "keyRequireAddToView", Boolean.FALSE, Boolean.class ),
+ ALLOW_OBJECT_ASSIGNMENT( "keyAllowObjectAssignment", Boolean.FALSE, Boolean.class ),
+ USE_CUSTOM_LOGO_FRONT( "keyUseCustomLogoFront", Boolean.FALSE, Boolean.class ),
+ USE_CUSTOM_LOGO_BANNER( "keyUseCustomLogoBanner", Boolean.FALSE, Boolean.class ),
METADATA_REPO_URL( "keyMetaDataRepoUrl", "http://metadata.dhis2.org", String.class ),
- DATA_IMPORT_STRICT_PERIODS( "keyDataImportStrictPeriods", Boolean.class ),
- DATA_IMPORT_STRICT_CATEGORY_OPTION_COMBOS( "keyDataImportStrictCategoryOptionCombos", Boolean.class ),
- DATA_IMPORT_STRICT_ORGANISATION_UNITS( "keyDataImportStrictOrganisationUnits", Boolean.class ),
- DATA_IMPORT_STRICT_ATTRIBUTE_OPTION_COMBOS( "keyDataImportStrictAttributeOptionCombos", Boolean.class ),
- DATA_IMPORT_REQUIRE_CATEGORY_OPTION_COMBO( "keyDataImportRequireCategoryOptionCombo", Boolean.class ),
- DATA_IMPORT_REQUIRE_ATTRIBUTE_OPTION_COMBO( "keyDataImportRequireAttributeOptionCombo", Boolean.class );
+ DATA_IMPORT_STRICT_PERIODS( "keyDataImportStrictPeriods", Boolean.FALSE, Boolean.class ),
+ DATA_IMPORT_STRICT_CATEGORY_OPTION_COMBOS( "keyDataImportStrictCategoryOptionCombos", Boolean.FALSE, Boolean.class ),
+ DATA_IMPORT_STRICT_ORGANISATION_UNITS( "keyDataImportStrictOrganisationUnits", Boolean.FALSE, Boolean.class ),
+ DATA_IMPORT_STRICT_ATTRIBUTE_OPTION_COMBOS( "keyDataImportStrictAttributeOptionCombos", Boolean.FALSE, Boolean.class ),
+ DATA_IMPORT_REQUIRE_CATEGORY_OPTION_COMBO( "keyDataImportRequireCategoryOptionCombo", Boolean.FALSE, Boolean.class ),
+ DATA_IMPORT_REQUIRE_ATTRIBUTE_OPTION_COMBO( "keyDataImportRequireAttributeOptionCombo", Boolean.FALSE, Boolean.class );
private final String name;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2015-10-06 16:57:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2015-10-06 17:18:17 +0000
@@ -161,6 +161,8 @@
Serializable getSystemSetting( String name, Serializable defaultValue );
+ Serializable getSystemSetting( Setting setting );
+
List<SystemSetting> getAllSystemSettings();
void deleteSystemSetting( String name );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java 2015-10-06 16:57:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java 2015-10-06 17:18:17 +0000
@@ -109,6 +109,12 @@
}
@Override
+ public Serializable getSystemSetting( Setting setting )
+ {
+ return getSystemSetting( setting.getName(), setting.getDefaultValue() );
+ }
+
+ @Override
public List<SystemSetting> getAllSystemSettings()
{
return systemSettingStore.getAll();
@@ -139,7 +145,7 @@
@Override
public String getFlagImage()
{
- String flag = (String) getSystemSetting( KEY_FLAG, DEFAULT_FLAG );
+ String flag = (String) getSystemSetting( Setting.FLAG );
return flag != null ? flag + ".png" : null;
}
@@ -147,49 +153,49 @@
@Override
public String getEmailHostName()
{
- return StringUtils.trimToNull( (String) getSystemSetting( KEY_EMAIL_HOST_NAME ) );
+ return StringUtils.trimToNull( (String) getSystemSetting( Setting.EMAIL_HOST_NAME ) );
}
@Override
public int getEmailPort()
{
- return (Integer) getSystemSetting( KEY_EMAIL_PORT, DEFAULT_EMAIL_PORT );
+ return (Integer) getSystemSetting( Setting.EMAIL_PORT );
}
@Override
public String getEmailUsername()
{
- return StringUtils.trimToNull( (String) getSystemSetting( KEY_EMAIL_USERNAME ) );
+ return StringUtils.trimToNull( (String) getSystemSetting( Setting.EMAIL_USERNAME ) );
}
@Override
public boolean getEmailTls()
{
- return (Boolean) getSystemSetting( KEY_EMAIL_TLS, true );
+ return (Boolean) getSystemSetting( Setting.EMAIL_TLS );
}
@Override
public String getEmailSender()
{
- return StringUtils.trimToNull( (String) getSystemSetting( KEY_EMAIL_SENDER ) );
+ return StringUtils.trimToNull( (String) getSystemSetting( Setting.EMAIL_SENDER ) );
}
@Override
public String getInstanceBaseUrl()
{
- return StringUtils.trimToNull( (String) getSystemSetting( KEY_INSTANCE_BASE_URL ) );
+ return StringUtils.trimToNull( (String) getSystemSetting( Setting.INSTANCE_BASE_URL ) );
}
@Override
public boolean accountRecoveryEnabled()
{
- return (Boolean) getSystemSetting( KEY_ACCOUNT_RECOVERY, false );
+ return (Boolean) getSystemSetting( Setting.ACCOUNT_RECOVERY );
}
@Override
public boolean selfRegistrationNoRecaptcha()
{
- return (Boolean) getSystemSetting( KEY_SELF_REGISTRATION_NO_RECAPTCHA, false );
+ return (Boolean) getSystemSetting( Setting.SELF_REGISTRATION_NO_RECAPTCHA );
}
@Override
@@ -201,7 +207,7 @@
@Override
public boolean systemNotificationEmailValid()
{
- String address = (String) getSystemSetting( KEY_SYSTEM_NOTIFICATIONS_EMAIL );
+ String address = (String) getSystemSetting( Setting.SYSTEM_NOTIFICATIONS_EMAIL );
return address != null && ValidationUtils.emailIsValid( address );
}
@@ -209,26 +215,28 @@
@Override
public boolean hideUnapprovedDataInAnalytics()
{
- return (Boolean) getSystemSetting( SystemSettingManager.KEY_HIDE_UNAPPROVED_DATA_IN_ANALYTICS, false );
+ return (Boolean) getSystemSetting( Setting.HIDE_UNAPPROVED_DATA_IN_ANALYTICS );
}
@Override
public String googleAnalyticsUA()
{
- return StringUtils.trimToNull( (String) getSystemSetting( KEY_GOOGLE_ANALYTICS_UA ) );
+ return StringUtils.trimToNull( (String) getSystemSetting( Setting.GOOGLE_ANALYTICS_UA ) );
}
@Override
public Integer credentialsExpires()
{
- return (Integer) (getSystemSetting( KEY_CREDENTIALS_EXPIRES ) == null ? 0 : getSystemSetting( KEY_CREDENTIALS_EXPIRES ) );
+ return (Integer) getSystemSetting( Setting.CREDENTIALS_EXPIRES );
}
@Override
@SuppressWarnings( "unchecked" )
public List<String> getCorsWhitelist()
{
- return (List<String>) (getSystemSetting( KEY_CORS_WHITELIST ) == null ? Collections.emptyList() : getSystemSetting( KEY_CORS_WHITELIST ));
+ Serializable value = getSystemSetting( Setting.CORS_WHITELIST );
+
+ return value != null ? (List<String>) value : Collections.emptyList();
}
@Override