Package org.apache.roller.model

Examples of org.apache.roller.model.WeblogManager


            weblog = userMgr.getWebsiteByHandle(weblogHandle);
            if (weblog == null) return;
           
            // now lookup weblog entry if possible
            if (entryAnchor != null) {
                WeblogManager weblogMgr = RollerFactory.getRoller().getWeblogManager();
                entry = weblogMgr.getWeblogEntryByAnchor(weblog, entryAnchor);
            }
        } catch (RollerException re) {
            // problem looking up website, gotta bail
            log.error("Error looking up website object", re);
            return;
View Full Code Here


        }   
        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();) {
View Full Code Here

                weblogEntry = rreq.getWeblogEntry();
            }
            else if (rreq.getWebsite() != null) {
                website = rreq.getWebsite();
            }
            WeblogManager blogmgr = roller.getWeblogManager();

            int offset = queryForm.getOffset();
            comments = blogmgr.getComments(
                website,
                weblogEntry,
                queryForm.getSearchString(),
                queryForm.getStartDate(request.getLocale()),
                queryForm.getEndDate(request.getLocale()),
View Full Code Here

        Roller roller = RollerFactory.getRoller();
        try
        {
            if (writer != null)
            {
                WeblogManager weblogManager = roller.getWeblogManager();

                List entries = weblogManager .getWeblogEntries(
                    website,                   // userName
                    null,                      // startDate
                    new Date(),                // endDate (don't index 'future' entries)
                    null,                      // catName
                    WeblogEntryData.PUBLISHED, // status
View Full Code Here

            throws HibernateException, RollerException {
       
        Session session = this.strategy.getSession();
       
        BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();
        WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
       
        // Remove the website's ping queue entries
        Criteria criteria = session.createCriteria(PingQueueEntryData.class);
        criteria.add(Expression.eq("website", website));
        List queueEntries = criteria.list();
       
        // Remove the website's auto ping configurations
        AutoPingManager autoPingMgr = RollerFactory.getRoller().getAutopingManager();
        List autopings = autoPingMgr.getAutoPingsByWebsite(website);
        Iterator it = autopings.iterator();
        while(it.hasNext()) {
            this.strategy.remove((AutoPingData) it.next());
        }
       
        // Remove the website's custom ping targets
        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
        List pingtargets = pingTargetMgr.getCustomPingTargets(website);
        it = pingtargets.iterator();
        while(it.hasNext()) {
            this.strategy.remove((PingTargetData) it.next());
        }
       
        // remove entries
        Criteria entryQuery = session.createCriteria(WeblogEntryData.class);
        entryQuery.add(Expression.eq("website", website));
        List entries = entryQuery.list();
        for (Iterator iter = entries.iterator(); iter.hasNext();) {
            WeblogEntryData entry = (WeblogEntryData) iter.next();
           
            this.strategy.remove(entry);
        }
       
        // remove associated referers
        Criteria refererQuery = session.createCriteria(RefererData.class);
        refererQuery.add(Expression.eq("website", website));
        List referers = refererQuery.list();
        for (Iterator iter = referers.iterator(); iter.hasNext();) {
            RefererData referer = (RefererData) iter.next();
            this.strategy.remove(referer);
        }
       
               
        // remove associated pages
        Criteria pageQuery = session.createCriteria(WeblogTemplate.class);
        pageQuery.add(Expression.eq("website", website));
        List pages = pageQuery.list();
        for (Iterator iter = pages.iterator(); iter.hasNext();) {
            WeblogTemplate page = (WeblogTemplate) iter.next();
            this.strategy.remove(page);
        }
       
        // remove folders (including bookmarks)
        FolderData rootFolder = bmgr.getRootFolder(website);
        if (null != rootFolder) {
            this.strategy.remove(rootFolder);
           
            // Still cannot get all Bookmarks cleared!
            Iterator allFolders = bmgr.getAllFolders(website).iterator();
            while (allFolders.hasNext()) {
                FolderData aFolder = (FolderData)allFolders.next();
                bmgr.removeFolderContents(aFolder);
                this.strategy.remove(aFolder);
            }
        }
       
        // remove categories
        WeblogCategoryData rootCat = wmgr.getRootWeblogCategory(website);
        if (null != rootCat) {
            this.strategy.remove(rootCat);
        }
       
    }
View Full Code Here

   
   
    private void addWeblogContents(WebsiteData newWeblog) throws RollerException {
       
        UserManager umgr = RollerFactory.getRoller().getUserManager();
        WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
       
        // grant weblog creator ADMIN permissions
        PermissionsData perms = new PermissionsData();
        perms.setUser(newWeblog.getCreator());
        perms.setWebsite(newWeblog);
View Full Code Here

                UserManager usermgr = RollerFactory.getRoller().getUserManager();
                WebsiteData website = usermgr.getWebsiteByHandle(sub.getAuthor());
                if (website == null) return newEntries;
               
                // figure website last update time
                WeblogManager blogmgr = RollerFactory.getRoller().getWeblogManager();
               
                Date siteUpdated = blogmgr.getWeblogLastPublishTime(website);
                if (siteUpdated == null) { // Site never updated, skip it
                    log.warn("Last-publish time null, skipping local feed ["
                            + website.getHandle() + "]");
                    return newEntries;
                }
               
                // if website last update time > subsciption last update time
                List entries = new ArrayList();
                if (sub.getLastUpdated()==null || siteUpdated.after(sub.getLastUpdated())) {
                    int entryCount = RollerRuntimeConfig.getIntProperty(
                            "site.newsfeeds.defaultEntries");
                    entries = blogmgr.getWeblogEntries(
                            website,
                            null,                        // startDate
                            new Date(),                  // endDate
                            null,                        // catName
                            WeblogEntryData.PUBLISHED,   // status
View Full Code Here

    /**
     * Test basic persistence operations ... Create, Update, Delete.
     */
    public void testWeblogCategoryCRUD() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
        WeblogCategoryData cat = null;
        List cats = null;
       
        // we need to know how many categories we start the test with
        int numCats = mgr.getRootWeblogCategory(testWeblog).getWeblogCategories().size();
       
        // add a new category
        WeblogCategoryData newCat = new WeblogCategoryData();
        newCat.setName("catTestCategory");
        newCat.setParent(testWeblog.getDefaultCategory());
        newCat.setWebsite(testWeblog);
        mgr.saveWeblogCategory(newCat);
        String id = newCat.getId();
        TestUtils.endSession(true);
       
        // make sure category was added
        cat = null;
        cat = mgr.getWeblogCategory(id);
        assertNotNull(cat);
        assertEquals(newCat, cat);
       
        // make sure category count increased
        testWeblog = RollerFactory.getRoller().getUserManager().getWebsite(testWeblog.getId());
        assertEquals(numCats+1, mgr.getRootWeblogCategory(testWeblog).getWeblogCategories().size());
       
        // update category
        cat.setName("testtest");
        mgr.saveWeblogCategory(cat);
        TestUtils.endSession(true);
       
        // verify category was updated
        cat = null;
        cat = mgr.getWeblogCategory(id);
        assertNotNull(cat);
        assertEquals("testtest", cat.getName());
       
        // remove category
        mgr.removeWeblogCategory(cat);
        TestUtils.endSession(true);
       
        // make sure category was removed
        cat = null;
        mgr.getWeblogCategory(id);
        assertNull(cat);
       
        // make sure category count decreased
        testWeblog = RollerFactory.getRoller().getUserManager().getWebsite(testWeblog.getId());
        assertEquals(numCats, mgr.getRootWeblogCategory(testWeblog).getWeblogCategories().size());
    }
View Full Code Here

   
   
    public void testWeblogCategoryPaths() throws Exception {
       
        WeblogCategoryData root = null;
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        root = mgr.getRootWeblogCategory(testWeblog);
       
        WeblogCategoryData f1 = new WeblogCategoryData();
        f1.setName("f1");
        f1.setParent(root);
        f1.setWebsite(testWeblog);
        mgr.saveWeblogCategory(f1);
       
        WeblogCategoryData f2 = new WeblogCategoryData();
        f2.setName("f2");
        f2.setParent(f1);
        f2.setWebsite(testWeblog);
        mgr.saveWeblogCategory(f2);
       
        WeblogCategoryData f3 = new WeblogCategoryData();
        f3.setName("f3");
        f3.setParent(f2);
        f3.setWebsite(testWeblog);
        mgr.saveWeblogCategory(f3);
       
        TestUtils.endSession(true);
       
        // check count of descendents and ancestors
        f1 = mgr.getWeblogCategory(f1.getId());
        assertEquals(2, f1.getAllDescendentAssocs().size());
        assertEquals(1, f1.getAncestorAssocs().size());
       
        f2 = mgr.getWeblogCategory(f2.getId());
        assertEquals(1, f2.getAllDescendentAssocs().size());
        assertEquals(2, f2.getAncestorAssocs().size());
       
        f3 = mgr.getWeblogCategory(f3.getId());
        assertEquals(0, f3.getAllDescendentAssocs().size());
        assertEquals(3, f3.getAncestorAssocs().size());
       
        // test get by path
        assertEquals("f1",
                mgr.getWeblogCategoryByPath(testWeblog, null, "f1").getName());
       
        assertEquals("f1",
                mgr.getWeblogCategoryByPath(testWeblog, null, "/f1").getName());
       
        assertEquals("f2",
                mgr.getWeblogCategoryByPath(testWeblog, null, "/f1/f2").getName());
       
        assertEquals("f3",
                mgr.getWeblogCategoryByPath(testWeblog, null, "/f1/f2/f3").getName());
       
        // test path creation
        f3 = mgr.getWeblogCategoryByPath(testWeblog, null, "/f1/f2/f3");
        String pathString = mgr.getPath(f3);
        String[] pathArray = Utilities.stringToStringArray(pathString,"/");
        assertEquals("f1", pathArray[0]);
        assertEquals("f2", pathArray[1]);
        assertEquals("f3", pathArray[2]);
    }
View Full Code Here

    }
   
   
    public void testMoveWeblogCategory() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        // add some categories and entries to test with
        WeblogCategoryData dest = new WeblogCategoryData();
        dest.setName("c0");
        dest.setParent(mgr.getRootWeblogCategory(testWeblog));
        dest.setWebsite(testWeblog);
        mgr.saveWeblogCategory(dest);
       
        WeblogCategoryData c1 = new WeblogCategoryData();
        c1.setName("c1");
        c1.setParent(mgr.getRootWeblogCategory(testWeblog));
        c1.setWebsite(testWeblog);
        mgr.saveWeblogCategory(c1);
       
        WeblogCategoryData c2 = new WeblogCategoryData();
        c2.setName("c2");
        c2.setParent(c1);
        c2.setWebsite(testWeblog);
        mgr.saveWeblogCategory(c2);
       
        WeblogCategoryData c3 = new WeblogCategoryData();
        c3.setName("c3");
        c3.setParent(c2);
        c3.setWebsite(testWeblog);
        mgr.saveWeblogCategory(c3);
       
        TestUtils.endSession(true);
       
        c1 = mgr.getWeblogCategory(c1.getId());
        c2 = mgr.getWeblogCategory(c2.getId());
        c3 = mgr.getWeblogCategory(c3.getId());
        dest = mgr.getWeblogCategory(dest.getId());
       
        WeblogEntryData e1 = TestUtils.setupWeblogEntry("e1", c1, testWeblog, testUser);
        WeblogEntryData e2 = TestUtils.setupWeblogEntry("e2", c2, testWeblog, testUser);
        WeblogEntryData e3 = TestUtils.setupWeblogEntry("e3", c3, testWeblog, testUser);
       
        TestUtils.endSession(true);
       
        // verify number of entries in each category
        assertEquals(0, dest.retrieveWeblogEntries(true).size());
        assertEquals(0, dest.retrieveWeblogEntries(false).size());
        assertEquals(1, c1.retrieveWeblogEntries(false).size());
        assertEquals(3, c1.retrieveWeblogEntries(true).size());
       
        // move contents of source category c1 to destination catetory dest
        c1.setParent(dest);
        mgr.saveWeblogCategory(c1);
        TestUtils.endSession(true);
       
        // after move, verify number of entries in each category
        dest = mgr.getWeblogCategory(dest.getId());
        c1 = mgr.getWeblogCategory(c1.getId());
        c2 = mgr.getWeblogCategory(c2.getId());
        c3 = mgr.getWeblogCategory(c3.getId());
       
        assertEquals(3, dest.retrieveWeblogEntries(true).size());
        assertEquals(0, dest.retrieveWeblogEntries(false).size());
       
        assertEquals(dest, c1.getParent());
View Full Code Here

TOP

Related Classes of org.apache.roller.model.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.