← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20542: Setting in FileController

 

------------------------------------------------------------
revno: 20542
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-06 23:55:05 +0200
message:
  Setting in FileController
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
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FileController.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 18:35:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/Setting.java	2015-10-06 21:55:05 +0000
@@ -104,7 +104,9 @@
     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 );
+    DATA_IMPORT_REQUIRE_ATTRIBUTE_OPTION_COMBO( "keyDataImportRequireAttributeOptionCombo", Boolean.FALSE, Boolean.class ),
+    CUSTOM_JS( "keyCustomJs" ),
+    CUSTOM_CSS( "keyCustomCss" );
     
     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 18:35:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2015-10-06 21:55:05 +0000
@@ -136,6 +136,12 @@
     List<SystemSetting> getAllSystemSettings();
 
     void deleteSystemSetting( String name );
+    
+    void deleteSystemSetting( Setting setting );
+
+    // -------------------------------------------------------------------------
+    // Specific methods
+    // -------------------------------------------------------------------------
 
     List<String> getFlags();
 

=== 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 18:35:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java	2015-10-06 21:55:05 +0000
@@ -132,7 +132,7 @@
     {
         return systemSettingStore.getAll();
     }
-
+    
     @Override
     public void deleteSystemSetting( String name )
     {
@@ -144,6 +144,12 @@
         }
     }
 
+    @Override
+    public void deleteSystemSetting( Setting setting )
+    {
+        deleteSystemSetting( setting.getName() );
+    }
+
     // -------------------------------------------------------------------------
     // Specific methods
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FileController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FileController.java	2015-07-15 15:49:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FileController.java	2015-10-06 21:55:05 +0000
@@ -29,6 +29,7 @@
  */
 
 import org.apache.commons.lang3.StringUtils;
+import org.hisp.dhis.setting.Setting;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.webapi.service.WebMessageService;
 import org.hisp.dhis.webapi.utils.ContextUtils;
@@ -43,6 +44,7 @@
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
 import java.io.IOException;
 import java.io.Writer;
 
@@ -55,9 +57,6 @@
 {
     public static final String RESOURCE_PATH = "/files";
 
-    private static final String KEY_CUSTOM_JS = "keyCustomJs";
-    private static final String KEY_CUSTOM_CSS = "keyCustomCss";
-
     @Autowired
     private SystemSettingManager systemSettingManager;
 
@@ -77,7 +76,7 @@
     {
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JAVASCRIPT, CacheStrategy.CACHE_TWO_WEEKS );
 
-        String content = (String) systemSettingManager.getSystemSetting( KEY_CUSTOM_JS, StringUtils.EMPTY );
+        String content = (String) systemSettingManager.getSystemSetting( Setting.CUSTOM_JS, StringUtils.EMPTY );
 
         writer.write( content );
     }
@@ -88,7 +87,7 @@
     {
         if ( content != null )
         {
-            systemSettingManager.saveSystemSetting( KEY_CUSTOM_JS, content );
+            systemSettingManager.saveSystemSetting( Setting.CUSTOM_JS, content );
             webMessageService.send( WebMessageUtils.ok( "Custom script created" ), response, request );
         }
     }
@@ -97,7 +96,7 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_INSERT_CUSTOM_JS_CSS')" )
     public void removeCustomScript( HttpServletResponse response )
     {
-        systemSettingManager.deleteSystemSetting( KEY_CUSTOM_JS );
+        systemSettingManager.deleteSystemSetting( Setting.CUSTOM_JS );
     }
 
     // -------------------------------------------------------------------------
@@ -113,7 +112,7 @@
     {
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSS, CacheStrategy.CACHE_TWO_WEEKS );
 
-        String content = (String) systemSettingManager.getSystemSetting( KEY_CUSTOM_CSS, StringUtils.EMPTY );
+        String content = (String) systemSettingManager.getSystemSetting( Setting.CUSTOM_CSS, StringUtils.EMPTY );
 
         writer.write( content );
     }
@@ -124,7 +123,7 @@
     {
         if ( content != null )
         {
-            systemSettingManager.saveSystemSetting( KEY_CUSTOM_CSS, content );
+            systemSettingManager.saveSystemSetting( Setting.CUSTOM_CSS, content );
             webMessageService.send( WebMessageUtils.ok( "Custom style created" ), response, request );
         }
     }
@@ -133,6 +132,6 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_INSERT_CUSTOM_JS_CSS')" )
     public void removeCustomStyle( HttpServletResponse response )
     {
-        systemSettingManager.deleteSystemSetting( KEY_CUSTOM_CSS );
+        systemSettingManager.deleteSystemSetting( Setting.CUSTOM_CSS );
     }
 }