Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.WeblogEntryData


        if (weblogHandle == null)
            return;
       
        String selfSiteFragment = "/"+weblogHandle;
        WebsiteData weblog = null;
        WeblogEntryData entry = null;
       
        // lookup the weblog now
        try {
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
            weblog = userMgr.getWebsiteByHandle(weblogHandle);
View Full Code Here


        ActionForward forward = mapping.findForward("weblogEdit.page");
        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);
            } else {
                forward = mapping.findForward("access-denied");
            }
        } catch (Exception e) {
View Full Code Here

            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"));
                   
View Full Code Here

            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"));
                    forward = mapping.findForward("error");
View Full Code Here

            HttpServletRequest  request,
            HttpServletResponse response)
            throws IOException, ServletException {
        try {
            WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
            WeblogEntryData wd =
                    mgr.getWeblogEntry(request.getParameter("id"));
            RollerSession rses =
                    RollerSession.getRollerSession(request);
            if (     rses.isUserAuthorizedToAuthor(wd.getWebsite())
            || (rses.isUserAuthorized(wd.getWebsite()) && wd.isDraft()) ) {
               
                // remove the index for it
                // TODO: can we do this in a better way?
                wd.setStatus(WeblogEntryData.DRAFT);
                reindexEntry(RollerFactory.getRoller(), wd);
               
                // remove entry itself
                mgr.removeWeblogEntry(wd);
                RollerFactory.getRoller().flush();
               
                // flush caches
                CacheManager.invalidate(wd);
               
                ActionMessages uiMessages = new ActionMessages();
                uiMessages.add(null,
                        new ActionMessage("weblogEdit.entryRemoved"));
                saveMessages(request, uiMessages);
               
                RollerRequest.getRollerRequest().setWebsite(wd.getWebsite());
            } else {
                return mapping.findForward("access-denied");
            }
        } catch (Exception e) {
            throw new ServletException(e);
View Full Code Here

            HttpServletRequest request,
            HttpServletResponse response) throws RollerException {
        ActionMessages resultMsg = new ActionMessages();
        ActionForward forward = mapping.findForward("weblogEdit.page");
        ActionErrors errors = new ActionErrors();
        WeblogEntryData entry = null;
        try {
            WeblogEntryFormEx form = (WeblogEntryFormEx)actionForm;
            String entryid = form.getId();
            if ( entryid == null ) {
                entryid =
                        request.getParameter(RequestConstants.WEBLOGENTRY_ID);
            }
            Roller roller = RollerFactory.getRoller();
            RollerContext rctx= RollerContext.getRollerContext();
            WeblogManager wmgr= roller.getWeblogManager();
            entry = wmgr.getWeblogEntry(entryid);
           
            RollerSession rses = RollerSession.getRollerSession(request);
            if (rses.isUserAuthorizedToAuthor(entry.getWebsite())) {
                // Run entry through registered PagePlugins
                PluginManager ppmgr = roller.getPagePluginManager();
                Map plugins = ppmgr.getWeblogEntryPlugins(
                        entry.getWebsite());
               
                String content = "";
                if (!StringUtils.isEmpty(entry.getText())) {
                    content = entry.getText();
                } else {
                    content = entry.getSummary();
                }
                content = ppmgr.applyWeblogEntryPlugins(plugins, entry, content);

                String title = entry.getTitle();
                String excerpt = StringUtils.left( Utilities.removeHTML(content),255 );
               
                String url = entry.getPermalink();
                String blog_name = entry.getWebsite().getName();
               
                if (form.getTrackbackUrl() != null) {
                    // by default let all trackbacks to be sent
                    boolean allowTrackback = true;
                   
View Full Code Here

            WeblogManager wmgr = roller.getWeblogManager();
            currEntry = wmgr.getWeblogEntryByAnchor(weblog, entryAnchor);
            if (currEntry != null) {
               
                // clone the entry since we don't want to work with the real pojo
                WeblogEntryData tmpEntry = new WeblogEntryData();
                tmpEntry.setData(currEntry);
               
                // set the pubtime to the current time if it is unset
                if(tmpEntry.getPubTime() == null) {
                    tmpEntry.setPubTime(new Timestamp(System.currentTimeMillis()));
                }
               
                // store the entry in the collection
                entries = new TreeMap();
                entries.put(tmpEntry.getPubTime(),
                        Collections.singletonList(WeblogEntryDataWrapper.wrap(tmpEntry)));
            }
        } catch (Exception e) {
            log.error("ERROR: fetching entry", e);
        }
View Full Code Here

        mLogger.debug("     UserId: " + userid);
        mLogger.debug("    Publish: " + publish);
       
        Roller roller = RollerFactory.getRoller();
        WeblogManager weblogMgr = roller.getWeblogManager();
        WeblogEntryData entry = weblogMgr.getWeblogEntry(postid);
       
        validate(entry.getWebsite().getHandle(), userid,password);
       
        Hashtable postcontent = struct;
        String description = (String)postcontent.get("description");
        String title = (String)postcontent.get("title");
        if (title == null) title = "";
       
        Date dateCreated = (Date)postcontent.get("dateCreated");
        if (dateCreated == null) dateCreated = (Date)postcontent.get("pubDate");
       
        String cat = null;
        if ( postcontent.get("categories") != null ) {
            Vector cats = (Vector)postcontent.get("categories");
            cat = (String)cats.elementAt(0);
        }
        mLogger.debug("      Title: " + title);
        mLogger.debug("   Category: " + cat);
       
        try {
           
            Timestamp current =
                    new Timestamp(System.currentTimeMillis());
           
            if ( !title.equals("") ) entry.setTitle(title);
            entry.setText(description);
            entry.setUpdateTime(current);
            if (Boolean.valueOf(publish).booleanValue()) {
                entry.setStatus(WeblogEntryData.PUBLISHED);
            } else {
                entry.setStatus(WeblogEntryData.DRAFT);
            }
            if (dateCreated != null) {
                entry.setPubTime(new Timestamp(dateCreated.getTime()));
            }
           
            if ( cat != null ) {
                // Use first category specified by request
                WeblogCategoryData cd =
                        weblogMgr.getWeblogCategoryByPath(entry.getWebsite(), cat);
                entry.setCategory(cd);
            }
           
            // save the entry
            weblogMgr.saveWeblogEntry(entry);
            roller.flush();
           
            // notify cache
            flushPageCache(entry.getWebsite());
           
            // TODO: Roller timestamps need better than 1 second accuracy
            // Until then, we can't allow more than one post per second
            Thread.sleep(1000);
           
View Full Code Here

            WeblogManager weblogMgr = roller.getWeblogManager();
            UserData user = roller.getUserManager().getUserByUserName(userid);
            Timestamp current =
                    new Timestamp(System.currentTimeMillis());
           
            WeblogEntryData entry = new WeblogEntryData();
            entry.setTitle(title);
            entry.setText(description);
            entry.setPubTime(new Timestamp(dateCreated.getTime()));
            entry.setUpdateTime(current);
            entry.setWebsite(website);
            entry.setCreator(user);
            if (Boolean.valueOf(publish).booleanValue()) {
                entry.setStatus(WeblogEntryData.PUBLISHED);
            } else {
                entry.setStatus(WeblogEntryData.DRAFT);
            }
           
            // MetaWeblog supports multiple cats, Roller supports one/entry
            // so here we take accept the first category that exists
            WeblogCategoryData rollerCat = null;
            if ( postcontent.get("categories") != null ) {
                Vector cats = (Vector)postcontent.get("categories");
                if (cats != null && cats.size() > 0) {
                    for (int i=0; i<cats.size(); i++) {
                        String cat = (String)cats.get(i);
                        rollerCat = weblogMgr.getWeblogCategoryByPath(website, cat);
                        if (rollerCat != null) {
                            entry.setCategory(rollerCat);
                            break;
                        }
                    }
                }
            }
            if (rollerCat == null) {
                // or we fall back to the default Blogger API category
                entry.setCategory(website.getBloggerCategory());
            }
           
            // save the entry
            weblogMgr.saveWeblogEntry(entry);
            roller.flush();
           
            // notify cache
            flushPageCache(entry.getWebsite());
           
            // TODO: Roller timestamps need better than 1 second accuracy
            // Until then, we can't allow more than one post per second
            Thread.sleep(1000);
           
            return entry.getId();
        } catch (Exception e) {
            String msg = "ERROR in MetaWeblogAPIHandler.newPost";
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
        }
View Full Code Here

        mLogger.debug("     PostId: " + postid);
        mLogger.debug("     UserId: " + userid);
       
        Roller roller = RollerFactory.getRoller();
        WeblogManager weblogMgr = roller.getWeblogManager();
        WeblogEntryData entry = weblogMgr.getWeblogEntry(postid);
       
        validate(entry.getWebsite().getHandle(), userid,password);
       
        try {
            return createPostStruct(entry, userid);
        } catch (Exception e) {
            String msg = "ERROR in MetaWeblogAPIHandler.getPost";
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.WeblogEntryData

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.