use of it.vige.rubia.model.Poster 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);
}
}
use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class ForumsModuleImpl method createTopic.
@Override
public Topic createTopic(Forum forum, String userId, String subject, TopicType type) throws ModuleException {
try {
Poster poster = findPosterByUserId(userId);
if (poster == null) {
poster = createPoster(userId);
}
em.persist(poster);
Topic topic = new Topic();
topic.setSubject(subject);
topic.setForum(forum);
topic.setPoster(poster);
topic.setType(type);
topic.setPoll(null);
em.persist(topic);
em.flush();
return topic;
} catch (Exception e) {
String errorMessage = "Cannot create topic";
throw new ModuleException(errorMessage, e);
}
}
use of it.vige.rubia.model.Poster 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);
}
}
use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class PortalUtil method getPoster.
/**
* @param forumsModule
* DOCUMENT_ME
* @param userModule
* DOCUMENT_ME
* @return the current user
* @throws Exception
* DOCUMENT_ME
*/
public static Poster getPoster(ForumsModule forumsModule, UserModule userModule) throws Exception {
Poster poster = null;
User user = getUser(userModule);
String userId = user.getId();
poster = forumsModule.findPosterByUserId(userId);
if (poster == null) {
poster = new Poster(userId);
}
return poster;
}
use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class PortalUtil method getGuestPoster.
public static Poster getGuestPoster(UserModule userModule, ForumsModule forumsModule) throws Exception {
Poster poster = null;
User user = null;
String guestUserName = forumsModule.getGuestUserName();
try {
user = userModule.findUserByUserName(guestUserName);
} catch (Exception e) {
}
Long userId = parseLong(user.getId());
poster = forumsModule.findPosterByUserId(String.valueOf(userId));
if (poster == null) {
poster = new Poster(userId.toString());
}
return poster;
}
Aggregations