Package org.apache.roller.ui.authoring.struts.formbeans

Examples of org.apache.roller.ui.authoring.struts.formbeans.WeblogEntryFormEx


        try {
            RollerSession rses = RollerSession.getRollerSession(request);
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            if (rreq.getWebsite() != null
                    && rses.isUserAuthorized(rreq.getWebsite())) {
                WeblogEntryFormEx form = (WeblogEntryFormEx)actionForm;
                form.initNew(request, response);
                form.setCreatorId(rses.getAuthenticatedUser().getId());
                form.setWebsiteId(rreq.getWebsite().getId());
                form.setAllowComments(rreq.getWebsite().getDefaultAllowComments());
                form.setCommentDays(new Integer(rreq.getWebsite().getDefaultCommentDays()));
               
                request.setAttribute("model",
                        new WeblogEntryPageModel(request, response, mapping,
                        (WeblogEntryFormEx)actionForm,
                        WeblogEntryPageModel.EDIT_MODE));
View Full Code Here


        try {
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            RollerSession rses = RollerSession.getRollerSession(request);
            WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
            WeblogEntryData entry = rreq.getWeblogEntry();
            WeblogEntryFormEx form = (WeblogEntryFormEx)actionForm;
            if (entry == null && form.getId() != null) {
                entry = wmgr.getWeblogEntry(form.getId());
            }
            if (entry == null) {
                ResourceBundle resources = ResourceBundle.getBundle(
                        "ApplicationResources", request.getLocale());
                request.setAttribute("javax.servlet.error.message",
                        resources.getString("weblogEntry.notFound"));
                forward = mapping.findForward("error");
            } else if (rses.isUserAuthorized(entry.getWebsite())
            || (rses.isUserAuthorized(entry.getWebsite()) && !entry.isPublished())) {
                form.copyFrom(entry, request.getLocale());
                WeblogEntryPageModel pageModel = new WeblogEntryPageModel(
                        request, response, mapping, form,
                        WeblogEntryPageModel.EDIT_MODE);
                pageModel.setWebsite(entry.getWebsite());
                request.setAttribute("model", pageModel);
View Full Code Here

            ActionForm          actionForm,
            HttpServletRequest  request,
            HttpServletResponse response)
            throws IOException, ServletException {
        // we need to save any new entries before Previewing
        WeblogEntryFormEx form = (WeblogEntryFormEx)actionForm;
        if (form.getId() == null) {
            save(mapping, actionForm, request, response);
        }
        return display(WeblogEntryPageModel.PREVIEW_MODE,
                mapping, actionForm, request, response);
    }
View Full Code Here

            throws IOException, ServletException {
       
        ActionForward forward = mapping.findForward("weblogEdit.page");
        ActionMessages uiMessages = new ActionMessages();
        try {
            WeblogEntryFormEx  form = (WeblogEntryFormEx)actionForm;
            Roller           roller = RollerFactory.getRoller();
            RollerSession      rses = RollerSession.getRollerSession(request);
            UserManager     userMgr = roller.getUserManager();
            WeblogManager weblogMgr = roller.getWeblogManager();
            UserData           ud  = userMgr.getUser(form.getCreatorId());
            WebsiteData       site = userMgr.getWebsite(form.getWebsiteId());
            WeblogEntryData  entry = null;
           
            if ( rses.isUserAuthorizedToAuthor(site)
            || (rses.isUserAuthorized(site)
            && !form.getStatus().equals(WeblogEntryData.PUBLISHED) )) {
               
                ActionErrors errors = validateEntry(null, form);
                if (errors.size() > 0) {
                    saveErrors(request, errors);
                    request.setAttribute("model",
                            new WeblogEntryPageModel(request, response, mapping,
                            (WeblogEntryFormEx)actionForm,
                            WeblogEntryPageModel.EDIT_MODE));
                    return forward;
                }
               
                if (form.getId() == null || form.getId().trim().length()==0) {
                    entry = new WeblogEntryData();
                    entry.setCreator(ud);
                    entry.setWebsite( site );
                } else {
                    entry = weblogMgr.getWeblogEntry(form.getId());
                }
               
                mLogger.debug("setting update time now");
                form.setUpdateTime(new Timestamp(new Date().getTime()));
               
                if ("PUBLISHED".equals(form.getStatus()) &&
                        "0/0/0".equals(form.getDateString())) {
                    mLogger.debug("setting pubtime now");
                   
                    /* NOTE: the wf.copyTo() method will override this value
                     * based on data submitted with the form if that data is
                     * not null.  check the method to verify.
                     *
                     * this means that setting the pubtime here only takes
                     * effect if the entry is being published for the first
                     * time.
                     */
                    form.setPubTime(form.getUpdateTime());
                }
               
                mLogger.debug("copying submitted form data to entry object");
                form.copyTo(entry, request.getLocale(),request.getParameterMap());
               
                // Fetch MediaCast content type and length
                mLogger.debug("Checking MediaCast attributes");
                if (!checkMediaCast(entry, uiMessages)) {
                    mLogger.debug("Invalid MediaCast attributes");
                } else {
                    mLogger.debug("Validated MediaCast attributes");
                }
               
                // Store value object (creates new or updates existing)
                entry.setUpdateTime(new Timestamp(new Date().getTime()));
               
                // make sure we have an anchor value set
                if(entry.getAnchor() == null || entry.getAnchor().trim().equals("")) {
                    entry.setAnchor(weblogMgr.createAnchor(entry));
                }

                mLogger.debug("Saving entry");
                weblogMgr.saveWeblogEntry(entry);
                RollerFactory.getRoller().flush();
               
                mLogger.debug("Populating form");
                form.copyFrom(entry, request.getLocale());
               
                request.setAttribute(
                        RequestConstants.WEBLOGENTRY_ID, entry.getId());
               
                // Reindex entry, flush caches, etc.
                reindexEntry(RollerFactory.getRoller(), entry);
                mLogger.debug("Removing from cache");
                RollerRequest rreq = RollerRequest.getRollerRequest(request);
                //PageCacheFilter.removeFromCache(request, entry.getWebsite());
                CacheManager.invalidate(entry);
               
                // Queue applicable pings for this update.
                if(entry.isPublished()) {
                    RollerFactory.getRoller().getAutopingManager().queueApplicableAutoPings(entry);
                }
               
                // Clean up session objects we used
                HttpSession session = request.getSession(true);
                session.removeAttribute("spellCheckEvents");
                session.removeAttribute("entryText");
               
                // Load up request with data for view
                request.setAttribute("model",
                        new WeblogEntryPageModel(request, response, mapping,
                        (WeblogEntryFormEx)actionForm,
                        WeblogEntryPageModel.EDIT_MODE));
               
                if (!rses.isUserAuthorizedToAuthor(site) &&
                        rses.isUserAuthorized(site) && entry.isPending()) {
                    // implies that entry just changed to pending
                    notifyWebsiteAuthorsOfPendingEntry(request, entry);
                    uiMessages.add(null,
                            new ActionMessage("weblogEdit.submittedForReview"));
                   
                    // so clear entry from editor
                    actionForm = new WeblogEntryFormEx();
                    request.setAttribute(mapping.getName(), actionForm);
                    forward = create(mapping, actionForm, request, response);
                } else {
                    uiMessages.add(null,
                            new ActionMessage("weblogEdit.changesSaved"));
View Full Code Here

            HttpServletResponse response)
            throws IOException, ServletException {
        ActionForward forward = mapping.findForward("weblogEntryRemove.page");
        try {
            Roller roller = RollerFactory.getRoller();
            WeblogEntryFormEx wf = (WeblogEntryFormEx)actionForm;
            WeblogEntryData wd =
                    roller.getWeblogManager().getWeblogEntry(wf.getId());
            RollerSession rses =
                    RollerSession.getRollerSession(request);
            if (     rses.isUserAuthorizedToAuthor(wd.getWebsite())
            || (rses.isUserAuthorized(wd.getWebsite()) && wd.isDraft()) ) {
                wf.copyFrom(wd, request.getLocale());
                if (wd == null || wd.getId() == null) {
                    ResourceBundle resources = ResourceBundle.getBundle(
                            "ApplicationResources", request.getLocale());
                    request.setAttribute("javax.servlet.error.message",
                            resources.getString("weblogEntry.notFound"));
View Full Code Here

        mapping.setParameter("method");
        strutsModule.addRequestParameter("weblog",testWeblog.getHandle());
        strutsModule.addRequestParameter("method","create");
       
        // Setup form bean
        WeblogEntryFormEx form = (WeblogEntryFormEx)
        strutsModule.createActionForm(WeblogEntryFormEx.class);
        form.setTitle("test_title");
        form.setText("Test blog text");
       
        try {
            RollerRequest rreq = new RollerRequest(strutsModule.getMockPageContext());
            rreq.setWebsite(testWeblog);
            strutsModule.setRequestAttribute(RollerRequest.ROLLER_REQUEST, rreq);
View Full Code Here

TOP

Related Classes of org.apache.roller.ui.authoring.struts.formbeans.WeblogEntryFormEx

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.