<commit_before>package net.toracode.moviedb.controllers.api;

import net.toracode.moviedb.entities.Movie;
import net.toracode.moviedb.entities.Review;
import net.toracode.moviedb.entities.User;
import net.toracode.moviedb.services.MovieService;
import net.toracode.moviedb.services.ReviewService;
import net.toracode.moviedb.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by sayemkcn on 10/25/16.
 */
@RestController
@RequestMapping(value = "/api/review")
public class ReviewApiController {
    @Autowired
    private ReviewService reviewService;
    @Autowired
    private UserService userService;
    @Autowired
    private MovieService movieService;

    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public ResponseEntity<Review> createReview(@ModelAttribute Review review, BindingResult bindingResult, @RequestParam("accountId") String accountId, @RequestParam("movieId") Long movieId) {
        User user = this.userService.getUserByAccountId(accountId);
        Movie movie = this.movieService.getMovie(movieId);
        // check if this fucking user has already a review in this movie
        // if true then restrict the fuck him from submitting another fucking review
        List<Review> reviewList = this.reviewService.getReviewByMovie(movie);
        if (reviewList!= null){
            for (Review r : reviewList){
                if (r.getUser().getAccountId().equals(accountId))
                    return new ResponseEntity<Review>(HttpStatus.LOCKED);
            }
        }

        // end
        if (user == null || movie == null)
            return new ResponseEntity<Review>(HttpStatus.NOT_ACCEPTABLE);
        review.setUser(user);
        review.setMovie(movie);
        review = this.reviewService.saveReview(review);
        return new ResponseEntity<Review>(review,HttpStatus.CREATED);
    }

}
<commit_msg>update review<commit_after>package net.toracode.moviedb.controllers.api;

import net.toracode.moviedb.entities.Movie;
import net.toracode.moviedb.entities.Review;
import net.toracode.moviedb.entities.User;
import net.toracode.moviedb.services.MovieService;
import net.toracode.moviedb.services.ReviewService;
import net.toracode.moviedb.services.UserService;
import org.apache.catalina.connector.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by sayemkcn on 10/25/16.
 */
@RestController
@RequestMapping(value = "/api/review")
public class ReviewApiController {
    @Autowired
    private ReviewService reviewService;
    @Autowired
    private UserService userService;
    @Autowired
    private MovieService movieService;

    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public ResponseEntity<Review> createReview(@ModelAttribute Review review, BindingResult bindingResult, @RequestParam("accountId") String accountId, @RequestParam("movieId") Long movieId) {
        User user = this.userService.getUserByAccountId(accountId);
        Movie movie = this.movieService.getMovie(movieId);
        // check if this fucking user has already a review in this movie
        // if true then restrict the fuck him from submitting another fucking review
        List<Review> reviewList = this.reviewService.getReviewByMovie(movie);
        if (reviewList != null) {
            for (Review r : reviewList) {
                if (r.getUser().getAccountId().equals(accountId))
                    return new ResponseEntity<Review>(HttpStatus.LOCKED);
            }
        }

        // end
        if (user == null || movie == null)
            return new ResponseEntity<Review>(HttpStatus.NOT_ACCEPTABLE);
        review.setUser(user);
        review.setMovie(movie);
        review = this.reviewService.saveReview(review);
        return new ResponseEntity<Review>(review, HttpStatus.CREATED);
    }

    @RequestMapping(value = "/update/{reviewId}", method = RequestMethod.POST)
    public ResponseEntity<Review> updateReview(@ModelAttribute Review review, BindingResult bindingResult, @PathVariable("reviewId") Long reviewId, @RequestParam("accountId") String accountId, @RequestParam("movieId") Long movieId) {
        if (bindingResult.hasErrors())
            return new ResponseEntity<Review>(HttpStatus.BAD_REQUEST);
        review.setUniqueId(reviewId);
        User user = this.userService.getUserByAccountId(accountId);
        if (user == null) {
            return new ResponseEntity<Review>(HttpStatus.FORBIDDEN);
        }
        review.setUser(user);
        Movie movie = this.movieService.getMovie(movieId);
        if (movie == null) {
            return new ResponseEntity<Review>(HttpStatus.NOT_ACCEPTABLE);
        }
        review.setMovie(movie);
        review = this.reviewService.saveReview(review);
        return new ResponseEntity<Review>(review, HttpStatus.CREATED);
    }

}

{'fraction_non_alphanumeric': 0.10122295390404515, 'fraction_numerical': 0.002257761053621825, 'mean_word_length': 3.6672519754170323, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5398392', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1430, 'n_words': 310}