Search in sources :

Example 16 with SecureActionForum

use of it.vige.rubia.auth.SecureActionForum 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 17 with SecureActionForum

use of it.vige.rubia.auth.SecureActionForum 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 18 with SecureActionForum

use of it.vige.rubia.auth.SecureActionForum in project rubia-forums by flashboss.

the class PostAction method setupPoll.

/**
 * sets the poll information of a post for the ui from the business object
 *
 * @param poll
 *            the poll to configure
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
protected void setupPoll(Poll poll) {
    if (poll != null) {
        question = poll.getTitle();
        activeDuration = poll.getLength();
        List<PollOption> pollOptions = poll.getOptions();
        if (pollOptions != null && pollOptions.size() > 0) {
            options = new TreeMap<String, String>();
            int counter = 1;
            for (PollOption cour : pollOptions) {
                options.put(Integer.toString(counter), cour.getQuestion());
                counter++;
            }
        }
    }
}
Also used : PollOption(it.vige.rubia.model.PollOption) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 19 with SecureActionForum

use of it.vige.rubia.auth.SecureActionForum in project rubia-forums by flashboss.

the class ReplyTopic method startQuote.

/**
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String startQuote() {
    String navState = start();
    try {
        String p = getParameter(p_postId);
        if (p != null && p.trim().length() > 0) {
            postId = parseInt(p);
        }
        // setup the quote information
        Post post = forumsModule.findPostById(postId);
        Poster poster = getPoster(forumsModule, userModule);
        String userName = userModule.findUserById(poster.getUserId()).getUserName();
        message = userName + "<" + QUOTE + ">" + post.getMessage().getText() + "</" + QUOTE + "></br>";
    } catch (Exception e) {
        handleException(e);
    }
    return navState;
}
Also used : Post(it.vige.rubia.model.Post) PortalUtil.getPoster(it.vige.rubia.PortalUtil.getPoster) Poster(it.vige.rubia.model.Poster) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 20 with SecureActionForum

use of it.vige.rubia.auth.SecureActionForum in project rubia-forums by flashboss.

the class SplitTopic method splitPosts.

/**
 * This user interface action is spliting topic bh=y moving all selected by
 * user posts into newly created topic.
 *
 * @return the name of the operation
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String splitPosts() {
    // Checking whether topic has only one post, so it can't be splitted
    if (posts.size() == 1) {
        setWarnBundleMessage("ERR_SPLIT_ONE_POST_TOPIC");
        return "";
    }
    // Removing all not slected posts
    Iterator<Integer> selectIt = checkboxes.keySet().iterator();
    while (selectIt.hasNext()) {
        Boolean postFlag = checkboxes.get(selectIt.next());
        if (!postFlag.booleanValue()) {
            selectIt.remove();
        }
    }
    // Checking if user selected anything.
    if (checkboxes.size() == 0) {
        setWarnBundleMessage("ERR_NO_POST_SELECTED");
        return "";
    }
    // Checking if user didn't select all posts.
    if (checkboxes.size() == posts.size()) {
        setWarnBundleMessage("ERR_SPLIT_ALL");
        return "";
    }
    // Trying to get destination forum for new topic.
    String toForumId = getParameter(p_forum_to_id);
    if (toForumId == null || toForumId.trim().compareToIgnoreCase("-1") == 0 || toForumId.trim().length() == 0) {
        setWarnBundleMessage("ERR_DEST_FORUM");
        return "";
    }
    // Checking if user gave subject for new topic.
    if (newTopicTitle == null || newTopicTitle.trim().compareToIgnoreCase("-1") == 0 || newTopicTitle.trim().length() == 0) {
        setWarnBundleMessage("ERR_NO_SUBJECT_GIVEN");
        return "";
    }
    try {
        Forum destForum = forumsModule.findForumById(new Integer(toForumId));
        // Creating new topic in selected destination forum.
        Topic newTopic = forumsModule.createTopic(destForum, getUser(userModule).getId().toString(), newTopicTitle, topic.getType());
        // Moving all selected posts to new topic.
        selectIt = checkboxes.keySet().iterator();
        Post movedPost = null;
        List<Post> postsToRemove = new ArrayList<Post>();
        while (selectIt.hasNext()) {
            movedPost = forumsModule.findPostById(selectIt.next());
            movedPost.setTopic(newTopic);
            forumsModule.update(movedPost);
            postsToRemove.add(movedPost);
        }
        Forum fromForum = topic.getForum();
        topic.setReplies(topic.getReplies() - checkboxes.size());
        fromForum.setPostCount(fromForum.getPostCount() - checkboxes.size());
        posts.removeAll(postsToRemove);
        topic.setLastPostDate(posts.get(posts.size() - 1).getCreateDate());
        newTopic.setReplies(checkboxes.size() - 1);
        List<Post> postsNewTopic = forumsModule.findPostsByTopicId(newTopic);
        newTopic.setLastPostDate(postsNewTopic.get(postsNewTopic.size() - 1).getCreateDate());
        destForum.addTopicSize();
        destForum.setPostCount(destForum.getPostCount() + newTopic.getReplies() + 1);
        forumsModule.update(topic);
        forumsModule.update(newTopic);
        forumsModule.update(fromForum);
        forumsModule.update(destForum);
    } catch (Exception e) {
        log.error(e);
        setWarnBundleMessage("ERR_INTERNAL");
        return "";
    }
    // Setting message that everything went smooth.
    setInfoBundleMessage("SUCC_TOPIC_SPLITTED");
    return "";
}
Also used : Post(it.vige.rubia.model.Post) ArrayList(java.util.ArrayList) Topic(it.vige.rubia.model.Topic) ModuleException(it.vige.rubia.ModuleException) Forum(it.vige.rubia.model.Forum) SecureActionForum(it.vige.rubia.auth.SecureActionForum) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Aggregations

SecureActionForum (it.vige.rubia.auth.SecureActionForum)21 Interceptors (javax.interceptor.Interceptors)21 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)17 Topic (it.vige.rubia.model.Topic)13 ModuleException (it.vige.rubia.ModuleException)9 Post (it.vige.rubia.model.Post)6 Forum (it.vige.rubia.model.Forum)5 PollOption (it.vige.rubia.model.PollOption)4 ViewTopic (it.vige.rubia.ui.view.ViewTopic)4 Poll (it.vige.rubia.model.Poll)3 Poster (it.vige.rubia.model.Poster)3 Date (java.util.Date)3 PortalUtil.createMessage (it.vige.rubia.PortalUtil.createMessage)2 PortalUtil.createPoll (it.vige.rubia.PortalUtil.createPoll)2 PortalUtil.createPollOption (it.vige.rubia.PortalUtil.createPollOption)2 Message (it.vige.rubia.model.Message)2 JSFUtil.getPoster (it.vige.rubia.ui.JSFUtil.getPoster)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 PortalUtil.getPoster (it.vige.rubia.PortalUtil.getPoster)1