aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-12-20 14:28:00 +0300
committerGravatar Vitaly Takmazov2016-12-20 14:28:00 +0300
commit3859c9616d0a7a04e68427d173b863161b818140 (patch)
treecba4d1aea88b7ce0d94cbc30fc05f765c9faaa15
parent8b02f969d3a09e39557474eb90ec821d550e3b1b (diff)
StringUtils.EMPTY
-rw-r--r--juick-api/src/main/java/com/juick/api/configuration/ApiAppConfiguration.java3
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/Post.java4
-rw-r--r--juick-core/src/main/java/com/juick/package-info.java4
-rw-r--r--juick-core/src/main/java/com/juick/util/MessageUtils.java6
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/Crosspost.java16
-rw-r--r--juick-notifications/src/main/java/com/juick/components/Notifications.java9
-rw-r--r--juick-server/src/main/java/com/juick/configuration/DataConfiguration.java5
-rw-r--r--juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java5
-rw-r--r--juick-server/src/main/java/com/juick/server/CrosspostQueries.java5
-rw-r--r--juick-server/src/main/java/com/juick/server/MessagesQueries.java4
-rw-r--r--juick-server/src/main/java/com/juick/server/UserQueries.java4
-rw-r--r--juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/protocol/annotation/UserCommand.java6
-rw-r--r--juick-server/src/main/java/com/juick/server/util/HttpBadRequestException.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/util/HttpForbiddenException.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/util/HttpNotFoundException.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/util/HttpUtils.java3
-rw-r--r--juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java5
-rw-r--r--juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java30
-rw-r--r--juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java3
-rw-r--r--juick-server/src/main/java/com/juick/service/UserServiceImpl.java4
-rw-r--r--juick-server/src/main/java/com/juick/service/search/SphinxSearchServiceImpl.java4
-rw-r--r--juick-server/src/main/java/com/juick/service/security/deprecated/CookieSimpleHashRememberMeServices.java2
-rw-r--r--juick-server/src/main/java/com/juick/util/TagUtils.java3
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/controllers/PMController.java3
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/controllers/PostController.java8
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java2
-rw-r--r--juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/Discover.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/FacebookLogin.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/Home.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/Main.java9
-rw-r--r--juick-www/src/main/java/com/juick/www/NewMessage.java13
-rw-r--r--juick-www/src/main/java/com/juick/www/PM.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/PageTemplates.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/Settings.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/TwitterAuth.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/User.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/Utils.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/VKontakteLogin.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/XMPPPost.java2
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/XMPPServer.java5
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java7
-rw-r--r--src/test/java/com/juick/json/MessageSerializer.java3
44 files changed, 125 insertions, 93 deletions
diff --git a/juick-api/src/main/java/com/juick/api/configuration/ApiAppConfiguration.java b/juick-api/src/main/java/com/juick/api/configuration/ApiAppConfiguration.java
index b4b9df57..409734e4 100644
--- a/juick-api/src/main/java/com/juick/api/configuration/ApiAppConfiguration.java
+++ b/juick-api/src/main/java/com/juick/api/configuration/ApiAppConfiguration.java
@@ -2,6 +2,7 @@ package com.juick.api.configuration;
import com.juick.api.ApiServer;
import com.juick.api.TGBot;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@@ -25,6 +26,6 @@ public class ApiAppConfiguration {
@Bean
public TGBot tgBot() {
- return new TGBot(env.getProperty("telegram_token", ""));
+ return new TGBot(env.getProperty("telegram_token", StringUtils.EMPTY));
}
}
diff --git a/juick-api/src/main/java/com/juick/api/controllers/Post.java b/juick-api/src/main/java/com/juick/api/controllers/Post.java
index 853a60ff..0c93fb7b 100644
--- a/juick-api/src/main/java/com/juick/api/controllers/Post.java
+++ b/juick-api/src/main/java/com/juick/api/controllers/Post.java
@@ -65,7 +65,7 @@ public class Post {
if (body == null || body.length() < 1 || body.length() > 4096) {
throw new HttpBadRequestException();
}
- body = body.replace("\r", "");
+ body = body.replace("\r", StringUtils.EMPTY);
String attachmentFName = HttpUtils.receiveMultiPartFile(attach, env.getProperty("upload_tmp_dir",
"/var/www/juick.com/i/tmp/"));
@@ -129,7 +129,7 @@ public class Post {
if (body == null || body.length() < 1 || body.length() > 4096) {
throw new HttpBadRequestException();
}
- body = body.replace("\r", "");
+ body = body.replace("\r", StringUtils.EMPTY);
if ((msg.ReadOnly && msg.getUser().getUid() != vuid) || userService.isInBLAny(msg.getUser().getUid(), vuid)
|| (reply != null && userService.isInBLAny(reply.getUser().getUid(), vuid))) {
diff --git a/juick-core/src/main/java/com/juick/package-info.java b/juick-core/src/main/java/com/juick/package-info.java
index 1ebddc60..63a50982 100644
--- a/juick-core/src/main/java/com/juick/package-info.java
+++ b/juick-core/src/main/java/com/juick/package-info.java
@@ -5,12 +5,14 @@
namespace="http://juick.com/message",
elementFormDefault = XmlNsForm.QUALIFIED,
xmlns={
- @XmlNs(prefix="", namespaceURI="http://juick.com/message"),
+ @XmlNs(prefix= StringUtils.EMPTY, namespaceURI="http://juick.com/message"),
@XmlNs(prefix="user", namespaceURI="http://juick.com/user")
}
)
package com.juick;
+import org.apache.commons.lang3.StringUtils;
+
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema; \ No newline at end of file
diff --git a/juick-core/src/main/java/com/juick/util/MessageUtils.java b/juick-core/src/main/java/com/juick/util/MessageUtils.java
index 96d650a8..0027716b 100644
--- a/juick-core/src/main/java/com/juick/util/MessageUtils.java
+++ b/juick-core/src/main/java/com/juick/util/MessageUtils.java
@@ -1,5 +1,7 @@
package com.juick.util;
+import org.apache.commons.lang3.StringUtils;
+
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -41,7 +43,7 @@ public class MessageUtils {
Matcher m = regexLinks2.matcher(msg);
StringBuffer sb = new StringBuffer();
while (m.find()) {
- String url = m.group(3).replace(" ", "%20").replaceAll("\\s+", "");
+ String url = m.group(3).replace(" ", "%20").replaceAll("\\s+", StringUtils.EMPTY);
m.appendReplacement(sb, "$1$2<a href=\"" + url + "\" rel=\"nofollow\">" + url + "</a>$5");
}
m.appendTail(sb);
@@ -105,7 +107,7 @@ public class MessageUtils {
Matcher m = regexLinks2.matcher(msg);
StringBuffer sb = new StringBuffer();
while (m.find()) {
- String url = m.group(3).replace(" ", "%20").replaceAll("\\s+", "");
+ String url = m.group(3).replace(" ", "%20").replaceAll("\\s+", StringUtils.EMPTY);
m.appendReplacement(sb, "$1$2<a href=\"" + url + "\" rel=\"nofollow\">$4</a>$5");
}
m.appendTail(sb);
diff --git a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
index 5e28c71e..7cf4ad3e 100644
--- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
+++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
@@ -73,16 +73,16 @@ public class Crosspost implements AutoCloseable {
this.crosspostService = crosspostService;
- twitter_consumer_key = env.getProperty("twitter_consumer_key", "");
- twitter_consumer_secret = env.getProperty("twitter_consumer_secret", "");
+ twitter_consumer_key = env.getProperty("twitter_consumer_key", StringUtils.EMPTY);
+ twitter_consumer_secret = env.getProperty("twitter_consumer_secret", StringUtils.EMPTY);
crosspostJid = env.getProperty("crosspost_jid", "crosspost.juick.local");
- password = env.getProperty("xmpp_password", "");
+ password = env.getProperty("xmpp_password", StringUtils.EMPTY);
port = NumberUtils.toInt(env.getProperty("xmpp_port"), 5347);
}
public static String percentEncode(final String s) {
- String ret = "";
+ String ret = StringUtils.EMPTY;
try {
ret = URLEncoder.encode(s, CharEncoding.UTF_8).replace("+", "%20").replace("*", "%2A").replace("%7E", "~");
} catch (UnsupportedEncodingException e) {
@@ -125,7 +125,7 @@ public class Crosspost implements AutoCloseable {
}
public boolean facebookPost(final com.juick.Message jmsg) {
- String token = crosspostService.getFacebookToken(jmsg.getUser().getUid()).orElse("");
+ String token = crosspostService.getFacebookToken(jmsg.getUser().getUid()).orElse(StringUtils.EMPTY);
if (token.isEmpty()) {
return false;
}
@@ -167,7 +167,7 @@ public class Crosspost implements AutoCloseable {
}
public boolean vkontaktePost(final com.juick.Message jmsg) {
- Pair<String, String> tokens = crosspostService.getVkTokens(jmsg.getUser().getUid()).orElse(Pair.of("", ""));
+ Pair<String, String> tokens = crosspostService.getVkTokens(jmsg.getUser().getUid()).orElse(Pair.of(StringUtils.EMPTY, StringUtils.EMPTY));
if (tokens.getLeft().isEmpty() || tokens.getRight().isEmpty()) {
return false;
}
@@ -204,7 +204,7 @@ public class Crosspost implements AutoCloseable {
}
public boolean twitterPost(final com.juick.Message jmsg) {
- Pair<String, String> tokens = crosspostService.getTwitterTokens(jmsg.getUser().getUid()).orElse(Pair.of("", ""));
+ Pair<String, String> tokens = crosspostService.getTwitterTokens(jmsg.getUser().getUid()).orElse(Pair.of(StringUtils.EMPTY, StringUtils.EMPTY));
if (tokens.getLeft().isEmpty() || tokens.getRight().isEmpty()) {
return false;
}
@@ -285,7 +285,7 @@ public class Crosspost implements AutoCloseable {
}
public String getMessageHashTags(final com.juick.Message jmsg) {
- String hashtags = "";
+ String hashtags = StringUtils.EMPTY;
for (Tag tag : jmsg.getTags()) {
hashtags += "#" + tag + " ";
}
diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java
index 0a4d1292..f41db9e3 100644
--- a/juick-notifications/src/main/java/com/juick/components/Notifications.java
+++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java
@@ -25,6 +25,7 @@ import com.juick.components.mpns.MPNSToken;
import com.notnoop.apns.APNS;
import com.notnoop.apns.ApnsService;
import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.http.*;
import org.apache.http.client.HttpClient;
@@ -80,13 +81,13 @@ public class Notifications implements AutoCloseable {
public Notifications(final Environment env, final RestTemplate rest) {
this.rest = rest;
- wns_application_sip = env.getProperty("wns_application_sip", "");
- wns_client_secret = env.getProperty("wns_client_secret", "");
- GCMSender = new Sender(env.getProperty("gcm_key", ""), Endpoint.GCM);
+ wns_application_sip = env.getProperty("wns_application_sip", StringUtils.EMPTY);
+ wns_client_secret = env.getProperty("wns_client_secret", StringUtils.EMPTY);
+ GCMSender = new Sender(env.getProperty("gcm_key", StringUtils.EMPTY), Endpoint.GCM);
pushJid = env.getProperty("push_jid");
xmppHost = env.getProperty("xmpp_host", "localhost");
xmppPort = NumberUtils.toInt(env.getProperty("xmpp_port"), 5347);
- xmppPushPassword = env.getProperty("push_xmpp_password", "");
+ xmppPushPassword = env.getProperty("push_xmpp_password", StringUtils.EMPTY);
mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
diff --git a/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java b/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java
index efee4731..4258703d 100644
--- a/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java
+++ b/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java
@@ -3,6 +3,7 @@ package com.juick.configuration;
import com.juick.database.MySqlUpdater;
import com.juick.service.search.SearchService;
import org.apache.commons.dbcp2.BasicDataSource;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.*;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -34,8 +35,8 @@ public class DataConfiguration implements TransactionManagementConfigurer {
dataSource.setDriverClassName(env.getProperty("datasource_driver", "com.mysql.jdbc.Driver"));
dataSource.setUrl(env.getProperty("datasource_url"));
- dataSource.setUsername(env.getProperty("datasource_user", ""));
- dataSource.setPassword(env.getProperty("datasource_password", ""));
+ dataSource.setUsername(env.getProperty("datasource_user", StringUtils.EMPTY));
+ dataSource.setPassword(env.getProperty("datasource_password", StringUtils.EMPTY));
dataSource.setValidationQuery("select 1");
diff --git a/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java b/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java
index 5f04ea4e..e6b446b6 100644
--- a/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java
+++ b/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java
@@ -3,6 +3,7 @@ package com.juick.configuration;
import com.juick.service.search.SearchService;
import com.juick.service.search.SphinxSearchServiceImpl;
import org.apache.commons.dbcp2.BasicDataSource;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
@@ -28,8 +29,8 @@ public class SearchConfiguration {
dataSource.setDriverClassName(env.getProperty("sphinx_driver", "com.mysql.jdbc.Driver"));
dataSource.setUrl(env.getProperty("sphinx_url"));
- dataSource.setUsername(env.getProperty("sphinx_user", ""));
- dataSource.setPassword(env.getProperty("sphinx_password", ""));
+ dataSource.setUsername(env.getProperty("sphinx_user", StringUtils.EMPTY));
+ dataSource.setPassword(env.getProperty("sphinx_password", StringUtils.EMPTY));
return dataSource;
}
diff --git a/juick-server/src/main/java/com/juick/server/CrosspostQueries.java b/juick-server/src/main/java/com/juick/server/CrosspostQueries.java
index 827dad09..9d0b5f4c 100644
--- a/juick-server/src/main/java/com/juick/server/CrosspostQueries.java
+++ b/juick-server/src/main/java/com/juick/server/CrosspostQueries.java
@@ -18,6 +18,7 @@
package com.juick.server;
import com.juick.server.helpers.ApplicationStatus;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -64,7 +65,7 @@ public class CrosspostQueries {
try {
return sql.queryForObject("SELECT uname FROM twitter WHERE user_id=?", String.class, uid);
} catch (EmptyResultDataAccessException e) {
- return "";
+ return StringUtils.EMPTY;
}
}
@@ -72,7 +73,7 @@ public class CrosspostQueries {
try {
return sql.queryForObject("SELECT tg_name FROM telegram WHERE user_id=?", String.class, uid);
} catch (EmptyResultDataAccessException e) {
- return "";
+ return StringUtils.EMPTY;
}
}
diff --git a/juick-server/src/main/java/com/juick/server/MessagesQueries.java b/juick-server/src/main/java/com/juick/server/MessagesQueries.java
index cac36979..f3de1f9b 100644
--- a/juick-server/src/main/java/com/juick/server/MessagesQueries.java
+++ b/juick-server/src/main/java/com/juick/server/MessagesQueries.java
@@ -101,8 +101,8 @@ public class MessagesQueries {
if (mid > 0) {
- String tagsNames = "";
- String tagsIDs = "";
+ String tagsNames = org.apache.commons.lang3.StringUtils.EMPTY;
+ String tagsIDs = org.apache.commons.lang3.StringUtils.EMPTY;
for (int i = 0; i < tags.size(); i++) {
if (i > 0) {
diff --git a/juick-server/src/main/java/com/juick/server/UserQueries.java b/juick-server/src/main/java/com/juick/server/UserQueries.java
index e91cb6b3..7a669230 100644
--- a/juick-server/src/main/java/com/juick/server/UserQueries.java
+++ b/juick-server/src/main/java/com/juick/server/UserQueries.java
@@ -241,7 +241,7 @@ public class UserQueries {
if (sql.update("INSERT INTO mail(user_id,hash) VALUES (?,?) ON DUPLICATE KEY UPDATE hash=?", user.getUid(), newHash, newHash) > 0) {
return newHash;
}
- return "";
+ return org.apache.commons.lang3.StringUtils.EMPTY;
}
public static int getUserOptionInt(JdbcTemplate sql, int uid, String option, int defaultValue) {
@@ -481,7 +481,7 @@ public class UserQueries {
return sql.queryForObject("SELECT hash FROM mail WHERE user_id=?", String.class, user.getUid())
+ "@mail.juick.com";
} catch (EmptyResultDataAccessException e) {
- return "";
+ return org.apache.commons.lang3.StringUtils.EMPTY;
}
}
}
diff --git a/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java b/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
index a024a0eb..cd7a4bc1 100644
--- a/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
+++ b/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
@@ -8,6 +8,7 @@ import com.juick.server.helpers.TagStats;
import com.juick.server.protocol.annotation.UserCommand;
import com.juick.service.*;
import com.juick.util.TagUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import javax.inject.Inject;
@@ -110,7 +111,7 @@ public class JuickProtocol {
bltags = tagService.getUserBLTags(user_from.getUid());
- String txt = "";
+ String txt = StringUtils.EMPTY;
if (bltags.size() > 0) {
for (String bltag : bltags) {
txt += "*" + bltag + "\n";
diff --git a/juick-server/src/main/java/com/juick/server/protocol/annotation/UserCommand.java b/juick-server/src/main/java/com/juick/server/protocol/annotation/UserCommand.java
index af7c4924..42a9bb59 100644
--- a/juick-server/src/main/java/com/juick/server/protocol/annotation/UserCommand.java
+++ b/juick-server/src/main/java/com/juick/server/protocol/annotation/UserCommand.java
@@ -1,5 +1,7 @@
package com.juick.server.protocol.annotation;
+import org.apache.commons.lang3.StringUtils;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -15,7 +17,7 @@ public @interface UserCommand {
*
* @return a command pattern
*/
- String pattern() default "";
+ String pattern() default StringUtils.EMPTY;
/**
*
@@ -27,5 +29,5 @@ public @interface UserCommand {
*
* @return a string used in HELP command output. Basically, only 1 string
*/
- String help() default "";
+ String help() default StringUtils.EMPTY;
}
diff --git a/juick-server/src/main/java/com/juick/server/util/HttpBadRequestException.java b/juick-server/src/main/java/com/juick/server/util/HttpBadRequestException.java
index 5c0593ec..1ba1aecb 100644
--- a/juick-server/src/main/java/com/juick/server/util/HttpBadRequestException.java
+++ b/juick-server/src/main/java/com/juick/server/util/HttpBadRequestException.java
@@ -1,5 +1,6 @@
package com.juick.server.util;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@@ -9,6 +10,6 @@ import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
public class HttpBadRequestException extends RuntimeException {
public HttpBadRequestException() {
- super("", null, false, false);
+ super(StringUtils.EMPTY, null, false, false);
}
}
diff --git a/juick-server/src/main/java/com/juick/server/util/HttpForbiddenException.java b/juick-server/src/main/java/com/juick/server/util/HttpForbiddenException.java
index a1004b41..733453ba 100644
--- a/juick-server/src/main/java/com/juick/server/util/HttpForbiddenException.java
+++ b/juick-server/src/main/java/com/juick/server/util/HttpForbiddenException.java
@@ -1,5 +1,6 @@
package com.juick.server.util;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@@ -9,7 +10,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.FORBIDDEN)
public class HttpForbiddenException extends RuntimeException {
public HttpForbiddenException() {
- super("", null, false, false);
+ super(StringUtils.EMPTY, null, false, false);
}
}
diff --git a/juick-server/src/main/java/com/juick/server/util/HttpNotFoundException.java b/juick-server/src/main/java/com/juick/server/util/HttpNotFoundException.java
index fd0f1cb0..942d90e2 100644
--- a/juick-server/src/main/java/com/juick/server/util/HttpNotFoundException.java
+++ b/juick-server/src/main/java/com/juick/server/util/HttpNotFoundException.java
@@ -1,5 +1,6 @@
package com.juick.server.util;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@@ -9,6 +10,6 @@ import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public class HttpNotFoundException extends RuntimeException {
public HttpNotFoundException() {
- super("", null, false, false);
+ super(StringUtils.EMPTY, null, false, false);
}
}
diff --git a/juick-server/src/main/java/com/juick/server/util/HttpUtils.java b/juick-server/src/main/java/com/juick/server/util/HttpUtils.java
index fa0b2ec2..e54bef87 100644
--- a/juick-server/src/main/java/com/juick/server/util/HttpUtils.java
+++ b/juick-server/src/main/java/com/juick/server/util/HttpUtils.java
@@ -18,6 +18,7 @@
package com.juick.server.util;
import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
@@ -58,7 +59,7 @@ public class HttpUtils {
}
}
}
- return "";
+ return StringUtils.EMPTY;
}
public static String downloadImage(URL url) throws Exception {
String attachmentFName = null;
diff --git a/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java b/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java
index 0f043292..df748526 100644
--- a/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java
@@ -1,6 +1,7 @@
package com.juick.service;
import com.juick.server.helpers.ApplicationStatus;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
@@ -96,7 +97,7 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
uid);
return list.isEmpty() ?
- "" : list.get(0);
+ StringUtils.EMPTY : list.get(0);
}
@Transactional(readOnly = true)
@@ -108,7 +109,7 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
uid);
return list.isEmpty() ?
- "" : list.get(0);
+ StringUtils.EMPTY : list.get(0);
}
@Transactional(readOnly = true)
diff --git a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
index 88167be8..1ad29d00 100644
--- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -107,7 +107,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
int mid = holder.getKey().intValue();
if (mid > 0) {
- String tagsNames = "";
+ String tagsNames = StringUtils.EMPTY;
if (CollectionUtils.isNotEmpty(tags)) {
StringBuilder tasNamesBuilder = new StringBuilder();
@@ -364,7 +364,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
return getNamedParameterJdbcTemplate().queryForList(
"SELECT m.message_id FROM messages m WHERE " +
(before > 0 ?
- " m.message_id < :before AND " : "") +
+ " m.message_id < :before AND " : StringUtils.EMPTY) +
" m.hidden = 0 AND (m.privacy > 0" +
(visitorUid > 1 ?
" OR m.user_id = :visitorUid) AND NOT EXISTS (" +
@@ -389,7 +389,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
"ON ((tags.synonym_id = :tid OR tags.tag_id = :tid) AND tags.tag_id = messages_tags.tag_id)) " +
"INNER JOIN messages USING(message_id) WHERE " +
(before > 0 ?
- " messages.message_id < :before AND " : "") +
+ " messages.message_id < :before AND " : StringUtils.EMPTY) +
"(messages.privacy > 0 OR messages.user_id = :visitorUid) ORDER BY message_id DESC LIMIT :cnt",
sqlParameterSource,
Integer.class);
@@ -407,7 +407,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
"SELECT messages.message_id FROM messages_tags " +
"INNER JOIN messages USING(message_id) WHERE messages_tags.tag_id IN (" + tids + ") " +
(before > 0 ?
- " AND messages.message_id < :before " : "") +
+ " AND messages.message_id < :before " : StringUtils.EMPTY) +
" AND (messages.privacy > 0 OR messages.user_id = :visitorUid) " +
"ORDER BY messages.message_id DESC LIMIT :cnt",
sqlParameterSource,
@@ -425,7 +425,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
return getNamedParameterJdbcTemplate().queryForList(
"SELECT message_id FROM messages WHERE place_id = :placeId " +
(before > 0 ?
- " AND message_id < :before " : "") +
+ " AND message_id < :before " : StringUtils.EMPTY) +
" AND (privacy > 0 OR user_id = :visitorUid) ORDER BY message_id DESC LIMIT 20",
sqlParameterSource,
Integer.class);
@@ -443,13 +443,13 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
" INNER JOIN subscr_users ON (subscr_users.suser_id = :uid AND subscr_users.user_id = messages.user_id) " +
" WHERE " +
(before > 0 ?
- " message_id < :before AND " : "") +
+ " message_id < :before AND " : StringUtils.EMPTY) +
" (privacy >= 0 OR (privacy >= -2 AND privacy <= -1" +
" AND EXISTS (SELECT 1 FROM wl_users w WHERE w.wl_user_id = :uid and w.user_id = messages.user_id)))) " +
" UNION " +
" (SELECT message_id FROM messages WHERE user_id=:uid " +
(before > 0 ?
- " AND message_id < :before " : "") +
+ " AND message_id < :before " : StringUtils.EMPTY) +
") ORDER BY message_id DESC LIMIT 20",
sqlParameterSource,
Integer.class);
@@ -467,7 +467,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
return getNamedParameterJdbcTemplate().queryForList
("SELECT message_id FROM messages WHERE user_id = :uid AND privacy < 0" +
(before > 0 ?
- " AND message_id < :before " : "") +
+ " AND message_id < :before " : StringUtils.EMPTY) +
"ORDER BY message_id DESC LIMIT 20",
sqlParameterSource,
Integer.class);
@@ -500,7 +500,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
"SELECT f.message_id FROM favorites f WHERE " +
"EXISTS (SELECT 1 FROM subscr_users s WHERE s.suser_id = :uid and f.user_id = s.user_id)" +
(before > 0 ?
- " AND f.message_id < :before " : "") +
+ " AND f.message_id < :before " : StringUtils.EMPTY) +
"ORDER BY f.message_id DESC LIMIT 20",
sqlParameterSource,
Integer.class);
@@ -516,7 +516,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
return getNamedParameterJdbcTemplate().queryForList(
"SELECT m.message_id FROM messages m WHERE m.privacy > 0 " +
(before > 0 ?
- " AND m.message_id < :before " : "") +
+ " AND m.message_id < :before " : StringUtils.EMPTY) +
" AND m.popular > 0 AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = m.user_id) " +
" ORDER BY m.message_id DESC LIMIT 20",
sqlParameterSource,
@@ -533,7 +533,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
return getNamedParameterJdbcTemplate().queryForList(
"SELECT m.message_id FROM messages m WHERE (m.privacy > 0 OR m.user_id = :vid) " +
(before > 0 ?
- " AND m.message_id < :before " : "") +
+ " AND m.message_id < :before " : StringUtils.EMPTY) +
" AND m.attach IS NOT NULL " +
" AND NOT EXISTS (SELECT 1 from users u WHERE u.banned = 1 and u.id = m.user_id) " +
" AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = m.user_id) " +
@@ -566,7 +566,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
return getNamedParameterJdbcTemplate().queryForList(
"SELECT message_id FROM messages WHERE user_id = :uid" +
(before > 0 ?
- " AND message_id < :before" : "") +
+ " AND message_id < :before" : StringUtils.EMPTY) +
" AND privacy >= :privacy ORDER BY message_id DESC LIMIT 20",
sqlParameterSource,
Integer.class);
@@ -585,7 +585,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
"SELECT messages.message_id FROM messages_tags INNER JOIN messages " +
" USING (message_id) WHERE messages.user_id = :uid AND messages_tags.tag_id = :tid " +
(before > 0 ?
- " AND messages.message_id < :before " : "") +
+ " AND messages.message_id < :before " : StringUtils.EMPTY) +
" AND messages.privacy >= :privacy ORDER BY messages.message_id DESC LIMIT 20",
sqlParameterSource,
Integer.class);
@@ -602,7 +602,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
"SELECT message_id FROM favorites " +
" WHERE user_id = :uid " +
(before > 0 ?
- " AND message_id < :before " : "") +
+ " AND message_id < :before " : StringUtils.EMPTY) +
" ORDER BY message_id DESC LIMIT 20",
sqlParameterSource,
Integer.class);
@@ -619,7 +619,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
return getNamedParameterJdbcTemplate().queryForList(
"SELECT message_id FROM messages WHERE user_id = :uid " +
(before > 0 ?
- " AND message_id < :before " : "") +
+ " AND message_id < :before " : StringUtils.EMPTY) +
" AND privacy >= :privacy AND attach IS NOT NULL ORDER BY message_id DESC LIMIT 20",
sqlParameterSource,
Integer.class);
diff --git a/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java b/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java
index decfe59d..4082e1ef 100644
--- a/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java
@@ -3,6 +3,7 @@ package com.juick.service;
import com.juick.Tag;
import com.juick.User;
import com.juick.server.helpers.NotifyOpts;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Repository;
@@ -47,7 +48,7 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
"SELECT jids.jid FROM subscr_users INNER JOIN jids " +
"ON (subscr_users.user_id = :uid AND subscr_users.suser_id = jids.user_id) WHERE jids.active = 1 " +
(friendsonly ?
- " AND EXISTS (SELECT 1 FROM wl_users w WHERE w.user_id = :uid and jids.user_id = w.wl_user_id)" : ""),
+ " AND EXISTS (SELECT 1 FROM wl_users w WHERE w.user_id = :uid and jids.user_id = w.wl_user_id)" : StringUtils.EMPTY),
new MapSqlParameterSource("uid", uid),
String.class);
}
diff --git a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java
index b3430254..f226b402 100644
--- a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java
@@ -357,7 +357,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
if (ret > 0)
return newHash;
}
- return "";
+ return StringUtils.EMPTY;
}
@Transactional(readOnly = true)
@@ -649,7 +649,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
"SELECT hash FROM mail WHERE user_id = ?",
String.class,
user.getUid());
- return list.isEmpty() ? "" : list.get(0) + "@mail.juick.com";
+ return list.isEmpty() ? StringUtils.EMPTY : list.get(0) + "@mail.juick.com";
}
@Transactional
diff --git a/juick-server/src/main/java/com/juick/service/search/SphinxSearchServiceImpl.java b/juick-server/src/main/java/com/juick/service/search/SphinxSearchServiceImpl.java
index de0a101f..161e0fb2 100644
--- a/juick-server/src/main/java/com/juick/service/search/SphinxSearchServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/search/SphinxSearchServiceImpl.java
@@ -49,7 +49,7 @@ public class SphinxSearchServiceImpl implements SearchService {
return namedParameterSearchJdbcTemplate.queryForList(
"SELECT id AS message_id FROM messages WHERE MATCH(:search) " +
(messageIdBefore > 0 ?
- " AND id < :before " : "") +
+ " AND id < :before " : StringUtils.EMPTY) +
" ORDER BY id DESC LIMIT :limit",
sqlParameterSource,
Integer.class);
@@ -69,7 +69,7 @@ public class SphinxSearchServiceImpl implements SearchService {
return namedParameterSearchJdbcTemplate.queryForList(
"SELECT id AS message_id FROM messages WHERE user_id = :userId AND MATCH(:search) " +
(messageIdBefore > 0 ?
- " AND id < :before " : "") +
+ " AND id < :before " : StringUtils.EMPTY) +
" ORDER BY id DESC LIMIT :limit",
sqlParameterSource,
Integer.class);
diff --git a/juick-server/src/main/java/com/juick/service/security/deprecated/CookieSimpleHashRememberMeServices.java b/juick-server/src/main/java/com/juick/service/security/deprecated/CookieSimpleHashRememberMeServices.java
index ec44baa0..1fb2c6a3 100644
--- a/juick-server/src/main/java/com/juick/service/security/deprecated/CookieSimpleHashRememberMeServices.java
+++ b/juick-server/src/main/java/com/juick/service/security/deprecated/CookieSimpleHashRememberMeServices.java
@@ -104,6 +104,6 @@ public class CookieSimpleHashRememberMeServices extends AbstractRememberMeServic
@Override
protected String encodeCookie(String[] cookieTokens) {
- return cookieTokens != null && cookieTokens.length > 0 ? cookieTokens[0] : "";
+ return cookieTokens != null && cookieTokens.length > 0 ? cookieTokens[0] : StringUtils.EMPTY;
}
}
diff --git a/juick-server/src/main/java/com/juick/util/TagUtils.java b/juick-server/src/main/java/com/juick/util/TagUtils.java
index 157522ab..fec59f29 100644
--- a/juick-server/src/main/java/com/juick/util/TagUtils.java
+++ b/juick-server/src/main/java/com/juick/util/TagUtils.java
@@ -2,6 +2,7 @@ package com.juick.util;
import com.juick.Tag;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.stream.Collectors;
@@ -16,7 +17,7 @@ public class TagUtils {
public static String toString(final List<Tag> tags) {
if (CollectionUtils.isEmpty(tags))
- return "";
+ return StringUtils.EMPTY;
return tags.stream().map(t -> " *" + t.getName())
.collect(Collectors.joining());
diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/PMController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/PMController.java
index 9fceb23c..f590fc7c 100644
--- a/juick-spring-www/src/main/java/com/juick/www/controllers/PMController.java
+++ b/juick-spring-www/src/main/java/com/juick/www/controllers/PMController.java
@@ -11,6 +11,7 @@ import com.juick.util.MessageUtils;
import com.juick.util.UserUtils;
import com.juick.util.WebUtils;
import com.juick.www.WebApp;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
@@ -64,7 +65,7 @@ public class PMController {
List<com.juick.Message> msgs = pmQueriesService.getLastPMSent(visitor.getUid());
if (WebUtils.isNotUserName(uname)) {
- uname = "";
+ uname = StringUtils.EMPTY;
}
context.put("title", title);
context.put("msgs", msgs);
diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/PostController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/PostController.java
index 1ce2f893..01f011be 100644
--- a/juick-spring-www/src/main/java/com/juick/www/controllers/PostController.java
+++ b/juick-spring-www/src/main/java/com/juick/www/controllers/PostController.java
@@ -69,7 +69,7 @@ public class PostController {
@RequestParam(required = false) MultipartFile attach,
ModelMap modelMap
) throws IOException {
- body = body.replace("\r", "");
+ body = body.replace("\r", StringUtils.EMPTY);
List<Tag> tags = tagService.fromString(tagsStr, true);
@@ -144,8 +144,8 @@ public class PostController {
logger.warn("XMPP unavailable");
}
- 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 += " ";
@@ -195,7 +195,7 @@ public class PostController {
if (body.length() < 1 || body.length() > 4096) {
throw new HttpBadRequestException();
}
- body = body.replace("\r", "");
+ body = body.replace("\r", StringUtils.EMPTY);
User visitor = UserUtils.getCurrentUser();
diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java
index 65309e4e..d1c872d7 100644
--- a/juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java
+++ b/juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java
@@ -123,7 +123,7 @@ public class SettingsController {
if (StringUtils.isEmpty(page) || !pages.contains(page)) {
throw new HttpBadRequestException();
}
- String result = "";
+ String result = StringUtils.EMPTY;
switch (page) {
case "password":
if (userService.updatePassword(visitor, password)) {
diff --git a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
index c73c50e5..32888797 100644
--- a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
+++ b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
@@ -37,7 +37,7 @@ public class WebsocketComponent extends TextWebSocketHandler {
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
URI hLocation;
- String hXRealIP = "";
+ String hXRealIP;
hLocation = session.getUri();
HttpHeaders headers = session.getHandshakeHeaders();
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 = "<meta name=\"robots\" content=\"noindex,nofollow\"/>";
} 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 = "<meta name=\"robots\" content=\"noindex\"/>";
}
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 = "<a onclick=\"return addTag('" + StringEscapeUtils.escapeHtml4(tags.get(i).getTag().getName()) + "')\" href=\"/" +
visitor.getName() + "/?tag=" + URLEncoder.encode(tags.get(i).getTag().getName(), CharEncoding.UTF_8) +
@@ -154,7 +155,7 @@ public class NewMessage {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
- body = body.replace("\r", "");
+ body = body.replace("\r", StringUtils.EMPTY);
List<Tag> 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<TagStats> 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<TagStats> 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) {
diff --git a/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java b/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java
index e057a9ea..ac2c9ec8 100644
--- a/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java
+++ b/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java
@@ -7,6 +7,7 @@ import com.juick.xmpp.Stanza;
import com.juick.xmpp.StanzaChild;
import com.juick.xmpp.extensions.JuickMessage;
import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,8 +72,8 @@ public class XMPPServer implements AutoCloseable {
int s2sPort = NumberUtils.toInt(env.getProperty("s2s_port"), 5269);
keystore = env.getProperty("keystore");
keystorePassword = env.getProperty("keystore_password");
- brokenSSLhosts = Arrays.asList(env.getProperty("broken_ssl_hosts", "").split(","));
- bannedHosts = Arrays.asList(env.getProperty("banned_hosts", "").split(","));
+ brokenSSLhosts = Arrays.asList(env.getProperty("broken_ssl_hosts", StringUtils.EMPTY).split(","));
+ bannedHosts = Arrays.asList(env.getProperty("banned_hosts", StringUtils.EMPTY).split(","));
jid = new JID(env.getProperty("xmppbot_jid"));
boolean disabled = BooleanUtils.toBoolean(env.getProperty("xmpp_disabled", "false"));
diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java b/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java
index 304d365e..eec9b8e2 100644
--- a/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java
+++ b/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java
@@ -8,6 +8,7 @@ import com.juick.xmpp.Presence;
import com.juick.xmpp.Stanza;
import com.juick.xmpp.extensions.Error;
import com.juick.xmpp.extensions.JuickMessage;
+import org.apache.commons.lang3.StringUtils;
import javax.inject.Inject;
import java.util.List;
@@ -145,8 +146,8 @@ public class JuickBot implements StanzaListener {
String username = msg.to.Username.toLowerCase();
- User user_from = null;
- String signuphash = "";
+ User user_from;
+ String signuphash = StringUtils.EMPTY;
user_from = xmpp.userService.getUserByJID(msg.from.Bare());
if (user_from == null) {
signuphash = xmpp.userService.getSignUpHashByJID(msg.from.Bare());
@@ -354,7 +355,7 @@ public class JuickBot implements StanzaListener {
List<User> blusers = xmpp.userService.getUserBLUsers(user_from.getUid());
List<String> bltags = xmpp.tagService.getUserBLTags(user_from.getUid());
- String txt = "";
+ String txt = StringUtils.EMPTY;
if (bltags.size() > 0) {
for (String bltag : bltags) {
txt += "*" + bltag + "\n";
diff --git a/src/test/java/com/juick/json/MessageSerializer.java b/src/test/java/com/juick/json/MessageSerializer.java
index 7ed060dd..6f0d462f 100644
--- a/src/test/java/com/juick/json/MessageSerializer.java
+++ b/src/test/java/com/juick/json/MessageSerializer.java
@@ -21,6 +21,7 @@ import com.juick.Message;
import com.juick.Photo;
import com.juick.Tag;
import com.juick.util.DateFormattersHolder;
+import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -124,7 +125,7 @@ public class MessageSerializer extends JSONSerializer<Message> {
}
if (msg.getAttachmentType() != null) {
json.put("attach", msg.getAttachmentType());
- String fname = msg.getMid() + (msg.getRid() > 0 ? "-" + msg.getRid() : "") + "." + msg.getAttachmentType();
+ String fname = msg.getMid() + (msg.getRid() > 0 ? "-" + msg.getRid() : StringUtils.EMPTY) + "." + msg.getAttachmentType();
JSONObject photo = new JSONObject();
String protocol = getUriScheme() == URIScheme.Plain ? "http:" : "https:";
photo.put("thumbnail", protocol + "//i.juick.com/ps/" + fname);