<commit_before>package com.ciandt.techgallery.service;

import com.google.api.server.spi.response.BadRequestException;
import com.google.api.server.spi.response.InternalServerErrorException;
import com.google.api.server.spi.response.NotFoundException;
import com.google.appengine.api.users.User;

import com.ciandt.techgallery.service.model.Response;
import com.ciandt.techgallery.service.model.TechnologyCommentTO;
import com.ciandt.techgallery.service.model.TechnologyRecommendationTO;
import com.ciandt.techgallery.service.model.TechnologyResponse;
import com.ciandt.techgallery.service.model.UserResponse;
import com.ciandt.techgallery.utils.i18n.I18n;

public class TechnologyRecommendationCommentServiceImpl
    implements TechnologyRecommendationCommentService {

  private static final I18n i18n = I18n.getInstance();
  private TechnologyRecommendationService recService = new TechnologyRecommendationServiceImpl();
  private TechnologyCommentService comService = new TechnologyCommentServiceImpl();

  @Override
  public Response addRecommendationComment(TechnologyRecommendationTO recommendationTO,
      TechnologyCommentTO commentTO, TechnologyResponse technology, User user)
          throws BadRequestException, InternalServerErrorException, NotFoundException {
    Response response = null;
    if (isLoggedUserSameAsRecommender(user, recommendationTO, commentTO, technology)) {

      commentTO = (TechnologyCommentTO) comService.addComment(commentTO, user);
      recommendationTO =
          (TechnologyRecommendationTO) recService.addRecommendation(recommendationTO, user);

      return response;
    } else {
      throw new BadRequestException(i18n.t("Inconsistent users"));
    }

  }


  /**
   * Checks whether the logged in user is both the recommender and the commenter.
   * 
   * @param user logged in user
   * @param recommendationTO recommendation
   * @param commentTO comment
   * @param technology technology
   * @return true if the user is the same, false otherwise
   */
  private boolean isLoggedUserSameAsRecommender(User user,
      TechnologyRecommendationTO recommendationTO, TechnologyCommentTO commentTO,
      TechnologyResponse technology) {
    UserResponse recommender = recommendationTO.getRecommender();
    UserResponse commenter = commentTO.getAuthor();
    return user.getUserId() == recommender.getGoogleId()
        && user.getUserId() == commenter.getGoogleId();
  }

}<commit_msg>[TECG-19]/[TECG-147]: Fixing way of comparing string and long<commit_after>package com.ciandt.techgallery.service;

import com.google.api.server.spi.response.BadRequestException;
import com.google.api.server.spi.response.InternalServerErrorException;
import com.google.api.server.spi.response.NotFoundException;
import com.google.appengine.api.users.User;

import com.ciandt.techgallery.service.model.Response;
import com.ciandt.techgallery.service.model.TechnologyCommentTO;
import com.ciandt.techgallery.service.model.TechnologyRecommendationTO;
import com.ciandt.techgallery.service.model.TechnologyResponse;
import com.ciandt.techgallery.service.model.UserResponse;
import com.ciandt.techgallery.utils.i18n.I18n;

public class TechnologyRecommendationCommentServiceImpl
    implements TechnologyRecommendationCommentService {

  private static final I18n i18n = I18n.getInstance();
  private TechnologyRecommendationService recService = new TechnologyRecommendationServiceImpl();
  private TechnologyCommentService comService = new TechnologyCommentServiceImpl();

  @Override
  public Response addRecommendationComment(TechnologyRecommendationTO recommendationTO,
      TechnologyCommentTO commentTO, TechnologyResponse technology, User user)
          throws BadRequestException, InternalServerErrorException, NotFoundException {
    Response response = null;
    if (isLoggedUserSameAsRecommender(user, recommendationTO, commentTO, technology)) {

      commentTO = (TechnologyCommentTO) comService.addComment(commentTO, user);
      recommendationTO =
          (TechnologyRecommendationTO) recService.addRecommendation(recommendationTO, user);

      return response;
    } else {
      throw new BadRequestException(i18n.t("Inconsistent users"));
    }

  }


  /**
   * Checks whether the logged in user is both the recommender and the commenter.
   * 
   * @param user logged in user
   * @param recommendationTO recommendation
   * @param commentTO comment
   * @param technology technology
   * @return true if the user is the same, false otherwise
   */
  private boolean isLoggedUserSameAsRecommender(User user,
      TechnologyRecommendationTO recommendationTO, TechnologyCommentTO commentTO,
      TechnologyResponse technology) {
    UserResponse recommender = recommendationTO.getRecommender();
    UserResponse commenter = commentTO.getAuthor();
    return user.getUserId().equals(recommender.getGoogleId())
        && user.getUserId().equals(commenter.getGoogleId());
  }

}
{'fraction_non_alphanumeric': 0.07823267126064046, 'fraction_numerical': 0.005877584110255371, 'mean_word_length': 5.2075471698113205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1378562', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1308, 'n_words': 283}