← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19196: reverted user setting API changes for now, will be put back soon

 

------------------------------------------------------------
revno: 19196
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-05-28 17:12:01 +0700
message:
  reverted user setting API changes for now, will be put back soon
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/UserSettingController.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/UserSettingController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/UserSettingController.java	2015-05-28 06:25:27 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/UserSettingController.java	2015-05-28 10:12:01 +0000
@@ -32,17 +32,15 @@
 import org.hisp.dhis.user.UserSettingService;
 import org.hisp.dhis.webapi.utils.ContextUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
 import java.io.Serializable;
 import java.util.Locale;
 
@@ -56,7 +54,7 @@
     @Autowired
     private UserSettingService userSettingService;
 
-    @RequestMapping( value = "/{key}", method = RequestMethod.POST )
+    @RequestMapping( value = "/{key}", method = RequestMethod.POST, consumes = { ContextUtils.CONTENT_TYPE_TEXT, ContextUtils.CONTENT_TYPE_HTML } )
     public void setUserSetting(
         @PathVariable String key,
         @RequestParam( value = "user", required = false ) String username,
@@ -90,40 +88,10 @@
         ContextUtils.okResponse( response, "User setting saved" );
     }
 
-    @RequestMapping( value = "/{key}", method = RequestMethod.GET )
-    public void getSystemSetting( @PathVariable( "key" ) String key,
-        @RequestParam( value = "user", required = false ) String username, HttpServletRequest request, HttpServletResponse response ) throws IOException
+    @RequestMapping( value = "/{key}", method = RequestMethod.GET, produces = ContextUtils.CONTENT_TYPE_TEXT )
+    public @ResponseBody String getSystemSetting( @PathVariable( "key" ) String key, @RequestParam( value = "user", required = false ) String username )
     {
-        String value;
-
-        if ( username == null )
-        {
-            value = getStringValue( key, userSettingService.getUserSetting( key ) );
-        }
-        else
-        {
-            value = getStringValue( key, userSettingService.getUserSetting( key, username ) );
-        }
-
-        if ( value == null )
-        {
-            ContextUtils.notFoundResponse( response, "User setting not found." );
-            return;
-        }
-
-        String contentType;
-
-        if ( request.getHeader( "Accept" ) == null || "*/*".equals( request.getHeader( "Accept" ) ) )
-        {
-            contentType = MediaType.TEXT_PLAIN_VALUE;
-        }
-        else
-        {
-            contentType = request.getHeader( "Accept" );
-        }
-
-        response.setContentType( contentType );
-        response.getWriter().println( value );
+        return username == null ? getStringValue( key, userSettingService.getUserSetting( key ) ) : getStringValue( key, userSettingService.getUserSetting( key, username ) );
     }
 
     @RequestMapping( value = "/{key}", method = RequestMethod.DELETE )