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; ...@@ -40,7 +40,7 @@ import org.b3log.latke.servlet.annotation.RequestProcessor;
import org.b3log.latke.servlet.renderer.TextXMLRenderer; import org.b3log.latke.servlet.renderer.TextXMLRenderer;
import org.b3log.latke.util.MD5; import org.b3log.latke.util.MD5;
import org.b3log.solo.model.Article; 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.model.Tag;
import org.b3log.solo.repository.ArticleRepository; import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.service.ArticleMgmtService; import org.b3log.solo.service.ArticleMgmtService;
...@@ -71,7 +71,7 @@ import org.jsoup.Jsoup; ...@@ -71,7 +71,7 @@ import org.jsoup.Jsoup;
* </p> * </p>
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.4.0
*/ */
@RequestProcessor @RequestProcessor
...@@ -629,7 +629,7 @@ public class MetaWeblogAPI { ...@@ -629,7 +629,7 @@ public class MetaWeblogAPI {
throws JSONException { throws JSONException {
final String blogId = preference.getString(Keys.OBJECT_ID); 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( final StringBuilder stringBuilder = new StringBuilder("<member><name>blogid</name><value>").append(blogId).append(
"</value></member>"); "</value></member>");
......
...@@ -32,7 +32,7 @@ import org.b3log.latke.servlet.renderer.JSONRenderer; ...@@ -32,7 +32,7 @@ import org.b3log.latke.servlet.renderer.JSONRenderer;
import org.b3log.latke.util.Requests; import org.b3log.latke.util.Requests;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import org.b3log.solo.model.Common; 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.ArticleMgmtService;
import org.b3log.solo.service.ArticleQueryService; import org.b3log.solo.service.ArticleQueryService;
import org.b3log.solo.service.PreferenceQueryService; import org.b3log.solo.service.PreferenceQueryService;
...@@ -46,7 +46,7 @@ import org.jsoup.Jsoup; ...@@ -46,7 +46,7 @@ import org.jsoup.Jsoup;
* Article receiver (from B3log Symphony). * Article receiver (from B3log Symphony).
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.5.5
*/ */
@RequestProcessor @RequestProcessor
...@@ -132,7 +132,7 @@ public class ArticleReceiver { ...@@ -132,7 +132,7 @@ public class ArticleReceiver {
final String userB3Key = article.optString("userB3Key"); final String userB3Key = article.optString("userB3Key");
final JSONObject preference = preferenceQueryService.getPreference(); 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"); LOGGER.log(Level.WARN, "B3 key not match, ignored add article");
return; return;
...@@ -224,7 +224,7 @@ public class ArticleReceiver { ...@@ -224,7 +224,7 @@ public class ArticleReceiver {
final String userB3Key = article.optString("userB3Key"); final String userB3Key = article.optString("userB3Key");
final JSONObject preference = preferenceQueryService.getPreference(); 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"); LOGGER.log(Level.WARN, "B3 key not match, ignored update article");
return; return;
......
...@@ -42,7 +42,7 @@ import org.b3log.solo.SoloServletListener; ...@@ -42,7 +42,7 @@ import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes; import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment; 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.ArticleRepository;
import org.b3log.solo.repository.CommentRepository; import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.service.ArticleMgmtService; import org.b3log.solo.service.ArticleMgmtService;
...@@ -57,7 +57,7 @@ import org.json.JSONObject; ...@@ -57,7 +57,7 @@ import org.json.JSONObject;
* Comment receiver (from B3log Symphony). * Comment receiver (from B3log Symphony).
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.5.5
*/ */
@RequestProcessor @RequestProcessor
...@@ -98,11 +98,6 @@ public class CommentReceiver { ...@@ -98,11 +98,6 @@ public class CommentReceiver {
@Inject @Inject
private ArticleRepository articleRepository; private ArticleRepository articleRepository;
/**
* Default user thumbnail.
*/
private static final String DEFAULT_USER_THUMBNAIL = "default-user-thumbnail.png";
/** /**
* URL fetch service. * URL fetch service.
*/ */
...@@ -168,7 +163,7 @@ public class CommentReceiver { ...@@ -168,7 +163,7 @@ public class CommentReceiver {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response); final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
final JSONObject symphonyCmt = requestJSONObject.optJSONObject(Comment.COMMENT); final JSONObject symphonyCmt = requestJSONObject.optJSONObject(Comment.COMMENT);
final JSONObject preference = preferenceQueryService.getPreference(); 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"); final String key = symphonyCmt.optString("userB3Key");
if (Strings.isEmptyOrNull(keyOfSolo) || !keyOfSolo.equals(key)) { if (Strings.isEmptyOrNull(keyOfSolo) || !keyOfSolo.equals(key)) {
......
...@@ -32,7 +32,7 @@ import org.b3log.solo.SoloServletListener; ...@@ -32,7 +32,7 @@ import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes; import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment; 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.CommentRepository;
import org.b3log.solo.repository.impl.CommentRepositoryImpl; import org.b3log.solo.repository.impl.CommentRepositoryImpl;
import org.b3log.solo.service.PreferenceQueryService; import org.b3log.solo.service.PreferenceQueryService;
...@@ -42,7 +42,7 @@ import org.json.JSONObject; ...@@ -42,7 +42,7 @@ import org.json.JSONObject;
* This listener is responsible for processing article comment reply. * This listener is responsible for processing article comment reply.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.1
*/ */
public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSONObject> { public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSONObject> {
...@@ -99,8 +99,8 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO ...@@ -99,8 +99,8 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
throw new EventException("Not found preference"); throw new EventException("Not found preference");
} }
final String blogTitle = preference.getString(Preference.BLOG_TITLE); final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String adminEmail = preference.getString(Preference.ADMIN_EMAIL); 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 commentContent = comment.getString(Comment.COMMENT_CONTENT).replaceAll(SoloServletListener.ENTER_ESC, "<br/>");
final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL); final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL);
......
...@@ -32,8 +32,8 @@ import org.b3log.latke.util.Strings; ...@@ -32,8 +32,8 @@ import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes; import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Comment; import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Page; import org.b3log.solo.model.Page;
import org.b3log.solo.model.Preference;
import org.b3log.solo.repository.CommentRepository; import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.impl.CommentRepositoryImpl; import org.b3log.solo.repository.impl.CommentRepositoryImpl;
import org.b3log.solo.service.PreferenceQueryService; import org.b3log.solo.service.PreferenceQueryService;
...@@ -44,7 +44,7 @@ import org.json.JSONObject; ...@@ -44,7 +44,7 @@ import org.json.JSONObject;
* This listener is responsible for processing page comment reply. * This listener is responsible for processing page comment reply.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.1
*/ */
public final class PageCommentReplyNotifier extends AbstractEventListener<JSONObject> { public final class PageCommentReplyNotifier extends AbstractEventListener<JSONObject> {
...@@ -94,8 +94,8 @@ public final class PageCommentReplyNotifier extends AbstractEventListener<JSONOb ...@@ -94,8 +94,8 @@ public final class PageCommentReplyNotifier extends AbstractEventListener<JSONOb
throw new EventException("Not found preference"); throw new EventException("Not found preference");
} }
final String blogTitle = preference.getString(Preference.BLOG_TITLE); final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String adminEmail = preference.getString(Preference.ADMIN_EMAIL); 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 commentContent = comment.getString(Comment.COMMENT_CONTENT).replaceAll(SoloServletListener.ENTER_ESC, "<br/>");
final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL); final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL);
......
...@@ -31,7 +31,7 @@ import org.b3log.latke.urlfetch.URLFetchService; ...@@ -31,7 +31,7 @@ import org.b3log.latke.urlfetch.URLFetchService;
import org.b3log.latke.urlfetch.URLFetchServiceFactory; import org.b3log.latke.urlfetch.URLFetchServiceFactory;
import org.b3log.solo.event.EventTypes; import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article; 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.b3log.solo.service.PreferenceQueryService;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -48,7 +48,7 @@ import org.json.JSONObject; ...@@ -48,7 +48,7 @@ import org.json.JSONObject;
* </p> * </p>
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @see UpdateArticleGoogleBlogSearchPinger
* @since 0.3.1 * @since 0.3.1
*/ */
...@@ -88,7 +88,7 @@ public final class AddArticleGoogleBlogSearchPinger extends AbstractEventListene ...@@ -88,7 +88,7 @@ public final class AddArticleGoogleBlogSearchPinger extends AbstractEventListene
articleTitle = article.getString(Article.ARTICLE_TITLE); articleTitle = article.getString(Article.ARTICLE_TITLE);
final JSONObject preference = preferenceQueryService.getPreference(); 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")) { if (Latkes.getServePath().contains("localhost")) {
LOGGER.log(Level.INFO, LOGGER.log(Level.INFO,
......
...@@ -31,7 +31,7 @@ import org.b3log.latke.urlfetch.URLFetchService; ...@@ -31,7 +31,7 @@ import org.b3log.latke.urlfetch.URLFetchService;
import org.b3log.latke.urlfetch.URLFetchServiceFactory; import org.b3log.latke.urlfetch.URLFetchServiceFactory;
import org.b3log.solo.event.EventTypes; import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article; 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.b3log.solo.service.PreferenceQueryService;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -48,7 +48,7 @@ import org.json.JSONObject; ...@@ -48,7 +48,7 @@ import org.json.JSONObject;
* </p> * </p>
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @see AddArticleGoogleBlogSearchPinger
* @since 0.3.1 * @since 0.3.1
*/ */
...@@ -88,7 +88,7 @@ public final class UpdateArticleGoogleBlogSearchPinger extends AbstractEventList ...@@ -88,7 +88,7 @@ public final class UpdateArticleGoogleBlogSearchPinger extends AbstractEventList
articleTitle = article.getString(Article.ARTICLE_TITLE); articleTitle = article.getString(Article.ARTICLE_TITLE);
final JSONObject preference = preferenceQueryService.getPreference(); 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")) { if (Latkes.getServePath().contains("localhost")) {
LOGGER.log(Level.INFO, LOGGER.log(Level.INFO,
......
...@@ -36,7 +36,7 @@ import org.b3log.solo.SoloServletListener; ...@@ -36,7 +36,7 @@ import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes; import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import org.b3log.solo.model.Common; 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.b3log.solo.service.PreferenceQueryService;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -49,7 +49,7 @@ import org.json.JSONObject; ...@@ -49,7 +49,7 @@ import org.json.JSONObject;
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author ArmstrongCN * @author ArmstrongCN
* @version 1.0.2.7, Jun 13, 2013 * @version 1.0.2.8, Nov 20, 2015
* @since 0.3.1 * @since 0.3.1
*/ */
public final class ArticleSender extends AbstractEventListener<JSONObject> { public final class ArticleSender extends AbstractEventListener<JSONObject> {
...@@ -134,10 +134,10 @@ 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(Article.ARTICLE, article);
requestJSONObject.put(Common.BLOG_VERSION, SoloServletListener.VERSION); requestJSONObject.put(Common.BLOG_VERSION, SoloServletListener.VERSION);
requestJSONObject.put(Common.BLOG, "B3log Solo"); 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("blogHost", Latkes.getServePath());
requestJSONObject.put("userB3Key", preference.optString(Preference.KEY_OF_SOLO)); requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
requestJSONObject.put("clientAdminEmail", preference.optString(Preference.ADMIN_EMAIL)); requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
requestJSONObject.put("clientRuntimeEnv", Latkes.getRuntimeEnv().name()); requestJSONObject.put("clientRuntimeEnv", Latkes.getRuntimeEnv().name());
httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8")); httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));
......
...@@ -36,7 +36,7 @@ import org.b3log.solo.SoloServletListener; ...@@ -36,7 +36,7 @@ import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes; import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import org.b3log.solo.model.Common; 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.b3log.solo.service.PreferenceQueryService;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -48,7 +48,7 @@ import org.json.JSONObject; ...@@ -48,7 +48,7 @@ import org.json.JSONObject;
* </p> * </p>
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.6.0
*/ */
public final class ArticleUpdater extends AbstractEventListener<JSONObject> { public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
...@@ -133,10 +133,10 @@ 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(Article.ARTICLE, article);
requestJSONObject.put(Common.BLOG_VERSION, SoloServletListener.VERSION); requestJSONObject.put(Common.BLOG_VERSION, SoloServletListener.VERSION);
requestJSONObject.put(Common.BLOG, "B3log Solo"); 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("blogHost", Latkes.getServerHost() + ":" + Latkes.getServerPort());
requestJSONObject.put("userB3Key", preference.optString(Preference.KEY_OF_SOLO)); requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
requestJSONObject.put("clientAdminEmail", preference.optString(Preference.ADMIN_EMAIL)); requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
requestJSONObject.put("clientRuntimeEnv", Latkes.getRuntimeEnv().name()); requestJSONObject.put("clientRuntimeEnv", Latkes.getRuntimeEnv().name());
httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8")); httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));
......
...@@ -35,7 +35,7 @@ import org.b3log.solo.SoloServletListener; ...@@ -35,7 +35,7 @@ import org.b3log.solo.SoloServletListener;
import org.b3log.solo.event.EventTypes; import org.b3log.solo.event.EventTypes;
import org.b3log.solo.event.rhythm.ArticleSender; import org.b3log.solo.event.rhythm.ArticleSender;
import org.b3log.solo.model.Comment; 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.b3log.solo.service.PreferenceQueryService;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -44,7 +44,7 @@ import org.json.JSONObject; ...@@ -44,7 +44,7 @@ import org.json.JSONObject;
* This listener is responsible for sending comment to B3log Symphony. * This listener is responsible for sending comment to B3log Symphony.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.5.5
*/ */
public final class CommentSender extends AbstractEventListener<JSONObject> { public final class CommentSender extends AbstractEventListener<JSONObject> {
...@@ -115,8 +115,8 @@ 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("clientRuntimeEnv", Latkes.getRuntimeEnv().name());
requestJSONObject.put("clientName", "B3log Solo"); requestJSONObject.put("clientName", "B3log Solo");
requestJSONObject.put("clientHost", Latkes.getServerHost() + ":" + Latkes.getServerPort()); requestJSONObject.put("clientHost", Latkes.getServerHost() + ":" + Latkes.getServerPort());
requestJSONObject.put("clientAdminEmail", preference.optString(Preference.ADMIN_EMAIL)); requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
requestJSONObject.put("userB3Key", preference.optString(Preference.KEY_OF_SOLO)); requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8")); httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));
......
...@@ -35,186 +35,6 @@ public final class Preference { ...@@ -35,186 +35,6 @@ public final class Preference {
*/ */
public static final String PREFERENCE = "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. * Private default constructor.
*/ */
......
...@@ -39,7 +39,6 @@ import org.b3log.latke.util.Requests; ...@@ -39,7 +39,6 @@ import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings; import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference;
import org.b3log.solo.service.OptionMgmtService; import org.b3log.solo.service.OptionMgmtService;
import org.b3log.solo.service.OptionQueryService; import org.b3log.solo.service.OptionQueryService;
import org.b3log.solo.service.PreferenceQueryService; import org.b3log.solo.service.PreferenceQueryService;
...@@ -52,7 +51,7 @@ import org.json.JSONObject; ...@@ -52,7 +51,7 @@ import org.json.JSONObject;
* Broadcast chance processor. * Broadcast chance processor.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.6.0
*/ */
@RequestProcessor @RequestProcessor
...@@ -285,11 +284,11 @@ public class ChanceProcessor { ...@@ -285,11 +284,11 @@ public class ChanceProcessor {
final JSONObject broadcast = requestJSONObject.getJSONObject("broadcast"); final JSONObject broadcast = requestJSONObject.getJSONObject("broadcast");
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
final String b3logKey = preference.getString(Preference.KEY_OF_SOLO); final String b3logKey = preference.getString(Option.ID_C_KEY_OF_SOLO);
final String email = preference.getString(Preference.ADMIN_EMAIL); final String email = preference.getString(Option.ID_C_ADMIN_EMAIL);
final String clientName = "B3log Solo"; final String clientName = "B3log Solo";
final String clientVersion = SoloServletListener.VERSION; 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 String clientRuntimeEnv = Latkes.getRuntimeEnv().name();
final JSONObject broadcastRequest = new JSONObject(); final JSONObject broadcastRequest = new JSONObject();
......
...@@ -38,7 +38,7 @@ import org.b3log.latke.util.MD5; ...@@ -38,7 +38,7 @@ import org.b3log.latke.util.MD5;
import org.b3log.latke.util.Strings; import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.Article; 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.model.Statistic;
import org.b3log.solo.service.ArticleQueryService; import org.b3log.solo.service.ArticleQueryService;
import org.b3log.solo.service.PreferenceQueryService; import org.b3log.solo.service.PreferenceQueryService;
...@@ -53,7 +53,7 @@ import org.json.JSONObject; ...@@ -53,7 +53,7 @@ import org.json.JSONObject;
* Blog processor. * Blog processor.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.4.6
*/ */
@RequestProcessor @RequestProcessor
...@@ -183,7 +183,7 @@ public class BlogProcessor { ...@@ -183,7 +183,7 @@ public class BlogProcessor {
requestJSONObject.put(User.USER_NAME, admin.getString(User.USER_NAME)); requestJSONObject.put(User.USER_NAME, admin.getString(User.USER_NAME));
requestJSONObject.put(User.USER_EMAIL, admin.getString(User.USER_EMAIL)); requestJSONObject.put(User.USER_EMAIL, admin.getString(User.USER_EMAIL));
requestJSONObject.put(User.USER_PASSWORD, admin.getString(User.USER_PASSWORD)); 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()); requestJSONObject.put("clientHost", Latkes.getServePath());
httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8")); httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package org.b3log.solo.processor; package org.b3log.solo.processor;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -46,7 +45,7 @@ import org.b3log.latke.util.Locales; ...@@ -46,7 +45,7 @@ import org.b3log.latke.util.Locales;
import org.b3log.latke.util.Strings; import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.Article; 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.model.Tag;
import org.b3log.solo.model.feed.atom.Category; import org.b3log.solo.model.feed.atom.Category;
import org.b3log.solo.model.feed.atom.Entry; import org.b3log.solo.model.feed.atom.Entry;
...@@ -62,12 +61,11 @@ import org.b3log.solo.service.UserQueryService; ...@@ -62,12 +61,11 @@ import org.b3log.solo.service.UserQueryService;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* Feed (Atom/RSS) processor. * Feed (Atom/RSS) processor.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.4, May 17, 2013 * @version 1.1.0.5, Nov 20, 2015
* @since 0.3.1 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -119,7 +117,7 @@ public class FeedProcessor { ...@@ -119,7 +117,7 @@ public class FeedProcessor {
* *
* @param context the specified context * @param context the specified context
*/ */
@RequestProcessing(value = { "/blog-articles-feed.do"}, method = { HTTPRequestMethod.GET, HTTPRequestMethod.HEAD}) @RequestProcessing(value = {"/blog-articles-feed.do"}, method = {HTTPRequestMethod.GET, HTTPRequestMethod.HEAD})
public void blogArticlesAtom(final HTTPRequestContext context) { public void blogArticlesAtom(final HTTPRequestContext context) {
final AtomRenderer renderer = new AtomRenderer(); final AtomRenderer renderer = new AtomRenderer();
...@@ -130,9 +128,9 @@ public class FeedProcessor { ...@@ -130,9 +128,9 @@ public class FeedProcessor {
try { try {
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
final String blogTitle = preference.getString(Preference.BLOG_TITLE); final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String blogSubtitle = preference.getString(Preference.BLOG_SUBTITLE); final String blogSubtitle = preference.getString(Option.ID_C_BLOG_SUBTITLE);
final int outputCnt = preference.getInt(Preference.FEED_OUTPUT_CNT); final int outputCnt = preference.getInt(Option.ID_C_FEED_OUTPUT_CNT);
feed.setTitle(StringEscapeUtils.escapeXml(blogTitle)); feed.setTitle(StringEscapeUtils.escapeXml(blogTitle));
feed.setSubtitle(StringEscapeUtils.escapeXml(blogSubtitle)); feed.setSubtitle(StringEscapeUtils.escapeXml(blogSubtitle));
...@@ -158,7 +156,7 @@ public class FeedProcessor { ...@@ -158,7 +156,7 @@ public class FeedProcessor {
authorName = articleQueryService.getAuthor(articles.getJSONObject(0)).getString(User.USER_NAME); authorName = articleQueryService.getAuthor(articles.getJSONObject(0)).getString(User.USER_NAME);
} }
final boolean isFullContent = "fullContent".equals(preference.getString(Preference.FEED_OUTPUT_MODE)); final boolean isFullContent = "fullContent".equals(preference.getString(Option.ID_C_FEED_OUTPUT_MODE));
for (int i = 0; i < articles.length(); i++) { for (int i = 0; i < articles.length(); i++) {
final JSONObject article = articles.getJSONObject(i); final JSONObject article = articles.getJSONObject(i);
...@@ -218,7 +216,7 @@ public class FeedProcessor { ...@@ -218,7 +216,7 @@ public class FeedProcessor {
* @param context the specified context * @param context the specified context
* @throws IOException io exception * @throws IOException io exception
*/ */
@RequestProcessing(value = { "/tag-articles-feed.do"}, method = { HTTPRequestMethod.GET, HTTPRequestMethod.HEAD}) @RequestProcessing(value = {"/tag-articles-feed.do"}, method = {HTTPRequestMethod.GET, HTTPRequestMethod.HEAD})
public void tagArticlesAtom(final HTTPRequestContext context) throws IOException { public void tagArticlesAtom(final HTTPRequestContext context) throws IOException {
final AtomRenderer renderer = new AtomRenderer(); final AtomRenderer renderer = new AtomRenderer();
...@@ -256,9 +254,9 @@ public class FeedProcessor { ...@@ -256,9 +254,9 @@ public class FeedProcessor {
return; return;
} }
final String blogTitle = preference.getString(Preference.BLOG_TITLE); final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String blogSubtitle = preference.getString(Preference.BLOG_SUBTITLE) + ", " + tagTitle; final String blogSubtitle = preference.getString(Option.ID_C_BLOG_SUBTITLE) + ", " + tagTitle;
final int outputCnt = preference.getInt(Preference.FEED_OUTPUT_CNT); final int outputCnt = preference.getInt(Option.ID_C_FEED_OUTPUT_CNT);
feed.setTitle(StringEscapeUtils.escapeXml(blogTitle)); feed.setTitle(StringEscapeUtils.escapeXml(blogTitle));
feed.setSubtitle(StringEscapeUtils.escapeXml(blogSubtitle)); feed.setSubtitle(StringEscapeUtils.escapeXml(blogSubtitle));
...@@ -295,7 +293,7 @@ public class FeedProcessor { ...@@ -295,7 +293,7 @@ public class FeedProcessor {
authorName = articleQueryService.getAuthor(articles.get(0)).getString(User.USER_NAME); authorName = articleQueryService.getAuthor(articles.get(0)).getString(User.USER_NAME);
} }
final boolean isFullContent = "fullContent".equals(preference.getString(Preference.FEED_OUTPUT_MODE)); final boolean isFullContent = "fullContent".equals(preference.getString(Option.ID_C_FEED_OUTPUT_MODE));
for (int i = 0; i < articles.size(); i++) { for (int i = 0; i < articles.size(); i++) {
final JSONObject article = articles.get(i); final JSONObject article = articles.get(i);
...@@ -352,7 +350,7 @@ public class FeedProcessor { ...@@ -352,7 +350,7 @@ public class FeedProcessor {
* *
* @param context the specified context * @param context the specified context
*/ */
@RequestProcessing(value = { "/blog-articles-rss.do"}, method = { HTTPRequestMethod.GET, HTTPRequestMethod.HEAD}) @RequestProcessing(value = {"/blog-articles-rss.do"}, method = {HTTPRequestMethod.GET, HTTPRequestMethod.HEAD})
public void blogArticlesRSS(final HTTPRequestContext context) { public void blogArticlesRSS(final HTTPRequestContext context) {
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
final RssRenderer renderer = new RssRenderer(); final RssRenderer renderer = new RssRenderer();
...@@ -369,16 +367,16 @@ public class FeedProcessor { ...@@ -369,16 +367,16 @@ public class FeedProcessor {
return; return;
} }
final String blogTitle = preference.getString(Preference.BLOG_TITLE); final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String blogSubtitle = preference.getString(Preference.BLOG_SUBTITLE); final String blogSubtitle = preference.getString(Option.ID_C_BLOG_SUBTITLE);
final int outputCnt = preference.getInt(Preference.FEED_OUTPUT_CNT); final int outputCnt = preference.getInt(Option.ID_C_FEED_OUTPUT_CNT);
channel.setTitle(StringEscapeUtils.escapeXml(blogTitle)); channel.setTitle(StringEscapeUtils.escapeXml(blogTitle));
channel.setLastBuildDate(new Date()); channel.setLastBuildDate(new Date());
channel.setLink(Latkes.getServePath()); channel.setLink(Latkes.getServePath());
channel.setAtomLink(Latkes.getServePath() + "/blog-articles-rss.do"); channel.setAtomLink(Latkes.getServePath() + "/blog-articles-rss.do");
channel.setGenerator("Solo, ver " + SoloServletListener.VERSION); channel.setGenerator("Solo, ver " + SoloServletListener.VERSION);
final String localeString = preference.getString(Preference.LOCALE_STRING); final String localeString = preference.getString(Option.ID_C_LOCALE_STRING);
final String country = Locales.getCountry(localeString).toLowerCase(); final String country = Locales.getCountry(localeString).toLowerCase();
final String language = Locales.getLanguage(localeString).toLowerCase(); final String language = Locales.getLanguage(localeString).toLowerCase();
...@@ -402,7 +400,7 @@ public class FeedProcessor { ...@@ -402,7 +400,7 @@ public class FeedProcessor {
authorName = articleQueryService.getAuthor(articles.getJSONObject(0)).getString(User.USER_NAME); authorName = articleQueryService.getAuthor(articles.getJSONObject(0)).getString(User.USER_NAME);
} }
final boolean isFullContent = "fullContent".equals(preference.getString(Preference.FEED_OUTPUT_MODE)); final boolean isFullContent = "fullContent".equals(preference.getString(Option.ID_C_FEED_OUTPUT_MODE));
for (int i = 0; i < articles.length(); i++) { for (int i = 0; i < articles.length(); i++) {
final JSONObject article = articles.getJSONObject(i); final JSONObject article = articles.getJSONObject(i);
...@@ -464,7 +462,7 @@ public class FeedProcessor { ...@@ -464,7 +462,7 @@ public class FeedProcessor {
* @param context the specified context * @param context the specified context
* @throws IOException io exception * @throws IOException io exception
*/ */
@RequestProcessing(value = { "/tag-articles-rss.do"}, method = { HTTPRequestMethod.GET, HTTPRequestMethod.HEAD}) @RequestProcessing(value = {"/tag-articles-rss.do"}, method = {HTTPRequestMethod.GET, HTTPRequestMethod.HEAD})
public void tagArticlesRSS(final HTTPRequestContext context) throws IOException { public void tagArticlesRSS(final HTTPRequestContext context) throws IOException {
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
final HttpServletRequest request = context.getRequest(); final HttpServletRequest request = context.getRequest();
...@@ -502,16 +500,16 @@ public class FeedProcessor { ...@@ -502,16 +500,16 @@ public class FeedProcessor {
return; return;
} }
final String blogTitle = preference.getString(Preference.BLOG_TITLE); final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String blogSubtitle = preference.getString(Preference.BLOG_SUBTITLE) + ", " + tagTitle; final String blogSubtitle = preference.getString(Option.ID_C_BLOG_SUBTITLE) + ", " + tagTitle;
final int outputCnt = preference.getInt(Preference.FEED_OUTPUT_CNT); final int outputCnt = preference.getInt(Option.ID_C_FEED_OUTPUT_CNT);
channel.setTitle(StringEscapeUtils.escapeXml(blogTitle)); channel.setTitle(StringEscapeUtils.escapeXml(blogTitle));
channel.setLastBuildDate(new Date()); channel.setLastBuildDate(new Date());
channel.setLink(Latkes.getServePath()); channel.setLink(Latkes.getServePath());
channel.setAtomLink(Latkes.getServePath() + "/tag-articles-rss.do"); channel.setAtomLink(Latkes.getServePath() + "/tag-articles-rss.do");
channel.setGenerator("Solo, ver " + SoloServletListener.VERSION); channel.setGenerator("Solo, ver " + SoloServletListener.VERSION);
final String localeString = preference.getString(Preference.LOCALE_STRING); final String localeString = preference.getString(Option.ID_C_LOCALE_STRING);
final String country = Locales.getCountry(localeString).toLowerCase(); final String country = Locales.getCountry(localeString).toLowerCase();
final String language = Locales.getLanguage(localeString).toLowerCase(); final String language = Locales.getLanguage(localeString).toLowerCase();
...@@ -546,7 +544,7 @@ public class FeedProcessor { ...@@ -546,7 +544,7 @@ public class FeedProcessor {
authorName = articleQueryService.getAuthor(articles.get(0)).getString(User.USER_NAME); authorName = articleQueryService.getAuthor(articles.get(0)).getString(User.USER_NAME);
} }
final boolean isFullContent = "fullContent".equals(preference.getString(Preference.FEED_OUTPUT_MODE)); final boolean isFullContent = "fullContent".equals(preference.getString(Option.ID_C_FEED_OUTPUT_MODE));
for (int i = 0; i < articles.size(); i++) { for (int i = 0; i < articles.size(); i++) {
final JSONObject article = articles.get(i); final JSONObject article = articles.get(i);
......
...@@ -40,7 +40,7 @@ import org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer; ...@@ -40,7 +40,7 @@ import org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer;
import org.b3log.latke.util.Locales; import org.b3log.latke.util.Locales;
import org.b3log.latke.util.Requests; import org.b3log.latke.util.Requests;
import org.b3log.solo.model.Common; 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.renderer.ConsoleRenderer;
import org.b3log.solo.processor.util.Filler; import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.service.PreferenceQueryService; import org.b3log.solo.service.PreferenceQueryService;
...@@ -53,7 +53,7 @@ import org.json.JSONObject; ...@@ -53,7 +53,7 @@ import org.json.JSONObject;
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:385321165@qq.com">DASHU</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 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -110,7 +110,7 @@ public class IndexProcessor { ...@@ -110,7 +110,7 @@ public class IndexProcessor {
final int currentPageNum = getCurrentPageNum(requestURI); final int currentPageNum = getCurrentPageNum(requestURI);
final JSONObject preference = preferenceQueryService.getPreference(); 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); filler.fillIndexArticles(request, dataModel, currentPageNum, preference);
......
...@@ -43,7 +43,6 @@ import org.b3log.latke.util.Strings; ...@@ -43,7 +43,6 @@ import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.Common; import org.b3log.solo.model.Common;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference;
import org.b3log.solo.processor.renderer.ConsoleRenderer; import org.b3log.solo.processor.renderer.ConsoleRenderer;
import org.b3log.solo.processor.util.Filler; import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.repository.OptionRepository; import org.b3log.solo.repository.OptionRepository;
...@@ -62,13 +61,13 @@ import java.util.Map; ...@@ -62,13 +61,13 @@ import java.util.Map;
/** /**
* Login/logout processor. * Login/logout processor.
* <p/> *
* <p>Initializes administrator</p>. * <p>Initializes administrator</p>.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @author <a href="mailto:dongxu.wang@acm.org">Dongxu Wang</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 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -401,7 +400,7 @@ public class LoginProcessor { ...@@ -401,7 +400,7 @@ public class LoginProcessor {
ServiceException, IOException, RepositoryException { ServiceException, IOException, RepositoryException {
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
final String token = new Randoms().nextStringWithMD5(); 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 mailSubject = langPropsService.get("resetPwdMailSubject");
final String mailBody = langPropsService.get("resetPwdMailBody") + " " + Latkes.getServePath() + "/forgot?token=" + token final String mailBody = langPropsService.get("resetPwdMailBody") + " " + Latkes.getServePath() + "/forgot?token=" + token
+ "&login=" + userEmail; + "&login=" + userEmail;
...@@ -458,7 +457,7 @@ public class LoginProcessor { ...@@ -458,7 +457,7 @@ public class LoginProcessor {
dataModel.put(Common.YEAR, String.valueOf(Calendar.getInstance().get(Calendar.YEAR))); dataModel.put(Common.YEAR, String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
dataModel.put(Common.VERSION, SoloServletListener.VERSION); dataModel.put(Common.VERSION, SoloServletListener.VERSION);
dataModel.put(Common.STATIC_RESOURCE_VERSION, Latkes.getStaticResourceVersion()); 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 token = request.getParameter("token");
final String email = request.getParameter("login"); final String email = request.getParameter("login");
......
...@@ -35,8 +35,8 @@ import org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer; ...@@ -35,8 +35,8 @@ import org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer;
import org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer; import org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer;
import org.b3log.latke.util.Stopwatchs; import org.b3log.latke.util.Stopwatchs;
import org.b3log.solo.model.Common; import org.b3log.solo.model.Common;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Page; import org.b3log.solo.model.Page;
import org.b3log.solo.model.Preference;
import org.b3log.solo.processor.util.Filler; import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.service.CommentQueryService; import org.b3log.solo.service.CommentQueryService;
import org.b3log.solo.service.PreferenceQueryService; import org.b3log.solo.service.PreferenceQueryService;
...@@ -50,7 +50,7 @@ import org.json.JSONObject; ...@@ -50,7 +50,7 @@ import org.json.JSONObject;
* Page processor. * Page processor.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -116,7 +116,7 @@ public class PageProcessor { ...@@ -116,7 +116,7 @@ public class PageProcessor {
return; 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()); final Map<String, String> langs = langPropsService.getAll(Latkes.getLocale());
...@@ -130,7 +130,7 @@ public class PageProcessor { ...@@ -130,7 +130,7 @@ public class PageProcessor {
final String pageId = page.getString(Keys.OBJECT_ID); 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)); page.put(Common.PERMALINK, page.getString(Page.PAGE_PERMALINK));
dataModel.put(Page.PAGE, page); dataModel.put(Page.PAGE, page);
final List<JSONObject> comments = commentQueryService.getComments(pageId); final List<JSONObject> comments = commentQueryService.getComments(pageId);
......
...@@ -68,7 +68,7 @@ import org.json.JSONObject; ...@@ -68,7 +68,7 @@ import org.json.JSONObject;
* See AuthFilter filter configurations in web.xml for authentication.</p> * See AuthFilter filter configurations in web.xml for authentication.</p>
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -247,19 +247,19 @@ public class RepairProcessor { ...@@ -247,19 +247,19 @@ public class RepairProcessor {
try { try {
final JSONObject preference = preferenceQueryService.getPreference(); 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); preferenceMgmtService.updatePreference(preference);
// Sends the sample signs to developer // Sends the sample signs to developer
final Message msg = new MailService.Message(); 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.addRecipient("DL88250@gmail.com");
msg.setSubject("Restore signs"); 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); MAIL_SVC.send(msg);
renderer.setContent("Restores signs succeeded."); renderer.setContent("Restores signs succeeded.");
......
...@@ -42,7 +42,7 @@ import org.b3log.latke.util.Requests; ...@@ -42,7 +42,7 @@ import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings; import org.b3log.latke.util.Strings;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import org.b3log.solo.model.Common; 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.model.Tag;
import org.b3log.solo.processor.util.Filler; import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.service.ArticleQueryService; import org.b3log.solo.service.ArticleQueryService;
...@@ -59,7 +59,7 @@ import org.json.JSONObject; ...@@ -59,7 +59,7 @@ import org.json.JSONObject;
* Tag processor. * Tag processor.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -160,10 +160,10 @@ public class TagProcessor { ...@@ -160,10 +160,10 @@ public class TagProcessor {
final JSONObject preference = preferenceQueryService.getPreference(); 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 pageSize = preference.getInt(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT);
final int windowSize = preference.getInt(Preference.ARTICLE_LIST_PAGINATION_WINDOW_SIZE); final int windowSize = preference.getInt(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
final List<JSONObject> articles = articleQueryService.getArticlesByTag(tagId, currentPageNum, pageSize); final List<JSONObject> articles = articleQueryService.getArticlesByTag(tagId, currentPageNum, pageSize);
......
...@@ -35,7 +35,7 @@ import org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer; ...@@ -35,7 +35,7 @@ import org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer;
import org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer; import org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer;
import org.b3log.latke.util.Locales; import org.b3log.latke.util.Locales;
import org.b3log.latke.util.freemarker.Templates; 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.processor.util.Filler;
import org.b3log.solo.service.PreferenceQueryService; import org.b3log.solo.service.PreferenceQueryService;
import org.b3log.solo.service.StatisticMgmtService; import org.b3log.solo.service.StatisticMgmtService;
...@@ -55,7 +55,7 @@ import org.json.JSONObject; ...@@ -55,7 +55,7 @@ import org.json.JSONObject;
* </p> * </p>
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.4.5
*/ */
@RequestProcessor @RequestProcessor
...@@ -135,7 +135,7 @@ public class UserTemplateProcessor { ...@@ -135,7 +135,7 @@ public class UserTemplateProcessor {
filler.fillBlogHeader(request, response, dataModel, preference); filler.fillBlogHeader(request, response, dataModel, preference);
filler.fillUserTemplate(request, template, dataModel, preference); filler.fillUserTemplate(request, template, dataModel, preference);
filler.fillBlogFooter(request, 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); statisticMgmtService.incBlogViewCount(request, response);
} catch (final Exception e) { } catch (final Exception e) {
......
...@@ -44,7 +44,6 @@ import org.b3log.latke.util.Strings; ...@@ -44,7 +44,6 @@ import org.b3log.latke.util.Strings;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.Common; import org.b3log.solo.model.Common;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Skin; import org.b3log.solo.model.Skin;
import org.b3log.solo.model.UserExt; import org.b3log.solo.model.UserExt;
import org.b3log.solo.processor.renderer.ConsoleRenderer; import org.b3log.solo.processor.renderer.ConsoleRenderer;
...@@ -59,7 +58,7 @@ import org.json.JSONObject; ...@@ -59,7 +58,7 @@ import org.json.JSONObject;
* Admin console render processing. * Admin console render processing.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.4.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -169,16 +168,16 @@ public class AdminConsole { ...@@ -169,16 +168,16 @@ public class AdminConsole {
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
dataModel.put(Preference.LOCALE_STRING, preference.getString(Preference.LOCALE_STRING)); dataModel.put(Option.ID_C_LOCALE_STRING, preference.getString(Option.ID_C_LOCALE_STRING));
dataModel.put(Preference.BLOG_TITLE, preference.getString(Preference.BLOG_TITLE)); dataModel.put(Option.ID_C_BLOG_TITLE, preference.getString(Option.ID_C_BLOG_TITLE));
dataModel.put(Preference.BLOG_SUBTITLE, preference.getString(Preference.BLOG_SUBTITLE)); dataModel.put(Option.ID_C_BLOG_SUBTITLE, preference.getString(Option.ID_C_BLOG_SUBTITLE));
dataModel.put(Common.VERSION, SoloServletListener.VERSION); dataModel.put(Common.VERSION, SoloServletListener.VERSION);
dataModel.put(Common.STATIC_RESOURCE_VERSION, Latkes.getStaticResourceVersion()); dataModel.put(Common.STATIC_RESOURCE_VERSION, Latkes.getStaticResourceVersion());
dataModel.put(Common.YEAR, String.valueOf(Calendar.getInstance().get(Calendar.YEAR))); 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(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT, preference.getInt(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT));
dataModel.put(Preference.ARTICLE_LIST_PAGINATION_WINDOW_SIZE, preference.getInt(Preference.ARTICLE_LIST_PAGINATION_WINDOW_SIZE)); dataModel.put(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE, preference.getInt(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE));
dataModel.put(Preference.LOCALE_STRING, preference.getString(Preference.LOCALE_STRING)); dataModel.put(Option.ID_C_LOCALE_STRING, preference.getString(Option.ID_C_LOCALE_STRING));
dataModel.put(Preference.EDITOR_TYPE, preference.getString(Preference.EDITOR_TYPE)); 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)); dataModel.put(Skin.SKIN_DIR_NAME, preference.getString(Skin.SKIN_DIR_NAME));
Keys.fillRuntime(dataModel); Keys.fillRuntime(dataModel);
...@@ -227,7 +226,7 @@ public class AdminConsole { ...@@ -227,7 +226,7 @@ public class AdminConsole {
Keys.fillRuntime(dataModel); Keys.fillRuntime(dataModel);
dataModel.put(Preference.LOCALE_STRING, locale.toString()); dataModel.put(Option.ID_C_LOCALE_STRING, locale.toString());
fireFreeMarkerActionEvent(templateName, dataModel); fireFreeMarkerActionEvent(templateName, dataModel);
} }
...@@ -253,7 +252,7 @@ public class AdminConsole { ...@@ -253,7 +252,7 @@ public class AdminConsole {
final Map<String, Object> dataModel = renderer.getDataModel(); final Map<String, Object> dataModel = renderer.getDataModel();
dataModel.putAll(langs); dataModel.putAll(langs);
dataModel.put(Preference.LOCALE_STRING, locale.toString()); dataModel.put(Option.ID_C_LOCALE_STRING, locale.toString());
JSONObject preference = null; JSONObject preference = null;
...@@ -270,7 +269,7 @@ public class AdminConsole { ...@@ -270,7 +269,7 @@ public class AdminConsole {
final String id = availableIDs[i]; final String id = availableIDs[i];
String option; 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>"; option = "<option value=\"" + id + "\" selected=\"true\">" + id + "</option>";
} else { } else {
option = "<option value=\"" + id + "\">" + id + "</option>"; option = "<option value=\"" + id + "\">" + id + "</option>";
......
...@@ -46,7 +46,7 @@ import org.json.JSONObject; ...@@ -46,7 +46,7 @@ import org.json.JSONObject;
* Preference console request processing. * Preference console request processing.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.4.0
*/ */
@RequestProcessor @RequestProcessor
...@@ -140,7 +140,7 @@ public class PreferenceConsole { ...@@ -140,7 +140,7 @@ public class PreferenceConsole {
renderer.setJSONObject(ret); renderer.setJSONObject(ret);
ret.put(Preference.REPLY_NOTIFICATION_TEMPLATE, replyNotificationTemplate); ret.put("replyNotificationTemplate", replyNotificationTemplate);
ret.put(Keys.STATUS_CODE, true); ret.put(Keys.STATUS_CODE, true);
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); LOGGER.log(Level.ERROR, e.getMessage(), e);
...@@ -185,7 +185,7 @@ public class PreferenceConsole { ...@@ -185,7 +185,7 @@ public class PreferenceConsole {
try { try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response); 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); preferenceMgmtService.updateReplyNotificationTemplate(replyNotificationTemplate);
...@@ -244,7 +244,7 @@ public class PreferenceConsole { ...@@ -244,7 +244,7 @@ public class PreferenceConsole {
final JSONArray signs = new JSONArray(); final JSONArray signs = new JSONArray();
final JSONArray allSigns = // includes the empty sign(id=0) 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 for (int i = 1; i < allSigns.length(); i++) { // excludes the empty sign
signs.put(allSigns.getJSONObject(i)); signs.put(allSigns.getJSONObject(i));
...@@ -596,7 +596,7 @@ public class PreferenceConsole { ...@@ -596,7 +596,7 @@ public class PreferenceConsole {
errMsgBuilder.append(" - "); 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)) { if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("externalRelevantArticlesDisplayCntLabel")).append("] ").append( errMsgBuilder.append(langPropsService.get("externalRelevantArticlesDisplayCntLabel")).append("] ").append(
...@@ -605,7 +605,7 @@ public class PreferenceConsole { ...@@ -605,7 +605,7 @@ public class PreferenceConsole {
return true; return true;
} }
input = preference.optString(Preference.RELEVANT_ARTICLES_DISPLAY_CNT); input = preference.optString(Option.ID_C_RELEVANT_ARTICLES_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) { if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("relevantArticlesDisplayCntLabel")).append("] ").append( errMsgBuilder.append(langPropsService.get("relevantArticlesDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel")); langPropsService.get("nonNegativeIntegerOnlyLabel"));
...@@ -613,7 +613,7 @@ public class PreferenceConsole { ...@@ -613,7 +613,7 @@ public class PreferenceConsole {
return true; return true;
} }
input = preference.optString(Preference.RANDOM_ARTICLES_DISPLAY_CNT); input = preference.optString(Option.ID_C_RANDOM_ARTICLES_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) { if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("randomArticlesDisplayCntLabel")).append("] ").append( errMsgBuilder.append(langPropsService.get("randomArticlesDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel")); langPropsService.get("nonNegativeIntegerOnlyLabel"));
...@@ -621,7 +621,7 @@ public class PreferenceConsole { ...@@ -621,7 +621,7 @@ public class PreferenceConsole {
return true; 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)) { if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexMostCommentArticleDisplayCntLabel")).append("] ").append( errMsgBuilder.append(langPropsService.get("indexMostCommentArticleDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel")); langPropsService.get("nonNegativeIntegerOnlyLabel"));
...@@ -629,7 +629,7 @@ public class PreferenceConsole { ...@@ -629,7 +629,7 @@ public class PreferenceConsole {
return true; 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)) { if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexMostViewArticleDisplayCntLabel")).append("] ").append( errMsgBuilder.append(langPropsService.get("indexMostViewArticleDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel")); langPropsService.get("nonNegativeIntegerOnlyLabel"));
...@@ -637,7 +637,7 @@ public class PreferenceConsole { ...@@ -637,7 +637,7 @@ public class PreferenceConsole {
return true; return true;
} }
input = preference.optString(Preference.RECENT_COMMENT_DISPLAY_CNT); input = preference.optString(Option.ID_C_RECENT_COMMENT_DISPLAY_CNT);
if (!isNonNegativeInteger(input)) { if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexRecentCommentDisplayCntLabel")).append("] ").append( errMsgBuilder.append(langPropsService.get("indexRecentCommentDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel")); langPropsService.get("nonNegativeIntegerOnlyLabel"));
...@@ -645,7 +645,7 @@ public class PreferenceConsole { ...@@ -645,7 +645,7 @@ public class PreferenceConsole {
return true; 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)) { if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("indexTagDisplayCntLabel")).append("] ").append( errMsgBuilder.append(langPropsService.get("indexTagDisplayCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel")); langPropsService.get("nonNegativeIntegerOnlyLabel"));
...@@ -653,7 +653,7 @@ public class PreferenceConsole { ...@@ -653,7 +653,7 @@ public class PreferenceConsole {
return true; return true;
} }
input = preference.optString(Preference.ARTICLE_LIST_DISPLAY_COUNT); input = preference.optString(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT);
if (!isNonNegativeInteger(input)) { if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("pageSizeLabel")).append("] ").append( errMsgBuilder.append(langPropsService.get("pageSizeLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel")); langPropsService.get("nonNegativeIntegerOnlyLabel"));
...@@ -661,7 +661,7 @@ public class PreferenceConsole { ...@@ -661,7 +661,7 @@ public class PreferenceConsole {
return true; 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)) { if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("windowSizeLabel")).append("] ").append( errMsgBuilder.append(langPropsService.get("windowSizeLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel")); langPropsService.get("nonNegativeIntegerOnlyLabel"));
...@@ -669,7 +669,7 @@ public class PreferenceConsole { ...@@ -669,7 +669,7 @@ public class PreferenceConsole {
return true; return true;
} }
input = preference.optString(Preference.FEED_OUTPUT_CNT); input = preference.optString(Option.ID_C_FEED_OUTPUT_CNT);
if (!isNonNegativeInteger(input)) { if (!isNonNegativeInteger(input)) {
errMsgBuilder.append(langPropsService.get("feedOutputCntLabel")).append("] ").append( errMsgBuilder.append(langPropsService.get("feedOutputCntLabel")).append("] ").append(
langPropsService.get("nonNegativeIntegerOnlyLabel")); langPropsService.get("nonNegativeIntegerOnlyLabel"));
......
...@@ -39,8 +39,14 @@ import org.b3log.latke.util.CollectionUtils; ...@@ -39,8 +39,14 @@ import org.b3log.latke.util.CollectionUtils;
import org.b3log.latke.util.Ids; import org.b3log.latke.util.Ids;
import org.b3log.latke.util.Strings; import org.b3log.latke.util.Strings;
import org.b3log.solo.event.EventTypes; 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 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.ArchiveDateArticleRepository;
import org.b3log.solo.repository.ArchiveDateRepository; import org.b3log.solo.repository.ArchiveDateRepository;
import org.b3log.solo.repository.ArticleRepository; import org.b3log.solo.repository.ArticleRepository;
...@@ -58,7 +64,7 @@ import org.json.JSONObject; ...@@ -58,7 +64,7 @@ import org.json.JSONObject;
* Article management service. * Article management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.5
*/ */
@Service @Service
...@@ -325,7 +331,7 @@ public class ArticleMgmtService { ...@@ -325,7 +331,7 @@ public class ArticleMgmtService {
// Set editor type // Set editor type
if (!article.has(Article.ARTICLE_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); final boolean publishNewArticle = !oldArticle.getBoolean(ARTICLE_IS_PUBLISHED) && article.getBoolean(ARTICLE_IS_PUBLISHED);
...@@ -526,7 +532,7 @@ public class ArticleMgmtService { ...@@ -526,7 +532,7 @@ public class ArticleMgmtService {
userRepository.update(author.optString(Keys.OBJECT_ID), author); userRepository.update(author.optString(Keys.OBJECT_ID), author);
// Step 14: Set editor type // Step 14: Set editor type
if (!article.has(Article.ARTICLE_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 // Step 15: Add article
articleRepository.add(article); articleRepository.add(article);
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package org.b3log.solo.service; package org.b3log.solo.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
...@@ -44,7 +43,7 @@ import org.b3log.latke.util.Strings; ...@@ -44,7 +43,7 @@ import org.b3log.latke.util.Strings;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import static org.b3log.solo.model.Article.*; import static org.b3log.solo.model.Article.*;
import org.b3log.solo.model.Common; import org.b3log.solo.model.Common;
import org.b3log.solo.model.Preference; import org.b3log.solo.model.Option;
import org.b3log.solo.model.Sign; import org.b3log.solo.model.Sign;
import org.b3log.solo.model.Tag; import org.b3log.solo.model.Tag;
import org.b3log.solo.repository.ArchiveDateArticleRepository; import org.b3log.solo.repository.ArchiveDateArticleRepository;
...@@ -58,13 +57,12 @@ import org.json.JSONArray; ...@@ -58,13 +57,12 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* Article query service. * Article query service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://blog.sweelia.com">ArmstrongCN</a> * @author <a href="http://blog.sweelia.com">ArmstrongCN</a>
* @version 1.1.2.3, Jun 13, 2015 * @version 1.1.2.4, Nov 20, 2015
* @since 0.3.5 * @since 0.3.5
*/ */
@Service @Service
...@@ -134,8 +132,7 @@ public class ArticleQueryService { ...@@ -134,8 +132,7 @@ public class ArticleQueryService {
* *
* @param articleId the given article id * @param articleId the given article id
* @param request the specified request * @param request the specified request
* @return {@code true} if the current user can access the article, * @return {@code true} if the current user can access the article, {@code false} otherwise
* {@code false} otherwise
* @throws Exception exception * @throws Exception exception
*/ */
public boolean canAccessArticle(final String articleId, final HttpServletRequest request) throws Exception { public boolean canAccessArticle(final String articleId, final HttpServletRequest request) throws Exception {
...@@ -234,14 +231,13 @@ public class ArticleQueryService { ...@@ -234,14 +231,13 @@ public class ArticleQueryService {
* Gets the specified article's author. * Gets the specified article's author.
* *
* <p> * <p>
* The specified article has a property * The specified article has a property {@value Article#ARTICLE_AUTHOR_EMAIL}, this method will use this property to
* {@value Article#ARTICLE_AUTHOR_EMAIL}, this method will use this property * get a user from users.
* to get a user from users.
* </p> * </p>
* *
* <p> * <p>
* If can't find the specified article's author (i.e. the author has been * If can't find the specified article's author (i.e. the author has been removed by administrator), returns
* removed by administrator), returns administrator. * administrator.
* </p> * </p>
* *
* @param article the specified article * @param article the specified article
...@@ -282,7 +278,7 @@ public class ArticleQueryService { ...@@ -282,7 +278,7 @@ public class ArticleQueryService {
* @throws JSONException json exception * @throws JSONException json exception
*/ */
public JSONObject getSign(final String signId, final JSONObject preference) throws JSONException, RepositoryException { public JSONObject getSign(final String signId, final JSONObject preference) throws JSONException, RepositoryException {
final JSONArray signs = new JSONArray(preference.getString(Preference.SIGNS)); final JSONArray signs = new JSONArray(preference.getString(Option.ID_C_SIGNS));
JSONObject defaultSign = null; JSONObject defaultSign = null;
...@@ -354,8 +350,7 @@ public class ArticleQueryService { ...@@ -354,8 +350,7 @@ public class ArticleQueryService {
* Gets the recent articles with the specified fetch size. * Gets the recent articles with the specified fetch size.
* *
* @param fetchSize the specified fetch size * @param fetchSize the specified fetch size
* @return a list of json object, its size less or equal to the specified * @return a list of json object, its size less or equal to the specified fetch size
* fetch size
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public List<JSONObject> getRecentArticles(final int fetchSize) throws ServiceException { public List<JSONObject> getRecentArticles(final int fetchSize) throws ServiceException {
...@@ -376,8 +371,7 @@ public class ArticleQueryService { ...@@ -376,8 +371,7 @@ public class ArticleQueryService {
* </p> * </p>
* *
* @param articleId the specified article id * @param articleId the specified article id
* @return for example, * @return for example, <pre>
* <pre>
* { * {
* "article": { * "article": {
* "oId": "", * "oId": "",
...@@ -432,7 +426,7 @@ public class ArticleQueryService { ...@@ -432,7 +426,7 @@ public class ArticleQueryService {
// Signs // Signs
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
article.put(Sign.SIGNS, new JSONArray(preference.getString(Preference.SIGNS))); article.put(Sign.SIGNS, new JSONArray(preference.getString(Option.ID_C_SIGNS)));
// Remove unused properties // Remove unused properties
article.remove(ARTICLE_AUTHOR_EMAIL); article.remove(ARTICLE_AUTHOR_EMAIL);
...@@ -453,20 +447,18 @@ public class ArticleQueryService { ...@@ -453,20 +447,18 @@ public class ArticleQueryService {
} }
/** /**
* Gets articles(by crate date descending) by the specified request json * Gets articles(by crate date descending) by the specified request json object.
* object.
* *
* <p> * <p>
* If the property "articleIsPublished" of the specified request json object is {@code true}, the returned articles all are published, * If the property "articleIsPublished" of the specified request json object is {@code true}, the returned articles
* {@code false} otherwise. * all are published, {@code false} otherwise.
* </p> * </p>
* *
* <p> * <p>
* Specified the "excludes" for results properties exclusion. * Specified the "excludes" for results properties exclusion.
* </p> * </p>
* *
* @param requestJSONObject the specified request json object, for example, * @param requestJSONObject the specified request json object, for example, <pre>
* <pre>
* { * {
* "paginationCurrentPageNum": 1, * "paginationCurrentPageNum": 1,
* "paginationPageSize": 20, * "paginationPageSize": 20,
...@@ -476,8 +468,7 @@ public class ArticleQueryService { ...@@ -476,8 +468,7 @@ public class ArticleQueryService {
* }, see {@link Pagination} for more details * }, see {@link Pagination} for more details
* </pre> * </pre>
* *
* @return for example, * @return for example, <pre>
* <pre>
* { * {
* "pagination": { * "pagination": {
* "paginationPageCount": 100, * "paginationPageCount": 100,
...@@ -697,8 +688,7 @@ public class ArticleQueryService { ...@@ -697,8 +688,7 @@ public class ArticleQueryService {
* </p> * </p>
* *
* @param fetchSize the specified fetch size * @param fetchSize the specified fetch size
* @return a list of json objects, its size less or equal to the specified * @return a list of json objects, its size less or equal to the specified fetch size
* fetch size
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public List<JSONObject> getArticlesRandomly(final int fetchSize) throws ServiceException { public List<JSONObject> getArticlesRandomly(final int fetchSize) throws ServiceException {
...@@ -729,7 +719,7 @@ public class ArticleQueryService { ...@@ -729,7 +719,7 @@ public class ArticleQueryService {
public List<JSONObject> getRelevantArticles(final JSONObject article, final JSONObject preference) public List<JSONObject> getRelevantArticles(final JSONObject article, final JSONObject preference)
throws ServiceException { throws ServiceException {
try { try {
final int displayCnt = preference.getInt(Preference.RELEVANT_ARTICLES_DISPLAY_CNT); final int displayCnt = preference.getInt(Option.ID_C_RELEVANT_ARTICLES_DISPLAY_CNT);
final String[] tagTitles = article.getString(Article.ARTICLE_TAGS_REF).split(","); final String[] tagTitles = article.getString(Article.ARTICLE_TAGS_REF).split(",");
final int maxTagCnt = displayCnt > tagTitles.length ? tagTitles.length : displayCnt; final int maxTagCnt = displayCnt > tagTitles.length ? tagTitles.length : displayCnt;
final String articleId = article.getString(Keys.OBJECT_ID); final String articleId = article.getString(Keys.OBJECT_ID);
...@@ -819,15 +809,13 @@ public class ArticleQueryService { ...@@ -819,15 +809,13 @@ public class ArticleQueryService {
* </p> * </p>
* *
* @param articleId the specified article id * @param articleId the specified article id
* @return the previous article, * @return the previous article, <pre>
* <pre>
* { * {
* "articleTitle": "", * "articleTitle": "",
* "articlePermalink": "", * "articlePermalink": "",
* "articleAbstract": "" * "articleAbstract": ""
* } * }
* </pre> * </pre> returns {@code null} if not found
* returns {@code null} if not found
* *
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
...@@ -848,15 +836,13 @@ public class ArticleQueryService { ...@@ -848,15 +836,13 @@ public class ArticleQueryService {
* </p> * </p>
* *
* @param articleId the specified article id * @param articleId the specified article id
* @return the previous article, * @return the previous article, <pre>
* <pre>
* { * {
* "articleTitle": "", * "articleTitle": "",
* "articlePermalink": "", * "articlePermalink": "",
* "articleAbstract": "" * "articleAbstract": ""
* } * }
* </pre> * </pre> returns {@code null} if not found
* returns {@code null} if not found
* *
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
......
...@@ -54,7 +54,7 @@ import org.json.JSONObject; ...@@ -54,7 +54,7 @@ import org.json.JSONObject;
* Comment management service. * Comment management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.5
*/ */
@Service @Service
...@@ -180,7 +180,7 @@ public class CommentMgmtService { ...@@ -180,7 +180,7 @@ public class CommentMgmtService {
final String commentId = comment.getString(Keys.OBJECT_ID); final String commentId = comment.getString(Keys.OBJECT_ID);
final String commentContent = comment.getString(Comment.COMMENT_CONTENT).replaceAll(SoloServletListener.ENTER_ESC, "<br/>"); 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)) { if (adminEmail.equalsIgnoreCase(commentEmail)) {
LOGGER.log(Level.DEBUG, "Do not send comment notification mail to admin itself[{0}]", adminEmail); LOGGER.log(Level.DEBUG, "Do not send comment notification mail to admin itself[{0}]", adminEmail);
...@@ -204,7 +204,7 @@ public class CommentMgmtService { ...@@ -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; boolean isArticle = true;
String title = articleOrPage.optString(Article.ARTICLE_TITLE); String title = articleOrPage.optString(Article.ARTICLE_TITLE);
...@@ -281,7 +281,7 @@ public class CommentMgmtService { ...@@ -281,7 +281,7 @@ public class CommentMgmtService {
ret.put(Keys.STATUS_CODE, false); ret.put(Keys.STATUS_CODE, false);
final JSONObject preference = preferenceQueryService.getPreference(); 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")); ret.put(Keys.MSG, langPropsService.get("notAllowCommentLabel"));
return ret; return ret;
......
...@@ -540,7 +540,7 @@ public class InitService { ...@@ -540,7 +540,7 @@ public class InitService {
final JSONObject replyNotificationTemplate = new JSONObject(Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE); 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(); final JSONObject subjectOpt = new JSONObject();
subjectOpt.put(Keys.OBJECT_ID, Option.ID_C_REPLY_NOTI_TPL_SUBJECT); subjectOpt.put(Keys.OBJECT_ID, Option.ID_C_REPLY_NOTI_TPL_SUBJECT);
......
...@@ -28,8 +28,8 @@ import org.b3log.latke.service.annotation.Service; ...@@ -28,8 +28,8 @@ import org.b3log.latke.service.annotation.Service;
import org.b3log.latke.util.Ids; import org.b3log.latke.util.Ids;
import org.b3log.latke.util.Strings; import org.b3log.latke.util.Strings;
import org.b3log.solo.model.Comment; import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Page; import org.b3log.solo.model.Page;
import org.b3log.solo.model.Preference;
import org.b3log.solo.repository.CommentRepository; import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.PageRepository; import org.b3log.solo.repository.PageRepository;
import org.b3log.solo.util.Comments; import org.b3log.solo.util.Comments;
...@@ -40,7 +40,7 @@ import org.json.JSONObject; ...@@ -40,7 +40,7 @@ import org.json.JSONObject;
* Page management service. * Page management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.4.0
*/ */
@Service @Service
...@@ -169,7 +169,7 @@ public class PageMgmtService { ...@@ -169,7 +169,7 @@ public class PageMgmtService {
// Set editor type // Set editor type
if (!newPage.has(Page.PAGE_EDITOR_TYPE)) { if (!newPage.has(Page.PAGE_EDITOR_TYPE)) {
final JSONObject preference = preferenceQueryService.getPreference(); 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); pageRepository.update(pageId, newPage);
...@@ -278,7 +278,7 @@ public class PageMgmtService { ...@@ -278,7 +278,7 @@ public class PageMgmtService {
// Set editor type // Set editor type
if (!page.has(Page.PAGE_EDITOR_TYPE)) { if (!page.has(Page.PAGE_EDITOR_TYPE)) {
final JSONObject preference = preferenceQueryService.getPreference(); 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); final String ret = pageRepository.add(page);
......
...@@ -38,7 +38,6 @@ import org.b3log.solo.model.Preference; ...@@ -38,7 +38,6 @@ import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Skin; import org.b3log.solo.model.Skin;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; 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.SKINS;
import static org.b3log.solo.model.Skin.SKIN_DIR_NAME; import static org.b3log.solo.model.Skin.SKIN_DIR_NAME;
import static org.b3log.solo.model.Skin.SKIN_NAME; import static org.b3log.solo.model.Skin.SKIN_NAME;
...@@ -50,7 +49,7 @@ import static org.b3log.solo.util.Skins.setDirectoryForTemplateLoading; ...@@ -50,7 +49,7 @@ import static org.b3log.solo.util.Skins.setDirectoryForTemplateLoading;
* Preference management service. * Preference management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.4.0
*/ */
@Service @Service
...@@ -148,7 +147,7 @@ public class PreferenceMgmtService { ...@@ -148,7 +147,7 @@ public class PreferenceMgmtService {
setDirectoryForTemplateLoading(preference.getString(SKIN_DIR_NAME)); 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)) { if ("zh_CN".equals(localeString)) {
TimeZones.setTimeZone("Asia/Shanghai"); TimeZones.setTimeZone("Asia/Shanghai");
...@@ -229,19 +228,19 @@ public class PreferenceMgmtService { ...@@ -229,19 +228,19 @@ public class PreferenceMgmtService {
preference.put(Skin.SKINS, skinArray.toString()); 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); 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 JSONObject oldPreference = preferenceQueryService.getPreference();
final String adminEmail = oldPreference.getString(ADMIN_EMAIL); final String adminEmail = oldPreference.getString(Option.ID_C_ADMIN_EMAIL);
preference.put(ADMIN_EMAIL, adminEmail); preference.put(Option.ID_C_ADMIN_EMAIL, adminEmail);
final String version = oldPreference.optString(VERSION); final String version = oldPreference.optString(Option.ID_C_VERSION);
preference.put(VERSION, 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); LOGGER.log(Level.DEBUG, "Current locale[string={0}]", localeString);
Latkes.setLocale(new Locale(Locales.getLanguage(localeString), Locales.getCountry(localeString))); Latkes.setLocale(new Locale(Locales.getLanguage(localeString), Locales.getCountry(localeString)));
......
...@@ -17,6 +17,7 @@ package org.b3log.solo.service; ...@@ -17,6 +17,7 @@ package org.b3log.solo.service;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.solo.AbstractTestCase; import org.b3log.solo.AbstractTestCase;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference; import org.b3log.solo.model.Preference;
import org.json.JSONObject; import org.json.JSONObject;
import org.testng.Assert; import org.testng.Assert;
...@@ -26,7 +27,7 @@ import org.testng.annotations.Test; ...@@ -26,7 +27,7 @@ import org.testng.annotations.Test;
* {@link PreferenceMgmtService} test case. * {@link PreferenceMgmtService} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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") @Test(suiteName = "service")
public class PreferenceMgmtServiceTestCase extends AbstractTestCase { public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
...@@ -62,14 +63,14 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase { ...@@ -62,14 +63,14 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
final PreferenceQueryService preferenceQueryService = getPreferenceQueryService(); final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
JSONObject preference = preferenceQueryService.getPreference(); 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.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); preferenceMgmtService.updatePreference(preference);
preference = preferenceQueryService.getPreference(); 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 { ...@@ -79,23 +80,16 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
*/ */
@Test(dependsOnMethods = "init") @Test(dependsOnMethods = "init")
public void updateReplyNotificationTemplate() throws Exception { public void updateReplyNotificationTemplate() throws Exception {
final PreferenceMgmtService preferenceMgmtService final PreferenceMgmtService preferenceMgmtService = getPreferenceMgmtService();
= getPreferenceMgmtService(); final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
final PreferenceQueryService preferenceQueryService JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
= getPreferenceQueryService();
JSONObject replyNotificationTemplate
= preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.toString(), Assert.assertEquals(replyNotificationTemplate.toString(), Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
replyNotificationTemplate.put("subject", "updated subject"); replyNotificationTemplate.put("subject", "updated subject");
preferenceMgmtService.updateReplyNotificationTemplate( preferenceMgmtService.updateReplyNotificationTemplate(replyNotificationTemplate);
replyNotificationTemplate);
replyNotificationTemplate replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
= preferenceQueryService.getReplyNotificationTemplate(); Assert.assertEquals(replyNotificationTemplate.getString("subject"), "updated subject");
Assert.assertEquals(replyNotificationTemplate.getString(
"subject"), "updated subject");
} }
} }
...@@ -17,6 +17,7 @@ package org.b3log.solo.service; ...@@ -17,6 +17,7 @@ package org.b3log.solo.service;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.solo.AbstractTestCase; import org.b3log.solo.AbstractTestCase;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference; import org.b3log.solo.model.Preference;
import org.json.JSONObject; import org.json.JSONObject;
import org.testng.Assert; import org.testng.Assert;
...@@ -26,7 +27,7 @@ import org.testng.annotations.Test; ...@@ -26,7 +27,7 @@ import org.testng.annotations.Test;
* {@link PreferenceQueryService} test case. * {@link PreferenceQueryService} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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") @Test(suiteName = "service")
public class PreferenceQueryServiceTestCase extends AbstractTestCase { public class PreferenceQueryServiceTestCase extends AbstractTestCase {
...@@ -58,12 +59,11 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase { ...@@ -58,12 +59,11 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase {
*/ */
@Test(dependsOnMethods = "init") @Test(dependsOnMethods = "init")
public void getPreference() throws Exception { public void getPreference() throws Exception {
final PreferenceQueryService preferenceQueryService = final PreferenceQueryService preferenceQueryService
getPreferenceQueryService(); = getPreferenceQueryService();
final JSONObject preference = preferenceQueryService.getPreference(); final 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.Default.DEFAULT_BLOG_TITLE);
} }
/** /**
...@@ -73,12 +73,11 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase { ...@@ -73,12 +73,11 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase {
*/ */
@Test(dependsOnMethods = "init") @Test(dependsOnMethods = "init")
public void getReplyNotificationTemplate() throws Exception { public void getReplyNotificationTemplate() throws Exception {
final PreferenceQueryService preferenceQueryService = final PreferenceQueryService preferenceQueryService
getPreferenceQueryService(); = getPreferenceQueryService();
final JSONObject replyNotificationTemplate = final JSONObject replyNotificationTemplate
preferenceQueryService.getReplyNotificationTemplate(); = preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.toString(), Assert.assertEquals(replyNotificationTemplate.toString(), Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
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