From 3859c9616d0a7a04e68427d173b863161b818140 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 20 Dec 2016 14:28:00 +0300 Subject: StringUtils.EMPTY --- juick-www/src/main/java/com/juick/www/Discover.java | 3 ++- juick-www/src/main/java/com/juick/www/FacebookLogin.java | 2 +- juick-www/src/main/java/com/juick/www/Home.java | 3 ++- juick-www/src/main/java/com/juick/www/Main.java | 9 +++++---- juick-www/src/main/java/com/juick/www/NewMessage.java | 13 +++++++------ juick-www/src/main/java/com/juick/www/PM.java | 3 ++- juick-www/src/main/java/com/juick/www/PageTemplates.java | 2 +- juick-www/src/main/java/com/juick/www/Settings.java | 2 +- juick-www/src/main/java/com/juick/www/TwitterAuth.java | 3 ++- juick-www/src/main/java/com/juick/www/User.java | 3 ++- juick-www/src/main/java/com/juick/www/Utils.java | 3 ++- juick-www/src/main/java/com/juick/www/VKontakteLogin.java | 3 ++- juick-www/src/main/java/com/juick/www/XMPPPost.java | 2 +- 13 files changed, 30 insertions(+), 21 deletions(-) (limited to 'juick-www/src/main/java/com/juick') diff --git a/juick-www/src/main/java/com/juick/www/Discover.java b/juick-www/src/main/java/com/juick/www/Discover.java index 9cfad874..af2b6659 100644 --- a/juick-www/src/main/java/com/juick/www/Discover.java +++ b/juick-www/src/main/java/com/juick/www/Discover.java @@ -22,6 +22,7 @@ import com.juick.server.MessagesQueries; import com.juick.server.TagQueries; import org.apache.commons.lang3.CharEncoding; import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.jdbc.core.JdbcTemplate; import javax.servlet.ServletException; @@ -80,7 +81,7 @@ public class Discover { response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { - String head = ""; + String head = StringUtils.EMPTY; if (TagQueries.getTagNoIndex(sql, paramTag.TID)) { head = ""; } else if (paramBefore > 0 || mids.size() < 5) { 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 1dcbb39f..ba7ab29f 100644 --- a/juick-www/src/main/java/com/juick/www/FacebookLogin.java +++ b/juick-www/src/main/java/com/juick/www/FacebookLogin.java @@ -63,7 +63,7 @@ public class FacebookLogin { String fbstate; String code = request.getParameter("code"); - if (code == null || code.equals("")) { + if (StringUtils.isBlank(code)) { fbstate = UUID.randomUUID().toString(); Cookie c = new Cookie("fbstate", fbstate); diff --git a/juick-www/src/main/java/com/juick/www/Home.java b/juick-www/src/main/java/com/juick/www/Home.java index 6bad083c..1d4fd521 100644 --- a/juick-www/src/main/java/com/juick/www/Home.java +++ b/juick-www/src/main/java/com/juick/www/Home.java @@ -21,6 +21,7 @@ import com.juick.server.AdsQueries; import com.juick.server.MessagesQueries; import org.apache.commons.lang3.CharEncoding; import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.springframework.jdbc.core.JdbcTemplate; @@ -98,7 +99,7 @@ public class Home { response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { - String head = ""; + String head = StringUtils.EMPTY; if (paramBefore > 0 || paramShow != null) { head = ""; } diff --git a/juick-www/src/main/java/com/juick/www/Main.java b/juick-www/src/main/java/com/juick/www/Main.java index 077a3e32..4fb13290 100644 --- a/juick-www/src/main/java/com/juick/www/Main.java +++ b/juick-www/src/main/java/com/juick/www/Main.java @@ -23,6 +23,7 @@ import com.mitchellbosecke.pebble.error.PebbleException; import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.CharEncoding; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.springframework.jdbc.core.JdbcTemplate; import rocks.xmpp.addr.Jid; @@ -92,7 +93,7 @@ public class Main extends HttpServlet { boolean isXmppDisabled = BooleanUtils.toBoolean(conf.getProperty("xmpp_disabled")); if (!isXmppDisabled) { setupXmppComponent(Jid.of(conf.getProperty("www_xmpp_jid", "www.juick.local")), - conf.getProperty("xmpp_password"), NumberUtils.toInt(conf.getProperty("xmpp_port", ""), 5347)); + conf.getProperty("xmpp_password"), NumberUtils.toInt(conf.getProperty("xmpp_port", StringUtils.EMPTY), 5347)); } twitterAuth = new TwitterAuth(conf.getProperty("twitter_consumer_key"), conf.getProperty("twitter_consumer_secret")); @@ -102,8 +103,8 @@ public class Main extends HttpServlet { String imgPath = conf.getProperty("img_path", "/var/www/juick.com/i/"); pagesNewMessage = new NewMessage(tmpDir, imgPath); settings = new Settings(imgPath); - String sapeUser = conf.getProperty("sape_user", ""); - if (!Objects.equals(sapeUser, "")) { + String sapeUser = conf.getProperty("sape_user", StringUtils.EMPTY); + if (!Objects.equals(sapeUser, StringUtils.EMPTY)) { PageTemplates.sape = new Sape(sapeUser, "juick.com", 2000, 3600); } else { log("Sape is not initialized"); @@ -305,7 +306,7 @@ public class Main extends HttpServlet { } } } else if (user != null && !user.isBanned()) { - Utils.sendPermanentRedirect(response, "/" + user.getName() + "/" + (uriparts.length > 2 ? uriparts[2] : "")); + Utils.sendPermanentRedirect(response, "/" + user.getName() + "/" + (uriparts.length > 2 ? uriparts[2] : StringUtils.EMPTY)); } else { Errors.doGet404(sql, request, response); } 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 de6d8038..43ea039c 100644 --- a/juick-www/src/main/java/com/juick/www/NewMessage.java +++ b/juick-www/src/main/java/com/juick/www/NewMessage.java @@ -23,6 +23,7 @@ import com.juick.server.helpers.TagStats; import net.coobird.thumbnailator.Thumbnails; import org.apache.commons.lang3.CharEncoding; import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -79,7 +80,7 @@ public class NewMessage { String body = request.getParameter("body"); if (body == null) { - body = ""; + body = StringUtils.EMPTY; } else { if (body.length() > 4096) { body = body.substring(0, 4096); @@ -125,7 +126,7 @@ public class NewMessage { if (i > 0) { out.print(" "); } - String taglink = ""; + String taglink = StringUtils.EMPTY; try { taglink = " tags = Utils.parseTags(sql, request.getParameter("tags")); @@ -230,8 +231,8 @@ public class NewMessage { PageTemplates.pageHead(out, visitor, "Сообщение опубликовано", null); PageTemplates.pageNavigation(out, visitor, null); - String hashtags = ""; - String tagscomma = ""; + String hashtags = StringUtils.EMPTY; + String tagscomma = StringUtils.EMPTY; for (int i = 0; i < jmsg.getTags().size(); i++) { if (i > 0) { hashtags += " "; @@ -298,7 +299,7 @@ public class NewMessage { response.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } - body = body.replace("\r", ""); + body = body.replace("\r", StringUtils.EMPTY); if ((msg.ReadOnly && msg.getUser().getUid() != visitor.getUid()) || UserQueries.isInBLAny(sql, msg.getUser().getUid(), visitor.getUid()) || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUid(), visitor.getUid()))) { response.sendError(HttpServletResponse.SC_FORBIDDEN); diff --git a/juick-www/src/main/java/com/juick/www/PM.java b/juick-www/src/main/java/com/juick/www/PM.java index d11de239..d0aa26e9 100644 --- a/juick-www/src/main/java/com/juick/www/PM.java +++ b/juick-www/src/main/java/com/juick/www/PM.java @@ -24,6 +24,7 @@ import com.juick.util.MessageUtils; import com.juick.util.WebUtils; import com.mitchellbosecke.pebble.error.PebbleException; import com.mitchellbosecke.pebble.template.PebbleTemplate; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.jdbc.core.JdbcTemplate; @@ -71,7 +72,7 @@ public class PM { String uname = request.getParameter("uname"); if (WebUtils.isNotUserName(uname)) { - uname = ""; + uname = StringUtils.EMPTY; } response.setContentType("text/html; charset=UTF-8"); 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 aad8fa60..4a625acc 100644 --- a/juick-www/src/main/java/com/juick/www/PageTemplates.java +++ b/juick-www/src/main/java/com/juick/www/PageTemplates.java @@ -187,7 +187,7 @@ public class PageTemplates { } public static String formatTags(List tags) { - String ret = ""; + String ret = org.apache.commons.lang3.StringUtils.EMPTY; for (TagStats tag : tags) { String tagName = StringEscapeUtils.escapeHtml4(tag.getTag().getName()); try { diff --git a/juick-www/src/main/java/com/juick/www/Settings.java b/juick-www/src/main/java/com/juick/www/Settings.java index 56cece34..1b2a6c8d 100644 --- a/juick-www/src/main/java/com/juick/www/Settings.java +++ b/juick-www/src/main/java/com/juick/www/Settings.java @@ -129,7 +129,7 @@ public class Settings { response.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } - String result = ""; + String result = StringUtils.EMPTY; switch (page) { case "password": if (UserQueries.updatePassword(sql, visitor, request.getParameter("password"))) { diff --git a/juick-www/src/main/java/com/juick/www/TwitterAuth.java b/juick-www/src/main/java/com/juick/www/TwitterAuth.java index 65998ece..a0c1d9b0 100644 --- a/juick-www/src/main/java/com/juick/www/TwitterAuth.java +++ b/juick-www/src/main/java/com/juick/www/TwitterAuth.java @@ -10,6 +10,7 @@ import com.github.scribejava.core.model.OAuthRequest; import com.github.scribejava.core.model.Verb; import com.github.scribejava.core.oauth.OAuth10aService; import com.juick.server.UserQueries; +import org.apache.commons.lang3.StringUtils; import org.springframework.jdbc.core.JdbcTemplate; import javax.servlet.ServletException; @@ -40,7 +41,7 @@ public class TwitterAuth { protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String hash = "", request_token = "", request_token_secret = ""; + String hash = StringUtils.EMPTY, request_token = StringUtils.EMPTY, request_token_secret = StringUtils.EMPTY; String verifier = request.getParameter("oauth_verifier"); Cookie[] cookies = request.getCookies(); for (Cookie cookie : cookies) { diff --git a/juick-www/src/main/java/com/juick/www/User.java b/juick-www/src/main/java/com/juick/www/User.java index 8a937565..926ce3e3 100644 --- a/juick-www/src/main/java/com/juick/www/User.java +++ b/juick-www/src/main/java/com/juick/www/User.java @@ -23,6 +23,7 @@ import com.juick.server.UserQueries; import com.juick.server.helpers.TagStats; import org.apache.commons.lang3.CharEncoding; import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.jdbc.core.JdbcTemplate; import javax.servlet.ServletException; @@ -328,7 +329,7 @@ public class User { List tags = TagQueries.getTagsStats(sql, user.getUid()).stream() .sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).collect(Collectors.toList()); int maxUsageCnt = tags.stream().map(TagStats::getUsageCount).max(Comparator.naturalOrder()).orElse(0); - String ret = ""; + String ret = StringUtils.EMPTY; int count = cnt > 0 ? Math.min(tags.size(), cnt) : tags.size(); for (int i = 0; i < count; i++) { String tag = StringEscapeUtils.escapeHtml4(tags.get(i).getTag().getName()); diff --git a/juick-www/src/main/java/com/juick/www/Utils.java b/juick-www/src/main/java/com/juick/www/Utils.java index b860504e..ca3535fd 100644 --- a/juick-www/src/main/java/com/juick/www/Utils.java +++ b/juick-www/src/main/java/com/juick/www/Utils.java @@ -23,6 +23,7 @@ import com.juick.server.TagQueries; import com.mitchellbosecke.pebble.PebbleEngine; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.jdbc.core.JdbcTemplate; @@ -110,7 +111,7 @@ public class Utils { public static String getPartFilename(Part part) { for (String cd : part.getHeader("content-disposition").split(";")) { if (cd.trim().startsWith("filename")) { - String filename = cd.substring(cd.indexOf('=') + 1).trim().replace("\"", ""); + String filename = cd.substring(cd.indexOf('=') + 1).trim().replace("\"", StringUtils.EMPTY); return filename.substring(filename.lastIndexOf('/') + 1).substring(filename.lastIndexOf('\\') + 1); // MSIE fix. } } 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 92b22805..2184fc9a 100644 --- a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java +++ b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java @@ -23,6 +23,7 @@ import com.juick.server.UserQueries; import com.juick.www.vk.Token; import com.juick.www.vk.UsersResponse; import org.apache.commons.lang3.CharEncoding; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.dao.EmptyResultDataAccessException; @@ -56,7 +57,7 @@ public class VKontakteLogin { protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String code = request.getParameter("code"); - if (code == null || code.equals("")) { + if (StringUtils.isBlank(code)) { response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); response.setHeader("Location", "https://oauth.vk.com/authorize?client_id=" + VK_APPID + "&redirect_uri=" + URLEncoder.encode(VK_REDIRECT, CharEncoding.UTF_8) + "&scope=friends,wall,offline&response_type=code"); return; diff --git a/juick-www/src/main/java/com/juick/www/XMPPPost.java b/juick-www/src/main/java/com/juick/www/XMPPPost.java index b2fda6e2..c2ec42d7 100644 --- a/juick-www/src/main/java/com/juick/www/XMPPPost.java +++ b/juick-www/src/main/java/com/juick/www/XMPPPost.java @@ -33,7 +33,7 @@ public class XMPPPost { response.sendError(HttpServletResponse.SC_FORBIDDEN); return; } - String body = request.getParameter("body").replace("\r", ""); + String body = request.getParameter("body").replace("\r", StringUtils.EMPTY); int mid = NumberUtils.toInt(request.getParameter("mid"), 0); int rid = NumberUtils.toInt(request.getParameter("rid"), 0); if (mid > 0 && rid > 0) { -- cgit v1.2.3