Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.WeblogEntryData


            cal.setTimeZone(website.getTimeZoneInstance());
        }
       
        SimpleDateFormat formatter = DateUtil.get8charDateFormat();
        for (Iterator wbItr = entries.iterator(); wbItr.hasNext();) {
            WeblogEntryData entry = (WeblogEntryData) wbItr.next();
            Date sDate = DateUtil.getNoonOfDay(entry.getPubTime(), cal);
            if (stringsOnly) {
                if (map.get(sDate) == null)
                    map.put(sDate, formatter.format(sDate));
            } else {
                List dayEntries = (List) map.get(sDate);
View Full Code Here


   
    public WeblogEntryData getNextEntry(WeblogEntryData current, String catName,
                                        String locale)
            throws RollerException {
       
        WeblogEntryData entry = null;
        List entryList = getNextEntries(current, catName, locale, 1);
        if (entryList != null && entryList.size() > 0) {
            entry = (WeblogEntryData)entryList.get(0);
        }
        return entry;
View Full Code Here

   
    public WeblogEntryData getPreviousEntry(WeblogEntryData current, String catName,
                                            String locale)
            throws RollerException {
       
        WeblogEntryData entry = null;
        List entryList = getPreviousEntries(current, catName, locale, 1);
        if (entryList != null && entryList.size() > 0) {
            entry = (WeblogEntryData)entryList.get(0);
        }
        return entry;
View Full Code Here

        website.setHandle("trekker");

        UserData user = new UserData();
        user.setUserName("nimoy");

        WeblogEntryData wd1 = new WeblogEntryData();           
        wd1.setId("dummy1");
        wd1.setAnchor("dummy1");
        wd1.setCreator(user);
        wd1.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        wd1.setPubTime(new Timestamp(System.currentTimeMillis()));
        wd1.setTitle("The Tholian Web");
        wd1.setWebsite(website);
        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.");
        imgr.executeIndexOperationNow(
            new AddEntryOperation((IndexManagerImpl) imgr, wd1));

        WeblogEntryData wd2 = new WeblogEntryData();
        wd2.setId("dummy2");
        wd2.setAnchor("dummy2");
        wd2.setCreator(user);
        wd2.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        wd2.setPubTime(new Timestamp(System.currentTimeMillis()));
        wd2.setTitle("A Piece of the Action");
        wd2.setWebsite(website);
        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.");
         imgr.executeIndexOperationNow(
             new AddEntryOperation((IndexManagerImpl) imgr, wd2));
View Full Code Here

                        WeblogEntryData.PUBLISHED, // status
                        null,                      // sortby (null means pubTime)
null,                         0, -1);     // offset, length, locale
               
                for (Iterator wbItr = entries.iterator(); wbItr.hasNext();) {
                    WeblogEntryData entry = (WeblogEntryData) wbItr.next();
                    writer.addDocument(getDocument(entry));
                    mLogger.debug(
                            MessageFormat.format("Indexed entry {0}: {1}",
                            new Object[] {entry.getPubTime(), entry.getAnchor()}));
                }
                // release the database connection
                roller.release();
            }
        } catch (Exception e) {
View Full Code Here

    public static void sendEmailNotification(CommentData cd, String rootURL) {
       
        // Send commment notifications in locale of server
        ResourceBundle resources = ResourceBundle.getBundle("ApplicationResources");

        WeblogEntryData entry = cd.getWeblogEntry();
        WebsiteData site = entry.getWebsite();
        UserData user = entry.getCreator();
       
        // Send e-mail to owner and subscribed users (if enabled)
        boolean notify = RollerRuntimeConfig.getBooleanProperty("users.comments.emailnotify");
        if (notify && site.getEmailComments().booleanValue()) {
            log.debug("Comment notification enabled ... preparing email");
           
            // Determine message and addressing options from init parameters
            boolean separateMessages =
                    RollerConfig.getBooleanProperty("comment.notification.separateOwnerMessage");
            boolean hideCommenterAddrs =
                    RollerConfig.getBooleanProperty("comment.notification.hideCommenterAddresses");
           
            //------------------------------------------
            // --- Determine the "from" address
            // --- Use either the site configured from address or the user's address
           
            String from =
                    (StringUtils.isEmpty(site.getEmailFromAddress()))
                    ? user.getEmailAddress()
                    : site.getEmailFromAddress();
           
            //------------------------------------------
            // --- Build list of email addresses to send notification to
           
            List comments = null;
            try {
                WeblogManager wMgr = RollerFactory.getRoller().getWeblogManager();
                // get only approved, non spam comments
                comments = entry.getComments(true, true);
            } catch(RollerException re) {
                // should never happen
                comments = new ArrayList();
            }
           
            // Get all the subscribers to this comment thread
            Set subscribers = new TreeSet();
            for (Iterator it = comments.iterator(); it.hasNext();) {
                CommentData comment = (CommentData) it.next();
                if (!StringUtils.isEmpty(comment.getEmail())) {
                    // If user has commented twice,
                    // count the most recent notify setting
                    if (comment.getNotify().booleanValue()) {
                        // only add those with valid email
                        if (comment.getEmail().matches(EMAIL_ADDR_REGEXP)) {
                            subscribers.add(comment.getEmail());
                        }
                    } else {
                        // remove user who doesn't want to be notified
                        subscribers.remove(comment.getEmail());
                    }
                }
            }
           
            // Form array of commenter addrs
            String[] commenterAddrs = (String[])subscribers.toArray(new String[0]);
           
            //------------------------------------------
            // --- Form the messages to be sent -
            // For simplicity we always build separate owner and commenter messages even if sending a single one
           
            // Determine with mime type to use for e-mail
            StringBuffer msg = new StringBuffer();
            StringBuffer ownermsg = new StringBuffer();
            boolean escapeHtml = RollerRuntimeConfig.getBooleanProperty("users.comments.escapehtml");
           
            if (!escapeHtml) {
                msg.append("<html><body style=\"background: white; ");
                msg.append(" color: black; font-size: 12px\">");
            }
           
            if (!StringUtils.isEmpty(cd.getName())) {
                msg.append(cd.getName() + " "
                        + resources.getString("email.comment.wrote")+": ");
            } else {
                msg.append(resources.getString("email.comment.anonymous")+": ");
            }
           
            msg.append((escapeHtml) ? "\n\n" : "<br /><br />");
                       
            msg.append((escapeHtml) ? Utilities.escapeHTML(cd.getContent())
                : UtilitiesModel.transformToHTMLSubset(Utilities.escapeHTML(cd.getContent())));
           
            msg.append((escapeHtml) ? "\n\n----\n"
                    : "<br /><br /><hr /><span style=\"font-size: 11px\">");
            msg.append(resources.getString("email.comment.respond") + ": ");
            msg.append((escapeHtml) ? "\n" : "<br />");

            // Build link back to comment
            StringBuffer commentURL = new StringBuffer(rootURL);
            commentURL.append(entry.getPermaLink());
            commentURL.append("#comments");
           
            if (escapeHtml) {
                msg.append(commentURL.toString());
            } else {
                msg.append("<a href=\""+commentURL+"\">"+commentURL+"</a></span>");
            }
           
            ownermsg.append(msg);
           
            // add link to weblog edit page so user can login to manage comments
            ownermsg.append((escapeHtml) ? "\n\n----\n" :
                "<br /><br /><hr /><span style=\"font-size: 11px\">");
            ownermsg.append("Link to comment management page:");
            ownermsg.append((escapeHtml) ? "\n" : "<br />");
           
            StringBuffer deleteURL = new StringBuffer(rootURL);
            deleteURL.append("/roller-ui/authoring/commentManagement.do?method=query&entryId=" + entry.getId());
           
            if (escapeHtml) {
                ownermsg.append(deleteURL.toString());
            } else {
                ownermsg.append(
                        "<a href=\"" + deleteURL + "\">" + deleteURL + "</a></span>");
                msg.append("</Body></html>");
                ownermsg.append("</Body></html>");
            }
           
            String subject = null;
            if ((subscribers.size() > 1) ||
                    (StringUtils.equals(cd.getEmail(), user.getEmailAddress()))) {
                subject= "RE: "+resources.getString("email.comment.title")+": ";
            } else {
                subject = resources.getString("email.comment.title") + ": ";
            }
            subject += entry.getTitle();
           
            //------------------------------------------
            // --- Send message to email recipients
            try {
                Context ctx = (Context)
View Full Code Here

    public static void sendEmailApprovalNotification(CommentData cd, String rootURL) {
       
        // Send commment notifications in locale of server
        ResourceBundle resources = ResourceBundle.getBundle("ApplicationResources");
       
        WeblogEntryData entry = cd.getWeblogEntry();
        WebsiteData site = entry.getWebsite();
        UserData user = entry.getCreator();
           
        // Only send email if email notificaiton is enabled
        boolean notify = RollerRuntimeConfig.getBooleanProperty("users.comments.emailnotify");
        if (notify && site.getEmailComments().booleanValue()) {
            log.debug("Comment notification enabled ... preparing email");
           

                               
            //------------------------------------------
            // --- Determine the "from" address
            // --- Use either the site configured from address or the user's address
           
            String from =
                    (StringUtils.isEmpty(site.getEmailFromAddress()))
                    ? user.getEmailAddress()
                    : site.getEmailFromAddress();
                       
            //------------------------------------------
            // --- Form the message to be sent -
           
            String subject = resources.getString("email.comment.commentApproved");
           
            StringBuffer msg = new StringBuffer();
            msg.append(resources.getString("email.comment.commentApproved"));

            // Build link back to comment
            StringBuffer commentURL = new StringBuffer(rootURL);
            commentURL.append(entry.getPermaLink());
            commentURL.append("#comments");
            msg.append(commentURL.toString());
           
            //------------------------------------------
            // --- Send message to author of approved comment
View Full Code Here

        } else if (request.getParameter(RequestConstants.WEBLOG_ID) != null) {
            String weblogId = request.getParameter(RequestConstants.WEBLOG_ID);
            weblog = roller.getUserManager().getWebsite(weblogId);
        } else if (request.getParameter(RequestConstants.WEBLOGENTRY_ID) != null) {
            String entryId = request.getParameter(RequestConstants.WEBLOGENTRY_ID);
            WeblogEntryData entry = roller.getWeblogManager().getWeblogEntry(entryId);
            if(entry != null) {
                weblog = entry.getWebsite();
            }
        } else if (request.getParameter(RequestConstants.WEBLOGCATEGORY_ID) != null) {
            String catId = request.getParameter(RequestConstants.WEBLOGCATEGORY_ID);
            WeblogCategoryData cat = roller.getWeblogManager().getWeblogCategory(catId);
            if(cat != null) {
View Full Code Here

       
        String error = null;
        PrintWriter pw = response.getWriter();
       
        WebsiteData weblog = null;
        WeblogEntryData entry = null;
       
        WeblogTrackbackRequest trackbackRequest = null;
        if(!RollerRuntimeConfig.getBooleanProperty("users.trackbacks.enabled")) {
            // TODO: i18n
            error = "Trackbacks are disabled for this site";
        } else {
           
            try {
                trackbackRequest = new WeblogTrackbackRequest(request);
               
                if((trackbackRequest.getTitle() == null) ||
                        "".equals(trackbackRequest.getTitle())) {
                    trackbackRequest.setTitle(trackbackRequest.getUrl());
                }
               
                if(trackbackRequest.getExcerpt() == null) {
                    trackbackRequest.setExcerpt("");
                } else if(trackbackRequest.getExcerpt().length() >= 255) {
                    trackbackRequest.setExcerpt(trackbackRequest.getExcerpt().substring(0, 252)+"...");
                }
               
                // lookup weblog specified by comment request
                UserManager uMgr = RollerFactory.getRoller().getUserManager();
                weblog = uMgr.getWebsiteByHandle(trackbackRequest.getWeblogHandle());
               
                if(weblog == null) {
                    throw new RollerException("unable to lookup weblog: "+
                            trackbackRequest.getWeblogHandle());
                }
               
                // lookup entry specified by comment request
                WeblogManager weblogMgr = RollerFactory.getRoller().getWeblogManager();
                entry = weblogMgr.getWeblogEntryByAnchor(weblog, trackbackRequest.getWeblogAnchor());
               
                if(entry == null) {
                    throw new RollerException("unable to lookup entry: "+
                            trackbackRequest.getWeblogAnchor());
                }
               
            } catch (Exception e) {
                // some kind of error parsing the request or looking up weblog
                logger.debug("error creating trackback request", e);
                error = e.getMessage();
            }
        }
       
        if(error != null) {
            pw.println(this.getErrorResponse(error));
            return;
        }
       
        try {
            boolean verified = true;
           
            // check if trackbacks are allowed for this entry
            // this checks site-wide settings, weblog settings, and entry settings
            if (entry != null && entry.getCommentsStillAllowed() && entry.isPublished()) {
               
                // Track trackbacks as comments
                CommentData comment = new CommentData();
                comment.setContent("[Trackback] "+trackbackRequest.getExcerpt());
                comment.setName(trackbackRequest.getBlogName());
                comment.setUrl(trackbackRequest.getUrl());
                comment.setWeblogEntry(entry);
                comment.setNotify(Boolean.FALSE);
                comment.setPostTime(new Timestamp(new Date().getTime()));
               
                // If comment contains blacklisted text, mark as spam
                SpamChecker checker = new SpamChecker();
                if (checker.checkTrackback(comment)) {
                    comment.setSpam(Boolean.TRUE);
                    logger.debug("Trackback blacklisted: "+comment.getUrl());
                    error = "REJECTED: trackback contains spam words";
                }
                // Else, if trackback verification is on...
                else if (RollerRuntimeConfig.getBooleanProperty(
                        "site.trackbackVerification.enabled")) {
                   
                    // ...ensure trackbacker actually links to us
                    LinkbackExtractor linkback = new LinkbackExtractor(
                            comment.getUrl(), URLUtilities.getWeblogEntryURL(weblog, null, entry.getAnchor(), true));
                    if (linkback.getExcerpt() == null) {
                        comment.setPending(Boolean.TRUE);
                        comment.setApproved(Boolean.FALSE);
                        verified = false;
                        // if we can't verify trackback, then reject it
View Full Code Here

        String error = null;
        String message = null;
        String dispatch_url = null;
       
        WebsiteData weblog = null;
        WeblogEntryData entry = null;
       
        // are we doing a preview?  or a post?
        String method = request.getParameter("method");
        boolean preview = (method != null && method.equals("preview")) ? true : false;
       
        // throttling protection against spammers
        if(commentThrottle != null &&
                commentThrottle.processHit(request.getRemoteAddr())) {
           
            log.debug("ABUSIVE "+request.getRemoteAddr());
            IPBanList.getInstance().addBannedIp(request.getRemoteAddr());
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
        WeblogCommentRequest commentRequest = null;
        try {
            commentRequest = new WeblogCommentRequest(request);
           
            // lookup weblog specified by comment request
            UserManager uMgr = RollerFactory.getRoller().getUserManager();
            weblog = uMgr.getWebsiteByHandle(commentRequest.getWeblogHandle());
           
            if(weblog == null) {
                throw new RollerException("unable to lookup weblog: "+
                        commentRequest.getWeblogHandle());
            }
           
            // lookup entry specified by comment request
            entry = commentRequest.getWeblogEntry();
            if(entry == null) {
                throw new RollerException("unable to lookup entry: "+
                        commentRequest.getWeblogAnchor());
            }
           
            // we know what the weblog entry is, so setup our urls
            dispatch_url = "/roller-ui/rendering/page/"+weblog.getHandle();
            if(commentRequest.getLocale() != null) {
                dispatch_url += "/"+commentRequest.getLocale();
            }
            dispatch_url += "/entry/"+URLUtilities.encode(commentRequest.getWeblogAnchor());
           
        } catch (Exception e) {
            // some kind of error parsing the request or looking up weblog
            log.debug("error creating page request", e);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
       
        log.debug("Doing comment posting for entry = "+entry.getPermaLink());
       
        // collect input from request params and construct new comment object
        // fields: name, email, url, content, notify
        // TODO: data validation on collected comment data
        CommentData comment = new CommentData();
        comment.setName(commentRequest.getName());
        comment.setEmail(commentRequest.getEmail());
        comment.setUrl(commentRequest.getUrl());
        comment.setContent(commentRequest.getContent());
        comment.setNotify(new Boolean(commentRequest.isNotify()));
        comment.setWeblogEntry(entry);
        comment.setRemoteHost(request.getRemoteHost());
        comment.setPostTime(new Timestamp(System.currentTimeMillis()));
       
        WeblogEntryCommentForm cf = new WeblogEntryCommentForm();
        cf.setData(comment);
       
        // check if comments are allowed for this entry
        // this checks site-wide settings, weblog settings, and entry settings
        if(!entry.getCommentsStillAllowed() || !entry.isPublished()) {
            error = bundle.getString("comments.disabled");
       
        // make sure comment authentication passed
        } else if(!this.authenticator.authenticate(request)) {
            error = bundle.getString("error.commentAuthFailed");
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.WeblogEntryData

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.