Skip to content

Commit

Permalink
⬆️ 升级 Latke
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 2, 2018
1 parent 246aa46 commit eafd3ae
Show file tree
Hide file tree
Showing 20 changed files with 62 additions and 67 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Description: Symphony POM.
Version: 2.16.6.98, Aug 29, 2018
Version: 2.16.6.99, Sep 2, 2018
Author: Liang Ding
Author: Zephyr
-->
Expand All @@ -22,7 +22,7 @@
<inceptionYear>2012</inceptionYear>

<properties>
<latke.version>2.4.10</latke.version>
<latke.version>2.4.11</latke.version>

<servlet.version>3.1.0</servlet.version>
<jetty.version>9.2.7.v20150116</jetty.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private void resolveSkinDir(final HttpServletRequest request) {
final JSONObject cookieJSONObject = new JSONObject(value);

final String userId = cookieJSONObject.optString(Keys.OBJECT_ID);
if (Strings.isEmptyOrNull(userId)) {
if (StringUtils.isBlank(userId)) {
break;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/b3log/symphony/model/sitemap/Sitemap.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.b3log.symphony.model.sitemap;

import org.b3log.latke.util.Strings;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -242,19 +242,19 @@ public String toString() {
stringBuilder.append(loc);
stringBuilder.append(END_LOC_ELEMENT);

if (!Strings.isEmptyOrNull(lastMod)) {
if (StringUtils.isNotBlank(lastMod)) {
stringBuilder.append(START_LAST_MOD_ELEMENT);
stringBuilder.append(lastMod);
stringBuilder.append(END_LAST_MOD_ELEMENT);
}

if (!Strings.isEmptyOrNull(changeFreq)) {
if (StringUtils.isNotBlank(changeFreq)) {
stringBuilder.append(START_CHANGE_REQ_ELEMENT);
stringBuilder.append(changeFreq);
stringBuilder.append(END_CHANGE_REQ_ELEMENT);
}

if (!Strings.isEmptyOrNull(priority)) {
if (StringUtils.isNotBlank(priority)) {
stringBuilder.append(START_PRIORITY_ELEMENT);
stringBuilder.append(priority);
stringBuilder.append(END_PRIORITY_ELEMENT);
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/b3log/symphony/processor/AdminProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ public void addTag(final HTTPRequestContext context, final HttpServletRequest re
throws Exception {
String title = StringUtils.trim(request.getParameter(Tag.TAG_TITLE));
try {
if (Strings.isEmptyOrNull(title)) {
if (StringUtils.isBlank(title)) {
throw new Exception(langPropsService.get("tagsErrorLabel"));
}

Expand Down Expand Up @@ -1380,7 +1380,7 @@ public void showUsers(final HTTPRequestContext context, final HttpServletRequest
requestJSONObject.put(Pagination.PAGINATION_PAGE_SIZE, pageSize);
requestJSONObject.put(Pagination.PAGINATION_WINDOW_SIZE, windowSize);
final String query = request.getParameter(Common.QUERY);
if (!Strings.isEmptyOrNull(query)) {
if (StringUtils.isNotBlank(query)) {
requestJSONObject.put(Common.QUERY, query);
}

Expand Down Expand Up @@ -1583,7 +1583,7 @@ public void updateUser(final HTTPRequestContext context, final HttpServletReques
break;
case User.USER_PASSWORD:
final String oldPwd = user.getString(name);
if (!oldPwd.equals(value) && !Strings.isEmptyOrNull(value)) {
if (!oldPwd.equals(value) && StringUtils.isNotBlank(value)) {
user.put(name, DigestUtils.md5Hex(value));
}

Expand Down Expand Up @@ -1932,7 +1932,7 @@ public void showArticles(final HTTPRequestContext context, final HttpServletRequ
requestJSONObject.put(Pagination.PAGINATION_WINDOW_SIZE, windowSize);

final String articleId = request.getParameter("id");
if (!Strings.isEmptyOrNull(articleId)) {
if (StringUtils.isNotBlank(articleId)) {
requestJSONObject.put(Keys.OBJECT_ID, articleId);
}

Expand Down Expand Up @@ -2260,7 +2260,7 @@ public void showTags(final HTTPRequestContext context, final HttpServletRequest
requestJSONObject.put(Pagination.PAGINATION_WINDOW_SIZE, windowSize);

final String tagTitle = request.getParameter(Common.TITLE);
if (!Strings.isEmptyOrNull(tagTitle)) {
if (StringUtils.isNotBlank(tagTitle)) {
requestJSONObject.put(Tag.TAG_TITLE, tagTitle);
}

Expand Down Expand Up @@ -2409,7 +2409,7 @@ public void showDomains(final HTTPRequestContext context, final HttpServletReque
requestJSONObject.put(Pagination.PAGINATION_WINDOW_SIZE, windowSize);

final String domainTitle = request.getParameter(Common.TITLE);
if (!Strings.isEmptyOrNull(domainTitle)) {
if (StringUtils.isNotBlank(domainTitle)) {
requestJSONObject.put(Domain.DOMAIN_TITLE, domainTitle);
}

Expand Down Expand Up @@ -2638,7 +2638,7 @@ public void addDomainTag(final HTTPRequestContext context,
tagId = tag.optString(Keys.OBJECT_ID);
} else {
try {
if (Strings.isEmptyOrNull(tagTitle)) {
if (StringUtils.isBlank(tagTitle)) {
throw new Exception(langPropsService.get("tagsErrorLabel"));
}

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/b3log/symphony/processor/ArticleProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public void showAddArticle(final HTTPRequestContext context, final HttpServletRe
for (final String title : tagTitles) {
final String tagTitle = title.trim();

if (Strings.isEmptyOrNull(tagTitle)) {
if (StringUtils.isBlank(tagTitle)) {
continue;
}

Expand Down Expand Up @@ -696,10 +696,10 @@ public void showArticle(final HTTPRequestContext context, final HttpServletReque
article.put(Common.REWARDED, rewardQueryService.isRewarded(currentUserId, articleId, Reward.TYPE_C_ARTICLE));
}

if (Strings.isEmptyOrNull(cmtViewModeStr) || !Strings.isNumeric(cmtViewModeStr)) {
if (StringUtils.isBlank(cmtViewModeStr) || !Strings.isNumeric(cmtViewModeStr)) {
cmtViewModeStr = currentUser.optString(UserExt.USER_COMMENT_VIEW_MODE);
}
} else if (Strings.isEmptyOrNull(cmtViewModeStr) || !Strings.isNumeric(cmtViewModeStr)) {
} else if (StringUtils.isBlank(cmtViewModeStr) || !Strings.isNumeric(cmtViewModeStr)) {
cmtViewModeStr = "0";
}

Expand Down Expand Up @@ -1015,7 +1015,7 @@ public void addArticle(final HTTPRequestContext context, final HttpServletReques
public void showUpdateArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
final String articleId = request.getParameter("id");
if (Strings.isEmptyOrNull(articleId)) {
if (StringUtils.isBlank(articleId)) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);

return;
Expand Down Expand Up @@ -1103,7 +1103,7 @@ public void showUpdateArticle(final HTTPRequestContext context, final HttpServle
@After(adviceClass = StopwatchEndAdvice.class)
public void updateArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response,
final String id) throws Exception {
if (Strings.isEmptyOrNull(id)) {
if (StringUtils.isBlank(id)) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);

return;
Expand Down Expand Up @@ -1215,7 +1215,7 @@ public void updateArticle(final HTTPRequestContext context, final HttpServletReq
public void markdown2HTML(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context) {
context.renderJSON(true);
String markdownText = request.getParameter("markdownText");
if (Strings.isEmptyOrNull(markdownText)) {
if (StringUtils.isBlank(markdownText)) {
context.renderJSONValue("html", "");

return;
Expand Down Expand Up @@ -1286,7 +1286,7 @@ public void reward(final HttpServletRequest request, final HttpServletResponse r
}

final String articleId = request.getParameter(Article.ARTICLE_T_ID);
if (Strings.isEmptyOrNull(articleId)) {
if (StringUtils.isBlank(articleId)) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);

return;
Expand Down Expand Up @@ -1330,7 +1330,7 @@ public void thank(final HttpServletRequest request, final HttpServletResponse re
}

final String articleId = request.getParameter(Article.ARTICLE_T_ID);
if (Strings.isEmptyOrNull(articleId)) {
if (StringUtils.isBlank(articleId)) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);

return;
Expand Down Expand Up @@ -1370,7 +1370,7 @@ public void stickArticle(final HttpServletRequest request, final HttpServletResp
}

final String articleId = request.getParameter(Article.ARTICLE_T_ID);
if (Strings.isEmptyOrNull(articleId)) {
if (StringUtils.isBlank(articleId)) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class CaptchaProcessor {
* @return {@code true} if it is invalid, returns {@code false} otherwise
*/
public static boolean invalidCaptcha(final String captcha) {
if (Strings.isEmptyOrNull(captcha) || captcha.length() != CAPTCHA_LENGTH) {
if (StringUtils.isBlank(captcha) || captcha.length() != CAPTCHA_LENGTH) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer;
import org.b3log.latke.util.Locales;
import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings;
import org.b3log.symphony.model.*;
import org.b3log.symphony.processor.advice.CSRFToken;
import org.b3log.symphony.processor.advice.LoginCheck;
Expand Down Expand Up @@ -501,7 +500,7 @@ public void showRegister(final HTTPRequestContext context, final HttpServletRequ
}

final String code = request.getParameter("code");
if (Strings.isEmptyOrNull(code)) { // Register Step 1
if (StringUtils.isBlank(code)) { // Register Step 1
renderer.setTemplateName("verify/register.ftl");
} else { // Register Step 2
final JSONObject verifycode = verifycodeQueryService.getVerifycode(code);
Expand All @@ -521,7 +520,7 @@ public void showRegister(final HTTPRequestContext context, final HttpServletRequ
renderer.setTemplateName("/error/custom.ftl");
} else {
referral = StringUtils.substringAfter(code, "r=");
if (!Strings.isEmptyOrNull(referral)) {
if (StringUtils.isNotBlank(referral)) {
dataModel.put(Common.REFERRAL, referral);
}
}
Expand Down Expand Up @@ -567,7 +566,7 @@ public void register(final HTTPRequestContext context, final HttpServletRequest
final JSONObject verifycode = new JSONObject();
verifycode.put(Verifycode.BIZ_TYPE, Verifycode.BIZ_TYPE_C_REGISTER);
String code = RandomStringUtils.randomAlphanumeric(6);
if (!Strings.isEmptyOrNull(referral)) {
if (StringUtils.isNotBlank(referral)) {
code += "r=" + referral;
}
verifycode.put(Verifycode.CODE, code);
Expand Down Expand Up @@ -640,7 +639,7 @@ public void register2(final HTTPRequestContext context, final HttpServletRequest
final String ip = Requests.getRemoteAddr(request);
userMgmtService.updateOnlineStatus(user.optString(Keys.OBJECT_ID), ip, true, true);

if (!Strings.isEmptyOrNull(referral) && !UserRegisterValidation.invalidUserName(referral)) {
if (StringUtils.isNotBlank(referral) && !UserRegisterValidation.invalidUserName(referral)) {
final JSONObject referralUser = userQueryService.getUserByName(referral);
if (null != referralUser) {
final String referralId = referralUser.optString(Keys.OBJECT_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.b3log.latke.servlet.HTTPRequestContext;
import org.b3log.latke.servlet.advice.BeforeRequestProcessAdvice;
import org.b3log.latke.servlet.advice.RequestProcessAdviceException;
import org.b3log.latke.util.Strings;
import org.b3log.symphony.model.Article;
import org.b3log.symphony.model.Role;
import org.b3log.symphony.model.Tag;
Expand Down Expand Up @@ -101,7 +100,7 @@ public static void validateArticleFields(final HttpServletRequest request,

String articleTitle = requestJSONObject.optString(Article.ARTICLE_TITLE);
articleTitle = StringUtils.trim(articleTitle);
if (Strings.isEmptyOrNull(articleTitle) || articleTitle.length() > MAX_ARTICLE_TITLE_LENGTH) {
if (StringUtils.isBlank(articleTitle) || articleTitle.length() > MAX_ARTICLE_TITLE_LENGTH) {
throw new RequestProcessAdviceException(exception.put(Keys.MSG, langPropsService.get("articleTitleErrorLabel")));
}
if (optionQueryService.containReservedWord(articleTitle)) {
Expand Down Expand Up @@ -136,7 +135,7 @@ public static void validateArticleFields(final HttpServletRequest request,
for (int i = 0; i < tagTitles.length; i++) {
final String tagTitle = tagTitles[i].trim();

if (Strings.isEmptyOrNull(tagTitle)) {
if (StringUtils.isBlank(tagTitle)) {
throw new RequestProcessAdviceException(exception.put(Keys.MSG, langPropsService.get("tagsErrorLabel")));
}

Expand Down Expand Up @@ -172,7 +171,7 @@ public static void validateArticleFields(final HttpServletRequest request,

String articleContent = requestJSONObject.optString(Article.ARTICLE_CONTENT);
articleContent = StringUtils.trim(articleContent);
if (Strings.isEmptyOrNull(articleContent) || articleContent.length() > MAX_ARTICLE_CONTENT_LENGTH
if (StringUtils.isBlank(articleContent) || articleContent.length() > MAX_ARTICLE_CONTENT_LENGTH
|| articleContent.length() < MIN_ARTICLE_CONTENT_LENGTH) {
String msg = langPropsService.get("articleContentErrorLabel");
msg = msg.replace("{maxArticleContentLength}", String.valueOf(MAX_ARTICLE_CONTENT_LENGTH));
Expand Down Expand Up @@ -200,7 +199,7 @@ public static void validateArticleFields(final HttpServletRequest request,
}

if (rewardPoint > 0) {
if (Strings.isEmptyOrNull(articleRewardContnt) || articleRewardContnt.length() > MAX_ARTICLE_CONTENT_LENGTH
if (StringUtils.isBlank(articleRewardContnt) || articleRewardContnt.length() > MAX_ARTICLE_CONTENT_LENGTH
|| articleRewardContnt.length() < MIN_ARTICLE_CONTENT_LENGTH) {
String msg = langPropsService.get("articleRewardContentErrorLabel");
msg = msg.replace("{maxArticleRewardContentLength}", String.valueOf(MAX_ARTICLE_REWARD_CONTENT_LENGTH));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.b3log.latke.servlet.advice.BeforeRequestProcessAdvice;
import org.b3log.latke.servlet.advice.RequestProcessAdviceException;
import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings;
import org.b3log.symphony.model.Common;
import org.b3log.symphony.model.Role;
import org.b3log.symphony.model.UserExt;
Expand Down Expand Up @@ -94,7 +93,7 @@ public void doAdvice(final HTTPRequestContext context, final Map<String, Object>

String content = requestJSONObject.optString(Common.CONTENT);
content = StringUtils.trim(content);
if (Strings.isEmptyOrNull(content) || content.length() > MAX_CONTENT_LENGTH) {
if (StringUtils.isBlank(content) || content.length() > MAX_CONTENT_LENGTH) {
throw new RequestProcessAdviceException(new JSONObject().put(Keys.MSG, langPropsService.get("commentErrorLabel")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.b3log.latke.servlet.advice.BeforeRequestProcessAdvice;
import org.b3log.latke.servlet.advice.RequestProcessAdviceException;
import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings;
import org.b3log.symphony.model.Article;
import org.b3log.symphony.model.Comment;
import org.b3log.symphony.model.UserExt;
Expand Down Expand Up @@ -97,7 +96,7 @@ public static void validateCommentFields(final JSONObject requestJSONObject) thr
exception.put(Keys.STATUS_CODE, StatusCodes.ERR);

final String commentContent = StringUtils.trim(requestJSONObject.optString(Comment.COMMENT_CONTENT));
if (Strings.isEmptyOrNull(commentContent) || commentContent.length() > MAX_COMMENT_CONTENT_LENGTH) {
if (StringUtils.isBlank(commentContent) || commentContent.length() > MAX_COMMENT_CONTENT_LENGTH) {
throw new RequestProcessAdviceException(exception.put(Keys.MSG, langPropsService.get("commentErrorLabel")));
}

Expand All @@ -107,7 +106,7 @@ public static void validateCommentFields(final JSONObject requestJSONObject) thr

try {
final String articleId = requestJSONObject.optString(Article.ARTICLE_T_ID);
if (Strings.isEmptyOrNull(articleId)) {
if (StringUtils.isBlank(articleId)) {
throw new RequestProcessAdviceException(exception.put(Keys.MSG, langPropsService.get("commentArticleErrorLabel")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.b3log.latke.servlet.advice.BeforeRequestProcessAdvice;
import org.b3log.latke.servlet.advice.RequestProcessAdviceException;
import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings;
import org.b3log.symphony.model.Comment;
import org.b3log.symphony.service.ArticleQueryService;
import org.b3log.symphony.service.CommentQueryService;
Expand Down Expand Up @@ -96,7 +95,7 @@ private static void validateCommentFields(final JSONObject requestJSONObject) th
exception.put(Keys.STATUS_CODE, StatusCodes.ERR);

final String commentContent = StringUtils.trim(requestJSONObject.optString(Comment.COMMENT_CONTENT));
if (Strings.isEmptyOrNull(commentContent) || commentContent.length() > MAX_COMMENT_CONTENT_LENGTH) {
if (StringUtils.isBlank(commentContent) || commentContent.length() > MAX_COMMENT_CONTENT_LENGTH) {
throw new RequestProcessAdviceException(exception.put(Keys.MSG, langPropsService.get("commentErrorLabel")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.b3log.symphony.processor.advice.validate;

import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys;
import org.b3log.latke.ioc.inject.Inject;
import org.b3log.latke.ioc.inject.Named;
Expand All @@ -27,7 +28,6 @@
import org.b3log.latke.servlet.advice.BeforeRequestProcessAdvice;
import org.b3log.latke.servlet.advice.RequestProcessAdviceException;
import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings;
import org.b3log.symphony.model.Common;
import org.b3log.symphony.model.UserExt;
import org.b3log.symphony.service.UserQueryService;
Expand Down Expand Up @@ -73,7 +73,7 @@ public void doAdvice(final HTTPRequestContext context, final Map<String, Object>
}

final String userName = requestJSONObject.optString(User.USER_NAME);
if (Strings.isEmptyOrNull(userName)
if (StringUtils.isBlank(userName)
|| UserExt.COM_BOT_NAME.equals(userName) || UserExt.NULL_USER_NAME.equals(userName)) {
throw new RequestProcessAdviceException(new JSONObject().put(Keys.MSG, langPropsService.get("notFoundUserLabel")));
}
Expand Down
Loading

0 comments on commit eafd3ae

Please sign in to comment.