use of it.vige.rubia.model.ForumWatch in project rubia-forums by flashboss.
the class ForumWatchController method updateNotificationType.
/**
* @return the name of the operation
*/
public String updateNotificationType() {
try {
String wt = getRequestParameter(p_notified_watch_type);
if (wt != null && wt.trim().length() > 0) {
watchMode = parseInt(wt);
} else {
watchMode = -1;
}
} catch (NumberFormatException e) {
handleException(e);
watchMode = -1;
}
try {
ForumWatch forumWatch = forumsModule.findForumWatchByUserAndForum(getUser(userModule), selectedForum);
forumWatch.setMode(watchMode);
forumsModule.update(forumWatch);
} catch (Exception e) {
handleException(e);
}
selectedForum = -1;
return "";
}
use of it.vige.rubia.model.ForumWatch in project rubia-forums by flashboss.
the class ForumWatchController method deActivateWatch.
/**
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String deActivateWatch() {
String navState = null;
try {
int watchId = -1;
String w = getRequestParameter(p_watchId);
if (w != null && w.trim().length() > 0) {
watchId = parseInt(w);
}
if (watchId == -1) {
String f = getRequestParameter(p_forumId);
if (f != null && f.trim().length() > 0) {
int forumId = parseInt(f);
ForumWatch forumWatch = forumsModule.findForumWatchByUserAndForum(getUser(userModule), forumId);
watchId = forumWatch != null ? forumWatch.getId().intValue() : -1;
}
}
if (watchId != -1) {
forumsModule.removeWatch(forumsModule.findForumWatchById(watchId));
}
} catch (Exception e) {
handleException(e);
}
return navState;
}
use of it.vige.rubia.model.ForumWatch in project rubia-forums by flashboss.
the class ForumsModuleImpl method createWatch.
@Override
public void createWatch(Poster poster, Forum forum, int mode) throws ModuleException {
try {
if (poster == null) {
throw new ModuleException("poster must not be null");
}
if (forum == null) {
throw new ModuleException("forum must not be null");
}
Poster posterOld = findPosterByUserId(poster.getUserId());
if (posterOld == null) {
em.persist(poster);
}
em.merge(poster);
ForumWatch forumWatch = new ForumWatch();
forumWatch.setPoster(poster);
forumWatch.setForum(forum);
forumWatch.setMode(mode);
em.persist(forumWatch);
// it is required
em.flush();
// for clustered versions
} catch (Exception e) {
String errorMessage = "Cannot create forum watch";
throw new ModuleException(errorMessage, e);
}
}
Aggregations