Ejemplo n.º 1
0
  @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;
  }
 public List<UserFriend> transform(List<User> users)
     throws com.geogenie.geo.service.exception.ServiceException {
   List<UserFriend> userFriends = new ArrayList<>();
   if (users != null && !users.isEmpty()) {
     for (User user : users) {
       UserFriend userFriend = new UserFriend();
       userFriend.setEmailId(user.getEmailId());
       userFriend.setName(user.getName());
       userFriend.setProfilePic(user.getProfilePictureURL());
       userFriends.add(userFriend);
     }
   }
   return userFriends;
 };