Package org.b3log.latke.event

Examples of org.b3log.latke.event.EventException


                return;
            }

            final JSONObject preference = preferenceQueryService.getPreference();
            if (null == preference) {
                throw new EventException("Not found preference");
            }

            final String blogTitle =
                    preference.getString(Preference.BLOG_TITLE);
            final String adminEmail =
                    preference.getString(Preference.ADMIN_EMAIL);

            final String commentContent =
                    comment.getString(Comment.COMMENT_CONTENT).
                    replaceAll(SoloServletListener.ENTER_ESC, "<br/>");
            final String commentSharpURL =
                    comment.getString(Comment.COMMENT_SHARP_URL);
            final Message message = new Message();
            message.setFrom(adminEmail);
            message.addRecipient(originalCommentEmail);
            final JSONObject replyNotificationTemplate =
                    preferenceQueryService.getReplyNotificationTemplate();
            final String mailSubject = replyNotificationTemplate.getString(
                    "subject").replace("${blogTitle}", blogTitle);
            message.setSubject(mailSubject);
            final String articleTitle = article.getString(Article.ARTICLE_TITLE);
            final String blogHost = preference.getString(Preference.BLOG_HOST);
            final String articleLink = "http://" + blogHost + article.getString(
                    Article.ARTICLE_PERMALINK);
            final String commentName = comment.getString(Comment.COMMENT_NAME);
            final String commentURL = comment.getString(Comment.COMMENT_URL);
            String commenter = null;
            if (!"http://".equals(commentURL)) {
                commenter = "<a target=\"_blank\" " + "href=\"" + commentURL
                            + "\">" + commentName + "</a>";
            } else {
                commenter = commentName;
            }

            final String mailBody = replyNotificationTemplate.getString("body").
                    replace("${postLink}", articleLink).
                    replace("${postTitle}", articleTitle).
                    replace("${replier}", commenter).
                    replace("${replyURL}", "http://" + blogHost
                                           + commentSharpURL).
                    replace("${replyContent}", commentContent);
            message.setHtmlBody(mailBody);
            LOGGER.log(Level.FINER,
                       "Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]",
                       new Object[]{mailSubject, mailBody,
                                    originalCommentEmail});
            mailService.send(message);

        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
            throw new EventException("Reply notifier error!");
        }
    }
View Full Code Here


                return;
            }

            final JSONObject preference = preferenceQueryService.getPreference();
            if (null == preference) {
                throw new EventException("Not found preference");
            }

            final String blogTitle =
                    preference.getString(Preference.BLOG_TITLE);
            final String adminEmail =
                    preference.getString(Preference.ADMIN_EMAIL);

            final String commentContent =
                    comment.getString(Comment.COMMENT_CONTENT).
                    replaceAll(SoloServletListener.ENTER_ESC, "<br/>");
            final String commentSharpURL =
                    comment.getString(Comment.COMMENT_SHARP_URL);
            final Message message = new Message();
            message.setFrom(adminEmail);
            message.addRecipient(originalCommentEmail);
            final JSONObject replyNotificationTemplate =
                    preferenceQueryService.getReplyNotificationTemplate();
            final String mailSubject = replyNotificationTemplate.getString(
                    "subject").replace("${blogTitle}", blogTitle);
            message.setSubject(mailSubject);
            final String pageTitle = page.getString(Page.PAGE_TITLE);
            final String blogHost = preference.getString(Preference.BLOG_HOST);
            final String pageLink = "http://" + blogHost
                                    + page.getString(Page.PAGE_PERMALINK);
            final String commentName = comment.getString(Comment.COMMENT_NAME);
            final String commentURL = comment.getString(Comment.COMMENT_URL);
            String commenter = null;
            if (!"http://".equals(commentURL)) {
                commenter = "<a target=\"_blank\" " + "href=\"" + commentURL
                            + "\">" + commentName + "</a>";
            } else {
                commenter = commentName;
            }

            final String mailBody = replyNotificationTemplate.getString("body").
                    replace("${postLink}", pageLink).
                    replace("${postTitle}", pageTitle).
                    replace("${replier}", commenter).
                    replace("${replyURL}", "http://" + blogHost
                                           + commentSharpURL).
                    replace("${replyContent}", commentContent);
            message.setHtmlBody(mailBody);
            LOGGER.log(Level.FINER,
                       "Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]",
                       new Object[]{mailSubject, mailBody,
                                    originalCommentEmail});
            mailService.send(message);
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
            throw new EventException("Reply notifier error!");
        }
    }
View Full Code Here

            final PreferenceQueryService preferenceQueryService = beanManager.getReference(PreferenceQueryService.class);

            final JSONObject preference = preferenceQueryService.getPreference();

            if (null == preference) {
                throw new EventException("Not found preference");
            }

            if (Latkes.getServePath().contains("localhost")) {
                LOGGER.log(Level.INFO, "Blog Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm",
                    new Object[] {originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE)});
View Full Code Here

            if (transaction.isActive()) {
                transaction.rollback();
            }

            LOGGER.log(Level.ERROR, "Processing plugin loaded event error", e);
            throw new EventException(e);
        }
    }
