Package ywebservicespackage.controllers
Class SampleController
- java.lang.Object
-
- ywebservicespackage.controllers.SampleController
-
@Controller @RequestMapping("/sample") public class SampleController extends java.lang.ObjectSample Controller
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_FIELD_SET
-
Constructor Summary
Constructors Constructor Description SampleController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetDouble(double value)java.util.List<java.lang.Object>getGetList()java.lang.LonggetLong(java.lang.Long value)java.util.Map<java.lang.String,java.lang.Object>getMap()SampleWsDTOgetSampleWsDTO(java.lang.String pathVariable)Sample method returning Cache-Control header and using Path Variable Example : GET http://localhost:9001/ywebservices/sample/dto/sampleValuejava.lang.StringgetString(java.lang.String val)SampleWsDTOgetTestBeanText()TestMapWsDTOgetTestMap()Request handler for getting object with map.UsersListWsDTOgetUsers(java.lang.String fields)Request handler for list response.UserWsDTOgetUsers(java.lang.String id, java.lang.String fields)Request handler for particular user.UsersPageWsDTOgetUsersPaged(java.lang.String fields, java.util.Map<java.lang.String,java.lang.String> params)Request handler for paginated response.SampleWsDTOpostSampleWsDTO(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 voidvalidate(java.lang.Object object, java.lang.String objectName, org.springframework.validation.Validator validator)
-
-
-
Field Detail
-
DEFAULT_FIELD_SET
public static final java.lang.String DEFAULT_FIELD_SET
- See Also:
- Constant Field Values
-
-
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()
-
-