Skip to content

Commit

Permalink
♻️ b3log#880
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Feb 27, 2019
1 parent 9e8c943 commit 1d8d11a
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/b3log/symphony/event/CommentNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void action(final Event<JSONObject> event) {
}

final long num = commentRepository.count(numQuery);
final int page = (int) ((num / Symphonys.getInt("articleCommentsPageSize")) + 1);
final int page = (int) ((num / Symphonys.ARTICLE_COMMENTS_CNT) + 1);
chData.put(Pagination.PAGINATION_CURRENT_PAGE_NUM, page);

final JSONObject originalCmt = commentRepository.get(originalCmtId);
Expand All @@ -207,7 +207,7 @@ public void action(final Event<JSONObject> event) {
chData.put(Common.TIME_AGO, langPropsService.get("justNowLabel"));
chData.put(Comment.COMMENT_CREATE_TIME_STR, DateFormatUtils.format(chData.optLong(Comment.COMMENT_CREATE_TIME), "yyyy-MM-dd HH:mm:ss"));
String thankTemplate = langPropsService.get("thankConfirmLabel");
thankTemplate = thankTemplate.replace("{point}", String.valueOf(Symphonys.getInt("pointThankComment")))
thankTemplate = thankTemplate.replace("{point}", String.valueOf(Symphonys.POINT_THANK_COMMENT))
.replace("{user}", commenterName);
chData.put(Comment.COMMENT_T_THANK_LABEL, thankTemplate);
String cc = shortLinkQueryService.linkArticle(commentContent);
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/b3log/symphony/processor/AdminProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ public void exchangePoint(final RequestContext context) {
final JSONObject user = userQueryService.getUser(userId);
final int currentPoint = user.optInt(UserExt.USER_POINT);

if (currentPoint - point < Symphonys.getInt("pointExchangeMin")) {
if (currentPoint - point < Symphonys.POINT_EXCHANGE_MIN) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(context, "admin/error.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();

Expand All @@ -1789,7 +1789,7 @@ public void exchangePoint(final RequestContext context) {
return;
}

final String memo = String.valueOf(Math.floor(point / (double) Symphonys.getInt("pointExchangeUnit")));
final String memo = String.valueOf(Math.floor(point / (double) Symphonys.POINT_EXCHANGE_UNIT));

final String transferId = pointtransferMgmtService.transfer(userId, Pointtransfer.ID_C_SYS,
Pointtransfer.TRANSFER_TYPE_C_EXCHANGE, point, memo, System.currentTimeMillis(), "");
Expand Down Expand Up @@ -2584,11 +2584,11 @@ public void removeDomainTag(final RequestContext context) {
public void rebuildArticleSearchIndex(final RequestContext context) {
context.renderJSON(true);

if (Symphonys.getBoolean("es.enabled")) {
if (Symphonys.ES_ENABLED) {
searchMgmtService.rebuildESIndex();
}

if (Symphonys.getBoolean("algolia.enabled")) {
if (Symphonys.ALGOLIA_ENABLED) {
searchMgmtService.rebuildAlgoliaIndex();
}

Expand All @@ -2602,11 +2602,11 @@ public void rebuildArticleSearchIndex(final RequestContext context) {
final List<JSONObject> articles = articleQueryService.getValidArticles(pageNum, 50, Article.ARTICLE_TYPE_C_NORMAL, Article.ARTICLE_TYPE_C_CITY_BROADCAST);

for (final JSONObject article : articles) {
if (Symphonys.getBoolean("algolia.enabled")) {
if (Symphonys.ALGOLIA_ENABLED) {
searchMgmtService.updateAlgoliaDocument(article);
}

if (Symphonys.getBoolean("es.enabled")) {
if (Symphonys.ES_ENABLED) {
searchMgmtService.updateESDocument(article, Article.ARTICLE);
}
}
Expand Down Expand Up @@ -2647,11 +2647,11 @@ private void updateArticleSearchIndex(final JSONObject article) {
return;
}

if (Symphonys.getBoolean("algolia.enabled")) {
if (Symphonys.ALGOLIA_ENABLED) {
searchMgmtService.updateAlgoliaDocument(article);
}

if (Symphonys.getBoolean("es.enabled")) {
if (Symphonys.ES_ENABLED) {
searchMgmtService.updateESDocument(article, Article.ARTICLE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ public void showGuide(final RequestContext context) {
}
dataModel.put(User.USERS, users);

final long imgMaxSize = Symphonys.getLong("upload.img.maxSize");
final long imgMaxSize = Symphonys.UPLOAD_IMG_MAX;
dataModel.put("imgMaxSize", imgMaxSize);
final long fileMaxSize = Symphonys.getLong("upload.file.maxSize");
final long fileMaxSize = Symphonys.UPLOAD_FILE_MAX;
dataModel.put("fileMaxSize", fileMaxSize);

dataModelService.fillHeaderAndFooter(context, dataModel);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/b3log/symphony/processor/SearchProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void search(final RequestContext context) {

final AbstractFreeMarkerRenderer renderer = new SkinRenderer(context, "search-articles.ftl");

if (!Symphonys.getBoolean("es.enabled") && !Symphonys.getBoolean("algolia.enabled")) {
if (!Symphonys.ES_ENABLED && !Symphonys.ALGOLIA_ENABLED) {
context.sendError(HttpServletResponse.SC_NOT_FOUND);

return;
Expand All @@ -128,15 +128,15 @@ public void search(final RequestContext context) {
dataModel.put(Common.KEY, Escapes.escapeHTML(keyword));

final int pageNum = Paginator.getPage(request);
int pageSize = Symphonys.getInt("indexArticlesCnt");
int pageSize = Symphonys.ARTICLE_LIST_CNT;
final JSONObject user = Sessions.getUser();
if (null != user) {
pageSize = user.optInt(UserExt.USER_LIST_PAGE_SIZE);
}
final List<JSONObject> articles = new ArrayList<>();
int total = 0;

if (Symphonys.getBoolean("es.enabled")) {
if (Symphonys.ES_ENABLED) {
final JSONObject result = searchQueryService.searchElasticsearch(Article.ARTICLE, keyword, pageNum, pageSize);
if (null == result || 0 != result.optInt("status")) {
context.sendError(HttpServletResponse.SC_NOT_FOUND);
Expand All @@ -155,7 +155,7 @@ public void search(final RequestContext context) {
total = result.optInt("total");
}

if (Symphonys.getBoolean("algolia.enabled")) {
if (Symphonys.ALGOLIA_ENABLED) {
final JSONObject result = searchQueryService.searchAlgolia(keyword, pageNum, pageSize);
if (null == result) {
context.sendError(HttpServletResponse.SC_NOT_FOUND);
Expand All @@ -177,7 +177,7 @@ public void search(final RequestContext context) {
}

articleQueryService.organizeArticles(articles);
final Integer participantsCnt = Symphonys.getInt("latestArticleParticipantsCnt");
final Integer participantsCnt = Symphonys.ARTICLE_LIST_PARTICIPANTS_CNT;
articleQueryService.genParticipants(articles, participantsCnt);

dataModel.put(Article.ARTICLES, articles);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/b3log/symphony/processor/SkinRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ public Template getTemplate(final boolean isSearchEngineBot, final JSONObject us
try {
ret = Skins.SKIN.getTemplate(templateDirName + "/" + templateName);
} catch (final Exception e) {
if (Symphonys.get("skinDirName").equals(templateDirName) ||
Symphonys.get("mobileSkinDirName").equals(templateDirName)) {
if (Symphonys.SKIN_DIR_NAME.equals(templateDirName) ||
Symphonys.MOBILE_SKIN_DIR_NAME.equals(templateDirName)) {
throw e;
}

// Try to load default template
ret = Skins.SKIN.getTemplate(Symphonys.get("skinDirName") + "/" + templateName);
ret = Skins.SKIN.getTemplate(Symphonys.SKIN_DIR_NAME + "/" + templateName);
}

if (isSearchEngineBot) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/b3log/symphony/processor/TopProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void showTop(final RequestContext context) {
public void showLink(final RequestContext context) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(context, "top/link.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
final List<JSONObject> topLinks = linkQueryService.getTopLink(Symphonys.getInt("topCnt"));
final List<JSONObject> topLinks = linkQueryService.getTopLink(Symphonys.TOP_CNT);
dataModel.put(Common.TOP_LINKS, topLinks);

dataModelService.fillHeaderAndFooter(context, dataModel);
Expand All @@ -136,7 +136,7 @@ public void showLink(final RequestContext context) {
public void showBalance(final RequestContext context) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(context, "top/balance.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
final List<JSONObject> users = pointtransferQueryService.getTopBalanceUsers(Symphonys.getInt("topCnt"));
final List<JSONObject> users = pointtransferQueryService.getTopBalanceUsers(Symphonys.TOP_CNT);
dataModel.put(Common.TOP_BALANCE_USERS, users);

dataModelService.fillHeaderAndFooter(context, dataModel);
Expand All @@ -157,7 +157,7 @@ public void showBalance(final RequestContext context) {
public void showConsumption(final RequestContext context) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(context, "top/consumption.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
final List<JSONObject> users = pointtransferQueryService.getTopConsumptionUsers(Symphonys.getInt("topCnt"));
final List<JSONObject> users = pointtransferQueryService.getTopConsumptionUsers(Symphonys.TOP_CNT);
dataModel.put(Common.TOP_CONSUMPTION_USERS, users);

dataModelService.fillHeaderAndFooter(context, dataModel);
Expand All @@ -178,7 +178,7 @@ public void showConsumption(final RequestContext context) {
public void showCheckin(final RequestContext context) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(context, "top/checkin.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
final List<JSONObject> users = activityQueryService.getTopCheckinUsers(Symphonys.getInt("topCnt"));
final List<JSONObject> users = activityQueryService.getTopCheckinUsers(Symphonys.TOP_CNT);
dataModel.put(Common.TOP_CHECKIN_USERS, users);

dataModelService.fillHeaderAndFooter(context, dataModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void doAdvice(final RequestContext context) throws RequestProcessAdviceEx
final HttpServletRequest request = context.getRequest();
final String requestURI = context.requestURI();

final String[] skips = Symphonys.get("anonymousViewSkips").split(",");
final String[] skips = Symphonys.ANONYMOUS_VIEW_SKIPS.split(",");
for (final String skip : skips) {
if (AntPathMatcher.match(Latkes.getContextPath() + skip, requestURI)) {
return;
Expand Down Expand Up @@ -173,7 +173,7 @@ public void doAdvice(final RequestContext context) throws RequestProcessAdviceEx
}

uris.put(requestURI);
if (uris.length() > Symphonys.getInt("anonymousViewURIs")) {
if (uris.length() > Symphonys.ANONYMOUS_VIEW_URIS) {
throw new RequestProcessAdviceException(exception401);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public synchronized JSONObject collectEatingSnake(final String userId, final int
return ret;
}

final int max = Symphonys.getInt("pointActivityEatingSnakeCollectMax");
final int max = Symphonys.POINT_ACTIVITY_EATINGSNAKE_COLLECT_MAX;
final int amout = score > max ? max : score;

final boolean succ = null != pointtransferMgmtService.transfer(Pointtransfer.ID_C_SYS, userId,
Expand Down Expand Up @@ -251,7 +251,7 @@ public synchronized JSONObject submitCharacter(final String userId, final String
record.put(org.b3log.symphony.model.Character.CHARACTER_IMG, characterImg);
record.put(org.b3log.symphony.model.Character.CHARACTER_USER_ID, userId);

String characterId = "";
String characterId;
final Transaction transaction = characterRepository.beginTransaction();
try {
characterId = characterRepository.add(record);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public void thankComment(final String commentId, final String senderId) throws S
throw new ServiceException(langPropsService.get("thankSelfLabel"));
}

final int rewardPoint = Symphonys.getInt("pointThankComment");
final int rewardPoint = Symphonys.POINT_THANK_COMMENT;

if (rewardQueryService.isRewarded(senderId, commentId, Reward.TYPE_C_COMMENT)) {
return;
Expand Down Expand Up @@ -427,7 +427,7 @@ public synchronized String addComment(final JSONObject requestJSONObject) throws
final int balance = commenter.optInt(UserExt.USER_POINT);

if (Comment.COMMENT_ANONYMOUS_C_ANONYMOUS == commentAnonymous) {
final int anonymousPoint = Symphonys.getInt("anonymous.point");
final int anonymousPoint = Symphonys.ANONYMOUS_POST_POINT;
if (balance < anonymousPoint) {
String anonymousEnabelPointLabel = langPropsService.get("anonymousEnabelPointLabel");
anonymousEnabelPointLabel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class InvitecodeMgmtService {
@Transactional
public void expireInvitecodes() {
final long now = System.currentTimeMillis();
final long expired = now - Symphonys.getLong("invitecode.expired");
final long expired = now - Symphonys.INVITECODE_EXPIRED;

final Query query = new Query().setPage(1, Integer.MAX_VALUE).
setFilter(CompositeFilterOperator.and(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ public JSONObject getCommentedNotifications(final String userId, final int curre
commentedNotification.put(Notification.NOTIFICATION_HAS_READ, notification.optBoolean(Notification.NOTIFICATION_HAS_READ));
commentedNotification.put(Comment.COMMENT_T_ARTICLE_PERFECT, articlePerfect);
final String articleId = comment.optString(Comment.COMMENT_ON_ARTICLE_ID);
final int cmtPage = commentQueryService.getCommentPage(articleId, commentId, cmtViewMode, Symphonys.getInt("articleCommentsPageSize"));
final int cmtPage = commentQueryService.getCommentPage(articleId, commentId, cmtViewMode, Symphonys.ARTICLE_COMMENTS_CNT);
commentedNotification.put(Comment.COMMENT_SHARP_URL, "/article/" + articleId + "?p=" + cmtPage
+ "&m=" + cmtViewMode + "#" + commentId);

Expand Down Expand Up @@ -998,7 +998,7 @@ public JSONObject getAtNotifications(final String userId, final int currentPageN

String userLinkVote = UserExt.getUserLink(voterUserName);
description = description.replace("{user}", userLinkVote);
final String cmtVoteURL = commentQueryService.getCommentURL(commentId, cmtViewMode, Symphonys.getInt("articleCommentsPageSize"));
final String cmtVoteURL = commentQueryService.getCommentURL(commentId, cmtViewMode, Symphonys.ARTICLE_COMMENTS_CNT);
atNotification.put(Common.DESCRIPTION, description.replace("{article}", Emotions.convert(cmtVoteURL)));
rslts.add(atNotification);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class PostExportService {
* @return download URL, returns {@code "-1"} if in sufficient balance, returns {@code null} if other exceptions
*/
public String exportPosts(final String userId) {
final int pointDataExport = Symphonys.getInt("pointDataExport");
final int pointDataExport = Symphonys.POINT_DATA_EXPORT;
try {
final JSONObject user = userRepository.get(userId);
final int balance = user.optInt(UserExt.USER_POINT);
Expand Down Expand Up @@ -207,12 +207,12 @@ public String exportPosts(final String userId) {
final byte[] zipData = IOUtils.toByteArray(inputStream);

if (FileUploadProcessor.QN_ENABLED) {
final Auth auth = Auth.create(Symphonys.get("qiniu.accessKey"), Symphonys.get("qiniu.secretKey"));
final Auth auth = Auth.create(Symphonys.UPLOAD_QINIU_AK, Symphonys.UPLOAD_QINIU_SK);
final UploadManager uploadManager = new UploadManager(new Configuration());
uploadManager.put(zipData, fileKey, auth.uploadToken(Symphonys.get("qiniu.bucket")),
uploadManager.put(zipData, fileKey, auth.uploadToken(Symphonys.UPLOAD_QINIU_BUCKET),
null, "application/zip", false);

return Symphonys.get("qiniu.domain") + "/" + fileKey;
return Symphonys.UPLOAD_QINIU_DOMAIN + "/" + fileKey;
} else {
fileKey = FileUploadProcessor.genFilePath(fileKey);
final String filePath = FileUploadProcessor.UPLOAD_DIR + fileKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public JSONObject getReports(final JSONObject requestJSONObject) {
if (null != comment) {
final String commentId = comment.optString(Keys.OBJECT_ID);
final int cmtViewMode = UserExt.USER_COMMENT_VIEW_MODE_C_REALTIME;
reportData = commentQueryService.getCommentURL(commentId, cmtViewMode, Symphonys.getInt("articleCommentsPageSize"));
reportData = commentQueryService.getCommentURL(commentId, cmtViewMode, Symphonys.ARTICLE_COMMENTS_CNT);
}

break;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/b3log/symphony/util/Sessions.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public static String login(final HttpServletResponse response,
cookieJSONObject.put(Keys.TOKEN, user.optString(User.USER_PASSWORD) + COOKIE_ITEM_SEPARATOR + random);
cookieJSONObject.put(Common.REMEMBER_LOGIN, rememberLogin);

final String ret = Crypts.encryptByAES(cookieJSONObject.toString(), Symphonys.get("cookie.secret"));
final String ret = Crypts.encryptByAES(cookieJSONObject.toString(), Symphonys.COOKIE_SECRET);
final Cookie cookie = new Cookie(COOKIE_NAME, ret);

cookie.setPath("/");
Expand Down Expand Up @@ -389,7 +389,7 @@ public static JSONObject currentUser(final HttpServletRequest request) {
continue;
}

final String value = Crypts.decryptByAES(cookie.getValue(), Symphonys.get("cookie.secret"));
final String value = Crypts.decryptByAES(cookie.getValue(), Symphonys.COOKIE_SECRET);
final JSONObject cookieJSONObject = new JSONObject(value);

final String userId = cookieJSONObject.optString(Keys.OBJECT_ID);
Expand Down

0 comments on commit 1d8d11a

Please sign in to comment.