Search in sources :

Example 81 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class ModeratorAction method deleteTopic.

// ui actions supported by this
// bean----------------------------------------------------------------------------------------------------
/**
 * UI Action for deleting topic(s) from the forum.
 *
 * @return the name of the operation
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String deleteTopic() {
    try {
        for (int topicId : checkboxes.keySet()) {
            boolean value = checkboxes.get(topicId);
            try {
                if (value) {
                    Topic topic = forumsModule.findTopicById(topicId);
                    forumsModule.removeTopic(topicId);
                    topics.remove(topic);
                }
            } catch (Exception e) {
                setWarnBundleMessage("ERR_CANNOT_REMOVE_TOPIC");
                return "success";
            }
        }
        setInfoBundleMessage("SUCC_TOPIC_REMOVED");
    } catch (Exception e) {
        handleException(e);
    }
    if (!conversation.isTransient())
        conversation.end();
    return "success";
}
Also used : ViewTopic(it.vige.rubia.ui.view.ViewTopic) Topic(it.vige.rubia.model.Topic) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 82 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class ModeratorAction method execute.

@PostConstruct
public void execute() {
    try {
        // trying to get forumId from request parameter
        int forumId = -1;
        String f = getParameter(p_forumId);
        if (f != null && f.trim().length() > 0) {
            forumId = parseInt(f);
        }
        checkboxes = new HashMap<Integer, Boolean>();
        // grab the data to be displayed for this page
        if (forumId != -1) {
            // setup the business objects like the forum, topics etc that
            // will
            // be displayed
            forum = forumsModule.findForumById(forumId);
        } else {
            // trying to get forumId from topicId read from request
            String t = getParameter(p_topicId);
            if (t != null && t.trim().length() > 0) {
                Topic topic = forumsModule.findTopicById(new Integer(t));
                forum = topic.getForum();
            } else {
                String p = getParameter(p_postId);
                if (p != null && p.trim().length() > 0) {
                    Post post = forumsModule.findPostById(new Integer(p));
                    Topic topic = post.getTopic();
                    forum = topic.getForum();
                }
            }
        }
        if (forum != null) {
            topics = forumsModule.findTopics(forum);
            topicsDataModel = new ListDataModel<Topic>(topics);
        }
    } catch (ModuleException e) {
        log.error(e);
    }
}
Also used : Post(it.vige.rubia.model.Post) ViewTopic(it.vige.rubia.ui.view.ViewTopic) Topic(it.vige.rubia.model.Topic) ModuleException(it.vige.rubia.ModuleException) PostConstruct(javax.annotation.PostConstruct)

Example 83 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class ModeratorAction method lockTopic.

/**
 * UI Action for locking selected topic(s).
 *
 * @return the name of the operation
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String lockTopic() {
    if (isAnyCheckboxSelected()) {
        try {
            for (int topicId : checkboxes.keySet()) {
                boolean value = checkboxes.get(topicId);
                try {
                    if (value) {
                        Topic topic = forumsModule.findTopicById(topicId);
                        updateStatus(topic, TOPIC_LOCKED);
                    }
                } catch (Exception e) {
                    setWarnBundleMessage("ERR_INTERNAL");
                    return "";
                }
            }
            setInfoBundleMessage("SUCC_TOPIC_LOCKED");
        } catch (Exception e) {
            handleException(e);
        }
        return "";
    } else {
        setWarnBundleMessage("None_selected");
        return "";
    }
}
Also used : ViewTopic(it.vige.rubia.ui.view.ViewTopic) Topic(it.vige.rubia.model.Topic) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 84 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class ModeratorAction method unlockTopic.

/**
 * UI Action for unlocking selected topic(s).
 *
 * @return the name of the operation
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String unlockTopic() {
    if (isAnyCheckboxSelected()) {
        try {
            for (int topicId : checkboxes.keySet()) {
                boolean value = checkboxes.get(topicId);
                try {
                    if (value) {
                        Topic topic = forumsModule.findTopicById(topicId);
                        updateStatus(topic, TOPIC_UNLOCKED);
                    }
                } catch (Exception e) {
                    setWarnBundleMessage("ERR_INTERNAL");
                    return "";
                }
            }
            setInfoBundleMessage("SUCC_TOPIC_UNLOCKED");
        } catch (Exception e) {
            handleException(e);
        }
        return "";
    } else {
        setWarnBundleMessage("None_selected");
        return "";
    }
}
Also used : ViewTopic(it.vige.rubia.ui.view.ViewTopic) Topic(it.vige.rubia.model.Topic) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 85 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class ReplyTopic method start.

public String start() {
    String navState = null;
    try {
        int forumId = -1;
        int topicId = -1;
        int postId = -1;
        String f = getParameter(p_forumId);
        String t = getParameter(p_topicId);
        String p = getParameter(p_postId);
        if (f != null && f.trim().length() > 0) {
            forumId = parseInt(f);
        }
        if (t != null && t.trim().length() > 0) {
            topicId = parseInt(t);
        }
        if (p != null && p.trim().length() > 0) {
            postId = parseInt(p);
        }
        Topic topic = null;
        if (topicId == -1 && postId != -1) {
            // If topicId was not given and postId is available we get
            // topicId from Post
            Post post = forumsModule.findPostById((postId));
            if (post != null) {
                topic = post.getTopic();
                topicId = topic.getId().intValue();
            }
        } else {
            topic = forumsModule.findTopicById(topicId);
        }
        if (forumId == -1 && topic != null) {
            forumId = topic.getForum().getId().intValue();
        }
        // re-initialize this controller to add a reply post in a topic
        // to the specified forum
        cleanup();
        // set the selected forum's id and topic's id
        this.forumId = forumId;
        this.topicId = topicId;
        // set the subject information
        subject = RE + topic.getSubject();
        navState = START_REPLY;
    } catch (Exception e) {
        handleException(e);
    }
    return navState;
}
Also used : Post(it.vige.rubia.model.Post) ViewTopic(it.vige.rubia.ui.view.ViewTopic) Topic(it.vige.rubia.model.Topic) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException)

Aggregations

Topic (it.vige.rubia.model.Topic)112 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)64 Forum (it.vige.rubia.model.Forum)63 Post (it.vige.rubia.model.Post)62 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)49 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)48 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)39 Category (it.vige.rubia.model.Category)36 Test (org.junit.Test)36 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)30 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)30 Poll (it.vige.rubia.model.Poll)25 PollOption (it.vige.rubia.model.PollOption)24 Attachment (it.vige.rubia.model.Attachment)23 Poster (it.vige.rubia.model.Poster)17 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)16 WebElement (org.openqa.selenium.WebElement)16 SecureActionForum (it.vige.rubia.auth.SecureActionForum)14 Date (java.util.Date)14 Interceptors (javax.interceptor.Interceptors)13