Package org.apache.roller.weblogger.business

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


       
        // run validation
        myValidate();
       
        if(!hasActionErrors()) try {
            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
            UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
           
            Weblog weblog = getActionWeblog();
           
            getBean().copyTo(weblog);
           
            // if blogger category changed then lookup new cat and set it
            if(getBean().getBloggerCategoryId() != null &&
                    !weblog.getBloggerCategory().getId().equals(getBean().getBloggerCategoryId())) {
                weblog.setBloggerCategory(wmgr.getWeblogCategory(getBean().getBloggerCategoryId()));
            }
           
            // ROL-485: comments not allowed on inactive weblogs
            if(!weblog.getActive()) {
                weblog.setAllowComments(Boolean.FALSE);
                addMessage("websiteSettings.commentsOffForInactiveWeblog");
            }
           
            // if blog has unchecked 'show all langs' then we must make sure
            // the multi-language blogging option is enabled.
            // TODO: this should be properly reflected via the UI
            if(!weblog.isShowAllLangs() && !weblog.isEnableMultiLang()) {
                weblog.setEnableMultiLang(true);
            }
           
            // save config
            WebloggerFactory.getWeblogger().getWeblogManager().saveWeblog(weblog);
           
            // ROL-1050: apply comment defaults to existing entries
            if(getBean().getApplyCommentDefaults()) {
                wmgr.applyCommentDefaultsToEntries(weblog);
            }
           
            // apply referer filters
            WebloggerFactory.getWeblogger().getRefererManager().applyRefererFilters(weblog);
           
View Full Code Here


       
        // Determine previous non-empty month
        // Get entries before startDate, using category restriction limit 1
        // Use entry's date as previous month
        try {
            WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
            List prevEntries = mgr.getWeblogEntries(
                   
                    weblog,                    // website
                    null,                      // user
                    null,                      // startDate
                    // since we need an entry.pubTime<startDate, but the method use <=
                    new Date(startDate.getTime()-1),                 // endDate
                    cat,                       // cat
                    null,WeblogEntry.PUBLISHED, // status
                    null,                      // text
                    null,                      // sortby (null means pubTime)
                    WeblogEntryManager.DESCENDING,  // sortorder, null means DESCENDING
                    locale,                    // locale
                    0, 1);                     // offset, range
            if (prevEntries.size() > 0) {
                WeblogEntry prevEntry = (WeblogEntry)prevEntries.get(0);
                prevMonth = DateUtil.getStartOfMonth(new Date(prevEntry.getPubTime().getTime()),getCalendar());
            }
        } catch (WebloggerException e) {
            log.error("ERROR determining previous non-empty month");
        }
       
        // Determine next non-empty month
        // Get entries after endDate, using category restriction limit 1
        // Use entry's date as next month
        try {
            WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
            List nextEntries = mgr.getWeblogEntries(
                   
                    weblog,                    // website
                    null,                      // user
                    // since we need an entry.pubTime>endDate, but the method use >=
                    new Date(endDate.getTime()+1),                   // startDate
View Full Code Here

        loadWeblogEntries(startDate, endDate, cat);
    }
   
    protected void loadWeblogEntries(Date startDate, Date endDate, String catName) {
        try {
            WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
            monthMap = mgr.getWeblogEntryStringMap(
                   
                    weblog,                  // website
                    startDate,                 // startDate
                    endDate,                   // endDate
                    catName,                   // cat
View Full Code Here

    public void loadComments() {
       
        List comments = Collections.EMPTY_LIST;
        boolean hasMore = false;
        try {
            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
           
            // lookup weblog entry if necessary
            if (!StringUtils.isEmpty(getBean().getEntryId())) {
                setQueryEntry(wmgr.getWeblogEntry(getBean().getEntryId()));
            }
           
            // query for comments
            List rawComments = wmgr.getComments(
                    getActionWeblog(),
                    getQueryEntry(),
                    getBean().getSearchString(),
                    getBean().getStartDate(),
                    getBean().getEndDate(),getBean().getStatus(),
View Full Code Here

       
        // load bean data using comments list
        getBean().loadCheckboxes(getPager().getItems());
       
        try {
            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
            List allMatchingComments = wmgr.getComments(
                    getActionWeblog(),
                    null,
                    getBean().getSearchString(),
                    getBean().getStartDate(),
                    getBean().getEndDate(),
View Full Code Here

     * Bulk delete all comments matching query criteria.
     */
    public String delete() {
       
        try {
            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
           
            // 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

     * Update a list of comments.
     */
    public String update() {
       
        try {
            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
           
            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

    }
   
   
    protected void loadWeblogEntries(Date startDate, Date endDate, String catName) {
        try {
            WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
            monthMap = mgr.getWeblogEntryObjectMap(
                   
                    weblog,                  // website
                    startDate,                 // startDate
                    endDate,                   // endDate
                    catName,                   // cat
View Full Code Here

            if (log.isDebugEnabled()) {
                log.debug("Seeking up to " + entryCount + " entries from " + localWeblog.getHandle());
            }
           
            // grab recent entries for this weblog
            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
            List<WeblogEntry> entries = wmgr.getWeblogEntries(
                    localWeblog,                 // weblog
                    null,                        // user
                    null,                        // startDate
                    null,                        // endDate
                    null,                        // catName
View Full Code Here

       
        IndexWriter writer = beginWriting();
       
        try {
            if (writer != null) {
                WeblogEntryManager weblogManager = roller.getWeblogEntryManager();
                List entries = weblogManager .getWeblogEntries(                       
                        website,                   // website           
                        null,
                        null,                      // startDate
                        null,                      // endDate
                        null,                      // catName
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.business.WeblogEntryManager

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.