Search in sources :

Example 51 with Forum

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;
}
Also used : Category(it.vige.rubia.model.Category) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Forum(it.vige.rubia.model.Forum) ViewForum(it.vige.rubia.ui.view.ViewForum) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 52 with Forum

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);
    }
}
Also used : Category(it.vige.rubia.model.Category) ModuleException(it.vige.rubia.ModuleException) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Forum(it.vige.rubia.model.Forum) ViewForum(it.vige.rubia.ui.view.ViewForum) SecureActionForum(it.vige.rubia.auth.SecureActionForum) PostConstruct(javax.annotation.PostConstruct)

Example 53 with Forum

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;
}
Also used : JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Forum(it.vige.rubia.model.Forum) ViewForum(it.vige.rubia.ui.view.ViewForum) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 54 with Forum

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;
}
Also used : JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Forum(it.vige.rubia.model.Forum) ViewForum(it.vige.rubia.ui.view.ViewForum) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 55 with Forum

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;
}
Also used : SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Forum(it.vige.rubia.model.Forum)

Aggregations

Forum (it.vige.rubia.model.Forum)100 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)65 Topic (it.vige.rubia.model.Topic)63 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)55 Post (it.vige.rubia.model.Post)52 Category (it.vige.rubia.model.Category)50 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)49 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)40 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)40 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)34 Test (org.junit.Test)33 Poll (it.vige.rubia.model.Poll)23 Attachment (it.vige.rubia.model.Attachment)21 PollOption (it.vige.rubia.model.PollOption)21 SecureActionForum (it.vige.rubia.auth.SecureActionForum)16 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)15 Poster (it.vige.rubia.model.Poster)14 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)14 BeforeClass (org.junit.BeforeClass)14 AfterClass (org.junit.AfterClass)13