Package org.apache.roller.ui.core

Examples of org.apache.roller.ui.core.RollerRequest


            HttpServletRequest  request,
            HttpServletResponse response)
            throws IOException, ServletException, RollerException {
       
        CommentManagementForm queryForm = (CommentManagementForm)actionForm;
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        if (rreq.getWeblogEntry() != null) {
            queryForm.setEntryid(rreq.getWeblogEntry().getId());
            queryForm.setWeblog(rreq.getWeblogEntry().getWebsite().getHandle());
        }       
        else if (rreq.getWebsite() != null) {
            queryForm.setWeblog(rreq.getWebsite().getHandle());
        }
        else {
            // user needs Global Admin rights to access site-wide comments
            RollerSession rses = RollerSession.getRollerSession(request);
            if (!rses.isGlobalAdminUser()) {
                return mapping.findForward("access-denied");
            }
        }
        RollerSession rses = RollerSession.getRollerSession(request);
        try {
            if (rses.isGlobalAdminUser()
                || (rreq.getWebsite()!=null && rses.isUserAuthorizedToAuthor(rreq.getWebsite())) ) {
                WeblogManager mgr= RollerFactory.getRoller().getWeblogManager();
               
                // delete all comments with delete box checked
                CommentData deleteComment = null;
                String[] deleteIds = queryForm.getDeleteComments();
                List deletedList = Arrays.asList(deleteIds);
                if (deleteIds != null && deleteIds.length > 0) {
                    for(int j=0; j < deleteIds.length; j++) {
                        deleteComment = mgr.getComment(deleteIds[j]);
                       
                        mgr.removeComment(deleteComment);
                    }
                }
               
                // Collect comments approved for first time, so we can send
                // out comment approved notifications later
                List approvedComments = new ArrayList();
               
                // loop through IDs of all comments displayed on page
                String[] ids = Utilities.stringToStringArray(queryForm.getIds(),",");
                List flushList = new ArrayList();
                for (int i=0; i<ids.length; i++) {                   
                    if (deletedList.contains(ids[i])) continue;                   
                    CommentData comment = mgr.getComment(ids[i]);
                   
                    // apply spam checkbox
                    List spamIds = Arrays.asList(queryForm.getSpamComments());
                    if (spamIds.contains(ids[i])) {
                        comment.setSpam(Boolean.TRUE);
                    } else {
                        comment.setSpam(Boolean.FALSE);
                    }
                   
                    // Only participate in comment review workflow if we're
                    // working within one specfic weblog. Global admins should
                    // be able to mark-as-spam and delete comments without
                    // interfering with moderation by bloggers.
                    if (rreq.getWebsite() != null) {
                       
                        // all comments reviewed, so they're no longer pending
                        if (comment.getPending() != null && comment.getPending().booleanValue()) {
                            comment.setPending(Boolean.FALSE);
                            approvedComments.add(comment);
                        }
                       
                        // apply pending checkbox
                        List approvedIds =
                            Arrays.asList(queryForm.getApprovedComments());
                        if (approvedIds.contains(ids[i])) {
                            comment.setApproved(Boolean.TRUE);
                           
                        } else {
                            comment.setApproved(Boolean.FALSE);
                        }
                    }
                    mgr.saveComment(comment);
                    flushList.add(comment);
                }
               
                RollerFactory.getRoller().flush();
                for (Iterator comments=flushList.iterator(); comments.hasNext();) {
                    CacheManager.invalidate((CommentData)comments.next());
                }
               
                sendCommentNotifications(request, approvedComments);
               
                ActionMessages msgs = new ActionMessages();
                msgs.add(ActionMessages.GLOBAL_MESSAGE,
                    new ActionMessage("commentManagement.updateSuccess"));
                saveMessages(request, msgs);
            }
        } catch (Exception e) {
            ActionMessages errors = new ActionMessages();
            errors.add(ActionErrors.GLOBAL_MESSAGE,
                new ActionMessage("commentManagement.updateError",e.toString()));
            saveErrors(request, errors);
            logger.error("ERROR updating comments", e);      
        }
        CommentManagementPageModel model = new CommentManagementPageModel(
           "commentManagement.title", request, response, mapping, queryForm);
        request.setAttribute("model", model);
        if (request.getAttribute("commentManagementForm") == null) {
            request.setAttribute("commentManagementForm", actionForm);
        }
       
        if (rreq.getWebsite() != null) {
            return mapping.findForward("commentManagement.page");
        }
        return mapping.findForward("commentManagementGlobal.page");
    }
