Class SampleController


  • @Controller
    @RequestMapping("/sample")
    public class SampleController
    extends java.lang.Object
    Sample Controller
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_FIELD_SET  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      SampleWsDTO createSample​(SampleWsDTO sampleWsDTO)
      Sample method showing how to validate object given in POST body parameter
      Example :
      URL : http://localhost:9001/ywebservices/sample/dto
      Method : POST
      Header : Content-Type=application/json
      POST body parameter :{ "value" : "sampleValue"}
      double doProcessDouble​(double value)  
      java.lang.Long doProcessLong​(java.lang.Long value)  
      java.lang.String doProcessString​(java.lang.String val)  
      java.util.List<java.lang.Object> getList()  
      java.util.Map<java.lang.String,​java.lang.Object> getMap()  
      SampleWsDTO getSample​(java.lang.String pathVariable)
      Sample method returning Cache-Control header and using Path Variable
      Example :
      GET http://localhost:9001/ywebservices/sample/dto/sampleValue
      SampleWsDTO getTestBeanText()  
      TestMapWsDTO getTestMap()
      Request handler for getting object with map.
      UserWsDTO getUser​(java.lang.String id, java.lang.String fields)
      Request handler for particular user.
      UsersPageWsDTO getUsers​(java.lang.String fields, java.util.Map<java.lang.String,​java.lang.String> params)
      Request handler for paginated response.
      UsersListWsDTO getUsersList​(java.lang.String fields)
      Request handler for list response.
      protected void validate​(java.lang.Object object, java.lang.String objectName, org.springframework.validation.Validator validator)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_FIELD_SET

        public static final java.lang.String DEFAULT_FIELD_SET
        See Also:
        Constant Field Values
    • Constructor Detail

      • SampleController

        public SampleController()
    • Method Detail

      • getSample

        @GetMapping("/dto/{pathVariable}")
        @ResponseBody
        public SampleWsDTO getSample​(@PathVariable
                                     java.lang.String pathVariable)
        Sample method returning Cache-Control header and using Path Variable
        Example :
        GET http://localhost:9001/ywebservices/sample/dto/sampleValue
        Parameters:
        pathVariable - - sample path variable parameter
        Returns:
        SampleWsDTO object filled with pathVariable value
      • createSample

        @PostMapping("/dto")
        @ResponseStatus(CREATED)
        @ResponseBody
        public SampleWsDTO createSample​(@RequestBody
                                        SampleWsDTO sampleWsDTO)
        Sample method showing how to validate object given in POST body parameter
        Example :
        URL : http://localhost:9001/ywebservices/sample/dto
        Method : POST
        Header : Content-Type=application/json
        POST body parameter :{ "value" : "sampleValue"}
        Parameters:
        sampleWsDTO - - Request body parameter (DTO in xml or json format)
        Returns:
        - The same object, which was send in POST body
      • validate

        protected void validate​(java.lang.Object object,
                                java.lang.String objectName,
                                org.springframework.validation.Validator validator)
      • getUsersList

        @GetMapping("/users")
        @ResponseBody
        public UsersListWsDTO getUsersList​(@RequestParam(required=false,defaultValue="DEFAULT")
                                           java.lang.String fields)
        Request handler for list response. Retrieves all user from userService and maps Collection of UserModel to UserListWsDTO Mapping is done according to configuration in WEB-INF/config/field-mapping.xml Sample url's:
        • http://localhost:9001/ywebservices/sample/users
        • http://localhost:9001/ywebservices/sample/users?fields=users(info)
        • http://localhost:9001/ywebservices/sample/users?fields=users(BASIC)
        • http://localhost:9001/ywebservices/sample/users?fields=users(DEFAULT)
        • http://localhost:9001/ywebservices/sample/users?fields=users(FULL)
        • http://localhost:9001/ywebservices/sample/users?fields=users(firstName,addresses(street))
      • getUsers

        @GetMapping("/usersPaged")
        @ResponseBody
        public UsersPageWsDTO getUsers​(@RequestParam(required=false,defaultValue="DEFAULT")
                                       java.lang.String fields,
                                       @RequestParam
                                       java.util.Map<java.lang.String,​java.lang.String> params)
        Request handler for paginated response. Retrieves user from userService and maps result to UsersPageWsDTO Mapping is done according to configuration in WEB-INF/config/field-mapping.xml Sample url's:
        • http://localhost:9001/ywebservices/sample/usersPaged
        • http://localhost:9001/ywebservices/sample/usersPaged?currentPage=1
        • http://localhost:9001/ywebservices/sample/usersPaged?currentPage=0?pageSize=1
      • getUser

        @GetMapping("/users/{id}")
        @ResponseBody
        public UserWsDTO getUser​(@PathVariable
                                 java.lang.String id,
                                 @RequestParam(required=false,defaultValue="DEFAULT")
                                 java.lang.String fields)
        Request handler for particular user. Retrieves single user from userService and maps UserModel to UserWsDTO Mapping is done according to configuration in WEB-INF/config/field-mapping.xml Sample url's:
        • http://localhost:9001/ywebservices/sample/users/user1
        • http://localhost:9001/ywebservices/sample/users/user1?fields=info
        • http://localhost:9001/ywebservices/sample/users/user1?fields=BASIC
        • http://localhost:9001/ywebservices/sample/users/user1?fields=DEFAULT
        • http://localhost:9001/ywebservices/sample/users/user1?fields=FULL
        • http://localhost:9001/ywebservices/sample/users/user1?fields=firstName,addresses(street)
      • getTestMap

        @GetMapping("/map")
        @ResponseBody
        public TestMapWsDTO getTestMap()
        Request handler for getting object with map. Created to test adapters for particular fields.

        Url: http://localhost:9001/ywebservices/sample/map

      • doProcessString

        @PostMapping("plain/string")
        @ResponseBody
        public java.lang.String doProcessString​(@RequestBody
                                                java.lang.String val)
      • doProcessLong

        @PostMapping("plain/long")
        @ResponseBody
        public java.lang.Long doProcessLong​(@RequestBody
                                            java.lang.Long value)
      • doProcessDouble

        @PostMapping("plain/double")
        @ResponseBody
        public double doProcessDouble​(@RequestBody
                                      double value)
      • getList

        @GetMapping("plain/list")
        @ResponseBody
        public java.util.List<java.lang.Object> getList()
      • getMap

        @GetMapping("plain/map")
        @ResponseBody
        public java.util.Map<java.lang.String,​java.lang.Object> getMap()
      • getTestBeanText

        @GetMapping("/testBean")
        @ResponseBody
        public SampleWsDTO getTestBeanText()