Commit 295132c3 authored by Liang Ding's avatar Liang Ding

后台验证已加,for #23

parent c8e34a60
......@@ -5,6 +5,14 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h2>Release 0.4.6 - Jul 1, 2012</h2>
<ul>
<li><a href="https://github.com/b3log/b3log-solo/issues/10">10 评论表情后台管理不显示</a></li>
<li><a href="https://github.com/b3log/b3log-solo/issues/12">12 编辑自定义导航报错</a></li>
<li><a href="https://github.com/b3log/b3log-solo/issues/15">15 sitemap.xml 导航生成重复</a></li>
<li><a href="https://github.com/b3log/b3log-solo/issues/17">17 默认皮肤改为 ease</a></li>
<li><a href="https://github.com/b3log/b3log-solo/issues/27">27 自定义导航后台链接问题</a></li>
</ul>
<h2>Release 0.4.5 - Jun 1, 2012</h2>
<ul>
<li><a href="http://code.google.com/p/b3log-solo/issues/detail?id=302">302 文章加密</a></li>
......
......@@ -28,7 +28,10 @@ import org.b3log.latke.annotation.RequestProcessor;
import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.servlet.HTTPRequestContext;
import org.b3log.latke.servlet.HTTPRequestMethod;
import org.b3log.latke.user.UserService;
import org.b3log.latke.user.UserServiceFactory;
import org.b3log.latke.util.Locales;
import org.b3log.solo.model.Common;
import org.b3log.solo.processor.renderer.ConsoleRenderer;
import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.service.PreferenceQueryService;
......@@ -38,7 +41,7 @@ import org.json.JSONObject;
* Error processor.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.0, May 18, 2012
* @version 1.0.0.1, Jun 20, 2012
* @since 0.4.5
*/
@RequestProcessor
......@@ -60,6 +63,10 @@ public final class ErrorProcessor {
* Language service.
*/
private LangPropsService langPropsService = LangPropsService.getInstance();
/**
* User service.
*/
private static UserService userService = UserServiceFactory.getUserService();
/**
* Shows the user template page.
......@@ -90,6 +97,8 @@ public final class ErrorProcessor {
filler.fillBlogHeader(request, dataModel, preference);
filler.fillBlogFooter(dataModel, preference);
dataModel.put(Common.LOGIN_URL, userService.createLoginURL(Common.ADMIN_INDEX_URI));
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
......
......@@ -41,7 +41,7 @@ import org.json.JSONObject;
* Preference console request processing.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.2, Mar 28, 2012
* @version 1.0.0.3, Jun 20, 2012
* @since 0.4.0
*/
@RequestProcessor
......@@ -241,13 +241,17 @@ public final class PreferenceConsole {
* {
* "sc": boolean,
* "preference": {
* "recentArticleDisplayCount": int,
* "mostViewArticleDisplayCount": int,
* "recentCommentDisplayCount": int,
* "mostUsedTagDisplayCount": int,
* "articleListDisplayCount": int,
* "articleListPaginationWindowSize": int,
* "mostCommentArticleDisplayCount": int,
* "externalRelevantArticlesDisplayCount": int,
* "relevantArticlesDisplayCount": int,
* "randomArticlesDisplayCount": int,
* "blogTitle": "",
* "blogSubtitle": "",
* "mostCommentArticleDisplayCount": int,
* "blogHost": "",
* "localeString": "",
* "timeZoneId": "",
......@@ -259,9 +263,6 @@ public final class PreferenceConsole {
* }, ....]",
* "noticeBoard": "",
* "htmlHead": "",
* "externalRelevantArticlesDisplayCount": int,
* "relevantArticlesDisplayCount": int,
* "randomArticlesDisplayCount": int,
* "adminEmail": "",
* "metaKeywords": "",
* "metaDescription": "",
......@@ -326,22 +327,23 @@ public final class PreferenceConsole {
* <pre>
* {
* "preference": {
* "recentArticleDisplayCount": int,
* "mostViewArticleDisplayCount": int,
* "recentCommentDisplayCount": int,
* "mostUsedTagDisplayCount": int,
* "articleListDisplayCount": int,
* "articleListPaginationWindowSize": int
* "articleListPaginationWindowSize": int,
* "mostCommentArticleDisplayCount": int,
* "externalRelevantArticlesDisplayCount": int,
* "relevantArticlesDisplayCount": int,
* "randomArticlesDisplayCount": int,
* "blogTitle": "",
* "blogSubtitle": "",
* "mostCommentArticleDisplayCount": int,
* "skinDirName": "",
* "blogHost": "",
* "localeString": "",
* "timeZoneId": "",
* "noticeBoard": "",
* "htmlHead": "",
* "externalRelevantArticlesDisplayCount": int,
* "relevantArticlesDisplayCount": int,
* "randomArticlesDisplayCount": int,
* "metaKeywords": "",
* "metaDescription": "",
* "enableArticleUpdateHint": boolean,
......@@ -376,14 +378,17 @@ public final class PreferenceConsole {
final JSONObject preference = requestJSONObject.getJSONObject(Preference.PREFERENCE);
preferenceMgmtService.updatePreference(preference);
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
if (isInvalid(preference, ret)) {
return;
}
preferenceMgmtService.updatePreference(preference);
ret.put(Keys.STATUS_CODE, true);
ret.put(Keys.MSG, langPropsService.get("updateSuccLabel"));
renderer.setJSONObject(ret);
} catch (final ServiceException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
......@@ -392,4 +397,106 @@ public final class PreferenceConsole {
jsonObject.put(Keys.MSG, e.getMessage());
}
}
/**
* Checks whether the specified preference is invalid and sets the specified response object.
*
* @param preference the specified preference
* @param responseObject the specified response object
* @return {@code true} if the specified preference is invalid, returns {@code false} otherwise
*/
private boolean isInvalid(final JSONObject preference, final JSONObject responseObject) {
responseObject.put(Keys.STATUS_CODE, false);
final StringBuilder errMsgBuilder = new StringBuilder('[' + langPropsService.get("paramSettingsLabel"));
errMsgBuilder.append(" - ");
String input = preference.optString(Preference.EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("externalRelevantArticlesDisplayCntLabel")).append("] ").append(langPropsService.get(
"nonNegativeIntegerOnlyLabel"));
responseObject.put(Keys.MSG, errMsgBuilder.toString());
return true;
}
input = preference.optString(Preference.RELEVANT_ARTICLES_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("relevantArticlesDisplayCntLabel")).append("] ").append(langPropsService.get(
"nonNegativeIntegerOnlyLabel"));
responseObject.put(Keys.MSG, errMsgBuilder.toString());
return true;
}
input = preference.optString(Preference.RANDOM_ARTICLES_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("randomArticlesDisplayCntLabel")).append("] ").append(langPropsService.get(
"nonNegativeIntegerOnlyLabel"));
responseObject.put(Keys.MSG, errMsgBuilder.toString());
return true;
}
input = preference.optString(Preference.MOST_COMMENT_ARTICLE_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexMostCommentArticleDisplayCntLabel")).append("] ").append(langPropsService.get(
"nonNegativeIntegerOnlyLabel"));
responseObject.put(Keys.MSG, errMsgBuilder.toString());
return true;
}
input = preference.optString(Preference.MOST_VIEW_ARTICLE_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexMostViewArticleDisplayCntLabel")).append("] ").append(langPropsService.get(
"nonNegativeIntegerOnlyLabel"));
responseObject.put(Keys.MSG, errMsgBuilder.toString());
return true;
}
input = preference.optString(Preference.RECENT_COMMENT_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexRecentCommentDisplayCntLabel")).append("] ").append(langPropsService.get(
"nonNegativeIntegerOnlyLabel"));
responseObject.put(Keys.MSG, errMsgBuilder.toString());
return true;
}
input = preference.optString(Preference.MOST_USED_TAG_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexTagDisplayCntLabel")).append("] ").append(langPropsService.get(
"nonNegativeIntegerOnlyLabel"));
responseObject.put(Keys.MSG, errMsgBuilder.toString());
return true;
}
input = preference.optString(Preference.ARTICLE_LIST_DISPLAY_COUNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("pageSizeLabel")).append("] ").append(langPropsService.get(
"nonNegativeIntegerOnlyLabel"));
responseObject.put(Keys.MSG, errMsgBuilder.toString());
return true;
}
input = preference.optString(Preference.ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("windowSizeLabel")).append("] ").append(langPropsService.get(
"nonNegativeIntegerOnlyLabel"));
responseObject.put(Keys.MSG, errMsgBuilder.toString());
return true;
}
return false;
}
/**
* Checks whether the specified input is a non-negative integer.
*
* @param input the specified input
* @return {@code true} if it is, returns {@code false} otherwise
*/
private boolean isNonNegativeInteger(final String input) {
try {
return 0 <= Integer.valueOf(input);
} catch (final Exception e) {
return false;
}
}
}
......@@ -16,7 +16,7 @@
#
# Description: B3log Solo language configurations(en_US).
# Version: 2.0.9.2, May 22, 2012
# Version: 2.0.9.3, Jun 20, 2012
# Author: Liang Ding
# Author: Liyuan Li
#
......@@ -184,15 +184,25 @@ categoryLabel=Category
noticeBoard1Label=Notice Board:
noticeBoardLabel=Notice Board
htmlhead1Label=HTML head:
indexTagDisplayCntLabel=Index Tag Display Count
indexTagDisplayCnt1Label=Index Tag Display Count:
indexRecentArticleDisplayCntLabel=Recent Article Display Count
indexRecentArticleDisplayCnt1Label=Recent Article Display Count:
indexRecentCommentDisplayCntLabel=Recent Comment Display Count
indexRecentCommentDisplayCnt1Label=Recent Comment Display Count:
indexMostCommentArticleDisplayCntLabel=Most Comment Article Display Count
indexMostCommentArticleDisplayCnt1Label=Most Comment Article Display Count:
indexMostViewArticleDisplayCntLabel=Most View Article Display Count
indexMostViewArticleDisplayCnt1Label=Most View Article Display Count:
relevantArticlesDisplayCntLabel=Relevant Article Display Count
relevantArticlesDisplayCnt1Label=Relevant Article Display Count:
randomArticlesDisplayCntLabel=Random Article Display Count
randomArticlesDisplayCnt1Label=Random Article Display Count:
externalRelevantArticlesDisplayCntLabel=External Relevant Article Display Count
externalRelevantArticlesDisplayCnt1Label=External Relevant Article Display Count:
windowSizeLabel=Pagination Window Size
windowSize1Label=Pagination Window Size:
pageSizeLabel=Pagination Page Size
pageSize1Label=Pagination Page Size:
blogTitle1Label=Blog Title:
blogSubtitle1Label=Blog Subtitle:
......@@ -298,6 +308,7 @@ nameTooLongLabel=Sorry, your username must be between 2 and 20 characters long.
mailCannotEmptyLabel=Mail is empty
mailInvalidLabel=Mail is invalid
urlInvalidLabel=URL is invalid
nonNegativeIntegerOnlyLabel=Non-Negative integer only
commentContentCannotEmptyLabel=Sorry, your content must be between 2 and 500 characters long.
captchaCannotEmptyLabel=Captcha is empty
loadingLabel=Loading....
......
......@@ -16,7 +16,7 @@
#
# Description: B3log Solo default language configurations(zh_CN).
# Version: 2.0.9.8, May 22, 2012
# Version: 2.0.9.9, Jun 20, 2012
# Author: Liang Ding
# Author: Liyuan Li
#
......@@ -184,15 +184,25 @@ categoryLabel=\u5206\u7c7b
noticeBoard1Label=\u516c\u544a\uff1a
noticeBoardLabel=\u516c\u544a
htmlhead1Label=HTML head\uff1a
indexTagDisplayCnt1Label= \u9996\u9875\u6807\u7b7e\u663e\u793a\u6570\uff1a
indexTagDisplayCntLabel=\u9996\u9875\u6807\u7b7e\u663e\u793a\u6570
indexTagDisplayCnt1Label=\u9996\u9875\u6807\u7b7e\u663e\u793a\u6570\uff1a
indexRecentArticleDisplayCntLabel=\u6700\u65b0\u6587\u7ae0\u663e\u793a\u6570\u76ee
indexRecentArticleDisplayCnt1Label=\u6700\u65b0\u6587\u7ae0\u663e\u793a\u6570\u76ee\uff1a
indexRecentCommentDisplayCntLabel=\u6700\u65b0\u8bc4\u8bba\u663e\u793a\u6570\u76ee
indexRecentCommentDisplayCnt1Label=\u6700\u65b0\u8bc4\u8bba\u663e\u793a\u6570\u76ee\uff1a
indexMostCommentArticleDisplayCntLabel=\u8bc4\u8bba\u6700\u591a\u6587\u7ae0\u663e\u793a\u6570\u76ee
indexMostCommentArticleDisplayCnt1Label=\u8bc4\u8bba\u6700\u591a\u6587\u7ae0\u663e\u793a\u6570\u76ee\uff1a
indexMostViewArticleDisplayCnt1Label=\u8bbf\u95ee\u6700\u591a\u6700\u591a\u6587\u7ae0\u663e\u793a\u6570\u76ee\uff1a
indexMostViewArticleDisplayCntLabel=\u8bbf\u95ee\u6700\u591a\u6587\u7ae0\u663e\u793a\u6570\u76ee
indexMostViewArticleDisplayCnt1Label=\u8bbf\u95ee\u6700\u591a\u6587\u7ae0\u663e\u793a\u6570\u76ee\uff1a
relevantArticlesDisplayCntLabel=\u76f8\u5173\u9605\u8bfb\u663e\u793a\u6570\u76ee
relevantArticlesDisplayCnt1Label=\u76f8\u5173\u9605\u8bfb\u663e\u793a\u6570\u76ee\uff1a
randomArticlesDisplayCntLabel=\u968f\u673a\u9605\u8bfb\u663e\u793a\u6570\u76ee
randomArticlesDisplayCnt1Label=\u968f\u673a\u9605\u8bfb\u663e\u793a\u6570\u76ee\uff1a
externalRelevantArticlesDisplayCntLabel=\u7ad9\u5916\u76f8\u5173\u9605\u8bfb\u663e\u793a\u6570\u76ee
externalRelevantArticlesDisplayCnt1Label=\u7ad9\u5916\u76f8\u5173\u9605\u8bfb\u663e\u793a\u6570\u76ee\uff1a
windowSizeLabel=\u5206\u9875\u9875\u7801\u6700\u5927\u5bbd\u5ea6
windowSize1Label=\u5206\u9875\u9875\u7801\u6700\u5927\u5bbd\u5ea6\uff1a
pageSizeLabel=\u5206\u9875\u6bcf\u9875\u663e\u793a\u6587\u7ae0\u6570
pageSize1Label=\u5206\u9875\u6bcf\u9875\u663e\u793a\u6587\u7ae0\u6570\uff1a
blogTitle1Label=\u535a\u5ba2\u6807\u9898\uff1a
blogSubtitle1Label=\u535a\u5ba2\u5b50\u6807\u9898\uff1a
......@@ -298,6 +308,7 @@ nameTooLongLabel=\u59d3\u540d\u53ea\u80fd\u4e3a 2 \u5230 20 \u4e2a\u5b57\u7b26\u
mailCannotEmptyLabel=\u90ae\u7bb1\u4e0d\u80fd\u4e3a\u7a7a\uff01
mailInvalidLabel=\u90ae\u7bb1\u683c\u5f0f\u4e0d\u6b63\u786e\uff01
urlInvalidLabel=\u94fe\u63a5\u683c\u5f0f\u4e0d\u6b63\u786e\uff01
nonNegativeIntegerOnlyLabel=\u53ea\u80fd\u4e3a\u975e\u8d1f\u6574\u6570\uff01
commentContentCannotEmptyLabel=\u8bc4\u8bba\u5185\u5bb9\u53ea\u80fd\u4e3a 2 \u5230 500 \u4e2a\u5b57\u7b26\uff01
captchaCannotEmptyLabel=\u9a8c\u8bc1\u7801\u4e0d\u80fd\u4e3a\u7a7a\uff01
loadingLabel=\u8f7d\u5165\u4e2d....
......
......@@ -5,6 +5,14 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h2>Release 0.4.6 - Jul 1, 2012</h2>
<ul>
<li><a href="https://github.com/b3log/b3log-solo/issues/10">10 评论表情后台管理不显示</a></li>
<li><a href="https://github.com/b3log/b3log-solo/issues/12">12 编辑自定义导航报错</a></li>
<li><a href="https://github.com/b3log/b3log-solo/issues/15">15 sitemap.xml 导航生成重复</a></li>
<li><a href="https://github.com/b3log/b3log-solo/issues/17">17 默认皮肤改为 ease</a></li>
<li><a href="https://github.com/b3log/b3log-solo/issues/27">27 自定义导航后台链接问题</a></li>
</ul>
<h2>Release 0.4.5 - Jun 1, 2012</h2>
<ul>
<li><a href="http://code.google.com/p/b3log-solo/issues/detail?id=302">302 文章加密</a></li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment