use of it.vige.rubia.model.Forum in project rubia-forums by flashboss.
the class AdminController method editForum.
/**
* @return the navigation state of the application
*/
public String editForum() {
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);
}
// grab the forum from the module and set the proper information
Forum forum = forumsModule.findForumById(forumId);
Category selectedCategory = forumsModule.findCategoryById(this.selectedCategory);
forum.setCategory(selectedCategory);
forum.setName(forumName);
forum.setDescription(forumDescription);
forumsModule.update(forum);
String start = getBundleMessage("ResourceJSF", "Forum_updated_0");
String end = getBundleMessage("ResourceJSF", "Forum_updated_1");
setMessage(FEEDBACK, start + " \"" + forumName + "\" " + end);
navState = "";
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 AdminController method startService.
/**
* Start the admin controller as service
*/
@PostConstruct
public void startService() {
try {
// load the selected category if a categoryid is found
// fetch the category to be edited/deleted
int categoryId = -1;
String cour = ForumUtil.getParameter(p_categoryId);
if (cour != null && cour.trim().length() > 0) {
categoryId = Integer.parseInt(cour);
}
if (categoryId != -1) {
Category category = null;
try {
category = forumsModule.findCategoryById(categoryId);
} catch (ModuleException e) {
// Category was deleted
}
if (category != null) {
categoryName = category.getTitle();
selectedCategory = category.getId().intValue();
}
}
// load the selected forum is a forumid is found
// fetch the forum to be edited/deleted
int forumId = -1;
String forumIdStr = ForumUtil.getParameter(p_forumId);
if (forumIdStr != null && forumIdStr.trim().length() > 0) {
forumId = Integer.parseInt(forumIdStr);
}
if (forumId != -1) {
Forum forum = null;
try {
forum = forumsModule.findForumById(forumId);
} catch (ModuleException e) {
// Forum was deleted
}
if (forum != null) {
forumName = forum.getName();
forumDescription = forum.getDescription();
selectedCategory = forum.getCategory().getId().intValue();
selectedForum = forum.getId().intValue();
}
}
// Checking for editModes flags
String editCatStr = ForumUtil.getParameter(EDIT_CATEGORY);
if (editCatStr != null && editCatStr.trim().length() > 0) {
editCategoryMode = Boolean.valueOf(editCatStr).booleanValue();
}
String editForStr = ForumUtil.getParameter(EDIT_FORUM);
if (editForStr != null && editForStr.trim().length() > 0) {
editForumMode = Boolean.valueOf(editForStr).booleanValue();
}
// Checking for addModes flags
String addCatStr = ForumUtil.getParameter(ADD_CATEGORY);
if (addCatStr != null && addCatStr.trim().length() > 0) {
addCategoryMode = Boolean.valueOf(addCatStr).booleanValue();
}
String addForStr = ForumUtil.getParameter(ADD_FORUM);
if (addForStr != null && addForStr.trim().length() > 0) {
addForumMode = Boolean.valueOf(addForStr).booleanValue();
}
} catch (Exception e) {
handleException(e);
}
}
use of it.vige.rubia.model.Forum in project rubia-forums by flashboss.
the class AdminController method lockForum.
/**
* @return the navigation state of the application
*/
public String lockForum() {
try {
// get the forumId 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.setStatus(FORUM_LOCKED);
forumsModule.update(forum);
String message = getBundleMessage("ResourceJSF", "Forum_locked");
setMessage(FEEDBACK, message);
viewForum.setForum(forum);
} catch (Exception e) {
handleException(e);
} finally {
// cleanup the state
cleanup();
}
return null;
}
use of it.vige.rubia.model.Forum in project rubia-forums by flashboss.
the class AdminController method unlockForum.
/**
* @return the navigation state of the application
*/
public String unlockForum() {
try {
// get the forumId 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.setStatus(FORUM_UNLOCKED);
forumsModule.update(forum);
String message = getBundleMessage("ResourceJSF", "Forum_unlocked");
setMessage(FEEDBACK, message);
viewForum.setForum(forum);
} catch (Exception e) {
handleException(e);
} finally {
// cleanup the state
cleanup();
}
return null;
}
use of it.vige.rubia.model.Forum in project rubia-forums by flashboss.
the class Search method getForumsItems.
public Collection<SelectItem> getForumsItems() {
Collection<SelectItem> forums = new ArrayList<SelectItem>();
forums.add(new SelectItem("", "Search All Forums"));
try {
// Luca Stancapiano start
// get the forumInstanceId where this forum should be added
int forumInstanceId = userPreferences.getForumInstanceId();
List<Forum> f = forumsModule.findForums(forumInstanceId);
if (f != null) {
for (Forum forum : f) {
forums.add(new SelectItem(forum.getId().toString(), forum.getName()));
}
}
} catch (Exception e) {
handleException(e);
}
return forums;
}
Aggregations