Example #1
0
  @Api(level = Role.USER)
  @RequestMapping(
      value = {PathVariables.PAGE_NUMBER + "/" + PathVariables.PAGE_SIZE},
      method = RequestMethod.GET)
  @ResponseBody
  public ApiResult getProfileHistory(
      @PathVariable String userKey,
      @PathVariable String profileHistoryType,
      @PathVariable int pageNumber,
      @PathVariable int pageSize,
      Locale locale)
      throws Exception {
    logger.debug("getProfileHistory!");

    if (!ProfileHistoryType.isValidType(profileHistoryType)) {
      logger.debug("Invalid parameter: wrong type");
      throw new InvalidParameterException("wrong type");
    }

    if (pageNumber <= 0 || pageSize <= 0 || pageSize > HistoryConstants.MAX_PAGE_SIZE) {
      logger.debug("Invalid parameter: wrong page request");
      throw new InvalidParameterException("wrong page request");
    }

    ProfileHistoryType type = ProfileHistoryType.search(profileHistoryType);
    List<UserHistory> list =
        historyService.getUserHistory(userKey, type.getReason(), pageNumber, pageSize);

    ProfileHistoryResult result = new ProfileHistoryResult(list);
    return resultFactory.getSuccess(result, locale);
  }
Example #2
0
  @Api(level = Role.USER)
  @RequestMapping(
      value = {"latest"},
      method = RequestMethod.GET)
  @ResponseBody
  public ApiResult getProfileHistoryLatest(
      @PathVariable String userKey, @PathVariable String profileHistoryType, Locale locale)
      throws Exception {
    logger.debug("getProfileHistoryLatest!");

    if (!ProfileHistoryType.isValidType(profileHistoryType)) {
      logger.debug("Invalid parameter: wrong type");
      throw new InvalidParameterException("wrong type");
    }

    ProfileHistoryType type = ProfileHistoryType.search(profileHistoryType);
    List<UserHistory> list =
        historyService.getUserHistory(
            userKey,
            type.getReason(),
            HistoryConstants.LATEST_PAGE_NUMBER,
            HistoryConstants.LATEST_PAGE_SIZE);

    ProfileHistoryResult result = new ProfileHistoryResult(list);
    return resultFactory.getSuccess(result, locale);
  }