View Full Code Here

            final PreferenceQueryService preferenceQueryService = beanManager.getReference(PreferenceQueryService.class);

            final JSONObject preference = preferenceQueryService.getPreference();

            if (null == preference) {
                throw new EventException("Not found preference");
            }

            if (Latkes.getServePath().contains("localhost")) {
                LOGGER.log(Level.INFO, "Blog Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm",
                    new Object[] {originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE)});
View Full Code Here

            final PreferenceQueryService preferenceQueryService = beanManager.getReference(PreferenceQueryService.class);

            final JSONObject preference = preferenceQueryService.getPreference();

            if (null == preference) {
                throw new EventException("Not found preference");
            }

            if (Latkes.getServePath().contains("localhost")) {
                LOGGER.log(Level.INFO, "Blog Solo runs on local server, so should not send this comment[id={0}] to Symphony",
                    new Object[] {originalComment.getString(Keys.OBJECT_ID)});
View Full Code Here

            if (transaction.isActive()) {
                transaction.rollback();
            }

            LOGGER.log(Level.SEVERE, "Processing plugin loaded event error", e);
            throw new EventException(e);
        }
    }
View Full Code Here

            }

            final JSONObject preference = preferenceQueryService.getPreference();

            if (null == preference) {
                throw new EventException("Not found preference");
            }

            final String blogTitle = preference.getString(Preference.BLOG_TITLE);
            final String adminEmail = preference.getString(Preference.ADMIN_EMAIL);

            final String commentContent = comment.getString(Comment.COMMENT_CONTENT).replaceAll(SoloServletListener.ENTER_ESC, "<br/>");
            final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL);
            final Message message = new Message();

            message.setFrom(adminEmail);
            message.addRecipient(originalCommentEmail);
            final JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
            final String mailSubject = replyNotificationTemplate.getString("subject").replace("${blogTitle}", blogTitle);

            message.setSubject(mailSubject);
            final String articleTitle = article.getString(Article.ARTICLE_TITLE);
            final String articleLink = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
            final String commentName = comment.getString(Comment.COMMENT_NAME);
            final String commentURL = comment.getString(Comment.COMMENT_URL);
            String commenter;

            if (!"http://".equals(commentURL)) {
                commenter = "<a target=\"_blank\" " + "href=\"" + commentURL + "\">" + commentName + "</a>";
            } else {
                commenter = commentName;
            }

            final String mailBody = replyNotificationTemplate.getString("body").replace("${postLink}", articleLink).replace("${postTitle}", articleTitle).replace("${replier}", commenter).replace("${replyURL}", Latkes.getServePath() + commentSharpURL).replace(
                "${replyContent}", commentContent);

            message.setHtmlBody(mailBody);
            LOGGER.log(Level.DEBUG, "Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]",
                new Object[] {mailSubject, mailBody, originalCommentEmail});
            mailService.send(message);

        } catch (final Exception e) {
            LOGGER.log(Level.ERROR, e.getMessage(), e);
            throw new EventException("Reply notifier error!");
        }
    }
View Full Code Here

            }

            final JSONObject preference = preferenceQueryService.getPreference();

            if (null == preference) {
                throw new EventException("Not found preference");
            }

            final String blogTitle = preference.getString(Preference.BLOG_TITLE);
            final String adminEmail = preference.getString(Preference.ADMIN_EMAIL);

            final String commentContent = comment.getString(Comment.COMMENT_CONTENT).replaceAll(SoloServletListener.ENTER_ESC, "<br/>");
            final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL);
            final Message message = new Message();

            message.setFrom(adminEmail);
            message.addRecipient(originalCommentEmail);
            final JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
            final String mailSubject = replyNotificationTemplate.getString("subject").replace("${blogTitle}", blogTitle);

            message.setSubject(mailSubject);
            final String pageTitle = page.getString(Page.PAGE_TITLE);
            final String pageLink = Latkes.getServePath() + page.getString(Page.PAGE_PERMALINK);
            final String commentName = comment.getString(Comment.COMMENT_NAME);
            final String commentURL = comment.getString(Comment.COMMENT_URL);
            String commenter;

            if (!"http://".equals(commentURL)) {
                commenter = "<a target=\"_blank\" " + "href=\"" + commentURL + "\">" + commentName + "</a>";
            } else {
                commenter = commentName;
            }

            final String mailBody = replyNotificationTemplate.getString("body").replace("${postLink}", pageLink).replace("${postTitle}", pageTitle).replace("${replier}", commenter).replace("${replyURL}", Latkes.getServePath() + commentSharpURL).replace(
                "${replyContent}", commentContent);

            message.setHtmlBody(mailBody);
            LOGGER.log(Level.DEBUG, "Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]",
                new Object[] {mailSubject, mailBody, originalCommentEmail});
            mailService.send(message);
        } catch (final Exception e) {
            LOGGER.log(Level.ERROR, e.getMessage(), e);
            throw new EventException("Reply notifier error!");
        }
    }
View Full Code Here

                return;
            }

            final JSONObject preference = preferenceQueryService.getPreference();
            if (null == preference) {
                throw new EventException("Not found preference");
            }

            final String blogHost = preference.getString(Preference.BLOG_HOST).toLowerCase();
            if (blogHost.contains("localhost")) {
                LOGGER.log(Level.INFO, "Blog Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm",
View Full Code Here

TOP

Related Classes of org.b3log.latke.event.EventException

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.