예제 #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());
 }