Source:
Map<String, Object> status(@PathVariable("contestId") Integer contestId, @PathVariable("lastFetched") Integer lastFetched, HttpSession session) { Map<String, Object> json = new HashMap<>(); try { UserDTO currentUser = getCurrentUser(session); ContestShowDTO contestShowDTO = contestService.getContestShowDTOByContestId(contestId); if (contestShowDTO == null) { throw new AppException("No such contest."); } if (!contestShowDTO.getIsVisible() && currentUser.getType() != Global.AuthenticationType.ADMIN.ordinal()) { throw new AppException("No such contest."); } StatusCondition statusCondition = new StatusCondition(); statusCondition.contestId = contestShowDTO.getContestId(); statusCondition.isForAdmin = isAdmin(session); statusCondition.orderFields = "time"; statusCondition.orderAsc = "true"; statusCondition.startId = lastFetched + 1; List<StatusListDTO> statusList = statusService.getStatusList(statusCondition); if (currentUser.getType() != Global.AuthenticationType.ADMIN.ordinal()) { for (StatusListDTO status: statusList) { if (!status.getUserName().equals(currentUser.getUserName())) { status.setLength(null); status.setTimeCost(null); status.setMemoryCost(null); status.setCaseNumber(null); status.setLanguage(null); } else { status.setReturnType(globalService.getReturnDescription(status.getReturnTypeId(), status.getCaseNumber())); if (status.getReturnTypeId() != Global.OnlineJudgeReturnType.OJ_AC.ordinal()) { status.setTimeCost(null); status.setMemoryCost(null); } } } } json.put("result", "success"); } catch (AppException e) { json.put("result", "error"); json.put("error_msg", e.getMessage()); } catch (Exception e) { e.printStackTrace(); json.put("result", "error"); json.put("error_msg", "Unknown exception occurred."); } return json; }

Target:
Map<String, Object> status(@PathVariable("contestId") Integer contestId, @PathVariable("lastFetched") Integer lastFetched, HttpSession session) { Map<String, Object> json = new HashMap<>(); try { UserDTO currentUser = getCurrentUser(session); ContestShowDTO contestShowDTO = contestService.getContestShowDTOByContestId(contestId); if (contestShowDTO == null) { throw new AppException("No such contest."); } if (!contestShowDTO.getIsVisible() && !isAdmin(session)) { throw new AppException("No such contest."); } StatusCondition statusCondition = new StatusCondition(); statusCondition.contestId = contestShowDTO.getContestId(); statusCondition.isForAdmin = isAdmin(session); statusCondition.orderFields = "time"; statusCondition.orderAsc = "true"; statusCondition.startId = lastFetched + 1; List<StatusListDTO> statusList = statusService.getStatusList(statusCondition); if (!isAdmin(session)) { for (StatusListDTO status: statusList) { if (!status.getUserName().equals(currentUser.getUserName())) { status.setLength(null); status.setTimeCost(null); status.setMemoryCost(null); status.setCaseNumber(null); status.setLanguage(null); } else { status.setReturnType(globalService.getReturnDescription(status.getReturnTypeId(), status.getCaseNumber())); if (status.getReturnTypeId() != Global.OnlineJudgeReturnType.OJ_AC.ordinal()) { status.setTimeCost(null); status.setMemoryCost(null); } } } } json.put("result", "success"); } catch (AppException e) { json.put("result", "error"); json.put("error_msg", e.getMessage()); } catch (Exception e) { e.printStackTrace(); json.put("result", "error"); json.put("error_msg", "Unknown exception occurred."); } return json; }