use of it.vige.rubia.model.Category in project rubia-forums by flashboss.
the class AdminController method editCategory.
/**
* edit category
*
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String editCategory() {
String navState = null;
boolean success = false;
try {
int categoryId = -1;
String cour = ForumUtil.getParameter(p_categoryId);
if (cour != null && cour.trim().length() > 0) {
categoryId = Integer.parseInt(cour);
}
// grab the category from the module and set the title
Category category = forumsModule.findCategoryById(categoryId);
category.setTitle(categoryName);
forumsModule.update(category);
String start = getBundleMessage("ResourceJSF", "Category_updated_0");
String end = getBundleMessage("ResourceJSF", "Category_updated_1");
setMessage(FEEDBACK, start + " \"" + categoryName + "\" " + end);
navState = "";
success = true;
} catch (Exception e) {
handleException(e);
} finally {
if (success) {
// cleanup the state
cleanup();
}
}
return navState;
}
use of it.vige.rubia.model.Category in project rubia-forums by flashboss.
the class AdminController method moveCategoryDown.
/**
* @return the navigation state of the application
*/
public String moveCategoryDown() {
String navState = null;
try {
// get the categoryId where this forum should be added
int categoryId = -1;
String cour = ForumUtil.getParameter(p_categoryId);
if (cour != null && cour.trim().length() > 0) {
categoryId = Integer.parseInt(cour);
}
Category category = forumsModule.findCategoryById(categoryId);
category.setOrder(category.getOrder() + down);
forumsModule.update(category);
// get the forumInstanceId where this forum should be added
int forumInstanceId = userPreferences.getForumInstanceId();
Iterator<Category> categories = forumsModule.findCategories(forumInstanceId).iterator();
for (int index = 10; categories.hasNext(); index += 10) {
category = categories.next();
category.setOrder(index);
forumsModule.update(category);
}
} catch (Exception e) {
handleException(e);
}
return navState;
}
use of it.vige.rubia.model.Category in project rubia-forums by flashboss.
the class AdminController method addForum.
/**
* adds a new forum
*
* @return the navigation state of the application
*/
public String addForum() {
String navState = null;
boolean success = false;
try {
// add this new forum to the category
Category category = forumsModule.findCategoryById(selectedCategory);
forumsModule.createForum(category, forumName, forumDescription);
String start = getBundleMessage("ResourceJSF", "Forum_created_0");
String end = getBundleMessage("ResourceJSF", "Forum_created_1");
setMessage(FEEDBACK, start + " \"" + forumName + "\" " + end);
success = true;
} catch (Exception e) {
handleException(e);
} finally {
if (success) {
// cleanup the state
cleanup();
}
}
return navState;
}
use of it.vige.rubia.model.Category in project rubia-forums by flashboss.
the class Search method getCategoriesItems.
public Collection<SelectItem> getCategoriesItems() {
Collection<SelectItem> categories = new ArrayList<SelectItem>();
categories.add(new SelectItem("", "Search All Categories"));
try {
// Luca Stancapiano start
// get the forumInstanceId where this forum should be added
int forumInstanceId = userPreferences.getForumInstanceId();
List<Category> c = forumsModule.findCategories(forumInstanceId);
if (c != null) {
for (Category category : c) {
categories.add(new SelectItem(category.getId().toString(), category.getTitle()));
}
}
} catch (Exception e) {
handleException(e);
}
return categories;
}
use of it.vige.rubia.model.Category in project rubia-forums by flashboss.
the class AdminController method moveCategoryUp.
/**
* @return the navigation state of the application
*/
public String moveCategoryUp() {
String navState = null;
try {
// get the categoryId where this forum should be added
int categoryId = -1;
String cour = ForumUtil.getParameter(p_categoryId);
if (cour != null && cour.trim().length() > 0) {
categoryId = Integer.parseInt(cour);
}
Category category = forumsModule.findCategoryById(categoryId);
category.setOrder(category.getOrder() + up);
forumsModule.update(category);
// get the forumInstanceId where this forum should be added
int forumInstanceId = userPreferences.getForumInstanceId();
Iterator<Category> categories = forumsModule.findCategories(forumInstanceId).iterator();
for (int index = 10; categories.hasNext(); index += 10) {
category = categories.next();
category.setOrder(index);
forumsModule.update(category);
}
} catch (Exception e) {
handleException(e);
}
return navState;
}
Aggregations