dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40761
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20731: Impl SystemSettingManager.getSystemSettings. Removed string constants from SystemSettingManager. ...
------------------------------------------------------------
revno: 20731
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-10-15 18:53:09 +0200
message:
Impl SystemSettingManager.getSystemSettings. Removed string constants from SystemSettingManager. Using it from SystemSettingInterceptor to reduce number of service layer calls.
modified:
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
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/RedirectAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.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/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2015-10-14 11:29:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2015-10-15 16:53:09 +0000
@@ -29,6 +29,7 @@
*/
import java.io.Serializable;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -45,70 +46,6 @@
{
String ID = SystemSettingManager.class.getName();
- //TODO migrate from strings to Setting enum throughout system
-
- String KEY_APPLICATION_TITLE = "applicationTitle";
- String KEY_APPLICATION_INTRO = "keyApplicationIntro";
- String KEY_APPLICATION_NOTIFICATION = "keyApplicationNotification";
- String KEY_APPLICATION_FOOTER = "keyApplicationFooter";
- String KEY_APPLICATION_RIGHT_FOOTER = "keyApplicationRightFooter";
- String KEY_FLAG = "keyFlag";
- String KEY_FLAG_IMAGE = "keyFlagImage";
- String KEY_START_MODULE = "startModule";
- String KEY_FACTOR_OF_DEVIATION = "factorDeviation";
- String KEY_EMAIL_HOST_NAME = "keyEmailHostName";
- String KEY_EMAIL_PORT = "keyEmailPort";
- String KEY_EMAIL_USERNAME = "keyEmailUsername";
- String KEY_EMAIL_PASSWORD = "keyEmailPassword";
- String KEY_EMAIL_TLS = "keyEmailTls";
- String KEY_EMAIL_SENDER = "keyEmailSender";
- String KEY_INSTANCE_BASE_URL = "keyInstanceBaseUrl";
- String KEY_SCHEDULED_TASKS = "keySchedTasks";
- String KEY_SMS_CONFIG = "keySmsConfig";
- String KEY_CACHE_STRATEGY = "keyCacheStrategy";
- String KEY_TIME_FOR_SENDING_MESSAGE = "timeSendingMessage";
- String KEY_SEND_MESSAGE_SCHEDULED_TASKS = "sendMessageScheduled";
- String KEY_SCHEDULE_MESSAGE_TASKS = "scheduleMessage";
- String KEY_PHONE_NUMBER_AREA_CODE = "phoneNumberAreaCode";
- String KEY_MULTI_ORGANISATION_UNIT_FORMS = "multiOrganisationUnitForms";
- String KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS = "scheduleAggregateQueryBuilder";
- String KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY = "scheduleAggregateQueryBuilderTackStrategy";
- String KEY_CONFIGURATION = "keyConfig";
- String KEY_ACCOUNT_RECOVERY = "keyAccountRecovery";
- String KEY_LAST_MONITORING_RUN = "keyLastMonitoringRun";
- String KEY_GOOGLE_ANALYTICS_UA = "googleAnalyticsUA";
- String KEY_CREDENTIALS_EXPIRES = "credentialsExpires";
- String KEY_SELF_REGISTRATION_NO_RECAPTCHA = "keySelfRegistrationNoRecaptcha";
- String KEY_OPENID_PROVIDER = "keyOpenIdProvider";
- String KEY_OPENID_PROVIDER_LABEL = "keyOpenIdProviderLabel";
- String KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS = "keyCanGrantOwnUserAuthorityGroups";
- String KEY_HIDE_UNAPPROVED_DATA_IN_ANALYTICS = "keyHideUnapprovedDataInAnalytics";
- String KEY_ANALYTICS_MAX_LIMIT = "keyAnalyticsMaxLimit";
- String KEY_CUSTOM_LOGIN_PAGE_LOGO = "keyCustomLoginPageLogo";
- String KEY_CUSTOM_TOP_MENU_LOGO = "keyCustomTopMenuLogo";
- String KEY_ANALYTICS_MAINTENANCE_MODE = "keyAnalyticsMaintenanceMode";
- String KEY_DATABASE_SERVER_CPUS = "keyDatabaseServerCpus";
- String KEY_LAST_SUCCESSFUL_DATA_SYNC = "keyLastSuccessfulDataSynch";
- String KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE = "keyLastSuccessfulAnalyticsTablesUpdate";
- String KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_RUNTIME = "keyLastSuccessfulAnalyticsTablesRuntime";
- String KEY_LAST_SUCCESSFUL_RESOURCE_TABLES_UPDATE = "keyLastSuccessfulResourceTablesUpdate";
- String KEY_LAST_SUCCESSFUL_MONITORING = "keyLastSuccessfulMonitoring";
- String KEY_HELP_PAGE_LINK = "helpPageLink";
- String KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL = "keyAcceptanceRequiredForApproval";
- String KEY_SYSTEM_NOTIFICATIONS_EMAIL = "keySystemNotificationsEmail";
- String KEY_ANALYSIS_RELATIVE_PERIOD = "keyAnalysisRelativePeriod";
- String KEY_REQUIRE_ADD_TO_VIEW = "keyRequireAddToView";
- String KEY_ALLOW_OBJECT_ASSIGNMENT = "keyAllowObjectAssignment";
- String KEY_USE_CUSTOM_LOGO_FRONT = "keyUseCustomLogoFront";
- String KEY_USE_CUSTOM_LOGO_BANNER = "keyUseCustomLogoBanner";
- String KEY_METADATA_REPO_URL = "keyMetaDataRepoUrl";
- String KEY_DATA_IMPORT_STRICT_PERIODS = "keyDataImportStrictPeriods";
- String KEY_DATA_IMPORT_STRICT_CATEGORY_OPTION_COMBOS = "keyDataImportStrictCategoryOptionCombos";
- String KEY_DATA_IMPORT_STRICT_ORGANISATION_UNITS = "keyDataImportStrictOrganisationUnits";
- String KEY_DATA_IMPORT_STRICT_ATTRIBUTE_OPTION_COMBOS = "keyDataImportStrictAttributeOptionCombos";
- String KEY_DATA_IMPORT_REQUIRE_CATEGORY_OPTION_COMBO = "keyDataImportRequireCategoryOptionCombo";
- String KEY_DATA_IMPORT_REQUIRE_ATTRIBUTE_OPTION_COMBO = "keyDataImportRequireAttributeOptionCombo";
-
String SYSPROP_PORTAL = "runningAsPortal";
HashSet<String> DEFAULT_SCHEDULED_PERIOD_TYPES = new HashSet<String>()
@@ -140,6 +77,8 @@
Map<String, Serializable> getSystemSettingsAsMap( Set<String> names );
+ Map<String, Serializable> getSystemSettings( Collection<Setting> settings );
+
void invalidateCache();
// -------------------------------------------------------------------------
=== 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-14 11:29:47 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java 2015-10-15 16:53:09 +0000
@@ -230,6 +230,24 @@
return map;
}
+
+ @Override
+ public Map<String, Serializable> getSystemSettings( Collection<Setting> settings )
+ {
+ Map<String, Serializable> map = new HashMap<>();
+
+ for ( Setting setting : settings )
+ {
+ Serializable value = getSystemSetting( setting );
+
+ if ( value != null )
+ {
+ map.put( setting.getName(), value );
+ }
+ }
+
+ return map;
+ }
@Override
public void invalidateCache()
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/RedirectAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/RedirectAction.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/RedirectAction.java 2015-10-15 16:53:09 +0000
@@ -31,13 +31,12 @@
import com.opensymphony.xwork2.Action;
import org.hisp.dhis.appmanager.App;
import org.hisp.dhis.appmanager.AppManager;
+import org.hisp.dhis.setting.Setting;
import org.hisp.dhis.setting.SystemSettingManager;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_START_MODULE;
-
/**
* @author Lars Helge Overland
*/
@@ -61,7 +60,7 @@
public String execute()
throws Exception
{
- String startModule = (String) systemSettingManager.getSystemSetting( KEY_START_MODULE );
+ String startModule = (String) systemSettingManager.getSystemSetting( Setting.START_MODULE );
if ( startModule != null && !startModule.trim().isEmpty() )
{
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java 2015-10-15 16:14:05 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java 2015-10-15 16:53:09 +0000
@@ -29,31 +29,11 @@
*/
import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_ACCOUNT_RECOVERY;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_ALLOW_OBJECT_ASSIGNMENT;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_ANALYTICS_MAINTENANCE_MODE;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_APPLICATION_FOOTER;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_APPLICATION_INTRO;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_APPLICATION_NOTIFICATION;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_APPLICATION_RIGHT_FOOTER;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_APPLICATION_TITLE;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_CONFIGURATION;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_CREDENTIALS_EXPIRES;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_FLAG;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_FLAG_IMAGE;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_GOOGLE_ANALYTICS_UA;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_HELP_PAGE_LINK;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_INSTANCE_BASE_URL;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_MULTI_ORGANISATION_UNIT_FORMS;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_OPENID_PROVIDER;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_OPENID_PROVIDER_LABEL;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_REQUIRE_ADD_TO_VIEW;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SELF_REGISTRATION_NO_RECAPTCHA;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_START_MODULE;
import static org.hisp.dhis.setting.SystemSettingManager.SYSPROP_PORTAL;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import org.hisp.dhis.calendar.CalendarService;
import org.hisp.dhis.configuration.ConfigurationService;
@@ -61,6 +41,7 @@
import org.hisp.dhis.setting.SystemSettingManager;
import org.springframework.beans.factory.annotation.Autowired;
+import com.google.common.collect.Sets;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
@@ -71,6 +52,12 @@
implements Interceptor
{
private static final String DATE_FORMAT = "dateFormat";
+
+ private static final Set<Setting> SETTINGS = Sets.newHashSet( Setting.APPLICATION_TITLE, Setting.APPLICATION_INTRO,
+ Setting.APPLICATION_NOTIFICATION, Setting.APPLICATION_FOOTER, Setting.APPLICATION_RIGHT_FOOTER,
+ Setting.FLAG, Setting.START_MODULE, Setting.MULTI_ORGANISATION_UNIT_FORMS, Setting.ACCOUNT_RECOVERY,
+ Setting.APP_BASE_URL, Setting.INSTANCE_BASE_URL, Setting.GOOGLE_ANALYTICS_UA, Setting.OPENID_PROVIDER,
+ Setting.OPENID_PROVIDER_LABEL, Setting.HELP_PAGE_LINK, Setting.REQUIRE_ADD_TO_VIEW, Setting.ALLOW_OBJECT_ASSIGNMENT );
// -------------------------------------------------------------------------
// Dependencies
@@ -114,33 +101,17 @@
Map<String, Object> map = new HashMap<>();
map.put( Setting.CALENDAR.getName(), calendarService.getSystemCalendarKey() );
- map.put( Setting.DATE_FORMAT.getName(), calendarService.getSystemDateFormatKey() );
-
+ map.put( Setting.DATE_FORMAT.getName(), calendarService.getSystemDateFormatKey() );
map.put( DATE_FORMAT, calendarService.getSystemDateFormat() );
- map.put( KEY_APPLICATION_TITLE, systemSettingManager.getSystemSetting( Setting.APPLICATION_TITLE ) );
- map.put( KEY_APPLICATION_INTRO, systemSettingManager.getSystemSetting( KEY_APPLICATION_INTRO ) );
- map.put( KEY_APPLICATION_NOTIFICATION, systemSettingManager.getSystemSetting( KEY_APPLICATION_NOTIFICATION ) );
- map.put( KEY_APPLICATION_FOOTER, systemSettingManager.getSystemSetting( KEY_APPLICATION_FOOTER ) );
- map.put( KEY_APPLICATION_RIGHT_FOOTER, systemSettingManager.getSystemSetting( KEY_APPLICATION_RIGHT_FOOTER ) );
- map.put( KEY_FLAG, systemSettingManager.getSystemSetting( Setting.FLAG ) );
- map.put( KEY_FLAG_IMAGE, systemSettingManager.getFlagImage() );
- map.put( KEY_START_MODULE, systemSettingManager.getSystemSetting( Setting.START_MODULE ) );
- map.put( KEY_MULTI_ORGANISATION_UNIT_FORMS, systemSettingManager.getSystemSetting( Setting.MULTI_ORGANISATION_UNIT_FORMS ) );
- map.put( KEY_ACCOUNT_RECOVERY, systemSettingManager.getSystemSetting( Setting.ACCOUNT_RECOVERY ) );
- map.put( KEY_CONFIGURATION, configurationService.getConfiguration() );
- map.put( Setting.APP_BASE_URL.getName(), systemSettingManager.getSystemSetting( Setting.APP_BASE_URL ) );
- map.put( KEY_INSTANCE_BASE_URL, systemSettingManager.getSystemSetting( KEY_INSTANCE_BASE_URL ) );
- map.put( KEY_GOOGLE_ANALYTICS_UA, systemSettingManager.getSystemSetting( Setting.GOOGLE_ANALYTICS_UA ) );
- map.put( KEY_CREDENTIALS_EXPIRES, systemSettingManager.credentialsExpires() );
- map.put( KEY_SELF_REGISTRATION_NO_RECAPTCHA, systemSettingManager.selfRegistrationNoRecaptcha() );
- map.put( KEY_OPENID_PROVIDER, systemSettingManager.getSystemSetting( KEY_OPENID_PROVIDER ) );
- map.put( KEY_OPENID_PROVIDER_LABEL, systemSettingManager.getSystemSetting( KEY_OPENID_PROVIDER_LABEL ) );
- map.put( KEY_ANALYTICS_MAINTENANCE_MODE, systemSettingManager.getSystemSetting( Setting.ANALYTICS_MAINTENANCE_MODE ) );
- map.put( KEY_HELP_PAGE_LINK, systemSettingManager.getSystemSetting( Setting.HELP_PAGE_LINK ) );
- map.put( KEY_REQUIRE_ADD_TO_VIEW, systemSettingManager.getSystemSetting( Setting.REQUIRE_ADD_TO_VIEW ) );
- map.put( KEY_ALLOW_OBJECT_ASSIGNMENT, systemSettingManager.getSystemSetting( Setting.ALLOW_OBJECT_ASSIGNMENT ) );
+ map.put( Setting.CONFIGURATION.getName(), configurationService.getConfiguration() );
+ map.put( Setting.FLAG_IMAGE.getName(), systemSettingManager.getFlagImage() );
map.put( SYSPROP_PORTAL, defaultIfEmpty( System.getProperty( SYSPROP_PORTAL ), String.valueOf( false ) ) );
-
+
+ map.put( Setting.CREDENTIALS_EXPIRES.getName(), systemSettingManager.credentialsExpires() );
+ map.put( Setting.SELF_REGISTRATION_NO_RECAPTCHA.getName(), systemSettingManager.selfRegistrationNoRecaptcha() );
+
+ map.putAll( systemSettingManager.getSystemSettings( SETTINGS ) );
+
invocation.getStack().push( map );
return invocation.invoke();