use of it.vige.rubia.model.TopicWatch in project rubia-forums by flashboss.
the class TopicWatchController method updateNotificationType.
/**
* @return the navigation state of the application
*/
public String updateNotificationType() {
String navState = null;
if (watchType == -1 || topicId == -1) {
return navState;
}
try {
TopicWatch topicWatch = forumsModule.findTopicWatchByUserAndTopic(getUser(userModule), topicId);
topicWatch.setMode(watchType);
forumsModule.update(topicWatch);
navState = "success";
} catch (Exception e) {
handleException(e);
}
topicId = -1;
return navState;
}
use of it.vige.rubia.model.TopicWatch in project rubia-forums by flashboss.
the class ForumsModuleImpl method createWatch.
@Override
public void createWatch(Poster poster, Topic topic, int mode) throws ModuleException {
try {
if (poster == null) {
throw new ModuleException("poster must not be null");
}
if (topic == null) {
throw new ModuleException("topic must not be null");
}
Poster posterOld = findPosterByUserId(poster.getUserId());
if (posterOld == null) {
em.persist(poster);
}
em.merge(poster);
// it is required
em.flush();
// for clustered versions
TopicWatch topicWatch = new TopicWatch();
topicWatch.setPoster(poster);
topicWatch.setTopic(topic);
topicWatch.setMode(mode);
em.persist(topicWatch);
// it is required
em.flush();
// for clustered versions
} catch (Exception e) {
String errorMessage = "Cannot create topic watch";
throw new ModuleException(errorMessage, e);
}
}
Aggregations