use of it.vige.rubia.model.Forum in project rubia-forums by flashboss.
the class AdminController method moveForumUp.
/**
* @return the navigation state of the application
*/
public String moveForumUp() {
String navState = null;
try {
// get the categoryId where this forum should be added
int forumId = -1;
String cour = ForumUtil.getParameter(p_forumId);
if (cour != null && cour.trim().length() > 0) {
forumId = Integer.parseInt(cour);
}
Forum forum = forumsModule.findForumById(forumId);
forum.setOrder(forum.getOrder() + up);
forumsModule.update(forum);
Iterator<Forum> forums = forumsModule.findForumsByCategory(forum.getCategory()).iterator();
for (int index = 10; forums.hasNext(); index += 10) {
forum = forums.next();
forum.setOrder(index);
forumsModule.update(forum);
}
} catch (Exception e) {
handleException(e);
}
return navState;
}
use of it.vige.rubia.model.Forum in project rubia-forums by flashboss.
the class AdminController method deleteForum.
/**
* @return the navigation state of the application
*/
public String deleteForum() {
String navState = null;
boolean success = false;
try {
int forumId = -1;
String cour = ForumUtil.getParameter(p_forumId);
if (cour != null && cour.trim().length() > 0) {
forumId = Integer.parseInt(cour);
}
Forum source = null;
// forum
if (selectedForum != -1) {
source = forumsModule.findForumByIdFetchTopics(forumId);
Forum target = forumsModule.findForumByIdFetchTopics(selectedForum);
target.getTopics().addAll(source.getTopics());
target.setPostCount(target.getPostCount() + source.getPostCount());
target.setTopicCount(target.getTopicCount() + source.getTopicCount());
forumsModule.update(target);
for (Topic tp : target.getTopics()) {
tp.setForum(target);
forumsModule.update(tp);
}
// clear the source out before delete
source.setTopics(new ArrayList<Topic>());
forumsModule.update(source);
} else {
source = forumsModule.findForumById(forumId);
}
// means delete all topic/posts on this forum
forumsModule.removeForum(source.getId());
String start = getBundleMessage("ResourceJSF", "Forum_deleted_0");
String end = getBundleMessage("ResourceJSF", "Forum_deleted_1");
setMessage(FEEDBACK, start + " \"" + forumName + "\" " + end);
navState = DELETE_FORUM;
success = true;
} catch (Exception e) {
handleException(e);
} finally {
if (success) {
// cleanup the state
cleanup();
}
}
return navState;
}
use of it.vige.rubia.model.Forum in project rubia-forums by flashboss.
the class NewTopic method execute.
/**
* Execute
*
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String execute() {
String navState = null;
boolean success = false;
try {
// setup the message
Message message = createMessage();
message.setText(this.message);
message.setSubject(subject);
// setup the forum and the corresponding poster
Forum forum = forumsModule.findForumById(forumId);
Poster poster = getPoster(userModule, forumsModule);
// setup the poll related information
Poll poll = createPoll();
if (question != null && question.trim().length() > 0) {
poll.setTitle(question);
poll.setLength(activeDuration);
List<PollOption> pollOptions = new LinkedList<PollOption>();
for (String option : options.keySet()) {
PollOption pollOption = createPollOption(poll);
pollOption.setQuestion((String) options.get(option));
pollOption.setVotes(0);
pollOptions.add(pollOption);
}
poll.setOptions(pollOptions);
validatePoll(poll);
}
poster.incrementPostCount();
// actually create the topic in this forum
// use this method when poll and attachments are actually integrated
// poll
forumsModule.createTopic(// poll
forum, // poll
message, // poll
new Date(), // poll
poster, // poll
poll, // attachments
attachments, topicType);
// setup the navigation state
navState = SUCCESS;
success = true;
} catch (MessageValidationException e) {
// handle proper validation error with a proper message...not just a
// generic message..
// just use generic error page for the proof of concept
// set the custom exception such that e.toString() results in the
// proper message
handleException(e);
} catch (PollValidationException e) {
// handle proper validation error with a proper message...not just a
// generic message..
// just use generic error page for the proof of concept
// set the custom exception such that e.toString() results in the
// proper message
handleException(e);
} catch (Exception e) {
handleException(e);
} finally {
// cleanup if necessary
if (success) {
cleanup();
}
}
return navState;
}
use of it.vige.rubia.model.Forum in project rubia-forums by flashboss.
the class ForumWatchController method activateWatch.
/**
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String activateWatch() {
String navState = null;
try {
int forumId = selectedForum;
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;
}
if (forumId == -1 || watchMode == -1) {
return null;
}
// make sure a watch for this forum is not already issued for this
// user
boolean isDuplicate = isDuplicateWatch(forumId);
if (isDuplicate) {
return "success";
}
// get the forum that must be activated for watching
Forum forum = forumsModule.findForumById(forumId);
// activate the watch for the selected forum
forumsModule.createWatch(getPoster(userModule, forumsModule), forum, watchMode);
navState = "success";
} catch (Exception e) {
handleException(e);
}
return navState;
}
use of it.vige.rubia.model.Forum in project rubia-forums by flashboss.
the class ViewMyForumsEditAllForums method execute.
/**
*/
@PostConstruct
public void execute() {
Collection<Forum> forums = getWatchedForums();
try {
// get the forumInstanceId where this forum should be added
int forumInstanceId = userPreferences.getForumInstanceId();
forumWatches = forumsModule.findForumWatches(getUser(userModule), forumInstanceId);
} catch (Exception e) {
handleException(e);
setForumWatches(new HashMap<Object, Object>(0));
}
Date userLastLogin = getUserLastLoginDate(userModule, userProfileModule);
for (Forum currentForum : forums) {
// setup folderLook based on whats specified in the theme
String folderImage = themeHelper.getResourceForumURL();
// bundle key
String folderAlt = "No_new_posts";
if (forumsLastPosts != null && forumsLastPosts.containsKey(currentForum.getId())) {
Post lastPost = (Post) forumsLastPosts.get(currentForum.getId());
Date lastPostDate = lastPost.getCreateDate();
if (lastPostDate != null && userLastLogin != null && lastPostDate.compareTo(userLastLogin) > 0) {
// bundle key
folderAlt = "New_posts";
folderImage = themeHelper.getResourceForumNewURL();
}
}
if (currentForum.getStatus() == FORUM_LOCKED) {
folderImage = themeHelper.getResourceForumLockedURL();
// bundle key
folderAlt = "Forum_locked";
}
getForumImages().put(currentForum.getId(), folderImage);
getForumImageDescriptions().put(currentForum.getId(), folderAlt);
}
try {
String t = getRequestParameter(p_forumId);
if (t != null && t.trim().length() > 0) {
forumId = parseInt(t);
} else {
forumId = -1;
}
if (forumId != -1) {
watch = forumsModule.findForumWatchByUserAndForum(getUser(userModule), forumId);
}
} catch (Exception e) {
handleException(e);
forumId = -1;
watch = null;
}
}
Aggregations