Exemple #1
0
  public void deleteQuestion(SocialUser loginUser, Long questionId) {
    Assert.notNull(loginUser, "loginUser should be not null!");
    Assert.notNull(questionId, "questionId should be not null!");

    Question question = questionRepository.findOne(questionId);
    question.delete(loginUser);
  }
Exemple #2
0
  public Question updateQuestion(SocialUser loginUser, QuestionDto questionDto) {
    Assert.notNull(loginUser, "loginUser should be not null!");
    Assert.notNull(questionDto, "question should be not null!");

    Question question = questionRepository.findOne(questionDto.getQuestionId());

    Set<Tag> tags = tagService.processTags(questionDto.getPlainTags());
    question.update(loginUser, questionDto.getTitle(), questionDto.getContents(), tags);
    return question;
  }
Exemple #3
0
 public void createAnswer(SocialUser loginUser, Long questionId, Answer answer) {
   Question question = questionRepository.findOne(questionId);
   answer.writedBy(loginUser);
   answer.answerTo(question);
   Answer savedAnswer = answerRepository.saveAndFlush(answer);
   notificationService.notifyToFacebook(
       loginUser, question, question.findNotificationUser(loginUser));
   if (answer.isConnected()) {
     log.info("firing sendAnswerMessageToFacebook!");
     facebookService.sendToAnswerMessage(loginUser, savedAnswer.getAnswerId());
   }
 }
Exemple #4
0
  public void deleteAnswer(SocialUser loginUser, Long questionId, Long answerId) {
    Assert.notNull(loginUser, "loginUser should be not null!");
    Assert.notNull(questionId, "questionId should be not null!");
    Assert.notNull(answerId, "answerId should be not null!");

    Answer answer = answerRepository.findOne(answerId);
    if (!answer.isWritedBy(loginUser)) {
      throw new AccessDeniedException(loginUser + " is not owner!");
    }
    answerRepository.delete(answer);
    Question question = questionRepository.findOne(questionId);
    question.deAnswered();
  }
Exemple #5
0
  public Question createQuestion(SocialUser loginUser, QuestionDto questionDto) {
    Assert.notNull(loginUser, "loginUser should be not null!");
    Assert.notNull(questionDto, "question should be not null!");

    Set<Tag> tags = tagService.processTags(questionDto.getPlainTags());

    Question newQuestion =
        new Question(loginUser, questionDto.getTitle(), questionDto.getContents(), tags);
    Question savedQuestion = questionRepository.saveAndFlush(newQuestion);

    if (questionDto.isConnected()) {
      log.info("firing sendMessageToFacebook!");
      facebookService.sendToQuestionMessage(loginUser, savedQuestion.getQuestionId());
    }
    return savedQuestion;
  }