From 6d60b86bfddb51c13c118de8e8ad2db59f1fe74f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 2 Feb 2016 14:59:26 +0300 Subject: log xmpp problems --- src/main/java/com/juick/http/www/NewMessage.java | 66 +++++++++++++----------- 1 file changed, 37 insertions(+), 29 deletions(-) (limited to 'src/main/java/com/juick/http/www/NewMessage.java') diff --git a/src/main/java/com/juick/http/www/NewMessage.java b/src/main/java/com/juick/http/www/NewMessage.java index 22d743b3..4d4ffde6 100644 --- a/src/main/java/com/juick/http/www/NewMessage.java +++ b/src/main/java/com/juick/http/www/NewMessage.java @@ -40,6 +40,7 @@ import java.net.URLEncoder; import java.sql.Connection; import java.util.ArrayList; import java.util.List; +import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -50,6 +51,8 @@ import javax.servlet.http.HttpServletResponse; */ public class NewMessage { + private static final Logger logger = Logger.getLogger(NewMessage.class.getName()); + protected void doGetNewMessage(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException { response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); @@ -211,33 +214,34 @@ public class NewMessage { xoob.URL = attachmentURL; xmsg.addChild(xoob); } + if (xmpp != null) { + String tagsStr2 = ""; + for (String tag : tagsArr) { + tagsStr2 += " *" + tag; + } + xmsg.body = "@" + jmsg.getUser().getUName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid; - String tagsStr2 = ""; - for (String tag : tagsArr) { - tagsStr2 += " *" + tag; - } - xmsg.body = "@" + jmsg.getUser().getUName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid; - - xmsg.to = new JID("juick", "s2s.juick.com", null); - xmpp.send(xmsg); - - xmsg.to.Host = "ws.juick.com"; - xmpp.send(xmsg); + xmsg.to = new JID("juick", "s2s.juick.com", null); + xmpp.send(xmsg); - xmsg.to.Host = "push.juick.com"; - xmpp.send(xmsg); + xmsg.to.Host = "ws.juick.com"; + xmpp.send(xmsg); - xmsg.to.Host = "crosspost.juick.com"; - xmsg.to.Username = "twitter"; - xmpp.send(xmsg); - xmsg.to.Username = "fb"; - xmpp.send(xmsg); + xmsg.to.Host = "push.juick.com"; + xmpp.send(xmsg); - xmsg.to.Host = "nologin.ru"; - xmsg.to.Username = "jubo"; - xmpp.send(xmsg); + xmsg.to.Host = "crosspost.juick.com"; + xmsg.to.Username = "twitter"; + xmpp.send(xmsg); + xmsg.to.Username = "fb"; + xmpp.send(xmsg); - // + xmsg.to.Host = "nologin.ru"; + xmsg.to.Username = "jubo"; + xmpp.send(xmsg); + } else { + logger.warning("XMPP is not available, users will not be notified"); + } response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { @@ -371,16 +375,20 @@ public class NewMessage { xmsg.addChild(xoob); } - xmsg.body = "Reply by @" + jmsg.getUser().getUName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew; + if (xmpp != null) { + xmsg.body = "Reply by @" + jmsg.getUser().getUName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew; - xmsg.to = new JID("juick", "s2s.juick.com", null); - xmpp.send(xmsg); + xmsg.to = new JID("juick", "s2s.juick.com", null); + xmpp.send(xmsg); - xmsg.to.Host = "ws.juick.com"; - xmpp.send(xmsg); + xmsg.to.Host = "ws.juick.com"; + xmpp.send(xmsg); - xmsg.to.Host = "push.juick.com"; - xmpp.send(xmsg); + xmsg.to.Host = "push.juick.com"; + xmpp.send(xmsg); + } else { + logger.warning("XMPP is not available, users will not be notified"); + } Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getUName() + "/" + mid + "#" + ridnew); } -- cgit v1.2.3