示例#1
0
 /**
  * Gets a user by the specified email.
  *
  * @param email the specified email
  * @return user, returns {@code null} if not found
  * @throws ServiceException service exception
  */
 public JSONObject getUserByEmail(final String email) throws ServiceException {
   try {
     return userRepository.getByEmail(email);
   } catch (final RepositoryException e) {
     LOGGER.log(Level.ERROR, "Gets user by email[" + email + "] failed", e);
     throw new ServiceException(e);
   }
 }
示例#2
0
  /**
   * Gets the current user.
   *
   * @param request the specified request
   * @return the current user, {@code null} if not found
   */
  public JSONObject getCurrentUser(final HttpServletRequest request) {
    final GeneralUser currentUser = userService.getCurrentUser(request);

    if (null == currentUser) {
      return null;
    }

    final String email = currentUser.getEmail();

    try {
      return userRepository.getByEmail(email);
    } catch (final RepositoryException e) {
      LOGGER.log(Level.ERROR, "Gets current user by request failed, returns null", e);

      return null;
    }
  }