@RequestMapping( value = "/movies/{movieId}", method = RequestMethod.POST, headers = "Accept=text/html") public String updateMovie( Model model, @PathVariable String movieId, @RequestParam(value = "rated", required = false) Integer stars, @RequestParam(value = "comment", required = false) String comment) { Movie movie = moviesRepository.getMovie(movieId); User user = userDetailsService.getUserFromSession(); moviesRepository.rateMovie( movie, user, stars == null ? -1 : stars, comment != null ? comment.trim() : null); return singleMovieView(model, movieId); }
/** * Only matches 'GET /moviies/{id}}' requests for JSON content; a 404 is sent otherwise. TODO send * a 406 if an unsupported representation, such as XML, is requested. See SPR-7353. */ @RequestMapping( value = "/movies/{id}", method = RequestMethod.GET, headers = "Accept=application/json") public @ResponseBody Movie getMovie(@PathVariable String id) { return moviesRepository.getMovie(id); }
@RequestMapping(value = "/movies", method = RequestMethod.GET, headers = "Accept=text/html") public String findMovies(Model model, @RequestParam("q") String query) { List<Movie> movies = moviesRepository.findMovies(query, 20); model.addAttribute("movies", movies); model.addAttribute("query", query); addUser(model); return "/movies/list"; }
@RequestMapping(value = "/actors/{id}", method = RequestMethod.GET, headers = "Accept=text/html") public String singleActorView(Model model, @PathVariable String id) { Person person = moviesRepository.getPerson(id); model.addAttribute("actor", person); model.addAttribute("id", id); model.addAttribute("roles", IteratorUtil.asCollection(person.getRoles())); addUser(model); return "/actors/show"; }
@RequestMapping( value = "/movies/{movieId}", method = RequestMethod.GET, headers = "Accept=text/html") public String singleMovieView(final Model model, @PathVariable String movieId) { User user = addUser(model); Movie movie = moviesRepository.getMovie(movieId); model.addAttribute("id", movieId); if (movie != null) { model.addAttribute("movie", movie); final int stars = movie.getStars(); model.addAttribute("stars", stars); Rating rating = null; if (user != null) rating = movie.getRelationshipTo(user, Rating.class, "RATED"); if (rating == null) rating = new Rating().rate(stars, null); model.addAttribute("userRating", rating); } return "/movies/show"; }