Package ywebservicespackage.controllers
Class SampleController
java.lang.Object
ywebservicespackage.controllers.SampleController
Sample Controller
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateSample(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"}doubledoProcessDouble(double value) doProcessLong(Long value) doProcessString(String val) getList()getMap()Sample method returning Cache-Control header and using Path Variable Example : GET http://localhost:9001/ywebservices/sample/dto/sampleValueRequest handler for getting object with map.Request handler for particular user.Request handler for paginated response.getUsersList(String fields) Request handler for list response.voidupdateUser(String userId, UserWsDTO user) Sample method for updating data of particular user using PATCH request.protected void
-
Field Details
-
DEFAULT_FIELD_SET
- See Also:
-
-
Constructor Details
-
SampleController
public SampleController()
-
-
Method Details
-
getSample
@GetMapping(value="/dto/{pathVariable}", produces={"application/json","application/xml"}) @ResponseBody public SampleWsDTO getSample(@PathVariable 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(value="/dto", consumes={"application/json","application/xml"}, produces={"application/json","application/xml"}) @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
-
getUsersList
@GetMapping(value="/users", produces={"application/json","application/xml"}) @ResponseBody public UsersListWsDTO getUsersList(@RequestParam(required=false,defaultValue="DEFAULT") 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(value="/usersPaged", produces={"application/json","application/xml"}) @ResponseBody public UsersPageWsDTO getUsers(@RequestParam(required=false,defaultValue="DEFAULT") String fields, @RequestParam Map<String, 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(value="/users/{id}", produces={"application/json","application/xml"}) @ResponseBody public UserWsDTO getUser(@PathVariable String id, @RequestParam(required=false,defaultValue="DEFAULT") 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)
-
updateUser
@PatchMapping(value="/users/{userId}", consumes={"application/json","application/xml"}) @ResponseStatus(OK) public void updateUser(@PathVariable String userId, @RequestBody UserWsDTO user) Sample method for updating data of particular user using PATCH request.- Parameters:
userId- User identifieruser- Username and info as DTO in xml or json format
-
getTestMap
@GetMapping(value="/map", produces={"application/json","application/xml"}) @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
-
doProcessLong
-
doProcessDouble
@PostMapping("plain/double") @ResponseBody public double doProcessDouble(@RequestBody double value) -
getList
-
getMap
-
getTestBeanText
-