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
      double getDouble​(double value)  
      java.util.List<java.lang.Object> getGetList()  
      java.lang.Long getLong​(java.lang.Long value)  
      java.util.Map<java.lang.String,​java.lang.Object> getMap()  
      SampleWsDTO getSampleWsDTO​(java.lang.String pathVariable)
      Sample method returning Cache-Control header and using Path Variable
      Example :
      GET http://localhost:9001/ywebservices/sample/dto/sampleValue
      java.lang.String getString​(java.lang.String val)  
      SampleWsDTO getTestBeanText()  
      TestMapWsDTO getTestMap()
      Request handler for getting object with map.
      UsersListWsDTO getUsers​(java.lang.String fields)
      Request handler for list response.
      UserWsDTO getUsers​(java.lang.String id, java.lang.String fields)
      Request handler for particular user.
      UsersPageWsDTO getUsersPaged​(java.lang.String fields, java.util.Map<java.lang.String,​java.lang.String> params)
      Request handler for paginated response.
      SampleWsDTO postSampleWsDTO​(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"}
      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

      • getSampleWsDTO

        @RequestMapping(value="/dto/{pathVariable}",
                        method=GET)
        @ResponseBody
        public SampleWsDTO getSampleWsDTO​(@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
      • postSampleWsDTO

        @RequestMapping(value="/dto",
                        method=POST)
        @ResponseStatus(CREATED)
        @ResponseBody
        public SampleWsDTO postSampleWsDTO​(@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)
      • getUsers

        @RequestMapping(value="/users",
                        method=GET)
        @ResponseBody
        public UsersListWsDTO getUsers​(@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))
      • getUsersPaged

        @RequestMapping(value="/usersPaged",
                        method=GET)
        @ResponseBody
        public UsersPageWsDTO getUsersPaged​(@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
      • getUsers

        @RequestMapping(value="/users/{id}",
                        method=GET)
        @ResponseBody
        public UserWsDTO getUsers​(@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

        @RequestMapping(value="/map",
                        method=GET)
        @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
      • getString

        @RequestMapping(value="plain/string",
                        method=POST)
        @ResponseBody
        public java.lang.String getString​(@RequestBody
                                          java.lang.String val)
      • getLong

        @RequestMapping(value="plain/long",
                        method=POST)
        @ResponseBody
        public java.lang.Long getLong​(@RequestBody
                                      java.lang.Long value)
      • getDouble

        @RequestMapping(value="plain/double",
                        method=POST)
        @ResponseBody
        public double getDouble​(@RequestBody
                                double value)
      • getGetList

        @RequestMapping(value="plain/list",
                        method=GET)
        @ResponseBody
        public java.util.List<java.lang.Object> getGetList()
      • getMap

        @RequestMapping(value="plain/map",
                        method=GET)
        @ResponseBody
        public java.util.Map<java.lang.String,​java.lang.Object> getMap()
      • getTestBeanText

        @RequestMapping(value="/testBean",
                        method=GET)
        @ResponseBody
        public SampleWsDTO getTestBeanText()