Package org.apache.roller.weblogger.pojos

Examples of org.apache.roller.weblogger.pojos.WeblogEntry


    /**
     * @inheritDoc
     */
    public WeblogEntry getPreviousEntry(WeblogEntry current,
            String catName, String locale) throws WebloggerException {
        WeblogEntry entry = null;
        List entryList = getNextPrevEntries(current, catName, locale, 1, false);
        if (entryList != null && entryList.size() > 0) {
            entry = (WeblogEntry)entryList.get(0);
        }
        return entry;
View Full Code Here


    /** URL for editing a weblog entry */
    public String editEntry(String anchor) {
        try {
            // need to determine entryId from anchor
            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
            WeblogEntry entry = wmgr.getWeblogEntryByAnchor(weblog, anchor);
            if(entry != null) {
                return urlStrategy.getEntryEditURL(weblog.getHandle(), entry.getId(), false);
            }
        } catch (WebloggerException ex) {
            log.error("Error looking up entry by anchor - "+anchor, ex);
        }
        return null;
View Full Code Here

        try {
            TreeSet categories = new TreeSet();
            Weblogger roller = WebloggerFactory.getWeblogger();
            WeblogEntryManager weblogMgr = roller.getWeblogEntryManager();
           
            WeblogEntry entry = null;
            Document doc = null;
            String handle = null;
            Timestamp now = new Timestamp(new Date().getTime());
            for(int i = offset; i < offset+limit; i++) {
               
                entry = null; // reset for each iteration
               
                doc = hits.doc(i);
                handle = doc.getField(FieldConstants.WEBSITE_HANDLE).stringValue();
               
                if(websiteSpecificSearch &&
                        handle.equals(searchRequest.getWeblogHandle())) {
                   
                    entry = weblogMgr.getWeblogEntry(
                            doc.getField(FieldConstants.ID).stringValue());
                } else {
                   
                    entry = weblogMgr.getWeblogEntry(
                            doc.getField(FieldConstants.ID).stringValue());
                   
                    if (doc.getField(FieldConstants.CATEGORY) != null) {
                        categories.add(
                                doc.getField(FieldConstants.CATEGORY).stringValue());
                    }
                }
               
                // maybe null if search result returned inactive user
                // or entry's user is not the requested user.
                // but don't return future posts
                if (entry != null && entry.getPubTime().before(now)) {
                    addEntryToResults(WeblogEntryWrapper.wrap(entry, urlStrategy));
                }
            }
           
            if(categories.size() > 0) {
View Full Code Here

    }
       
    public void testSearch() throws Exception {
        WeblogEntryManager wem = WebloggerFactory.getWeblogger().getWeblogEntryManager();

        WeblogEntry wd1 = new WeblogEntry();           
        wd1.setTitle("The Tholian Web");
        wd1.setText(
         "When the Enterprise attempts to ascertain the fate of the  "
        +"U.S.S. Defiant which vanished 3 weeks ago, the warp engines  "
        +"begin to lose power, and Spock reports strange sensor readings.");
        wd1.setAnchor("dummy1");
        wd1.setCreatorUserName(testUser.getUserName());
        wd1.setStatus(WeblogEntry.PUBLISHED);
        wd1.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        wd1.setPubTime(new Timestamp(System.currentTimeMillis()));
        wd1.setWebsite(TestUtils.getManagedWebsite(testWeblog));

        WeblogCategory cat = wem.getWeblogCategory(testWeblog.getDefaultCategory().getId());
        wd1.setCategory(cat);

        wem.saveWeblogEntry(wd1);
        TestUtils.endSession(true);
        wd1 = TestUtils.getManagedWeblogEntry(wd1);

        IndexManager imgr = WebloggerFactory.getWeblogger().getIndexManager();
        imgr.executeIndexOperationNow(
            new AddEntryOperation(WebloggerFactory.getWeblogger(), (IndexManagerImpl)imgr, wd1));

        WeblogEntry wd2 = new WeblogEntry();
        wd2.setTitle("A Piece of the Action");
        wd2.setText(
          "The crew of the Enterprise attempts to make contact with "
          +"the inhabitants of planet Sigma Iotia II, and Uhura puts Kirk "
          +"in communication with Boss Oxmyx.");
        wd2.setAnchor("dummy2");
        wd2.setStatus(WeblogEntry.PUBLISHED);
        wd2.setCreatorUserName(testUser.getUserName());
        wd2.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        wd2.setPubTime(new Timestamp(System.currentTimeMillis()));
        wd2.setWebsite(TestUtils.getManagedWebsite(testWeblog));

        cat = wem.getWeblogCategory(testWeblog.getDefaultCategory().getId());
        wd2.setCategory(cat);

        wem.saveWeblogEntry(wd2);
        TestUtils.endSession(true);
        wd2 = TestUtils.getManagedWeblogEntry(wd2);
View Full Code Here

        // remove entries
        Query refQuery = strategy.getNamedQuery("WeblogEntry.getByWebsite");
        refQuery.setParameter(1, website);
        List entries = refQuery.getResultList();
        for (Iterator iter = entries.iterator(); iter.hasNext();) {
            WeblogEntry entry = (WeblogEntry) iter.next();
            emgr.removeWeblogEntry(entry);
        }
        this.strategy.flush();
       
        // remove categories
View Full Code Here

   
    public String remove() {
       
        if(getRemoveEntry() != null) try {
           
            WeblogEntry entry = getRemoveEntry();
           
            try {
                // remove the entry from the search index
                // TODO: can we do this in a better way?
                String originalStatus = entry.getStatus();
                entry.setStatus(WeblogEntry.DRAFT);
                IndexManager manager = WebloggerFactory.getWeblogger().getIndexManager();
                manager.addEntryReIndexOperation(entry);
                entry.setStatus(originalStatus);
            } catch (WebloggerException ex) {
                log.warn("Trouble triggering entry indexing", ex);
            }
           
            // remove from search index
View Full Code Here

        }
       
        if(!hasActionErrors()) try {
            WeblogEntryManager weblogMgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
           
            WeblogEntry entry = getEntry();
           
            // set updatetime & pubtime
            entry.setUpdateTime(new Timestamp(new Date().getTime()));
            entry.setPubTime(getBean().getPubTime(getLocale(), getActionWeblog().getTimeZoneInstance()));
           
            // copy data to pojo
            getBean().copyTo(entry);
           
            // handle pubtime auto set
            if(entry.isPublished()) {
                if(entry.getPubTime() == null) {
                    // no time specified, use current time
                    entry.setPubTime(entry.getUpdateTime());
                }
               
                // if user does not have author perms then force PENDING status
                if(!getActionWeblog().hasUserPermission(getAuthenticatedUser(), WeblogPermission.POST)) {
                    entry.setStatus(WeblogEntry.PENDING);
                }
            }
           
            // if user is an admin then apply pinned to main value as well
            GlobalPermission adminPerm =
                new GlobalPermission(Collections.singletonList(GlobalPermission.ADMIN));
            if (WebloggerFactory.getWeblogger().getUserManager().checkPermission(adminPerm, getAuthenticatedUser())) {
                entry.setPinnedToMain(getBean().getPinnedToMain());
            }
           
            if (!StringUtils.isEmpty(getBean().getEnclosureURL())) {
                try {
                    // Fetch MediaCast resource
                    log.debug("Checking MediaCast attributes");
                    MediacastResource mediacast = MediacastUtil.lookupResource(getBean().getEnclosureURL());

                    // set mediacast attributes
                    entry.putEntryAttribute("att_mediacast_url", mediacast.getUrl());
                    entry.putEntryAttribute("att_mediacast_type", mediacast.getContentType());
                    entry.putEntryAttribute("att_mediacast_length", ""+mediacast.getLength());

                } catch (MediacastException ex) {
                    addMessage(getText(ex.getErrorKey()));
                }
            } else {
                try {
                    // if MediaCast string is empty, clean out MediaCast attributes
                    weblogMgr.removeWeblogEntryAttribute("att_mediacast_url", entry);
                    weblogMgr.removeWeblogEntryAttribute("att_mediacast_type", entry);
                    weblogMgr.removeWeblogEntryAttribute("att_mediacast_length", entry);
                   
                } catch (WebloggerException e) {
                    addMessage(getText("weblogEdit.mediaCastErrorRemoving"));
                }
            }
           
            if(log.isDebugEnabled()) {
                log.debug("entry bean is ...\n"+getBean().toString());
                log.debug("final status = "+entry.getStatus());
                log.debug("updtime = "+entry.getUpdateTime());
                log.debug("pubtime = "+entry.getPubTime());
            }
           
            log.debug("Saving entry");
            weblogMgr.saveWeblogEntry(entry);
            WebloggerFactory.getWeblogger().flush();
           
            // notify search of the new entry
            reindexEntry(entry);
           
            // notify caches
            CacheManager.invalidate(entry);
           
            // Queue applicable pings for this update.
            if(entry.isPublished()) {
                WebloggerFactory.getWeblogger().getAutopingManager().queueApplicableAutoPings(entry);
            }
           
            if(entry.isPending()) {
                // implies that entry just changed to pending
                MailUtil.sendPendingEntryNotice(entry);
                addMessage("weblogEdit.submittedForReview");
            } else {
                addMessage("weblogEdit.changesSaved");
View Full Code Here

        mLogger.debug("     PostId: " + postid);
        mLogger.debug("     UserId: " + userid);
       
        Weblogger roller = WebloggerFactory.getWeblogger();
        WeblogEntryManager weblogMgr = roller.getWeblogEntryManager();
        WeblogEntry entry = weblogMgr.getWeblogEntry(postid);
       
        // Return false if entry not found
        if (entry == null) return false;
       
        validate(entry.getWebsite().getHandle(), userid, password);
       
        try {
            // notify cache
            flushPageCache(entry.getWebsite());

            // delete the entry
            weblogMgr.removeWeblogEntry(entry);
            roller.flush();
           
View Full Code Here

            try {
                Timestamp current = new Timestamp(System.currentTimeMillis());
               
                Weblogger roller = WebloggerFactory.getWeblogger();
                WeblogEntryManager weblogMgr = roller.getWeblogEntryManager();
                WeblogEntry entry = weblogMgr.getWeblogEntry(postid);
                entry.setText(content);
                entry.setUpdateTime(current);
                if (Boolean.valueOf(publish).booleanValue()) {
                    entry.setStatus(WeblogEntry.PUBLISHED);
                } else {
                    entry.setStatus(WeblogEntry.DRAFT);
                }
               
                // save the entry
                weblogMgr.saveWeblogEntry(entry);
                roller.flush();
               
                // notify cache
                flushPageCache(entry.getWebsite());
               
                return true;
            } catch (Exception e) {
                String msg = "ERROR in BlooggerAPIHander.editPost";
                mLogger.error(msg,e);
View Full Code Here

        if (weblogHandle == null)
            return;

        String selfSiteFragment = "/"+weblogHandle;
        Weblog weblog = null;
        WeblogEntry entry = null;

        // lookup the weblog now
        try {
            weblog = roller.getWeblogManager().getWeblogByHandle(weblogHandle);
            if (weblog == null) return;
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.pojos.WeblogEntry

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.