Пример #1
0
 private void setLike(long id, String user, HttpServletResponse res, boolean isLike) {
   Video v = videos.findOne(id);
   int code = HttpServletResponse.SC_OK;
   if (v == null) {
     code = HttpServletResponse.SC_NOT_FOUND;
   } else {
     if (isLike ? v.addLikedUser(user) : v.removeLikedUser(user)) {
       videos.save(v);
     } else {
       code = HttpServletResponse.SC_BAD_REQUEST;
     }
   }
   res.setStatus(code);
 }
Пример #2
0
 @RequestMapping(value = VIDEO_LIKEDBY_PATH, method = RequestMethod.GET)
 public @ResponseBody Set<String> likedbyVideo(@PathVariable(VIDEO_ID) long id) {
   Video v = videos.findOne(id);
   if (v == null) {
     throw new ResourceNotFoundException();
   }
   return v.getLikedUsers();
 }
Пример #3
0
 @RequestMapping(method = RequestMethod.POST)
 public @ResponseBody Video addVideo(@RequestBody Video v) {
   return videos.save(v);
 }
Пример #4
0
 @RequestMapping(value = VIDEO_ID_PATH, method = RequestMethod.GET)
 public @ResponseBody Video getVideo(@PathVariable long id) {
   return videos.findOne(id);
 }
Пример #5
0
 @RequestMapping(method = RequestMethod.GET)
 public @ResponseBody Collection<Video> getVideoList() {
   return Lists.newArrayList(videos.findAll());
 }