aboutsummaryrefslogtreecommitdiff
path: root/juick-www
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-30 15:10:15 +0700
committerGravatar Alexander Alexeev2016-11-30 15:10:15 +0700
commit1d837a835c04078ec66325e9fb9de21ac401874e (patch)
tree428217d2c617b9caf2eb6d42a7716789881d0937 /juick-www
parentb45c000ed478f2407288aab1532425288f998689 (diff)
prevent string concatenation for disabled loggers
Diffstat (limited to 'juick-www')
-rw-r--r--juick-www/src/main/java/com/juick/www/FacebookLogin.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/NewMessage.java11
-rw-r--r--juick-www/src/main/java/com/juick/www/PageTemplates.java15
-rw-r--r--juick-www/src/main/java/com/juick/www/VKontakteLogin.java9
-rw-r--r--juick-www/src/main/java/ru/sape/SapeConnection.java2
5 files changed, 18 insertions, 21 deletions
diff --git a/juick-www/src/main/java/com/juick/www/FacebookLogin.java b/juick-www/src/main/java/com/juick/www/FacebookLogin.java
index 34385a3d..e9c4b786 100644
--- a/juick-www/src/main/java/com/juick/www/FacebookLogin.java
+++ b/juick-www/src/main/java/com/juick/www/FacebookLogin.java
@@ -85,7 +85,7 @@ public class FacebookLogin {
String token = Utils.fetchURL("https://graph.facebook.com/oauth/access_token?client_id=" + FACEBOOK_APPID + "&redirect_uri=" + URLEncoder.encode(FACEBOOK_REDIRECT, "utf-8") + "&client_secret=" + FACEBOOK_SECRET + "&code=" + URLEncoder.encode(code, "utf-8"));
if (token == null || token.isEmpty() || !token.startsWith("access_token=")) {
- logger.error("FACEBOOK TOKEN ERROR: " + token);
+ logger.error("FACEBOOK TOKEN ERROR: {}", token);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
diff --git a/juick-www/src/main/java/com/juick/www/NewMessage.java b/juick-www/src/main/java/com/juick/www/NewMessage.java
index f6e8ec47..c066c5b3 100644
--- a/juick-www/src/main/java/com/juick/www/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/NewMessage.java
@@ -48,7 +48,6 @@ import java.util.ArrayList;
import java.util.List;
/**
- *
* @author Ugnich Anton
*/
public class NewMessage {
@@ -185,7 +184,7 @@ public class NewMessage {
}
String paramImg = request.getParameter("img");
- if (attachmentFName == null && paramImg != null && paramImg.length() > 10 ) {
+ if (attachmentFName == null && paramImg != null && paramImg.length() > 10) {
try {
URL imgUrl = new URL(paramImg);
attachmentFName = Utils.downloadImage(imgUrl);
@@ -225,7 +224,7 @@ public class NewMessage {
try {
xmsg.addExtension(new OobX(new URI(attachmentURL)));
} catch (URISyntaxException e) {
- logger.warn("invalid uri: " + attachmentURL, e);
+ logger.warn("invalid uri: {} exception {}", attachmentURL, e);
}
}
if (xmpp != null) {
@@ -296,8 +295,8 @@ public class NewMessage {
out.println("<p class=\"social\"><a href=\"https://plus.google.com/share?url=" + url + "\" class=\"ico32-gp sharenew\">Отправить в Google+</a></p>");
out.println("<p>Ссылка на сообщение: <a href=\"http://juick.com/" + mid + "\">http://juick.com/" + mid + "</a></p>");
out.println("</section>");
-
- PageTemplates.pageHomeColumn(out, sql, visitor);
+
+ PageTemplates.pageHomeColumn(out, sql, visitor);
PageTemplates.pageFooter(request, out, visitor, false);
PageTemplates.pageEnd(out);
@@ -393,7 +392,7 @@ public class NewMessage {
try {
xmsg.addExtension(new OobX(new URI(attachmentURL)));
} catch (URISyntaxException e) {
- logger.warn("invalid uri: " + attachmentURL, e);
+ logger.warn("invalid uri: {}, exception {}", attachmentURL, e);
}
}
diff --git a/juick-www/src/main/java/com/juick/www/PageTemplates.java b/juick-www/src/main/java/com/juick/www/PageTemplates.java
index f0974e69..74b8b543 100644
--- a/juick-www/src/main/java/com/juick/www/PageTemplates.java
+++ b/juick-www/src/main/java/com/juick/www/PageTemplates.java
@@ -42,7 +42,6 @@ import java.util.List;
import java.util.stream.Collectors;
/**
- *
* @author Ugnich Anton
*/
public class PageTemplates {
@@ -254,7 +253,7 @@ public class PageTemplates {
ret = sdfFull.format(fulldate);
}
} catch (Exception e) {
- logger.error("PARSE EXCEPTION: " + fulldate);
+ logger.error("PARSE EXCEPTION: {}, exception {}", fulldate, e);
}
}
return ret;
@@ -263,9 +262,9 @@ public class PageTemplates {
public static String formatJSLocalTime(Date ts) {
return "<script type=\"text/javascript\">"
- + "var d=new Date(" + ts.getTime() + ");"
- + "document.write((d.getDate()<10?'0':'')+d.getDate()+'.'+(d.getMonth()<9?'0':'')+(d.getMonth()+1)+'.'+d.getFullYear()+' '+(d.getHours()<10?'0':'')+d.getHours()+':'+(d.getMinutes()<10?'0':'')+d.getMinutes());"
- + "</script>";
+ + "var d=new Date(" + ts.getTime() + ");"
+ + "document.write((d.getDate()<10?'0':'')+d.getDate()+'.'+(d.getMonth()<9?'0':'')+(d.getMonth()+1)+'.'+d.getFullYear()+' '+(d.getHours()<10?'0':'')+d.getHours()+':'+(d.getMinutes()<10?'0':'')+d.getMinutes());"
+ + "</script>";
}
public static String formatReplies(int replies) {
@@ -326,10 +325,10 @@ public class PageTemplates {
out.println(" @<a href=\"/" + msg.getUser().getName() + "/\">" + msg.getUser().getName() + "</a>:");
out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.getUser().getName() + "/\"><img src=\"//i.juick.com/a/" + msg.getUser().getUid() + ".png\" alt=\"" + msg.getUser().getName() + "\"/></a></div>");
out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.getUser().getName() + "/" + msg.getMid() + "\"><time datetime=\"" + sdfSQL.format(msg.getDate()) + "Z\" title=\"" + sdfSQL.format(msg.getDate()) + " GMT\">" + formatDate(msg.TimeAgo, msg.getDate()) + "</time></a></div>");
-
+
out.println(" <div class=\"msg-tags\">" + tagsStr + "</div>");
out.println(" </header>");
-
+
if (msg.AttachmentType != null) {
String fname = msg.getMid() + "." + msg.AttachmentType;
out.println(" <p class=\"ir\"><a href=\"//i.juick.com/photos-512/" + fname + "\" data-fname=\"" + fname + "\"><img src=\"//i.juick.com/photos-512/" + fname + "\" alt=\"\"/></a></p>");
@@ -346,7 +345,7 @@ public class PageTemplates {
out.print("<a href=\"/post?body=!+%23" + msg.getMid() + "\" class=\"a-like\">Мне нравится</a>");
}
if (visitor.getUid() == 0 && !msg.ReadOnly) {
- out.print("<a href=\"/"+ msg.getMid() + "\" class=\"a-login\">Комментировать</a> ");
+ out.print("<a href=\"/" + msg.getMid() + "\" class=\"a-login\">Комментировать</a> ");
} else if (visitor.getUid() > 0 && (!msg.ReadOnly || visitor.getUid() == msg.getUser().getUid())) {
out.print("<a class=\"a-comment\" href=\"/" + msg.getMid() + "\">Комментировать</a> ");
}
diff --git a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
index 55dfd202..6b1d4571 100644
--- a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
+++ b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
@@ -20,7 +20,8 @@ package com.juick.www;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.server.UserQueries;
-import com.juick.www.vk.*;
+import com.juick.www.vk.Token;
+import com.juick.www.vk.UsersResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.EmptyResultDataAccessException;
@@ -35,7 +36,6 @@ import java.net.URLEncoder;
import java.util.UUID;
/**
- *
* @author Ugnich Anton
*/
public class VKontakteLogin {
@@ -50,6 +50,7 @@ public class VKontakteLogin {
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
}
+
private final ObjectMapper mapper;
protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
@@ -73,13 +74,11 @@ public class VKontakteLogin {
token = json.getAccessToken();
vkID = json.getUserId();
if (token == null || vkID == 0) {
- logger.error("VK TOKEN EMPTY: " + tokenjson);
+ logger.error("VK TOKEN EMPTY: {}", tokenjson);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
-
-
String graph = Utils.fetchURL("https://api.vk.com/method/users.get?uids=" + vkID + "&fields=screen_name&access_token=" + token);
if (graph == null || graph.isEmpty()) {
logger.error("VK GRAPH ERROR");
diff --git a/juick-www/src/main/java/ru/sape/SapeConnection.java b/juick-www/src/main/java/ru/sape/SapeConnection.java
index 5c2e3397..a15658fa 100644
--- a/juick-www/src/main/java/ru/sape/SapeConnection.java
+++ b/juick-www/src/main/java/ru/sape/SapeConnection.java
@@ -81,7 +81,7 @@ public class SapeConnection {
}
if (data.startsWith("FATAL ERROR:")) {
- logger.error("Sape responded with error: " + data);
+ logger.error("Sape responded with error: {}", data);
continue;
}