public List<Movie> getAllMovies() throws RentalServiceException {
   List<Movie> movies = movieDAO.getAll();
   if (log.isDebugEnabled()) {
     log.debug("getAllMovies() done");
   }
   return movies;
 }
 public void saveOrUpdateMovie(Movie movie) throws RentalServiceException {
   if (movie == null) {
     throw new RentalServiceException("'movie' parameter is not set!");
   }
   movieDAO.saveOrUpdate(movie);
   if (log.isDebugEnabled()) {
     log.debug("saved or updated movie[" + movie.getId() + "]");
   }
 }
  @SuppressWarnings("unchecked")
  public void deleteMovie(Movie movie) throws RentalServiceException {
    if (movie == null) {
      throw new RentalServiceException("'movie' parameter is not set!");
    }
    if (movie.isRented()) {
      throw new RentalServiceException("movie is still used");
    }

    if (movieDAO instanceof ManagedDAO<?>) {
      movie = ((ManagedDAO<Movie>) movieDAO).manage(movie);
    }

    movieDAO.delete(movie);

    if (log.isDebugEnabled()) {
      log.debug("movie[" + movie.getId() + "] deleted");
    }
  }
 public List<Movie> getMoviesByTitle(String title) throws RentalServiceException {
   return movieDAO.getByTitle(title);
 }
 public Movie getMovieById(Long id) throws RentalServiceException {
   return movieDAO.getById(id);
 }