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(); }