Search in sources :

Example 6 with Interceptors

use of javax.interceptor.Interceptors in project rubia-forums by flashboss.

the class ViewMyForumsBase method execute.

/**
 * @throws Exception
 *             an error exception is launched
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public void execute() throws Exception {
    Collection<Topic> topics = getWatchedTopics();
    // minipaging
    if (topics != null) {
        for (Topic courTopic : topics) {
            if (courTopic.getReplies() > 0) {
                PageNavigator topicNav = new PageNavigator(courTopic.getReplies() + 1, // this
                getUserPreferences().getPostsPerTopic(), // current page of the navigator
                0) {

                    /**
                     */
                    private static final long serialVersionUID = 1L;

                    protected Collection<Integer> initializePage() {
                        return null;
                    }
                };
                topicNavigator.put(courTopic.getId(), topicNav);
            }
        }
    }
}
Also used : PageNavigator(it.vige.rubia.ui.PageNavigator) Topic(it.vige.rubia.model.Topic) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 7 with Interceptors

use of javax.interceptor.Interceptors in project rubia-forums by flashboss.

the class ViewMyForumsMain method getWatchedTopics.

/**
 * @return the watched topics
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public Collection<Topic> getWatchedTopics() {
    if (watchedTopics == null) {
        try {
            Date lastLoginDate = getUserLastLoginDate(userModule, userProfileModule);
            if (lastLoginDate == null) {
                return watchedTopics;
            }
            // get the forumInstanceId where this forum should be added
            int forumInstanceId = userPreferences.getForumInstanceId();
            watchedTopics = forumsModule.findTopicWatchedByUser(getUser(userModule), lastLoginDate, forumInstanceId);
        } catch (Exception e) {
            handleException(e);
        }
    }
    return watchedTopics;
}
Also used : Date(java.util.Date) JSFUtil.getUserLastLoginDate(it.vige.rubia.ui.JSFUtil.getUserLastLoginDate) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 8 with Interceptors

use of javax.interceptor.Interceptors in project rubia-forums by flashboss.

the class AdminController method addCategory.

// ----actions---------------------------------------------------------------------------------------------------------------------------
/**
 * adds a category
 *
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String addCategory() {
    String navState = null;
    boolean success = false;
    try {
        // get the forumInstanceId where this forum should be added
        int forumInstanceId = userPreferences.getForumInstanceId();
        // add this new category to the forum instance
        ForumInstance forumInstance = forumsModule.findForumInstanceById(forumInstanceId);
        forumsModule.createCategory(categoryName, forumInstance);
        String start = getBundleMessage("ResourceJSF", "Category_created_0");
        String end = getBundleMessage("ResourceJSF", "Category_created_1");
        setMessage(FEEDBACK, start + " \"" + categoryName + "\" " + end);
        success = true;
    } catch (Exception e) {
        handleException(e);
    } finally {
        if (success) {
            // cleanup the state
            cleanup();
        }
    }
    return navState;
}
Also used : ForumInstance(it.vige.rubia.model.ForumInstance) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 9 with Interceptors

use of javax.interceptor.Interceptors 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;
}
Also used : Category(it.vige.rubia.model.Category) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 10 with Interceptors

use of javax.interceptor.Interceptors in project rubia-forums by flashboss.

the class EditPost method start.

// action processing
// methods-----------------------------------------------------------------------------------------------------
/**
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String start() {
    String navState = null;
    try {
        int postId = -1;
        String p = getParameter(p_postId);
        if (p != null && p.trim().length() > 0) {
            postId = parseInt(p);
        }
        // grab the post information
        if (postId != -1) {
            // re-initialize this controller to edit the specified post
            cleanup();
            // get the post from the module
            Post post = forumsModule.findPostById(postId);
            Topic topic = post.getTopic();
            // set the selected post's topic id
            topicId = topic.getId().intValue();
            this.postId = postId;
            // set the subject of the post
            subject = post.getMessage().getSubject();
            // set the message of the post
            message = post.getMessage().getText();
            // set the topicType
            topicType = topic.getType();
            // setup poll related information
            setupPoll(topic.getPoll());
            attachments = forumsModule.findAttachments(post);
            // setup the attachment related information
            List<Post> posts = forumsModule.findPostsByTopicId(topic);
            isFirstPost = false;
            if (posts.get(0).getId().intValue() == post.getId().intValue()) {
                isFirstPost = true;
            }
        }
        navState = START_EDIT_POST;
    } 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) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Aggregations

Interceptors (javax.interceptor.Interceptors)27 SecureActionForum (it.vige.rubia.auth.SecureActionForum)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 IUserRoleInterceptor (eu.europa.ec.fisheries.uvms.activity.rest.IUserRoleInterceptor)4 PollOption (it.vige.rubia.model.PollOption)4 ViewTopic (it.vige.rubia.ui.view.ViewTopic)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Poll (it.vige.rubia.model.Poll)3 Poster (it.vige.rubia.model.Poster)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 Consumes (javax.ws.rs.Consumes)3 POST (javax.ws.rs.POST)3 Dataset (eu.europa.ec.fisheries.wsdl.user.types.Dataset)2 PortalUtil.createMessage (it.vige.rubia.PortalUtil.createMessage)2