Package org.apache.roller.business

Examples of org.apache.roller.business.WeblogManager


        mLogger.debug("getPost() Called =========[ SUPPORTED ]=====");
        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);
View Full Code Here


       
        try {
            Vector results = new Vector();
           
            Roller roller = RollerFactory.getRoller();
            WeblogManager weblogMgr = roller.getWeblogManager();
            if (website != null) {
                List entries = weblogMgr.getWeblogEntries(
                        website,           // website
                        null,
                        null,              // startDate
                        null,              // endDate
                        null,              // catName
View Full Code Here

   
   
    public Map getEntries() {
        if (entries == null) try {
            Roller roller = RollerFactory.getRoller();
            WeblogManager wmgr = roller.getWeblogManager();
            currEntry = wmgr.getWeblogEntryByAnchor(weblog, entryAnchor);
            if (currEntry != null && currEntry.getStatus().equals(WeblogEntryData.PUBLISHED)) {
                entries = new TreeMap();
                entries.put(new Date(currEntry.getPubTime().getTime()),
                        Collections.singletonList(WeblogEntryDataWrapper.wrap(currEntry)));
            }
View Full Code Here

   
   
    private WeblogEntryData getNextEntry() {
        if (nextEntry == null) try {
            Roller roller = RollerFactory.getRoller();
            WeblogManager wmgr = roller.getWeblogManager();
            nextEntry = wmgr.getNextEntry(currEntry, null, locale);
            // make sure that entry is published and not to future
            if (nextEntry != null && nextEntry.getPubTime().after(new Date())
            && nextEntry.getStatus().equals(WeblogEntryData.PUBLISHED)) {
                nextEntry = null;
            }
View Full Code Here

   
   
    private WeblogEntryData getPrevEntry() {
        if (prevEntry == null) try {
            Roller roller = RollerFactory.getRoller();
            WeblogManager wmgr = roller.getWeblogManager();
            prevEntry = wmgr.getPreviousEntry(currEntry, null, locale);
            // make sure that entry is published and not to future
            if (prevEntry != null && prevEntry.getPubTime().after(new Date())
            && prevEntry.getStatus().equals(WeblogEntryData.PUBLISHED)) {
                prevEntry = null;
            }
View Full Code Here

    public void execute() {
       
        log.debug("starting");
       
        try {
            WeblogManager wMgr = RollerFactory.getRoller().getWeblogManager();
            UserManager uMgr = RollerFactory.getRoller().getUserManager();
           
            Date now = new Date();
           
            if(nextExpirations != null) {
                String websiteid = null;
                WebsiteData weblog = null;
               
                Iterator weblogs = nextExpirations.iterator();
                while(weblogs.hasNext()) {
                    websiteid = (String) weblogs.next();
                   
                    try {
                        // lookup the actual entry
                        weblog = uMgr.getWebsite(websiteid);
                       
                        log.debug("expiring"+weblog.getHandle());
                       
                        // to expire weblog content we have to update the
                        // last modified time of the weblog and save it
                        weblog.setLastModified(now);
                        uMgr.saveWebsite(weblog);
                       
                    } catch (RollerException ex) {
                        log.warn("couldn't lookup entry "+websiteid);
                    }
                }
               
                // commit the changes
                RollerFactory.getRoller().flush();
            }
           
            // XX mins in the future
            Calendar cal = Calendar.getInstance();
            cal.setTime(now);
            cal.add(Calendar.MINUTE, this.peerTime);
            Date end = cal.getTime();
           
            log.debug("looking up entries between "+now+" and "+end);
           
            // get all published entries between start and end date
            List expiringEntries = wMgr.getWeblogEntries(null, null, now, end, null,
                    null, null, WeblogEntryData.PUBLISHED, null, 0, -1);
           
            // we only really want the weblog ids
            Set expiringWeblogs = new HashSet();
            Iterator it = expiringEntries.iterator();
View Full Code Here

    /**
     * Test basic persistence operations ... Create, Update, Delete.
     */
    public void testHitCountCRUD() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        HitCountData testCount = new HitCountData();
        testCount.setWeblog(testWeblog);
        testCount.setDailyHits(10);
       
        // create
        mgr.saveHitCount(testCount);
        String id = testCount.getId();
        TestUtils.endSession(true);
       
        // make sure it was created
        HitCountData hitCount = null;
        hitCount = mgr.getHitCount(id);
        assertNotNull(hitCount);
        assertEquals(testCount, hitCount);
        assertEquals(10, hitCount.getDailyHits());
       
        // update
        hitCount.setDailyHits(25);
        mgr.saveHitCount(hitCount);
        TestUtils.endSession(true);
       
        // make sure it was updated
        hitCount = null;
        hitCount = mgr.getHitCount(id);
        assertNotNull(hitCount);
        assertEquals(testCount, hitCount);
        assertEquals(25, hitCount.getDailyHits());
       
        // delete
        mgr.removeHitCount(hitCount);
        TestUtils.endSession(true);
       
        // make sure it was deleted
        hitCount = null;
        hitCount = mgr.getHitCount(id);
        assertNull(hitCount);
    }
View Full Code Here

    }
   
   
    public void testHitCountLookups() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        HitCountData testCount = new HitCountData();
        testCount.setWeblog(testWeblog);
        testCount.setDailyHits(10);
       
        // create
        mgr.saveHitCount(testCount);
        String id = testCount.getId();
        TestUtils.endSession(true);
       
        // test lookup by id
        HitCountData hitCount = null;
        hitCount = mgr.getHitCount(id);
        assertNotNull(hitCount);
        assertEquals(testCount, hitCount);
        assertEquals(10, hitCount.getDailyHits());
       
        // test lookup by weblog
        hitCount = null;
        hitCount = mgr.getHitCountByWeblog(testWeblog);
        assertNotNull(hitCount);
        assertEquals(testCount, hitCount);
        assertEquals(10, hitCount.getDailyHits());
       
        // delete
        mgr.removeHitCount(hitCount);
        TestUtils.endSession(true);
       
        // make sure it was deleted
        hitCount = null;
        hitCount = mgr.getHitCount(id);
        assertNull(hitCount);
    }
View Full Code Here

    }
   
   
    public void testIncrementHitCount() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        HitCountData testCount = new HitCountData();
        testCount.setWeblog(testWeblog);
        testCount.setDailyHits(10);
       
        // create
        mgr.saveHitCount(testCount);
        String id = testCount.getId();
        TestUtils.endSession(true);
       
        // make sure it was created
        HitCountData hitCount = null;
        hitCount = mgr.getHitCountByWeblog(testWeblog);
        assertNotNull(hitCount);
        assertEquals(10, hitCount.getDailyHits());
       
        // increment
        mgr.incrementHitCount(testWeblog, 25);
        TestUtils.endSession(true);
       
        // make sure it was incremented properly
        hitCount = null;
        hitCount = mgr.getHitCountByWeblog(testWeblog);
        assertNotNull(hitCount);
        assertEquals(35, hitCount.getDailyHits());
       
        // delete
        mgr.removeHitCount(hitCount);
        TestUtils.endSession(true);
       
        // make sure it was deleted
        hitCount = null;
        hitCount = mgr.getHitCount(id);
        assertNull(hitCount);
    }
View Full Code Here

    }
   
   
    public void testResetHitCounts() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        WebsiteData blog1 = TestUtils.setupWeblog("hitCntTest1", testUser);
        WebsiteData blog2 = TestUtils.setupWeblog("hitCntTest2", testUser);
        WebsiteData blog3 = TestUtils.setupWeblog("hitCntTest3", testUser);
       
        HitCountData cnt1 = TestUtils.setupHitCount(blog1, 10);
        HitCountData cnt2 = TestUtils.setupHitCount(blog2, 20);
        HitCountData cnt3 = TestUtils.setupHitCount(blog3, 30);
       
        TestUtils.endSession(true);
       
        // make sure data was properly initialized
        HitCountData testCount = null;
        testCount = mgr.getHitCount(cnt1.getId());
        assertEquals(10, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt2.getId());
        assertEquals(20, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt3.getId());
        assertEquals(30, testCount.getDailyHits());
       
        // reset count for one weblog
        mgr.resetHitCount(blog1);
        TestUtils.endSession(true);
       
        // make sure it reset only one weblog
        testCount = mgr.getHitCount(cnt1.getId());
        assertEquals(0, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt2.getId());
        assertEquals(20, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt3.getId());
        assertEquals(30, testCount.getDailyHits());
       
        // reset all counts
        mgr.resetAllHitCounts();
        TestUtils.endSession(true);
       
        // make sure it reset all counts
        testCount = mgr.getHitCount(cnt1.getId());
        assertEquals(0, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt2.getId());
        assertEquals(0, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt3.getId());
        assertEquals(0, testCount.getDailyHits());
       
        // cleanup
        TestUtils.teardownHitCount(cnt1.getId());
        TestUtils.teardownHitCount(cnt2.getId());
View Full Code Here

TOP

Related Classes of org.apache.roller.business.WeblogManager

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.