← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20546: Removed constants

 

------------------------------------------------------------
revno: 20546
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-10-07 00:23:53 +0200
message:
  Removed constants
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.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/appmanager/DefaultAppManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.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/appmanager/AppManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java	2015-10-06 22:15:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java	2015-10-06 22:23:53 +0000
@@ -41,9 +41,6 @@
 {
     String ID = AppManager.class.getName();
 
-    String KEY_APP_FOLDER_PATH = "appFolderPath";
-    String KEY_APP_BASE_URL = "appBaseUrl";
-    String KEY_APP_STORE_URL = "appStoreUrl";
     String APPS_DIR = "/apps";
     String APPS_API_PATH = "/api/apps";
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.java	2015-10-06 22:15:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.java	2015-10-06 22:23:53 +0000
@@ -37,9 +37,6 @@
  */
 public interface CalendarService
 {
-    String KEY_CALENDAR = "keyCalendar";
-    String KEY_DATE_FORMAT = "keyDateFormat";
-    
     /**
      * Gets all available calendars as a sorted list.
      * @return All available calendars

=== 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 21:55:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2015-10-06 22:23:53 +0000
@@ -139,6 +139,10 @@
     
     void deleteSystemSetting( Setting setting );
 
+    Map<String, Serializable> getSystemSettingsAsMap();
+    
+    Map<String, Serializable> getSystemSettingsAsMap( Set<String> names );
+    
     // -------------------------------------------------------------------------
     // Specific methods
     // -------------------------------------------------------------------------
@@ -174,8 +178,4 @@
     Integer credentialsExpires();
 
     List<String> getCorsWhitelist();
-
-    Map<String, Serializable> getSystemSettingsAsMap();
-    
-    Map<String, Serializable> getSystemSettingsAsMap( Set<String> names );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java	2015-10-06 22:15:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java	2015-10-06 22:23:53 +0000
@@ -237,7 +237,7 @@
             }
         }
 
-        appSettingManager.saveSystemSetting( KEY_APP_FOLDER_PATH, appFolderPath );
+        appSettingManager.saveSystemSetting( Setting.APP_FOLDER_PATH, appFolderPath );
     }
 
     @Override
@@ -249,7 +249,7 @@
     @Override
     public void setAppBaseUrl( String appBaseUrl )
     {
-        appSettingManager.saveSystemSetting( KEY_APP_BASE_URL, appBaseUrl );
+        appSettingManager.saveSystemSetting( Setting.APP_BASE_URL, appBaseUrl );
     }
 
     @Override
@@ -261,7 +261,7 @@
     @Override
     public void setAppStoreUrl( String appStoreUrl )
     {
-        appSettingManager.saveSystemSetting( KEY_APP_STORE_URL, appStoreUrl );
+        appSettingManager.saveSystemSetting( Setting.APP_STORE_URL, appStoreUrl );
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java	2015-10-06 22:15:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java	2015-10-06 22:23:53 +0000
@@ -149,32 +149,32 @@
     @Override
     public String getSystemCalendarKey()
     {
-        String key = keyCache.get( KEY_CALENDAR );        
+        String key = keyCache.get( Setting.CALENDAR.getName() );        
         key = !isEmpty( key ) ? key : (String) settingManager.getSystemSetting( Setting.CALENDAR );        
-        keyCache.put( KEY_CALENDAR, key );        
+        keyCache.put( Setting.CALENDAR.getName(), key );        
         return key;
     }
     
     @Override
     public void setSystemCalendarKey( String calendarKey )
     {
-        keyCache.put( KEY_CALENDAR, calendarKey );
-        settingManager.saveSystemSetting( KEY_CALENDAR, calendarKey );
+        keyCache.put( Setting.CALENDAR.getName(), calendarKey );
+        settingManager.saveSystemSetting( Setting.CALENDAR.getName(), calendarKey );
     }
     
     @Override
     public String getSystemDateFormatKey()
     {
-        String key = keyCache.get( KEY_DATE_FORMAT );
+        String key = keyCache.get( Setting.DATE_FORMAT.getName() );
         key = !isEmpty( key ) ? key : (String) settingManager.getSystemSetting( Setting.DATE_FORMAT );
-        keyCache.put( KEY_DATE_FORMAT, key );
+        keyCache.put( Setting.DATE_FORMAT.getName(), key );
         return key;
     }
 
     @Override
     public void setSystemDateFormatKey( String dateFormatKey )
     {
-        keyCache.put( KEY_DATE_FORMAT, dateFormatKey );
-        settingManager.saveSystemSetting( KEY_DATE_FORMAT, dateFormatKey );
+        keyCache.put( Setting.DATE_FORMAT.getName(), dateFormatKey );
+        settingManager.saveSystemSetting( Setting.DATE_FORMAT.getName(), dateFormatKey );
     }
 }

=== 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 21:55:05 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java	2015-10-06 22:23:53 +0000
@@ -150,6 +150,60 @@
         deleteSystemSetting( setting.getName() );
     }
 
+    @Override
+    public Map<String, Serializable> getSystemSettingsAsMap()
+    {
+        Map<String, Serializable> settingsMap = new HashMap<>();
+        Collection<SystemSetting> systemSettings = getAllSystemSettings();
+
+        for ( SystemSetting systemSetting : systemSettings )
+        {
+            Serializable settingValue = systemSetting.getValue();
+            
+            if ( settingValue == null )
+            {
+                Optional<Setting> setting = Setting.getByName( systemSetting.getName() );
+                
+                if ( setting.isPresent() )
+                {
+                    settingValue = setting.get().getDefaultValue();
+                }
+            }
+
+            settingsMap.put( systemSetting.getName(), settingValue );
+        }
+
+        return settingsMap;
+    }
+
+    @Override
+    public Map<String, Serializable> getSystemSettingsAsMap( Set<String> names )
+    {
+        Map<String, Serializable> map = new HashMap<>();
+
+        for ( String name : names )
+        {
+            Serializable settingValue = getSystemSetting( name );
+
+            if ( settingValue == null )
+            {
+                Optional<Setting> setting = Setting.getByName( name );
+                
+                if ( setting.isPresent() )
+                {
+                    settingValue = setting.get().getDefaultValue();
+                }
+            }
+            
+            if ( settingValue != null )
+            {
+                map.put( name, settingValue );
+            }
+        }
+
+        return map;
+    }
+    
     // -------------------------------------------------------------------------
     // Specific methods
     // -------------------------------------------------------------------------
@@ -257,58 +311,4 @@
         
         return value != null ? (List<String>) value : Collections.emptyList();
     }
-
-    @Override
-    public Map<String, Serializable> getSystemSettingsAsMap()
-    {
-        Map<String, Serializable> settingsMap = new HashMap<>();
-        Collection<SystemSetting> systemSettings = getAllSystemSettings();
-
-        for ( SystemSetting systemSetting : systemSettings )
-        {
-            Serializable settingValue = systemSetting.getValue();
-            
-            if ( settingValue == null )
-            {
-                Optional<Setting> setting = Setting.getByName( systemSetting.getName() );
-                
-                if ( setting.isPresent() )
-                {
-                    settingValue = setting.get().getDefaultValue();
-                }
-            }
-
-            settingsMap.put( systemSetting.getName(), settingValue );
-        }
-
-        return settingsMap;
-    }
-
-    @Override
-    public Map<String, Serializable> getSystemSettingsAsMap( Set<String> names )
-    {
-        Map<String, Serializable> map = new HashMap<>();
-
-        for ( String name : names )
-        {
-            Serializable settingValue = getSystemSetting( name );
-
-            if ( settingValue == null )
-            {
-                Optional<Setting> setting = Setting.getByName( name );
-                
-                if ( setting.isPresent() )
-                {
-                    settingValue = setting.get().getDefaultValue();
-                }
-            }
-            
-            if ( settingValue != null )
-            {
-                map.put( name, settingValue );
-            }
-        }
-
-        return map;
-    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java	2015-09-14 17:57:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java	2015-10-06 22:23:53 +0000
@@ -46,6 +46,7 @@
 import org.hisp.dhis.dxf2.webmessage.WebMessageException;
 import org.hisp.dhis.external.location.LocationManager;
 import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException;
+import org.hisp.dhis.setting.Setting;
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.webapi.utils.ContextUtils;
 import org.hisp.dhis.webapi.utils.WebMessageUtils;
@@ -239,9 +240,9 @@
             throw new WebMessageException( WebMessageUtils.conflict( "No config specified" ) );
         }
 
-        String appBaseUrl = StringUtils.trimToNull( config.get( AppManager.KEY_APP_BASE_URL ) );
-        String appFolderPath = StringUtils.trimToNull( config.get( AppManager.KEY_APP_FOLDER_PATH ) );
-        String appStoreUrl = StringUtils.trimToNull( config.get( AppManager.KEY_APP_STORE_URL ) );
+        String appBaseUrl = StringUtils.trimToNull( config.get( Setting.APP_BASE_URL.getName() ) );
+        String appFolderPath = StringUtils.trimToNull( config.get( Setting.APP_FOLDER_PATH.getName() ) );
+        String appStoreUrl = StringUtils.trimToNull( config.get( Setting.APP_STORE_URL.getName() ) );
 
         if ( appBaseUrl != null )
         {

=== 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-06 22:15:19 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2015-10-06 22:23:53 +0000
@@ -28,8 +28,44 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.interceptor.Interceptor;
+import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL;
+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_ANALYSIS_RELATIVE_PERIOD;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_ANALYTICS_MAINTENANCE_MODE;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_ANALYTICS_MAX_LIMIT;
+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_CACHE_STRATEGY;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS;
+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_CUSTOM_LOGIN_PAGE_LOGO;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_CUSTOM_TOP_MENU_LOGO;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_DATABASE_SERVER_CPUS;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_FACTOR_OF_DEVIATION;
+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_HIDE_UNAPPROVED_DATA_IN_ANALYTICS;
+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_PHONE_NUMBER_AREA_CODE;
+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.KEY_SYSTEM_NOTIFICATIONS_EMAIL;
+import static org.hisp.dhis.setting.SystemSettingManager.SYSPROP_PORTAL;
+
+import java.util.HashMap;
+import java.util.Map;
 
 import org.hisp.dhis.calendar.CalendarService;
 import org.hisp.dhis.configuration.ConfigurationService;
@@ -37,12 +73,8 @@
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;
-import static org.hisp.dhis.appmanager.AppManager.KEY_APP_BASE_URL;
-import static org.hisp.dhis.setting.SystemSettingManager.*;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.Interceptor;
 
 /**
  * @author Lars Helge Overland
@@ -93,8 +125,8 @@
     {
         Map<String, Object> map = new HashMap<>();
 
-        map.put( CalendarService.KEY_CALENDAR, calendarService.getSystemCalendarKey() );
-        map.put( CalendarService.KEY_DATE_FORMAT, calendarService.getSystemDateFormatKey() );
+        map.put( Setting.CALENDAR.getName(), calendarService.getSystemCalendarKey() );
+        map.put( Setting.DATE_FORMAT.getName(), calendarService.getSystemDateFormatKey() );
         
         map.put( DATE_FORMAT, calendarService.getSystemDateFormat() );
         map.put( KEY_CACHE_STRATEGY, systemSettingManager.getSystemSetting( Setting.CACHE_STRATEGY ) );
@@ -113,7 +145,7 @@
         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( KEY_APP_BASE_URL, systemSettingManager.getSystemSetting( KEY_APP_BASE_URL ) );
+        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() );