Search in sources :

Example 11 with SecureActionForum

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

the class TopicWatchController method activateWatch.

/**
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String activateWatch() {
    String navState = null;
    try {
        // checking for needed parameters
        if (topicId == -1 || watchType == -1) {
            return navState;
        }
        // make sure a watch for this topic is not already issued for this
        // user
        boolean isDuplicate = isWatched();
        if (isDuplicate) {
            return navState;
        }
        // get the topic that must be activated for watching
        Topic topic = forumsModule.findTopicById(topicId);
        // activate the watch for the selected topic
        forumsModule.createWatch(getPoster(userModule, forumsModule), topic, watchType);
        navState = "success";
    } catch (Exception e) {
        handleException(e);
    }
    return navState;
}
Also used : Topic(it.vige.rubia.model.Topic) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 12 with SecureActionForum

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

the class DeletePost method confirmDelete.

// actions---------------------------------------------------------------------------------------------------------------------------------
/**
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String confirmDelete() {
    String navState = null;
    try {
        // setup the business objects/data of interest
        Post post = forumsModule.findPostById(postId);
        Topic topic = post.getTopic();
        // make sure this topic is not locked
        if (topic.getStatus() == TOPIC_LOCKED) {
            // should not allow posting a reply since the topic is locked
            throw new Exception(getBundleMessage(BUNDLE_NAME, TOPIC_LOCKED_ERR_KEY));
        }
        boolean isFirstPost = false;
        boolean isLastPost = false;
        List<Post> posts = forumsModule.findPostsByTopicId(topic);
        if (posts.get(0).getId() == post.getId().intValue()) {
            isFirstPost = true;
        }
        if (posts.get(posts.size() - 1).getId().intValue() == post.getId().intValue()) {
            isLastPost = true;
        }
        // now perform the actual delete operation.........................
        if (isLastPost && isFirstPost) {
            // cascade delete will take care of removing
            // the post
            // the watches
            // the poll
            // the links
            forumsModule.removeTopic(post.getTopic().getId());
            // set the proper navigation state
            navState = TOPIC_DELETED;
        } else {
            forumsModule.removePost(post.getId(), isLastPost);
            // set the proper navigation state
            navState = SUCCESS;
        }
    } catch (Exception e) {
        handleException(e);
    }
    return navState;
}
Also used : Post(it.vige.rubia.model.Post) 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 13 with SecureActionForum

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

the class ForumWatchController method activateWatch.

/**
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String activateWatch() {
    String navState = null;
    try {
        int forumId = selectedForum;
        try {
            String wt = getRequestParameter(p_notified_watch_type);
            if (wt != null && wt.trim().length() > 0) {
                watchMode = parseInt(wt);
            } else {
                watchMode = -1;
            }
        } catch (NumberFormatException e) {
            handleException(e);
            watchMode = -1;
        }
        if (forumId == -1 || watchMode == -1) {
            return null;
        }
        // make sure a watch for this forum is not already issued for this
        // user
        boolean isDuplicate = isDuplicateWatch(forumId);
        if (isDuplicate) {
            return "success";
        }
        // get the forum that must be activated for watching
        Forum forum = forumsModule.findForumById(forumId);
        // activate the watch for the selected forum
        forumsModule.createWatch(getPoster(userModule, forumsModule), forum, watchMode);
        navState = "success";
    } catch (Exception e) {
        handleException(e);
    }
    return navState;
}
Also used : JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Forum(it.vige.rubia.model.Forum) SecureActionForum(it.vige.rubia.auth.SecureActionForum) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 14 with SecureActionForum

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

the class ForumWatchController method deActivateWatch.

/**
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String deActivateWatch() {
    String navState = null;
    try {
        int watchId = -1;
        String w = getRequestParameter(p_watchId);
        if (w != null && w.trim().length() > 0) {
            watchId = parseInt(w);
        }
        if (watchId == -1) {
            String f = getRequestParameter(p_forumId);
            if (f != null && f.trim().length() > 0) {
                int forumId = parseInt(f);
                ForumWatch forumWatch = forumsModule.findForumWatchByUserAndForum(getUser(userModule), forumId);
                watchId = forumWatch != null ? forumWatch.getId().intValue() : -1;
            }
        }
        if (watchId != -1) {
            forumsModule.removeWatch(forumsModule.findForumWatchById(watchId));
        }
    } catch (Exception e) {
        handleException(e);
    }
    return navState;
}
Also used : ForumWatch(it.vige.rubia.model.ForumWatch) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 15 with SecureActionForum

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

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