dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38491
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19607: use WebMessage in FileController
------------------------------------------------------------
revno: 19607
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-07-10 10:07:16 +0700
message:
use WebMessage in FileController
modified:
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-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-02-19 09:18:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FileController.java 2015-07-10 03:07:16 +0000
@@ -30,8 +30,10 @@
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.webapi.service.WebMessageService;
import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
+import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
@@ -39,6 +41,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Writer;
@@ -61,6 +64,9 @@
@Autowired
private ContextUtils contextUtils;
+ @Autowired
+ private WebMessageService webMessageService;
+
// -------------------------------------------------------------------------
// Custom script
// -------------------------------------------------------------------------
@@ -78,12 +84,12 @@
@RequestMapping( value = "/script", method = RequestMethod.POST, consumes = "application/javascript" )
@PreAuthorize( "hasRole('ALL') or hasRole('F_INSERT_CUSTOM_JS_CSS')" )
- public void postCustomScript( @RequestBody String content, HttpServletResponse response )
+ public void postCustomScript( @RequestBody String content, HttpServletResponse response, HttpServletRequest request )
{
if ( content != null )
{
systemSettingManager.saveSystemSetting( KEY_CUSTOM_JS, content );
- ContextUtils.okResponse( response, "Custom script created" );
+ webMessageService.send( WebMessageUtils.ok( "Custom script created" ), response, request );
}
}
@@ -114,12 +120,12 @@
@RequestMapping( value = "/style", method = RequestMethod.POST, consumes = "text/css" )
@PreAuthorize( "hasRole('ALL') or hasRole('F_INSERT_CUSTOM_JS_CSS')" )
- public void postCustomStyle( @RequestBody String content, HttpServletResponse response )
+ public void postCustomStyle( @RequestBody String content, HttpServletResponse response, HttpServletRequest request )
{
if ( content != null )
{
systemSettingManager.saveSystemSetting( KEY_CUSTOM_CSS, content );
- ContextUtils.okResponse( response, "Custom style created" );
+ webMessageService.send( WebMessageUtils.ok( "Custom style created" ), response, request );
}
}