Commit c9e1e51e authored by Liang Ding's avatar Liang Ding

#12042

重构代码引用的 key
parent 7c1b49c2
......@@ -40,7 +40,7 @@ import org.b3log.latke.servlet.annotation.RequestProcessor;
import org.b3log.latke.servlet.renderer.TextXMLRenderer;
import org.b3log.latke.util.MD5;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Tag;
import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.service.ArticleMgmtService;
......@@ -71,7 +71,7 @@ import org.jsoup.Jsoup;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.11, May 17, 2013
* @version 1.0.0.12, Nov 20, 2015
* @since 0.4.0
*/
@RequestProcessor
......@@ -629,7 +629,7 @@ public class MetaWeblogAPI {
throws JSONException {
final String blogId = preference.getString(Keys.OBJECT_ID);
final String blogTitle = StringEscapeUtils.escapeXml(preference.getString(Preference.BLOG_TITLE));
final String blogTitle = StringEscapeUtils.escapeXml(preference.getString(Option.ID_C_BLOG_TITLE));
final StringBuilder stringBuilder = new StringBuilder("<member><name>blogid</name><value>").append(blogId).append(
"</value></member>");
......
......@@ -32,7 +32,7 @@ import org.b3log.latke.servlet.renderer.JSONRenderer;
import org.b3log.latke.util.Requests;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.service.ArticleMgmtService;
import org.b3log.solo.service.ArticleQueryService;
import org.b3log.solo.service.PreferenceQueryService;
......@@ -46,7 +46,7 @@ import org.jsoup.Jsoup;
* Article receiver (from B3log Symphony).
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.5, Mar 18, 2013
* @version 1.0.0.6, Nov 20, 2015
* @since 0.5.5
*/
@RequestProcessor
......@@ -132,7 +132,7 @@ public class ArticleReceiver {
final String userB3Key = article.optString("userB3Key");
final JSONObject preference = preferenceQueryService.getPreference();
if (!userB3Key.equals(preference.optString(Preference.KEY_OF_SOLO))) {
if (!userB3Key.equals(preference.optString(Option.ID_C_KEY_OF_SOLO))) {
LOGGER.log(Level.WARN, "B3 key not match, ignored add article");
return;
......@@ -224,7 +224,7 @@ public class ArticleReceiver {
final String userB3Key = article.optString("userB3Key");
final JSONObject preference = preferenceQueryService.getPreference();
if (!userB3Key.equals(preference.optString(Preference.KEY_OF_SOLO))) {
if (!userB3Key.equals(preference.optString(Option.ID_C_KEY_OF_SOLO))) {
LOGGER.log(Level.WARN, "B3 key not match, ignored update article");
return;
......
......@@ -42,7 +42,7 @@ import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.service.ArticleMgmtService;
......@@ -57,7 +57,7 @@ import org.json.JSONObject;
* Comment receiver (from B3log Symphony).
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.9, Nov 5, 2015
* @version 1.1.0.10, Nov 20, 2015
* @since 0.5.5
*/
@RequestProcessor
......@@ -98,11 +98,6 @@ public class CommentReceiver {
@Inject
private ArticleRepository articleRepository;
/**
* Default user thumbnail.
*/
private static final String DEFAULT_USER_THUMBNAIL = "default-user-thumbnail.png";
/**
* URL fetch service.
*/
......@@ -168,7 +163,7 @@ public class CommentReceiver {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
final JSONObject symphonyCmt = requestJSONObject.optJSONObject(Comment.COMMENT);
final JSONObject preference = preferenceQueryService.getPreference();
final String keyOfSolo = preference.optString(Preference.KEY_OF_SOLO);
final String keyOfSolo = preference.optString(Option.ID_C_KEY_OF_SOLO);
final String key = symphonyCmt.optString("userB3Key");
if (Strings.isEmptyOrNull(keyOfSolo) || !keyOfSolo.equals(key)) {
......
......@@ -32,7 +32,7 @@ import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.impl.CommentRepositoryImpl;
import org.b3log.solo.service.PreferenceQueryService;
......@@ -42,7 +42,7 @@ import org.json.JSONObject;
* This listener is responsible for processing article comment reply.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.6, Oct 1, 2015
* @version 1.1.1.7, Nov 20, 2015
* @since 0.3.1
*/
public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSONObject> {
......@@ -99,8 +99,8 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
throw new EventException("Not found preference");
}
final String blogTitle = preference.getString(Preference.BLOG_TITLE);
final String adminEmail = preference.getString(Preference.ADMIN_EMAIL);
final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String adminEmail = preference.getString(Option.ID_C_ADMIN_EMAIL);
final String commentContent = comment.getString(Comment.COMMENT_CONTENT).replaceAll(SoloServletListener.ENTER_ESC, "<br/>");
final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL);
......
......@@ -32,8 +32,8 @@ import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Page;
import org.b3log.solo.model.Preference;
import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.impl.CommentRepositoryImpl;
import org.b3log.solo.service.PreferenceQueryService;
......@@ -44,7 +44,7 @@ import org.json.JSONObject;
* This listener is responsible for processing page comment reply.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.2, May 17, 2013
* @version 1.0.1.3, Nov 20, 2015
* @since 0.3.1
*/
public final class PageCommentReplyNotifier extends AbstractEventListener<JSONObject> {
......@@ -94,8 +94,8 @@ public final class PageCommentReplyNotifier extends AbstractEventListener<JSONOb
throw new EventException("Not found preference");
}
final String blogTitle = preference.getString(Preference.BLOG_TITLE);
final String adminEmail = preference.getString(Preference.ADMIN_EMAIL);
final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String adminEmail = preference.getString(Option.ID_C_ADMIN_EMAIL);
final String commentContent = comment.getString(Comment.COMMENT_CONTENT).replaceAll(SoloServletListener.ENTER_ESC, "<br/>");
final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL);
......
......@@ -31,7 +31,7 @@ import org.b3log.latke.urlfetch.URLFetchService;
import org.b3log.latke.urlfetch.URLFetchServiceFactory;
import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.service.PreferenceQueryService;
import org.json.JSONObject;
......@@ -48,7 +48,7 @@ import org.json.JSONObject;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.3, May 17, 2013
* @version 1.0.0.4, Nov 20, 2015
* @see UpdateArticleGoogleBlogSearchPinger
* @since 0.3.1
*/
......@@ -88,7 +88,7 @@ public final class AddArticleGoogleBlogSearchPinger extends AbstractEventListene
articleTitle = article.getString(Article.ARTICLE_TITLE);
final JSONObject preference = preferenceQueryService.getPreference();
final String blogTitle = preference.getString(Preference.BLOG_TITLE);
final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
if (Latkes.getServePath().contains("localhost")) {
LOGGER.log(Level.INFO,
......
......@@ -31,7 +31,7 @@ import org.b3log.latke.urlfetch.URLFetchService;
import org.b3log.latke.urlfetch.URLFetchServiceFactory;
import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.service.PreferenceQueryService;
import org.json.JSONObject;
......@@ -48,7 +48,7 @@ import org.json.JSONObject;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.3, May 17, 2013
* @version 1.0.0.4, Nov 20, 2015
* @see AddArticleGoogleBlogSearchPinger
* @since 0.3.1
*/
......@@ -88,7 +88,7 @@ public final class UpdateArticleGoogleBlogSearchPinger extends AbstractEventList
articleTitle = article.getString(Article.ARTICLE_TITLE);
final JSONObject preference = preferenceQueryService.getPreference();
final String blogTitle = preference.getString(Preference.BLOG_TITLE);
final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
if (Latkes.getServePath().contains("localhost")) {
LOGGER.log(Level.INFO,
......
......@@ -36,7 +36,7 @@ import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.service.PreferenceQueryService;
import org.json.JSONObject;
......@@ -49,7 +49,7 @@ import org.json.JSONObject;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author ArmstrongCN
* @version 1.0.2.7, Jun 13, 2013
* @version 1.0.2.8, Nov 20, 2015
* @since 0.3.1
*/
public final class ArticleSender extends AbstractEventListener<JSONObject> {
......@@ -134,10 +134,10 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> {
requestJSONObject.put(Article.ARTICLE, article);
requestJSONObject.put(Common.BLOG_VERSION, SoloServletListener.VERSION);
requestJSONObject.put(Common.BLOG, "B3log Solo");
requestJSONObject.put(Preference.BLOG_TITLE, preference.getString(Preference.BLOG_TITLE));
requestJSONObject.put(Option.ID_C_BLOG_TITLE, preference.getString(Option.ID_C_BLOG_TITLE));
requestJSONObject.put("blogHost", Latkes.getServePath());
requestJSONObject.put("userB3Key", preference.optString(Preference.KEY_OF_SOLO));
requestJSONObject.put("clientAdminEmail", preference.optString(Preference.ADMIN_EMAIL));
requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
requestJSONObject.put("clientRuntimeEnv", Latkes.getRuntimeEnv().name());
httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));
......
......@@ -36,7 +36,7 @@ import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.service.PreferenceQueryService;
import org.json.JSONObject;
......@@ -48,7 +48,7 @@ import org.json.JSONObject;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1, May 17, 2013
* @version 1.0.0.2, Nov 20, 2015
* @since 0.6.0
*/
public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
......@@ -133,10 +133,10 @@ public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
requestJSONObject.put(Article.ARTICLE, article);
requestJSONObject.put(Common.BLOG_VERSION, SoloServletListener.VERSION);
requestJSONObject.put(Common.BLOG, "B3log Solo");
requestJSONObject.put(Preference.BLOG_TITLE, preference.getString(Preference.BLOG_TITLE));
requestJSONObject.put(Option.ID_C_BLOG_TITLE, preference.getString(Option.ID_C_BLOG_TITLE));
requestJSONObject.put("blogHost", Latkes.getServerHost() + ":" + Latkes.getServerPort());
requestJSONObject.put("userB3Key", preference.optString(Preference.KEY_OF_SOLO));
requestJSONObject.put("clientAdminEmail", preference.optString(Preference.ADMIN_EMAIL));
requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
requestJSONObject.put("clientRuntimeEnv", Latkes.getRuntimeEnv().name());
httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));
......
......@@ -35,7 +35,7 @@ import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes;
import org.b3log.solo.event.rhythm.ArticleSender;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.service.PreferenceQueryService;
import org.json.JSONObject;
......@@ -44,7 +44,7 @@ import org.json.JSONObject;
* This listener is responsible for sending comment to B3log Symphony.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.3, Mar 5, 2013
* @version 1.0.0.4, Nov 20, 2015
* @since 0.5.5
*/
public final class CommentSender extends AbstractEventListener<JSONObject> {
......@@ -115,8 +115,8 @@ public final class CommentSender extends AbstractEventListener<JSONObject> {
requestJSONObject.put("clientRuntimeEnv", Latkes.getRuntimeEnv().name());
requestJSONObject.put("clientName", "B3log Solo");
requestJSONObject.put("clientHost", Latkes.getServerHost() + ":" + Latkes.getServerPort());
requestJSONObject.put("clientAdminEmail", preference.optString(Preference.ADMIN_EMAIL));
requestJSONObject.put("userB3Key", preference.optString(Preference.KEY_OF_SOLO));
requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));
......
......@@ -35,186 +35,6 @@ public final class Preference {
*/
public static final String PREFERENCE = "preference";
/**
* Blog title.
*/
public static final String BLOG_TITLE = "blogTitle";
/**
* Blog subtitle.
*/
public static final String BLOG_SUBTITLE = "blogSubtitle";
/**
* Relevant articles display count.
*/
public static final String RELEVANT_ARTICLES_DISPLAY_CNT = "relevantArticlesDisplayCount";
/**
* Random articles display count.
*/
public static final String RANDOM_ARTICLES_DISPLAY_CNT = "randomArticlesDisplayCount";
/**
* External relevant articles display count.
*/
public static final String EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT = "externalRelevantArticlesDisplayCount";
/**
* Recent article display count.
*/
public static final String RECENT_ARTICLE_DISPLAY_CNT = "recentArticleDisplayCount";
/**
* Recent comment display count.
*/
public static final String RECENT_COMMENT_DISPLAY_CNT = "recentCommentDisplayCount";
/**
* Most used tag display count.
*/
public static final String MOST_USED_TAG_DISPLAY_CNT = "mostUsedTagDisplayCount";
/**
* Most comment article display count.
*/
public static final String MOST_COMMENT_ARTICLE_DISPLAY_CNT = "mostCommentArticleDisplayCount";
/**
* Most view article display count.
*/
public static final String MOST_VIEW_ARTICLE_DISPLAY_CNT = "mostViewArticleDisplayCount";
/**
* Article list display count.
*/
public static final String ARTICLE_LIST_DISPLAY_COUNT = "articleListDisplayCount";
/**
* Article list pagination window size.
*/
public static final String ARTICLE_LIST_PAGINATION_WINDOW_SIZE = "articleListPaginationWindowSize";
/**
* Administrator's email.
*/
public static final String ADMIN_EMAIL = "adminEmail";
/**
* Locale string.
*/
public static final String LOCALE_STRING = "localeString";
/**
* Time zone id.
*/
public static final String TIME_ZONE_ID = "timeZoneId";
/**
* Notice board.
*/
public static final String NOTICE_BOARD = "noticeBoard";
/**
* HTML head.
*/
public static final String HTML_HEAD = "htmlHead";
/**
* Key of meta keywords.
*/
public static final String META_KEYWORDS = "metaKeywords";
/**
* Key of meta description.
*/
public static final String META_DESCRIPTION = "metaDescription";
/**
* Key of article update hint flag.
*/
public static final String ENABLE_ARTICLE_UPDATE_HINT = "enableArticleUpdateHint";
/**
* Key of signs.
*/
public static final String SIGNS = "signs";
/**
* Key of key of Solo.
*/
public static final String KEY_OF_SOLO = "keyOfSolo";
/**
* Key of allow visit draft via permalink.
*/
public static final String ALLOW_VISIT_DRAFT_VIA_PERMALINK = "allowVisitDraftViaPermalink";
/**
* Key of allow register.
*/
public static final String ALLOW_REGISTER = "allowRegister";
/**
* Key of version.
*/
public static final String VERSION = "version";
/**
* Key of article list display style.
*
* <p>
* Optional values:
* <ul>
* <li>"titleOnly"</li>
* <li>"titleAndContent"</li>
* <li>"titleAndAbstract"</li>
* </ul>
* </p>
*/
public static final String ARTICLE_LIST_STYLE = "articleListStyle";
/**
* Key of reply notification template.
*/
public static final String REPLY_NOTIFICATION_TEMPLATE = "replyNotificationTemplate";
/**
* Key of article/page comment-able.
*/
public static final String COMMENTABLE = "commentable";
/**
* Key of feed (Atom/RSS) output mode.
*
* <p>
* Optional values:
* <ul>
* <li>"abstract"</li>
* <li>"fullContent"</li>
* </ul>
* </p>
*/
public static final String FEED_OUTPUT_MODE = "feedOutputMode";
/**
* Key of feed (Atom/RSS) output entry count.
*/
public static final String FEED_OUTPUT_CNT = "feedOutputCnt";
/**
* Key of editor type.
*
* Optional values:
* <p>
* <ul>
* <li>"tinyMCE"</li>
* <li>"CodeMirror-Markdown"</li>
* </ul>
* </p>
*/
public static final String EDITOR_TYPE = "editorType";
/**
* Private default constructor.
*/
......
......@@ -39,7 +39,6 @@ import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference;
import org.b3log.solo.service.OptionMgmtService;
import org.b3log.solo.service.OptionQueryService;
import org.b3log.solo.service.PreferenceQueryService;
......@@ -52,7 +51,7 @@ import org.json.JSONObject;
* Broadcast chance processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.9, Jun 13, 2013
* @version 1.0.0.10, Nov 20, 2015
* @since 0.6.0
*/
@RequestProcessor
......@@ -285,11 +284,11 @@ public class ChanceProcessor {
final JSONObject broadcast = requestJSONObject.getJSONObject("broadcast");
final JSONObject preference = preferenceQueryService.getPreference();
final String b3logKey = preference.getString(Preference.KEY_OF_SOLO);
final String email = preference.getString(Preference.ADMIN_EMAIL);
final String b3logKey = preference.getString(Option.ID_C_KEY_OF_SOLO);
final String email = preference.getString(Option.ID_C_ADMIN_EMAIL);
final String clientName = "B3log Solo";
final String clientVersion = SoloServletListener.VERSION;
final String clientTitle = preference.getString(Preference.BLOG_TITLE);
final String clientTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String clientRuntimeEnv = Latkes.getRuntimeEnv().name();
final JSONObject broadcastRequest = new JSONObject();
......
......@@ -38,7 +38,7 @@ import org.b3log.latke.util.MD5;
import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Statistic;
import org.b3log.solo.service.ArticleQueryService;
import org.b3log.solo.service.PreferenceQueryService;
......@@ -53,7 +53,7 @@ import org.json.JSONObject;
* Blog processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.3, Mar 12, 2015
* @version 1.2.0.4, Nov 20, 2015
* @since 0.4.6
*/
@RequestProcessor
......@@ -183,7 +183,7 @@ public class BlogProcessor {
requestJSONObject.put(User.USER_NAME, admin.getString(User.USER_NAME));
requestJSONObject.put(User.USER_EMAIL, admin.getString(User.USER_EMAIL));
requestJSONObject.put(User.USER_PASSWORD, admin.getString(User.USER_PASSWORD));
requestJSONObject.put("userB3Key", preference.optString(Preference.KEY_OF_SOLO));
requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
requestJSONObject.put("clientHost", Latkes.getServePath());
httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));
......
......@@ -40,7 +40,7 @@ import org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer;
import org.b3log.latke.util.Locales;
import org.b3log.latke.util.Requests;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.processor.renderer.ConsoleRenderer;
import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.service.PreferenceQueryService;
......@@ -53,7 +53,7 @@ import org.json.JSONObject;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:385321165@qq.com">DASHU</a>
* @version 1.1.2.5, Jun 13, 2015
* @version 1.1.2.6, Nov 20, 2015
* @since 0.3.1
*/
@RequestProcessor
......@@ -110,7 +110,7 @@ public class IndexProcessor {
final int currentPageNum = getCurrentPageNum(requestURI);
final JSONObject preference = preferenceQueryService.getPreference();
Skins.fillLangs(preference.optString(Preference.LOCALE_STRING), (String) request.getAttribute(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) request.getAttribute(Keys.TEMAPLTE_DIR_NAME), dataModel);
filler.fillIndexArticles(request, dataModel, currentPageNum, preference);
......
......@@ -43,7 +43,6 @@ import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference;
import org.b3log.solo.processor.renderer.ConsoleRenderer;
import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.repository.OptionRepository;
......@@ -62,13 +61,13 @@ import java.util.Map;
/**
* Login/logout processor.
* <p/>
*
* <p>Initializes administrator</p>.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @author <a href="mailto:dongxu.wang@acm.org">Dongxu Wang</a>
* @version 1.1.1.6, Oct 26, 2013
* @version 1.1.1.7, Nov 20, 2015
* @since 0.3.1
*/
@RequestProcessor
......@@ -401,7 +400,7 @@ public class LoginProcessor {
ServiceException, IOException, RepositoryException {
final JSONObject preference = preferenceQueryService.getPreference();
final String token = new Randoms().nextStringWithMD5();
final String adminEmail = preference.getString(Preference.ADMIN_EMAIL);
final String adminEmail = preference.getString(Option.ID_C_ADMIN_EMAIL);
final String mailSubject = langPropsService.get("resetPwdMailSubject");
final String mailBody = langPropsService.get("resetPwdMailBody") + " " + Latkes.getServePath() + "/forgot?token=" + token
+ "&login=" + userEmail;
......@@ -458,7 +457,7 @@ public class LoginProcessor {
dataModel.put(Common.YEAR, String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
dataModel.put(Common.VERSION, SoloServletListener.VERSION);
dataModel.put(Common.STATIC_RESOURCE_VERSION, Latkes.getStaticResourceVersion());
dataModel.put(Preference.BLOG_TITLE, preference.getString(Preference.BLOG_TITLE));
dataModel.put(Option.ID_C_BLOG_TITLE, preference.getString(Option.ID_C_BLOG_TITLE));
final String token = request.getParameter("token");
final String email = request.getParameter("login");
......
......@@ -35,8 +35,8 @@ import org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer;
import org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer;
import org.b3log.latke.util.Stopwatchs;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Page;
import org.b3log.solo.model.Preference;
import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.service.CommentQueryService;
import org.b3log.solo.service.PreferenceQueryService;
......@@ -50,7 +50,7 @@ import org.json.JSONObject;
* Page processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.4, Nov 17, 2013
* @version 1.1.0.5, Nov 20, 2015
* @since 0.3.1
*/
@RequestProcessor
......@@ -116,7 +116,7 @@ public class PageProcessor {
return;
}
Skins.fillLangs(preference.getString(Preference.LOCALE_STRING), (String) request.getAttribute(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.getString(Option.ID_C_LOCALE_STRING), (String) request.getAttribute(Keys.TEMAPLTE_DIR_NAME), dataModel);
final Map<String, String> langs = langPropsService.getAll(Latkes.getLocale());
......@@ -130,7 +130,7 @@ public class PageProcessor {
final String pageId = page.getString(Keys.OBJECT_ID);
page.put(Common.COMMENTABLE, preference.getBoolean(Preference.COMMENTABLE) && page.getBoolean(Page.PAGE_COMMENTABLE));
page.put(Common.COMMENTABLE, preference.getBoolean(Option.ID_C_COMMENTABLE) && page.getBoolean(Page.PAGE_COMMENTABLE));
page.put(Common.PERMALINK, page.getString(Page.PAGE_PERMALINK));
dataModel.put(Page.PAGE, page);
final List<JSONObject> comments = commentQueryService.getComments(pageId);
......
......@@ -68,7 +68,7 @@ import org.json.JSONObject;
* See AuthFilter filter configurations in web.xml for authentication.</p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.10, Nov 8, 2015
* @version 1.2.0.11, Nov 20, 2015
* @since 0.3.1
*/
@RequestProcessor
......@@ -247,19 +247,19 @@ public class RepairProcessor {
try {
final JSONObject preference = preferenceQueryService.getPreference();
final String originalSigns = preference.getString(Preference.SIGNS);
final String originalSigns = preference.getString(Option.ID_C_SIGNS);
preference.put(Preference.SIGNS, Preference.Default.DEFAULT_SIGNS);
preference.put(Option.ID_C_SIGNS, Preference.Default.DEFAULT_SIGNS);
preferenceMgmtService.updatePreference(preference);
// Sends the sample signs to developer
final Message msg = new MailService.Message();
msg.setFrom(preference.getString(Preference.ADMIN_EMAIL));
msg.setFrom(preference.getString(Option.ID_C_ADMIN_EMAIL));
msg.addRecipient("DL88250@gmail.com");
msg.setSubject("Restore signs");
msg.setHtmlBody(originalSigns + "<p>Admin email: " + preference.getString(Preference.ADMIN_EMAIL) + "</p>");
msg.setHtmlBody(originalSigns + "<p>Admin email: " + preference.getString(Option.ID_C_ADMIN_EMAIL) + "</p>");
MAIL_SVC.send(msg);
renderer.setContent("Restores signs succeeded.");
......
......@@ -42,7 +42,7 @@ import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Tag;
import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.service.ArticleQueryService;
......@@ -59,7 +59,7 @@ import org.json.JSONObject;
* Tag processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.3, Nov 17, 2013
* @version 1.1.1.4, Nov 20, 2015
* @since 0.3.1
*/
@RequestProcessor
......@@ -160,10 +160,10 @@ public class TagProcessor {
final JSONObject preference = preferenceQueryService.getPreference();
Skins.fillLangs(preference.optString(Preference.LOCALE_STRING), (String) request.getAttribute(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) request.getAttribute(Keys.TEMAPLTE_DIR_NAME), dataModel);
final int pageSize = preference.getInt(Preference.ARTICLE_LIST_DISPLAY_COUNT);
final int windowSize = preference.getInt(Preference.ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
final int pageSize = preference.getInt(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT);
final int windowSize = preference.getInt(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
final List<JSONObject> articles = articleQueryService.getArticlesByTag(tagId, currentPageNum, pageSize);
......
......@@ -35,7 +35,7 @@ import org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer;
import org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer;
import org.b3log.latke.util.Locales;
import org.b3log.latke.util.freemarker.Templates;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.service.PreferenceQueryService;
import org.b3log.solo.service.StatisticMgmtService;
......@@ -55,7 +55,7 @@ import org.json.JSONObject;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.4, Nov 17, 2013
* @version 1.0.0.5, Nov 20, 2015
* @since 0.4.5
*/
@RequestProcessor
......@@ -135,7 +135,7 @@ public class UserTemplateProcessor {
filler.fillBlogHeader(request, response, dataModel, preference);
filler.fillUserTemplate(request, template, dataModel, preference);
filler.fillBlogFooter(request, dataModel, preference);
Skins.fillLangs(preference.optString(Preference.LOCALE_STRING), (String) request.getAttribute(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) request.getAttribute(Keys.TEMAPLTE_DIR_NAME), dataModel);
statisticMgmtService.incBlogViewCount(request, response);
} catch (final Exception e) {
......
......@@ -44,7 +44,6 @@ import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Skin;
import org.b3log.solo.model.UserExt;
import org.b3log.solo.processor.renderer.ConsoleRenderer;
......@@ -59,7 +58,7 @@ import org.json.JSONObject;
* Admin console render processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.1.7, Sep 28, 2015
* @version 1.2.1.8, Nov 20, 2015
* @since 0.4.1
*/
@RequestProcessor
......@@ -169,16 +168,16 @@ public class AdminConsole {
final JSONObject preference = preferenceQueryService.getPreference();
dataModel.put(Preference.LOCALE_STRING, preference.getString(Preference.LOCALE_STRING));
dataModel.put(Preference.BLOG_TITLE, preference.getString(Preference.BLOG_TITLE));
dataModel.put(Preference.BLOG_SUBTITLE, preference.getString(Preference.BLOG_SUBTITLE));
dataModel.put(Option.ID_C_LOCALE_STRING, preference.getString(Option.ID_C_LOCALE_STRING));
dataModel.put(Option.ID_C_BLOG_TITLE, preference.getString(Option.ID_C_BLOG_TITLE));
dataModel.put(Option.ID_C_BLOG_SUBTITLE, preference.getString(Option.ID_C_BLOG_SUBTITLE));
dataModel.put(Common.VERSION, SoloServletListener.VERSION);
dataModel.put(Common.STATIC_RESOURCE_VERSION, Latkes.getStaticResourceVersion());
dataModel.put(Common.YEAR, String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
dataModel.put(Preference.ARTICLE_LIST_DISPLAY_COUNT, preference.getInt(Preference.ARTICLE_LIST_DISPLAY_COUNT));
dataModel.put(Preference.ARTICLE_LIST_PAGINATION_WINDOW_SIZE, preference.getInt(Preference.ARTICLE_LIST_PAGINATION_WINDOW_SIZE));
dataModel.put(Preference.LOCALE_STRING, preference.getString(Preference.LOCALE_STRING));
dataModel.put(Preference.EDITOR_TYPE, preference.getString(Preference.EDITOR_TYPE));
dataModel.put(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT, preference.getInt(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT));
dataModel.put(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE, preference.getInt(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE));
dataModel.put(Option.ID_C_LOCALE_STRING, preference.getString(Option.ID_C_LOCALE_STRING));
dataModel.put(Option.ID_C_EDITOR_TYPE, preference.getString(Option.ID_C_EDITOR_TYPE));
dataModel.put(Skin.SKIN_DIR_NAME, preference.getString(Skin.SKIN_DIR_NAME));
Keys.fillRuntime(dataModel);
......@@ -227,7 +226,7 @@ public class AdminConsole {
Keys.fillRuntime(dataModel);
dataModel.put(Preference.LOCALE_STRING, locale.toString());
dataModel.put(Option.ID_C_LOCALE_STRING, locale.toString());
fireFreeMarkerActionEvent(templateName, dataModel);
}
......@@ -253,7 +252,7 @@ public class AdminConsole {
final Map<String, Object> dataModel = renderer.getDataModel();
dataModel.putAll(langs);
dataModel.put(Preference.LOCALE_STRING, locale.toString());
dataModel.put(Option.ID_C_LOCALE_STRING, locale.toString());
JSONObject preference = null;
......@@ -270,7 +269,7 @@ public class AdminConsole {
final String id = availableIDs[i];
String option;
if (id.equals(preference.optString(Preference.TIME_ZONE_ID))) {
if (id.equals(preference.optString(Option.ID_C_TIME_ZONE_ID))) {
option = "<option value=\"" + id + "\" selected=\"true\">" + id + "</option>";
} else {
option = "<option value=\"" + id + "\">" + id + "</option>";
......
......@@ -46,7 +46,7 @@ import org.json.JSONObject;
* Preference console request processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.7, Nov 20, 2015
* @version 1.2.0.8, Nov 20, 2015
* @since 0.4.0
*/
@RequestProcessor
......@@ -140,7 +140,7 @@ public class PreferenceConsole {
renderer.setJSONObject(ret);
ret.put(Preference.REPLY_NOTIFICATION_TEMPLATE, replyNotificationTemplate);
ret.put("replyNotificationTemplate", replyNotificationTemplate);
ret.put(Keys.STATUS_CODE, true);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
......@@ -185,7 +185,7 @@ public class PreferenceConsole {
try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
final JSONObject replyNotificationTemplate = requestJSONObject.getJSONObject(Preference.REPLY_NOTIFICATION_TEMPLATE);
final JSONObject replyNotificationTemplate = requestJSONObject.getJSONObject("replyNotificationTemplate");
preferenceMgmtService.updateReplyNotificationTemplate(replyNotificationTemplate);
......@@ -244,7 +244,7 @@ public class PreferenceConsole {
final JSONArray signs = new JSONArray();
final JSONArray allSigns = // includes the empty sign(id=0)
new JSONArray(preference.getString(Preference.SIGNS));
new JSONArray(preference.getString(Option.ID_C_SIGNS));
for (int i = 1; i < allSigns.length(); i++) { // excludes the empty sign
signs.put(allSigns.getJSONObject(i));
......@@ -596,7 +596,7 @@ public class PreferenceConsole {
errMsgBuilder.append(" - ");
String input = preference.optString(Preference.EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT);
String input = preference.optString(Option.ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("externalRelevantArticlesDisplayCntLabel")).append("] ").append(
......@@ -605,7 +605,7 @@ public class PreferenceConsole {
return true;
}
input = preference.optString(Preference.RELEVANT_ARTICLES_DISPLAY_CNT);
input = preference.optString(Option.ID_C_RELEVANT_ARTICLES_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("relevantArticlesDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel"));
......@@ -613,7 +613,7 @@ public class PreferenceConsole {
return true;
}
input = preference.optString(Preference.RANDOM_ARTICLES_DISPLAY_CNT);
input = preference.optString(Option.ID_C_RANDOM_ARTICLES_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("randomArticlesDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel"));
......@@ -621,7 +621,7 @@ public class PreferenceConsole {
return true;
}
input = preference.optString(Preference.MOST_COMMENT_ARTICLE_DISPLAY_CNT);
input = preference.optString(Option.ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexMostCommentArticleDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel"));
......@@ -629,7 +629,7 @@ public class PreferenceConsole {
return true;
}
input = preference.optString(Preference.MOST_VIEW_ARTICLE_DISPLAY_CNT);
input = preference.optString(Option.ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexMostViewArticleDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel"));
......@@ -637,7 +637,7 @@ public class PreferenceConsole {
return true;
}
input = preference.optString(Preference.RECENT_COMMENT_DISPLAY_CNT);
input = preference.optString(Option.ID_C_RECENT_COMMENT_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexRecentCommentDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel"));
......@@ -645,7 +645,7 @@ public class PreferenceConsole {
return true;
}
input = preference.optString(Preference.MOST_USED_TAG_DISPLAY_CNT);
input = preference.optString(Option.ID_C_MOST_USED_TAG_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexTagDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel"));
......@@ -653,7 +653,7 @@ public class PreferenceConsole {
return true;
}
input = preference.optString(Preference.ARTICLE_LIST_DISPLAY_COUNT);
input = preference.optString(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("pageSizeLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel"));
......@@ -661,7 +661,7 @@ public class PreferenceConsole {
return true;
}
input = preference.optString(Preference.ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
input = preference.optString(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("windowSizeLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel"));
......@@ -669,7 +669,7 @@ public class PreferenceConsole {
return true;
}
input = preference.optString(Preference.FEED_OUTPUT_CNT);
input = preference.optString(Option.ID_C_FEED_OUTPUT_CNT);
if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("feedOutputCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel"));
......
......@@ -39,8 +39,14 @@ import org.b3log.latke.util.CollectionUtils;
import org.b3log.latke.util.Ids;
import org.b3log.latke.util.Strings;
import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.*;
import org.b3log.solo.model.ArchiveDate;
import org.b3log.solo.model.Article;
import static org.b3log.solo.model.Article.*;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Tag;
import org.b3log.solo.model.UserExt;
import org.b3log.solo.repository.ArchiveDateArticleRepository;
import org.b3log.solo.repository.ArchiveDateRepository;
import org.b3log.solo.repository.ArticleRepository;
......@@ -58,7 +64,7 @@ import org.json.JSONObject;
* Article management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.2.6, Apr 16, 2015
* @version 1.2.2.7, Nov 20, 2015
* @since 0.3.5
*/
@Service
......@@ -325,7 +331,7 @@ public class ArticleMgmtService {
// Set editor type
if (!article.has(Article.ARTICLE_EDITOR_TYPE)) {
article.put(Article.ARTICLE_EDITOR_TYPE, preference.optString(Preference.EDITOR_TYPE));
article.put(Article.ARTICLE_EDITOR_TYPE, preference.optString(Option.ID_C_EDITOR_TYPE));
}
final boolean publishNewArticle = !oldArticle.getBoolean(ARTICLE_IS_PUBLISHED) && article.getBoolean(ARTICLE_IS_PUBLISHED);
......@@ -526,7 +532,7 @@ public class ArticleMgmtService {
userRepository.update(author.optString(Keys.OBJECT_ID), author);
// Step 14: Set editor type
if (!article.has(Article.ARTICLE_EDITOR_TYPE)) {
article.put(Article.ARTICLE_EDITOR_TYPE, preference.optString(Preference.EDITOR_TYPE));
article.put(Article.ARTICLE_EDITOR_TYPE, preference.optString(Option.ID_C_EDITOR_TYPE));
}
// Step 15: Add article
articleRepository.add(article);
......
......@@ -54,7 +54,7 @@ import org.json.JSONObject;
* Comment management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.7, Nov 5, 2015
* @version 1.1.0.8, Nov 20, 2015
* @since 0.3.5
*/
@Service
......@@ -180,7 +180,7 @@ public class CommentMgmtService {
final String commentId = comment.getString(Keys.OBJECT_ID);
final String commentContent = comment.getString(Comment.COMMENT_CONTENT).replaceAll(SoloServletListener.ENTER_ESC, "<br/>");
final String adminEmail = preference.getString(Preference.ADMIN_EMAIL);
final String adminEmail = preference.getString(Option.ID_C_ADMIN_EMAIL);
if (adminEmail.equalsIgnoreCase(commentEmail)) {
LOGGER.log(Level.DEBUG, "Do not send comment notification mail to admin itself[{0}]", adminEmail);
......@@ -204,7 +204,7 @@ public class CommentMgmtService {
}
}
final String blogTitle = preference.getString(Preference.BLOG_TITLE);
final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
boolean isArticle = true;
String title = articleOrPage.optString(Article.ARTICLE_TITLE);
......@@ -281,7 +281,7 @@ public class CommentMgmtService {
ret.put(Keys.STATUS_CODE, false);
final JSONObject preference = preferenceQueryService.getPreference();
if (null == preference || !preference.optBoolean(Preference.COMMENTABLE)) {
if (null == preference || !preference.optBoolean(Option.ID_C_COMMENTABLE)) {
ret.put(Keys.MSG, langPropsService.get("notAllowCommentLabel"));
return ret;
......@@ -728,14 +728,14 @@ public class CommentMgmtService {
*/
public void setCommentThumbnailURL(final JSONObject comment) throws Exception {
final String commentEmail = comment.getString(Comment.COMMENT_EMAIL);
// 1. user avatar
final JSONObject user = userRepository.getByEmail(commentEmail);
if (null != user) {
final String avatar = user.optString(UserExt.USER_AVATAR);
if (!Strings.isEmptyOrNull(avatar)) {
comment.put(Comment.COMMENT_THUMBNAIL_URL, avatar);
return;
}
}
......
......@@ -540,7 +540,7 @@ public class InitService {
final JSONObject replyNotificationTemplate = new JSONObject(Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
replyNotificationTemplate.put(Keys.OBJECT_ID, Preference.REPLY_NOTIFICATION_TEMPLATE);
replyNotificationTemplate.put(Keys.OBJECT_ID, "replyNotificationTemplate");
final JSONObject subjectOpt = new JSONObject();
subjectOpt.put(Keys.OBJECT_ID, Option.ID_C_REPLY_NOTI_TPL_SUBJECT);
......
......@@ -28,8 +28,8 @@ import org.b3log.latke.service.annotation.Service;
import org.b3log.latke.util.Ids;
import org.b3log.latke.util.Strings;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Page;
import org.b3log.solo.model.Preference;
import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.PageRepository;
import org.b3log.solo.util.Comments;
......@@ -40,7 +40,7 @@ import org.json.JSONObject;
* Page management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.7, May 30, 2015
* @version 1.1.0.8, Nov 20, 2015
* @since 0.4.0
*/
@Service
......@@ -169,7 +169,7 @@ public class PageMgmtService {
// Set editor type
if (!newPage.has(Page.PAGE_EDITOR_TYPE)) {
final JSONObject preference = preferenceQueryService.getPreference();
newPage.put(Page.PAGE_EDITOR_TYPE, preference.optString(Preference.EDITOR_TYPE));
newPage.put(Page.PAGE_EDITOR_TYPE, preference.optString(Option.ID_C_EDITOR_TYPE));
}
pageRepository.update(pageId, newPage);
......@@ -278,7 +278,7 @@ public class PageMgmtService {
// Set editor type
if (!page.has(Page.PAGE_EDITOR_TYPE)) {
final JSONObject preference = preferenceQueryService.getPreference();
page.put(Page.PAGE_EDITOR_TYPE, preference.optString(Preference.EDITOR_TYPE));
page.put(Page.PAGE_EDITOR_TYPE, preference.optString(Option.ID_C_EDITOR_TYPE));
}
final String ret = pageRepository.add(page);
......
......@@ -38,7 +38,6 @@ import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Skin;
import org.json.JSONArray;
import org.json.JSONObject;
import static org.b3log.solo.model.Preference.*;
import static org.b3log.solo.model.Skin.SKINS;
import static org.b3log.solo.model.Skin.SKIN_DIR_NAME;
import static org.b3log.solo.model.Skin.SKIN_NAME;
......@@ -50,7 +49,7 @@ import static org.b3log.solo.util.Skins.setDirectoryForTemplateLoading;
* Preference management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.1.9, Nov 20, 2015
* @version 1.3.1.10, Nov 20, 2015
* @since 0.4.0
*/
@Service
......@@ -148,7 +147,7 @@ public class PreferenceMgmtService {
setDirectoryForTemplateLoading(preference.getString(SKIN_DIR_NAME));
final String localeString = preference.getString(Preference.LOCALE_STRING);
final String localeString = preference.getString(Option.ID_C_LOCALE_STRING);
if ("zh_CN".equals(localeString)) {
TimeZones.setTimeZone("Asia/Shanghai");
......@@ -229,19 +228,19 @@ public class PreferenceMgmtService {
preference.put(Skin.SKINS, skinArray.toString());
final String timeZoneId = preference.getString(TIME_ZONE_ID);
final String timeZoneId = preference.getString(Option.ID_C_TIME_ZONE_ID);
TimeZones.setTimeZone(timeZoneId);
preference.put(Preference.SIGNS, preference.get(Preference.SIGNS).toString());
preference.put(Option.ID_C_SIGNS, preference.get(Option.ID_C_SIGNS).toString());
final JSONObject oldPreference = preferenceQueryService.getPreference();
final String adminEmail = oldPreference.getString(ADMIN_EMAIL);
preference.put(ADMIN_EMAIL, adminEmail);
final String adminEmail = oldPreference.getString(Option.ID_C_ADMIN_EMAIL);
preference.put(Option.ID_C_ADMIN_EMAIL, adminEmail);
final String version = oldPreference.optString(VERSION);
preference.put(VERSION, version);
final String version = oldPreference.optString(Option.ID_C_VERSION);
preference.put(Option.ID_C_VERSION, version);
final String localeString = preference.getString(Preference.LOCALE_STRING);
final String localeString = preference.getString(Option.ID_C_LOCALE_STRING);
LOGGER.log(Level.DEBUG, "Current locale[string={0}]", localeString);
Latkes.setLocale(new Locale(Locales.getLanguage(localeString), Locales.getCountry(localeString)));
......
......@@ -17,6 +17,7 @@ package org.b3log.solo.service;
import org.b3log.latke.model.User;
import org.b3log.solo.AbstractTestCase;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference;
import org.json.JSONObject;
import org.testng.Assert;
......@@ -26,7 +27,7 @@ import org.testng.annotations.Test;
* {@link PreferenceMgmtService} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1, Sep 11, 2012
* @version 1.0.0.2, Nov 20, 2015
*/
@Test(suiteName = "service")
public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
......@@ -62,14 +63,14 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
JSONObject preference = preferenceQueryService.getPreference();
Assert.assertEquals(preference.getString(Preference.BLOG_TITLE),
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE),
Preference.Default.DEFAULT_BLOG_TITLE);
preference.put(Preference.BLOG_TITLE, "updated blog title");
preference.put(Option.ID_C_BLOG_TITLE, "updated blog title");
preferenceMgmtService.updatePreference(preference);
preference = preferenceQueryService.getPreference();
Assert.assertEquals(preference.getString(Preference.BLOG_TITLE), "updated blog title");
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "updated blog title");
}
/**
......@@ -79,23 +80,16 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
*/
@Test(dependsOnMethods = "init")
public void updateReplyNotificationTemplate() throws Exception {
final PreferenceMgmtService preferenceMgmtService
= getPreferenceMgmtService();
final PreferenceQueryService preferenceQueryService
= getPreferenceQueryService();
JSONObject replyNotificationTemplate
= preferenceQueryService.getReplyNotificationTemplate();
final PreferenceMgmtService preferenceMgmtService = getPreferenceMgmtService();
final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.toString(),
Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
Assert.assertEquals(replyNotificationTemplate.toString(), Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
replyNotificationTemplate.put("subject", "updated subject");
preferenceMgmtService.updateReplyNotificationTemplate(
replyNotificationTemplate);
preferenceMgmtService.updateReplyNotificationTemplate(replyNotificationTemplate);
replyNotificationTemplate
= preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.getString(
"subject"), "updated subject");
replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.getString("subject"), "updated subject");
}
}
......@@ -17,6 +17,7 @@ package org.b3log.solo.service;
import org.b3log.latke.model.User;
import org.b3log.solo.AbstractTestCase;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference;
import org.json.JSONObject;
import org.testng.Assert;
......@@ -26,14 +27,14 @@ import org.testng.annotations.Test;
* {@link PreferenceQueryService} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1, Sep 11, 2012
* @version 1.0.0.2, Nov 20, 2015
*/
@Test(suiteName = "service")
public class PreferenceQueryServiceTestCase extends AbstractTestCase {
/**
* Init.
*
*
* @throws Exception exception
*/
@Test
......@@ -53,32 +54,30 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase {
/**
* Get Preference.
*
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void getPreference() throws Exception {
final PreferenceQueryService preferenceQueryService =
getPreferenceQueryService();
final PreferenceQueryService preferenceQueryService
= getPreferenceQueryService();
final JSONObject preference = preferenceQueryService.getPreference();
Assert.assertEquals(preference.getString(Preference.BLOG_TITLE),
Preference.Default.DEFAULT_BLOG_TITLE);
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), Preference.Default.DEFAULT_BLOG_TITLE);
}
/**
* Get Reply Notification Template.
*
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void getReplyNotificationTemplate() throws Exception {
final PreferenceQueryService preferenceQueryService =
getPreferenceQueryService();
final JSONObject replyNotificationTemplate =
preferenceQueryService.getReplyNotificationTemplate();
final PreferenceQueryService preferenceQueryService
= getPreferenceQueryService();
final JSONObject replyNotificationTemplate
= preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.toString(),
Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
Assert.assertEquals(replyNotificationTemplate.toString(), Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
}
}
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