View Full Code Here


           
            super(titleKey, request, response, mapping);
            this.queryForm = queryForm;
           
            Roller roller = RollerFactory.getRoller();
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            if (rreq.getWeblogEntry() != null) {
                website = rreq.getWeblogEntry().getWebsite();
                weblogEntry = rreq.getWeblogEntry();
            }
            else if (rreq.getWebsite() != null) {
                website = rreq.getWebsite();
            }
            WeblogManager blogmgr = roller.getWeblogManager();
        
            int offset = queryForm.getOffset();
            comments = blogmgr.getComments(
View Full Code Here

        HttpServletResponse response)
        throws Exception
    {
        ActionForward forward = mapping.findForward("categories");
        WeblogCategoryFormEx form = (WeblogCategoryFormEx)actionForm;
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();

        WeblogCategoryData cd = null;
        if (null != form.getId() && !form.getId().trim().equals(""))
        {
View Full Code Here

     * @return forward to the ping targets page
     * @throws Exception
     */
    public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
        ActionForward forward = mapping.findForward(VIEW_PAGE);
        RollerRequest rreq = RollerRequest.getRollerRequest(req);
        try {
            BasePageModel pageModel = new BasePageModel(getPingTargetsTitle(), req, res, mapping);
            req.setAttribute("model", pageModel);
            if (!hasRequiredRights(rreq, rreq.getWebsite())) {
                return mapping.findForward(ACCESS_DENIED_PAGE);
            }

            List pingTargets = getPingTargets(rreq);
            req.setAttribute("pingTargets", pingTargets);
View Full Code Here

     * @param res
     * @return the result of <code>view()</code> after the target is saved.
     * @throws Exception
     */
    public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
        RollerRequest rreq = RollerRequest.getRollerRequest(req);
        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
        PingTargetForm pingTargetForm = (PingTargetForm) form;
        try {
            BasePageModel pageModel = new BasePageModel(getPingTargetEditTitle(), req, res, mapping);
            req.setAttribute("model", pageModel);
            if (!hasRequiredRights(rreq, rreq.getWebsite())) {
                return mapping.findForward(ACCESS_DENIED_PAGE);
            }

            PingTargetData pingTarget = null;
            String pingTargetId = pingTargetForm.getId();
            if (pingTargetId != null && pingTargetId.length() > 0) {
                pingTarget = pingTargetMgr.getPingTarget(pingTargetForm.getId());
                if (pingTarget == null) throw new RollerException("No such ping target id: " + pingTargetId);
                pingTargetForm.copyTo(pingTarget, req.getLocale());
            } else {
                pingTarget = createPingTarget(rreq, pingTargetForm);
            }

            // Call private helper to validate ping target
            // If there are errors, go back to the target edit page.
            ActionMessages errors = validate(rreq, pingTarget);
            if (!errors.isEmpty()) {
                saveErrors(rreq.getRequest(), errors);
                return mapping.findForward(PING_TARGET_EDIT_PAGE);
            }

            // Appears to be ok. 
            // Save it, commit and return refreshed view of target list.
View Full Code Here

     * @return the edit view with the form populated with the ping target specified by the id in the request.
     * @throws Exception
     */
    public ActionForward editSelected(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
        ActionForward forward = mapping.findForward(PING_TARGET_EDIT_PAGE);
        RollerRequest rreq = RollerRequest.getRollerRequest(req);
        try {
            BasePageModel pageModel = new BasePageModel(getPingTargetEditTitle(), req, res, mapping);
            req.setAttribute("model", pageModel);
            if (!hasRequiredRights(rreq, rreq.getWebsite())) {
                return mapping.findForward(ACCESS_DENIED_PAGE);
            }
            PingTargetData pingTarget = select(rreq);
            ((PingTargetForm) form).copyFrom(pingTarget, req.getLocale());
            return forward;
View Full Code Here

     * @return the delete confirmation view with the form populated with the ping target specified by the id in the request.
     * @throws Exception
     */
    public ActionForward deleteSelected(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
        ActionForward forward = mapping.findForward(PING_TARGET_DELETE_PAGE);
        RollerRequest rreq = RollerRequest.getRollerRequest(req);
        try {
            BasePageModel pageModel = new BasePageModel(getPingTargetDeleteOKTitle(), req, res, mapping);
            req.setAttribute("model", pageModel);
            if (!hasRequiredRights(rreq, rreq.getWebsite())) {
                return mapping.findForward(ACCESS_DENIED_PAGE);
            }
            PingTargetData pingTarget = select(rreq);
            ((PingTargetForm) form).copyFrom(pingTarget, req.getLocale());
            return forward;
View Full Code Here

     * @param res
     * @return the result of <code>view()</code> after the deletion
     * @throws Exception
     */
    public ActionForward deleteConfirmed(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
        RollerRequest rreq = RollerRequest.getRollerRequest(req);
        PingTargetForm pingTargetForm = (PingTargetForm) form;
        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
        try {
            if (!hasRequiredRights(rreq, rreq.getWebsite())) {
                return mapping.findForward(ACCESS_DENIED_PAGE);
            }
            String pingTargetId = pingTargetForm.getId();
            if (pingTargetId == null || pingTargetId.length() == 0) {
                throw new RollerException("Missing ping target id.");
View Full Code Here

                ActionMapping mapping,
                BookmarksForm form) throws RollerException
        {
            super("",  request, response, mapping);
           
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            RollerSession rollerSession = RollerSession.getRollerSession(request);
            BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();

            allFolders = new TreeSet(new FolderPathComparator());

            // Find folderid wherever it may be
            String folderId = (String)
                request.getAttribute(RequestConstants.FOLDER_ID);
            if (null == folderId)
            {
                folderId = request.getParameter(RequestConstants.FOLDER_ID);
            }
            if (null == folderId)
            {
                folderId = form.getFolderId();
            }

            if (null == folderId || folderId.equals("null"))
            {
                website = rreq.getWebsite();
                folder = bmgr.getRootFolder(website);
                folderId = folder.getId();
            }
            else
            {
View Full Code Here

     * Other actions can get the website handle from request params, but
     * request params don't come accross in a file-upload post so we have to
     * stash the website handle in the session.
     */
    private WebsiteData getWebsite(HttpServletRequest request) throws RollerException {
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        WebsiteData website = rreq.getWebsite();
        if (website != null) {
            request.getSession().setAttribute(RequestConstants.WEBLOG_SESSION_STASH, website.getHandle());
        } else {
            String handle = (String)request.getSession().getAttribute(RequestConstants.WEBLOG_SESSION_STASH);
            Roller roller = RollerFactory.getRoller();
View Full Code Here

TOP

Related Classes of org.apache.roller.ui.core.RollerRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.