class MovieServiceImpl implements MovieService {

    @Override
    public MovieDto createMovie(MovieDto movieDto) {
        movieDto.setId(UUID.randomUUID());
        movieDto.setCreationTimestamp(Instant.now());
        movieDto.setUpdateTimestamp(Instant.now());

        final Movie movie = movieMapper.movieDtoToMovie(movieDto);
        movie.setRevision(UUID.randomUUID().toString());
        movie.setUpdated(true);
        movie.setDeleted(false);
        movie.setTotalLikes(0);
        movie.setPendingLikes(new HashSet<>());
        movie.setPendingUnlikes(new HashSet<>());

        try {
            movieRepository.save(movie);
        }
        catch (final Exception ex) {
            final String errorMessage = String.format("An error occured while creating a new movie: %s",
                ex.getMessage());

            log.error(errorMessage, ex);
            throw new MoviePersistenceException(errorMessage, ex);
        }

        movieIndexHelper.indexMovie(movie);

        return movieDto;
    }

}