@RequestMapping( method = RequestMethod.POST, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}) @ResponseStatus(HttpStatus.CREATED) public User signinOrSignupUser( @RequestHeader(required = true, value = Constants.USER_TYPE_HEADER) String userType, @Valid @RequestBody User user, HttpServletRequest request) throws ServiceException { logger.info("### Request recieved- signinOrSignupUser. Arguments : {} ###" + user); logger.info(" Social Details : {} ", user.getSocialDetails()); logger.info(" User Type : " + userType); UserTypeBasedOnDevice userTypeBasedOnDevice = null; if (userType.equals(UserTypeBasedOnDevice.MOBILE.toString())) { userTypeBasedOnDevice = UserTypeBasedOnDevice.MOBILE; } else if (userType.equals(UserTypeBasedOnDevice.WEB.toString())) { userTypeBasedOnDevice = UserTypeBasedOnDevice.WEB; } else { throw new ClientException(RestErrorCodes.ERR_001, ERROR_USER_TYPE_INVALID); } User createdUser = userService.signupOrSignin(user, userTypeBasedOnDevice); logger.info("### Signup/Signin successfull for user : {} ", user.getEmailId()); return createdUser; }
@RequestMapping( method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}) @ResponseStatus(HttpStatus.OK) public List<User> getAllUsers() { logger.info("### Request recieved- Get All Users ###"); List<User> users = userService.getAllUsers(); return users; }
@RequestMapping( value = "/{id}", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}) @ResponseStatus(HttpStatus.OK) public User getUser(@PathVariable long id) { logger.debug("### Inside getUser method.Arguments {} ###", id); // TODO:Check if user can access other user's profile? User user = userService.getUser(id); return user; }