use of org.mamute.event.QuestionCreated in project mamute by caelum.
the class QuestionController method newQuestion.
@Post
@CustomBrutauthRules({ LoggedRule.class, InputRule.class })
public void newQuestion(String title, MarkedText description, String tagNames, boolean watching, List<Long> attachmentsIds) {
List<Attachment> attachments = this.attachments.load(attachmentsIds);
attachmentsValidator.validate(attachments);
List<String> splitedTags = splitter.splitTags(tagNames);
List<Tag> foundTags = tagsManager.findOrCreate(splitedTags);
validate(foundTags, splitedTags);
QuestionInformation information = new QuestionInformation(title, description, currentUser, foundTags, "new question");
brutalValidator.validate(information);
User author = currentUser.getCurrent();
Question question = new Question(information, author);
result.include("question", question);
validator.onErrorUse(Results.page()).of(this.getClass()).questionForm();
questions.save(question);
index.indexQuestion(question);
question.add(attachments);
ReputationEvent reputationEvent = new ReputationEvent(EventType.CREATED_QUESTION, question, author);
author.increaseKarma(reputationEvent.getKarmaReward());
reputationEvents.save(reputationEvent);
if (watching) {
watchers.add(question, new Watcher(author));
}
questionCreated.fire(new QuestionCreated(question));
result.include("mamuteMessages", asList(messageFactory.build("alert", "question.quality_reminder")));
result.redirectTo(this).showQuestion(question, question.getSluggedTitle());
}
Aggregations