Examples of WeblogManager


Examples of org.apache.roller.weblogger.business.WeblogManager

     * Bulk delete all comments matching query criteria.
     */
    public String delete() {
       
        try {
            WeblogManager wmgr = WebloggerFactory.getWeblogger().getWeblogManager();
           
            // if search is enabled, we will need to re-index all entries with
            // comments that have been deleted, so build a list of those entries
            Set<WeblogEntry> reindexEntries = new HashSet<WeblogEntry>();
            if (WebloggerConfig.getBooleanProperty("search.enabled")) {                
                List<WeblogEntryComment> targetted = (List<WeblogEntryComment>)wmgr.getComments(
                    getActionWeblog(),
                    getQueryEntry(),
                    getBean().getSearchString(),
                    getBean().getStartDate(),
                    getBean().getEndDate(),
                    getBean().getStatus(),
                    true,
                    0, -1);
                for (WeblogEntryComment comment : targetted) {
                    reindexEntries.add(comment.getWeblogEntry());
                }
            }
           
            int deleted = wmgr.removeMatchingComments(
                    getActionWeblog(),
                    null,
                    getBean().getSearchString(),
                    getBean().getStartDate(),
                    getBean().getEndDate(),
View Full Code Here

Examples of org.apache.roller.weblogger.business.WeblogManager

       
        if (entries == null) {
            entries = new TreeMap(new ReverseComparator());
            try {
                Weblogger roller = WebloggerFactory.getWeblogger();
                WeblogManager wmgr = roller.getWeblogManager();
                Map mmap = WebloggerFactory.getWeblogger().getWeblogManager().getWeblogEntryObjectMap(
                        weblog,
                        null,
                        new Date(),
                        catPath,
View Full Code Here

Examples of org.apache.roller.weblogger.business.WeblogManager

     * Update a list of comments.
     */
    public String update() {
       
        try {
            WeblogManager wmgr = WebloggerFactory.getWeblogger().getWeblogManager();
           
            List<WeblogEntryComment> flushList = new ArrayList();

            // if search is enabled, we will need to re-index all entries with
            // comments that have been approved, so build a list of those entries
            Set<WeblogEntry> reindexList = new HashSet<WeblogEntry>();
           
            // delete all comments with delete box checked
            List<String> deletes = Arrays.asList(getBean().getDeleteComments());
            if(deletes != null && deletes.size() > 0) {
                log.debug("Processing deletes - "+deletes.size());
               
                WeblogEntryComment deleteComment = null;
                for(String deleteId : deletes) {
                    deleteComment = wmgr.getComment(deleteId);
                   
                    // make sure comment is tied to action weblog
                    if(getActionWeblog().equals(deleteComment.getWeblogEntry().getWebsite())) {
                        flushList.add(deleteComment);
                        reindexList.add(deleteComment.getWeblogEntry());
                        wmgr.removeComment(deleteComment);
                    }
                }
            }
           
            // loop through IDs of all comments displayed on page
            List<String> approvedIds = Arrays.asList(getBean().getApprovedComments());
            List<String> spamIds = Arrays.asList(getBean().getSpamComments());
            log.debug(spamIds.size()+" comments marked as spam");
           
            // track comments approved via moderation
            List<WeblogEntryComment> approvedComments = new ArrayList();
           
            String[] ids = Utilities.stringToStringArray(getBean().getIds(),",");
            for (int i=0; i < ids.length; i++) {
                log.debug("processing id - "+ ids[i]);
               
                // if we already deleted it then skip forward
                if(deletes.contains(ids[i])) {
                    log.debug("Already deleted, skipping - "+ids[i]);
                    continue;
                }
               
                WeblogEntryComment comment = wmgr.getComment(ids[i]);
               
                // make sure comment is tied to action weblog
                if(getActionWeblog().equals(comment.getWeblogEntry().getWebsite())) {
                    // comment approvals and mark/unmark spam
                    if(approvedIds.contains(ids[i])) {
                        // if a comment was previously PENDING then this is
                        // it's first approval, so track it for notification
                        if(WeblogEntryComment.PENDING.equals(comment.getStatus())) {
                            approvedComments.add(comment);
                        }
                       
                        log.debug("Marking as approved - "+comment.getId());
                        comment.setStatus(WeblogEntryComment.APPROVED);
                        wmgr.saveComment(comment);
                       
                        flushList.add(comment);
                        reindexList.add(comment.getWeblogEntry());
                       
                    } else if(spamIds.contains(ids[i])) {
                        log.debug("Marking as spam - "+comment.getId());
                        comment.setStatus(WeblogEntryComment.SPAM);
                        wmgr.saveComment(comment);
                       
                        flushList.add(comment);
                        reindexList.add(comment.getWeblogEntry());

                    } else if(!WeblogEntryComment.DISAPPROVED.equals(comment.getStatus())) {
                        log.debug("Marking as disapproved - "+comment.getId());
                        comment.setStatus(WeblogEntryComment.DISAPPROVED);
                        wmgr.saveComment(comment);
                       
                        flushList.add(comment);
                        reindexList.add(comment.getWeblogEntry());
                    }
                }
View Full Code Here

Examples of org.apache.roller.weblogger.business.WeblogManager

    }
   
   
    public void myPrepare() {
        try {
            WeblogManager wmgr = WebloggerFactory.getWeblogger().getWeblogManager();
            if(!StringUtils.isEmpty(getRemoveId())) {
                setCategory(wmgr.getWeblogCategory(getRemoveId()));
            }
        } catch (WebloggerException ex) {
            log.error("Error looking up category", ex);
        }
    }
View Full Code Here

Examples of org.apache.roller.weblogger.business.WeblogManager

        // build list of categories for display
        TreeSet allCategories = new TreeSet(new WeblogCategoryPathComparator());
       
        try {
            // Build list of all categories, except for current one, sorted by path.
            WeblogManager wmgr = WebloggerFactory.getWeblogger().getWeblogManager();
            List<WeblogCategory> cats = wmgr.getWeblogCategories(getActionWeblog(), true);
            for(WeblogCategory cat : cats) {
                if (!cat.getId().equals(getRemoveId())) {
                    allCategories.add(cat);
                }
            }
View Full Code Here

Examples of org.apache.roller.weblogger.business.WeblogManager

     * Remove a new template.
     */
    public String remove() {
       
        if(getCategory() != null) try {
            WeblogManager wmgr = WebloggerFactory.getWeblogger().getWeblogManager();
           
            if(getTargetCategoryId() != null) {
                WeblogCategory target = wmgr.getWeblogCategory(getTargetCategoryId());
                wmgr.moveWeblogCategoryContents(getCategory(), target);
                WebloggerFactory.getWeblogger().flush();
            }
           
            // notify cache
            String id = getCategory().getId();
            CacheManager.invalidate(getCategory());
           
            wmgr.removeWeblogCategory(getCategory());
            WebloggerFactory.getWeblogger().flush();
           
            // set category id to parent for next page
            setRemoveId(id);
           
View Full Code Here

Examples of org.apache.roller.weblogger.business.WeblogManager

   
   
    public void myPrepare() {
        if(getBean().getId() != null) {
            try {
                WeblogManager wmgr = WebloggerFactory.getWeblogger().getWeblogManager();
                setEntry(wmgr.getWeblogEntry(getBean().getId()));
            } catch (WebloggerException ex) {
                log.error("Error looking up entry by id - "+getBean().getId(), ex);
            }
        }
    }
View Full Code Here

Examples of org.apache.roller.weblogger.business.WeblogManager

        } else if(!getEntry().getWebsite().equals(getActionWeblog())) {
            return DENIED;
        }
       
        if(!hasActionErrors()) try {
            WeblogManager weblogMgr = WebloggerFactory.getWeblogger().getWeblogManager();
           
            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().hasUserPermissions(getAuthenticatedUser(),WeblogPermission.AUTHOR)) {
                    entry.setStatus(WeblogEntry.PENDING);
                }
            }
           
            // if user is an admin then apply pinned to main value as well
            if(getAuthenticatedUser().hasRole("admin")) {
                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);
           
View Full Code Here

Examples of org.apache.roller.weblogger.business.WeblogManager

    /**
     * Get the list of all categories for the action weblog, not including root.
     */
    public List<WeblogCategory> getCategories() {
        try {
            WeblogManager wmgr = WebloggerFactory.getWeblogger().getWeblogManager();
            return wmgr.getWeblogCategories(getActionWeblog(), false);
        } catch (WebloggerException ex) {
            log.error("Error getting category list for weblog - "+getWeblog(), ex);
            return Collections.EMPTY_LIST;
        }
    }
View Full Code Here

Examples of org.apache.roller.weblogger.business.WeblogManager

     */
    private void removeWebsiteContents(Weblog website)
    throws  WebloggerException {
       
        BookmarkManager bmgr = roller.getBookmarkManager();
        WeblogManager wmgr = roller.getWeblogManager();
       
        // remove tags
        Query tagQuery = strategy.getNamedQuery("WeblogEntryTag.getByWeblog");
        tagQuery.setParameter(1, website);
        List results = tagQuery.getResultList();
       
        for(Iterator iter = results.iterator(); iter.hasNext();) {
            WeblogEntryTag tagData = (WeblogEntryTag) iter.next();
            this.strategy.remove(tagData);
        }
       
        // remove site tag aggregates
        List tags = wmgr.getTags(website, null, null, -1);
        updateTagAggregates(tags);
       
        // delete all weblog tag aggregates
        Query removeAggs= strategy.getNamedUpdate(
                "WeblogEntryTagAggregate.removeByWeblog");
        removeAggs.setParameter(1, website);
        removeAggs.executeUpdate();
       
        // delete all bad counts
        Query removeCounts = strategy.getNamedUpdate(
                "WeblogEntryTagAggregate.removeByTotalLessEqual");
        removeCounts.setParameter(1, new Integer(0));
        removeCounts.executeUpdate();
       
       
        // Remove the website's ping queue entries
        Query q = strategy.getNamedQuery("PingQueueEntry.getByWebsite");
        q.setParameter(1, website);
        List queueEntries = q.getResultList();
        Iterator it = queueEntries.iterator();
        while(it.hasNext()) {
            this.strategy.remove((PingQueueEntry) it.next());
        }
       
        // Remove the website's auto ping configurations
        AutoPingManager autoPingMgr = roller
        .getAutopingManager();
        List autopings = autoPingMgr.getAutoPingsByWebsite(website);
        it = autopings.iterator();
        while(it.hasNext()) {
            this.strategy.remove((AutoPing) it.next());
        }
       
        // Remove the website's custom ping targets
        PingTargetManager pingTargetMgr = roller.getPingTargetManager();
        List pingtargets = pingTargetMgr.getCustomPingTargets(website);
        it = pingtargets.iterator();
        while(it.hasNext()) {
            this.strategy.remove((PingTarget) it.next());
        }
       
        // remove associated referers
        Query refQuery2 = strategy.getNamedQuery("WeblogReferrer.getByWebsite");
        refQuery2.setParameter(1, website);
        List referers = refQuery2.getResultList();
        for (Iterator iter = referers.iterator(); iter.hasNext();) {
            WeblogReferrer referer = (WeblogReferrer) iter.next();
            this.strategy.remove(referer);
        }
       
        // remove associated pages
        Query pageQuery = strategy.getNamedQuery("WeblogTemplate.getByWebsite");
        pageQuery.setParameter(1, website);
        List pages = pageQuery.getResultList();
        for (Iterator iter = pages.iterator(); iter.hasNext();) {
            WeblogTemplate page = (WeblogTemplate) iter.next();
            this.strategy.remove(page);
        }
       
        // remove folders (including bookmarks)
        WeblogBookmarkFolder rootFolder = bmgr.getRootFolder(website);
        if (null != rootFolder) {
            this.strategy.remove(rootFolder);
        }
       
        this.strategy.flush();

        // 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();
            wmgr.removeWeblogEntry(entry);
        }
       
        // remove categories
        WeblogCategory rootCat = wmgr.getRootWeblogCategory(website);
        if (null != rootCat) {
            this.strategy.remove(rootCat);
        }
       
        // remove permissions
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.