Commit 6bdfa922 authored by Liang Ding's avatar Liang Ding

Fix #12041

parent 017f9fda
...@@ -43,9 +43,10 @@ import org.b3log.solo.event.rhythm.ArticleUpdater; ...@@ -43,9 +43,10 @@ import org.b3log.solo.event.rhythm.ArticleUpdater;
import org.b3log.solo.event.symphony.CommentSender; import org.b3log.solo.event.symphony.CommentSender;
import org.b3log.solo.model.Preference; import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Skin; import org.b3log.solo.model.Skin;
import org.b3log.solo.repository.PreferenceRepository; import org.b3log.solo.repository.OptionRepository;
import org.b3log.solo.repository.impl.PreferenceRepositoryImpl; import org.b3log.solo.repository.impl.OptionRepositoryImpl;
import org.b3log.solo.service.PreferenceMgmtService; import org.b3log.solo.service.PreferenceMgmtService;
import org.b3log.solo.service.PreferenceQueryService;
import org.b3log.solo.service.StatisticMgmtService; import org.b3log.solo.service.StatisticMgmtService;
import org.b3log.solo.service.UpgradeService; import org.b3log.solo.service.UpgradeService;
import org.b3log.solo.util.Skins; import org.b3log.solo.util.Skins;
...@@ -55,7 +56,7 @@ import org.json.JSONObject; ...@@ -55,7 +56,7 @@ import org.json.JSONObject;
* Solo Servlet listener. * Solo Servlet listener.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.6.0.9, Nov 5, 2015 * @version 1.7.0.9, Nov 8, 2015
* @since 0.3.1 * @since 0.3.1
*/ */
public final class SoloServletListener extends AbstractServletListener { public final class SoloServletListener extends AbstractServletListener {
...@@ -123,9 +124,9 @@ public final class SoloServletListener extends AbstractServletListener { ...@@ -123,9 +124,9 @@ public final class SoloServletListener extends AbstractServletListener {
// Set default skin, loads from preference later // Set default skin, loads from preference later
Skins.setDirectoryForTemplateLoading(Preference.Default.DEFAULT_SKIN_DIR_NAME); Skins.setDirectoryForTemplateLoading(Preference.Default.DEFAULT_SKIN_DIR_NAME);
final PreferenceRepository preferenceRepository = beanManager.getReference(PreferenceRepositoryImpl.class); final OptionRepository optionRepository = beanManager.getReference(OptionRepositoryImpl.class);
final Transaction transaction = preferenceRepository.beginTransaction(); final Transaction transaction = optionRepository.beginTransaction();
try { try {
loadPreference(); loadPreference();
...@@ -218,11 +219,11 @@ public final class SoloServletListener extends AbstractServletListener { ...@@ -218,11 +219,11 @@ public final class SoloServletListener extends AbstractServletListener {
LOGGER.debug("Loading preference...."); LOGGER.debug("Loading preference....");
final PreferenceRepository preferenceRepository = beanManager.getReference(PreferenceRepositoryImpl.class); final PreferenceQueryService preferenceQueryService = beanManager.getReference(PreferenceQueryService.class);
JSONObject preference; JSONObject preference;
try { try {
preference = preferenceRepository.get(Preference.PREFERENCE); preference = preferenceQueryService.getPreference();
if (null == preference) { if (null == preference) {
LOGGER.warn("Can't not init default skin, please init Solo first"); LOGGER.warn("Can't not init default skin, please init Solo first");
return; return;
...@@ -282,8 +283,8 @@ public final class SoloServletListener extends AbstractServletListener { ...@@ -282,8 +283,8 @@ public final class SoloServletListener extends AbstractServletListener {
*/ */
private void resolveSkinDir(final HttpServletRequest httpServletRequest) { private void resolveSkinDir(final HttpServletRequest httpServletRequest) {
try { try {
final PreferenceRepository preferenceRepository = beanManager.getReference(PreferenceRepositoryImpl.class); final PreferenceQueryService preferenceQueryService = beanManager.getReference(PreferenceQueryService.class);
final JSONObject preference = preferenceRepository.get(Preference.PREFERENCE); final JSONObject preference = preferenceQueryService.getPreference();
if (null == preference) { // Did not initialize yet if (null == preference) { // Did not initialize yet
return; return;
......
...@@ -19,7 +19,7 @@ package org.b3log.solo.model; ...@@ -19,7 +19,7 @@ package org.b3log.solo.model;
* This class defines option model relevant keys. * This class defines option model relevant keys.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.1, Nov 7, 2015 * @version 1.2.0.1, Nov 8, 2015
* @since 0.6.0 * @since 0.6.0
*/ */
public final class Option { public final class Option {
...@@ -70,6 +70,201 @@ public final class Option { ...@@ -70,6 +70,201 @@ public final class Option {
*/ */
public static final String ID_C_QINIU_BUCKET = "qiniuBucket"; public static final String ID_C_QINIU_BUCKET = "qiniuBucket";
/**
* Key of blog title.
*/
public static final String ID_C_BLOG_TITLE = "blogTitle";
/**
* Key of blog subtitle.
*/
public static final String ID_C_BLOG_SUBTITLE = "blogSubtitle";
/**
* Key of relevant articles display count.
*/
public static final String ID_C_RELEVANT_ARTICLES_DISPLAY_CNT = "relevantArticlesDisplayCount";
/**
* Key of random articles display count.
*/
public static final String ID_C_RANDOM_ARTICLES_DISPLAY_CNT = "randomArticlesDisplayCount";
/**
* Key of external relevant articles display count.
*/
public static final String ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT = "externalRelevantArticlesDisplayCount";
/**
* Key of recent article display count.
*/
public static final String ID_C_RECENT_ARTICLE_DISPLAY_CNT = "recentArticleDisplayCount";
/**
* Key of recent comment display count.
*/
public static final String ID_C_RECENT_COMMENT_DISPLAY_CNT = "recentCommentDisplayCount";
/**
* Key of most used tag display count.
*/
public static final String ID_C_MOST_USED_TAG_DISPLAY_CNT = "mostUsedTagDisplayCount";
/**
* Key of most comment article display count.
*/
public static final String ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT = "mostCommentArticleDisplayCount";
/**
* Key of most view article display count.
*/
public static final String ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT = "mostViewArticleDisplayCount";
/**
* Key of article list display count.
*/
public static final String ID_C_ARTICLE_LIST_DISPLAY_COUNT = "articleListDisplayCount";
/**
* Key of article list pagination window size.
*/
public static final String ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE = "articleListPaginationWindowSize";
/**
* Key of administrator's email.
*/
public static final String ID_C_ADMIN_EMAIL = "adminEmail";
/**
* Key of locale string.
*/
public static final String ID_C_LOCALE_STRING = "localeString";
/**
* Key of time zone id.
*/
public static final String ID_C_TIME_ZONE_ID = "timeZoneId";
/**
* Key of notice board.
*/
public static final String ID_C_NOTICE_BOARD = "noticeBoard";
/**
* Key of HTML head.
*/
public static final String ID_C_HTML_HEAD = "htmlHead";
/**
* Key of meta keywords.
*/
public static final String ID_C_META_KEYWORDS = "metaKeywords";
/**
* Key of meta description.
*/
public static final String ID_C_META_DESCRIPTION = "metaDescription";
/**
* Key of article update hint flag.
*/
public static final String ID_C_ENABLE_ARTICLE_UPDATE_HINT = "enableArticleUpdateHint";
/**
* Key of signs.
*/
public static final String ID_C_SIGNS = "signs";
/**
* Key of key of Solo.
*/
public static final String ID_C_KEY_OF_SOLO = "keyOfSolo";
/**
* Key of allow visit draft via permalink.
*/
public static final String ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK = "allowVisitDraftViaPermalink";
/**
* Key of version.
*/
public static final String ID_C_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 ID_C_ARTICLE_LIST_STYLE = "articleListStyle";
/**
* Key of article/page comment-able.
*/
public static final String ID_C_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 ID_C_FEED_OUTPUT_MODE = "feedOutputMode";
/**
* Key of feed (Atom/RSS) output entry count.
*/
public static final String ID_C_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 ID_C_EDITOR_TYPE = "editorType";
/**
* Key of skins.
*/
public static final String ID_C_SKINS = "skins";
/**
* Key of skin dir name.
*/
public static final String ID_C_SKIN_DIR_NAME = "skinDirName";
/**
* Key of skin name.
*/
public static final String ID_C_SKIN_NAME = "skinName";
/**
* Key of reply notification template body.
*/
public static final String ID_C_REPLY_NOTI_TPL_BODY = "replyNotiTplBody";
/**
* Key of reply notification template subject.
*/
public static final String ID_C_REPLY_NOTI_TPL_SUBJECT = "replyNotiTplSubject";
/** /**
* Key of footer content. * Key of footer content.
*/ */
......
...@@ -27,7 +27,7 @@ import org.json.JSONObject; ...@@ -27,7 +27,7 @@ import org.json.JSONObject;
* This class defines all comment model relevant keys. * This class defines all comment model relevant keys.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.10, Jun 18, 2015 * @version 1.2.0.10, Nov 8, 2015
* @since 0.3.1 * @since 0.3.1
*/ */
public final class Preference { public final class Preference {
...@@ -291,7 +291,7 @@ public final class Preference { ...@@ -291,7 +291,7 @@ public final class Preference {
/** /**
* Default enable article update hint. * Default enable article update hint.
*/ */
public static final boolean DEFAULT_ENABLE_ARTICLE_UPDATE_HINT = true; public static final String DEFAULT_ENABLE_ARTICLE_UPDATE_HINT = "true";
/** /**
* Default notice board. * Default notice board.
...@@ -313,6 +313,11 @@ public final class Preference { ...@@ -313,6 +313,11 @@ public final class Preference {
*/ */
public static final String DEFAULT_HTML_HEAD = ""; public static final String DEFAULT_HTML_HEAD = "";
/**
* Default footer content.
*/
public static final String DEFAULT_FOOTER_CONTENT = "";
/** /**
* Default relevant articles display count. * Default relevant articles display count.
*/ */
...@@ -341,12 +346,12 @@ public final class Preference { ...@@ -341,12 +346,12 @@ public final class Preference {
/** /**
* Default allow visit draft via permalink. * Default allow visit draft via permalink.
*/ */
public static final boolean DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK = false; public static final String DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK = "false";
/** /**
* Default allow comment article/page. * Default allow comment article/page.
*/ */
public static final boolean DEFAULT_COMMENTABLE = true; public static final String DEFAULT_COMMENTABLE = "true";
/** /**
* Default administrator's password. * Default administrator's password.
...@@ -404,7 +409,6 @@ public final class Preference { ...@@ -404,7 +409,6 @@ public final class Preference {
final JSONObject replyNotificationTemplate = new JSONObject(); final JSONObject replyNotificationTemplate = new JSONObject();
replyNotificationTemplate.put(Keys.OBJECT_ID, Preference.REPLY_NOTIFICATION_TEMPLATE);
replyNotificationTemplate.put("subject", "${blogTitle}: New reply of your comment"); replyNotificationTemplate.put("subject", "${blogTitle}: New reply of your comment");
replyNotificationTemplate.put("body", replyNotificationTemplate.put("body",
"Your comment on post[<a href='${postLink}'>" + "${postTitle}</a>] received an reply: <p>${replier}" "Your comment on post[<a href='${postLink}'>" + "${postTitle}</a>] received an reply: <p>${replier}"
......
...@@ -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.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -48,9 +47,9 @@ import org.b3log.solo.repository.impl.ArchiveDateRepositoryImpl; ...@@ -48,9 +47,9 @@ import org.b3log.solo.repository.impl.ArchiveDateRepositoryImpl;
import org.b3log.solo.repository.impl.ArticleRepositoryImpl; import org.b3log.solo.repository.impl.ArticleRepositoryImpl;
import org.b3log.solo.repository.impl.CommentRepositoryImpl; import org.b3log.solo.repository.impl.CommentRepositoryImpl;
import org.b3log.solo.repository.impl.LinkRepositoryImpl; import org.b3log.solo.repository.impl.LinkRepositoryImpl;
import org.b3log.solo.repository.impl.OptionRepositoryImpl;
import org.b3log.solo.repository.impl.PageRepositoryImpl; import org.b3log.solo.repository.impl.PageRepositoryImpl;
import org.b3log.solo.repository.impl.PluginRepositoryImpl; import org.b3log.solo.repository.impl.PluginRepositoryImpl;
import org.b3log.solo.repository.impl.PreferenceRepositoryImpl;
import org.b3log.solo.repository.impl.StatisticRepositoryImpl; import org.b3log.solo.repository.impl.StatisticRepositoryImpl;
import org.b3log.solo.repository.impl.TagArticleRepositoryImpl; import org.b3log.solo.repository.impl.TagArticleRepositoryImpl;
import org.b3log.solo.repository.impl.TagRepositoryImpl; import org.b3log.solo.repository.impl.TagRepositoryImpl;
...@@ -62,14 +61,14 @@ import org.b3log.solo.service.StatisticQueryService; ...@@ -62,14 +61,14 @@ import org.b3log.solo.service.StatisticQueryService;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* Provides patches on some special issues. * Provides patches on some special issues.
* *
* <p>See AuthFilter filter configurations in web.xml for authentication.</p> * <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.1.0.10, Oct 26, 2013 * @version 1.2.0.10, Nov 8, 2015
* @since 0.3.1 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -173,7 +172,7 @@ public class RepairProcessor { ...@@ -173,7 +172,7 @@ public class RepairProcessor {
articleRepository.update(article.getString(Keys.OBJECT_ID), article); articleRepository.update(article.getString(Keys.OBJECT_ID), article);
LOGGER.log(Level.INFO, "Found an article[id={0}] exists unused properties[{1}]", LOGGER.log(Level.INFO, "Found an article[id={0}] exists unused properties[{1}]",
new Object[] {article.getString(Keys.OBJECT_ID), nameSet}); new Object[]{article.getString(Keys.OBJECT_ID), nameSet});
} }
} }
...@@ -193,10 +192,10 @@ public class RepairProcessor { ...@@ -193,10 +192,10 @@ public class RepairProcessor {
* *
* <p> * <p>
* <ul> * <ul>
* <li>Uses the value of {@link Statistic#STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT} * <li>Uses the value of {@link Statistic#STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT} for
* for {@link Statistic#STATISTIC_BLOG_COMMENT_COUNT}</li> * {@link Statistic#STATISTIC_BLOG_COMMENT_COUNT}</li>
* <li>Uses the value of {@link Statistic#STATISTIC_PUBLISHED_ARTICLE_COUNT} * <li>Uses the value of {@link Statistic#STATISTIC_PUBLISHED_ARTICLE_COUNT} for
* for {@link Statistic#STATISTIC_BLOG_ARTICLE_COUNT}</li> * {@link Statistic#STATISTIC_BLOG_ARTICLE_COUNT}</li>
* </ul> * </ul>
* </p> * </p>
* *
...@@ -316,7 +315,7 @@ public class RepairProcessor { ...@@ -316,7 +315,7 @@ public class RepairProcessor {
tagRepository.update(tagId, tag); tagRepository.update(tagId, tag);
LOGGER.log(Level.INFO, "Repaired tag[title={0}, refCnt={1}, publishedTagRefCnt={2}]", LOGGER.log(Level.INFO, "Repaired tag[title={0}, refCnt={1}, publishedTagRefCnt={2}]",
new Object[] {tag.getString(Tag.TAG_TITLE), tagRefCnt, publishedTagRefCnt}); new Object[]{tag.getString(Tag.TAG_TITLE), tagRefCnt, publishedTagRefCnt});
} }
renderer.setContent("Repair sucessfully!"); renderer.setContent("Repair sucessfully!");
...@@ -382,13 +381,13 @@ public class RepairProcessor { ...@@ -382,13 +381,13 @@ public class RepairProcessor {
remove(beanManager.getReference(ArticleRepositoryImpl.class)); remove(beanManager.getReference(ArticleRepositoryImpl.class));
remove(beanManager.getReference(CommentRepositoryImpl.class)); remove(beanManager.getReference(CommentRepositoryImpl.class));
remove(beanManager.getReference(LinkRepositoryImpl.class)); remove(beanManager.getReference(LinkRepositoryImpl.class));
remove(beanManager.getReference(OptionRepositoryImpl.class));
remove(beanManager.getReference(PageRepositoryImpl.class)); remove(beanManager.getReference(PageRepositoryImpl.class));
remove(beanManager.getReference(PreferenceRepositoryImpl.class)); remove(beanManager.getReference(PluginRepositoryImpl.class));
remove(beanManager.getReference(StatisticRepositoryImpl.class)); remove(beanManager.getReference(StatisticRepositoryImpl.class));
remove(beanManager.getReference(TagArticleRepositoryImpl.class)); remove(beanManager.getReference(TagArticleRepositoryImpl.class));
remove(beanManager.getReference(TagRepositoryImpl.class)); remove(beanManager.getReference(TagRepositoryImpl.class));
remove(beanManager.getReference(UserRepositoryImpl.class)); remove(beanManager.getReference(UserRepositoryImpl.class));
remove(beanManager.getReference(PluginRepositoryImpl.class));
succeed = true; succeed = true;
} catch (final Exception e) { } catch (final Exception e) {
......
...@@ -25,5 +25,7 @@ import org.b3log.latke.repository.Repository; ...@@ -25,5 +25,7 @@ import org.b3log.latke.repository.Repository;
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Aug 14, 2010 * @version 1.0.0.0, Aug 14, 2010
* @since 0.3.1 * @since 0.3.1
* @deprecated this class will be removed in 1.3.0, see issue <a href="https://github.com/b3log/solo/issues/12042">#12042</a>
* for more details
*/ */
public interface PreferenceRepository extends Repository {} public interface PreferenceRepository extends Repository {}
...@@ -30,6 +30,8 @@ import org.json.JSONObject; ...@@ -30,6 +30,8 @@ import org.json.JSONObject;
* @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, Feb 28, 2012 * @version 1.0.0.3, Feb 28, 2012
* @since 0.3.1 * @since 0.3.1
* @deprecated this class will be removed in 1.3.0, see issue <a href="https://github.com/b3log/solo/issues/12042">#12042</a>
* for more details
*/ */
@Repository @Repository
public class PreferenceRepositoryImpl extends AbstractRepository implements PreferenceRepository { public class PreferenceRepositoryImpl extends AbstractRepository implements PreferenceRepository {
......
...@@ -48,9 +48,16 @@ import org.b3log.latke.util.MD5; ...@@ -48,9 +48,16 @@ import org.b3log.latke.util.MD5;
import org.b3log.latke.util.freemarker.Templates; import org.b3log.latke.util.freemarker.Templates;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.*; import org.b3log.solo.model.*;
import static org.b3log.solo.model.Preference.*;
import org.b3log.solo.model.Preference.Default; import org.b3log.solo.model.Preference.Default;
import org.b3log.solo.repository.*; import org.b3log.solo.repository.ArchiveDateArticleRepository;
import org.b3log.solo.repository.ArchiveDateRepository;
import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.OptionRepository;
import org.b3log.solo.repository.StatisticRepository;
import org.b3log.solo.repository.TagArticleRepository;
import org.b3log.solo.repository.TagRepository;
import org.b3log.solo.repository.UserRepository;
import org.b3log.solo.util.Comments; import org.b3log.solo.util.Comments;
import org.b3log.solo.util.Skins; import org.b3log.solo.util.Skins;
import org.b3log.solo.util.Thumbnails; import org.b3log.solo.util.Thumbnails;
...@@ -63,7 +70,7 @@ import org.json.JSONObject; ...@@ -63,7 +70,7 @@ import org.json.JSONObject;
* Solo initialization service. * Solo initialization 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.8, Oct 17, 2015 * @version 1.3.2.8, Nov 8, 2015
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -81,10 +88,10 @@ public class InitService { ...@@ -81,10 +88,10 @@ public class InitService {
private StatisticRepository statisticRepository; private StatisticRepository statisticRepository;
/** /**
* Preference repository. * Option repository.
*/ */
@Inject @Inject
private PreferenceRepository preferenceRepository; private OptionRepository optionRepository;
/** /**
* User repository. * User repository.
...@@ -173,9 +180,9 @@ public class InitService { ...@@ -173,9 +180,9 @@ public class InitService {
* <p> * <p>
* Initializes the followings in sequence: * Initializes the followings in sequence:
* <ol> * <ol>
* <li>Statistic.</li> * <li>Statistic</li>
* <li>Preference.</li> * <li>Preference</li>
* <li>Administrator.</li> * <li>Administrator</li>
* </ol> * </ol>
* </p> * </p>
* *
...@@ -231,6 +238,7 @@ public class InitService { ...@@ -231,6 +238,7 @@ public class InitService {
} }
transaction.commit(); transaction.commit();
break; break;
} catch (final Exception e) { } catch (final Exception e) {
if (0 == retries) { if (0 == retries) {
...@@ -296,11 +304,14 @@ public class InitService { ...@@ -296,11 +304,14 @@ public class InitService {
article.put(Article.ARTICLE_VIEW_COUNT, 0); article.put(Article.ARTICLE_VIEW_COUNT, 0);
final Date date = new Date(); final Date date = new Date();
final JSONObject admin = userRepository.getAdmin();
final String authorEmail = admin.optString(User.USER_EMAIL);
article.put(Article.ARTICLE_CREATE_DATE, date); article.put(Article.ARTICLE_CREATE_DATE, date);
article.put(Article.ARTICLE_UPDATE_DATE, date); article.put(Article.ARTICLE_UPDATE_DATE, date);
article.put(Article.ARTICLE_PUT_TOP, false); article.put(Article.ARTICLE_PUT_TOP, false);
article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random()); article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random());
article.put(Article.ARTICLE_AUTHOR_EMAIL, preferenceRepository.get(Preference.PREFERENCE).optString(Preference.ADMIN_EMAIL)); article.put(Article.ARTICLE_AUTHOR_EMAIL, authorEmail);
article.put(Article.ARTICLE_COMMENTABLE, true); article.put(Article.ARTICLE_COMMENTABLE, true);
article.put(Article.ARTICLE_VIEW_PWD, ""); article.put(Article.ARTICLE_VIEW_PWD, "");
article.put(Article.ARTICLE_EDITOR_TYPE, Default.DEFAULT_EDITOR_TYPE); article.put(Article.ARTICLE_EDITOR_TYPE, Default.DEFAULT_EDITOR_TYPE);
...@@ -501,25 +512,22 @@ public class InitService { ...@@ -501,25 +512,22 @@ public class InitService {
/** /**
* Initializes statistic. * Initializes statistic.
* *
* @return statistic
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
* @throws JSONException json exception * @throws JSONException json exception
*/ */
private JSONObject initStatistic() throws RepositoryException, JSONException { private void initStatistic() throws RepositoryException, JSONException {
LOGGER.info("Initializing statistic...."); LOGGER.info("Initializing statistic....");
final JSONObject ret = new JSONObject(); final JSONObject statistic = new JSONObject();
ret.put(Keys.OBJECT_ID, Statistic.STATISTIC); statistic.put(Keys.OBJECT_ID, Statistic.STATISTIC);
ret.put(Statistic.STATISTIC_BLOG_ARTICLE_COUNT, 0); statistic.put(Statistic.STATISTIC_BLOG_ARTICLE_COUNT, 0);
ret.put(Statistic.STATISTIC_PUBLISHED_ARTICLE_COUNT, 0); statistic.put(Statistic.STATISTIC_PUBLISHED_ARTICLE_COUNT, 0);
ret.put(Statistic.STATISTIC_BLOG_VIEW_COUNT, 0); statistic.put(Statistic.STATISTIC_BLOG_VIEW_COUNT, 0);
ret.put(Statistic.STATISTIC_BLOG_COMMENT_COUNT, 0); statistic.put(Statistic.STATISTIC_BLOG_COMMENT_COUNT, 0);
ret.put(Statistic.STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT, 0); statistic.put(Statistic.STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT, 0);
statisticRepository.add(ret); statisticRepository.add(statistic);
LOGGER.info("Initialized statistic"); LOGGER.info("Initialized statistic");
return ret;
} }
/** /**
...@@ -534,7 +542,17 @@ public class InitService { ...@@ -534,7 +542,17 @@ public class InitService {
replyNotificationTemplate.put(Keys.OBJECT_ID, Preference.REPLY_NOTIFICATION_TEMPLATE); replyNotificationTemplate.put(Keys.OBJECT_ID, Preference.REPLY_NOTIFICATION_TEMPLATE);
preferenceRepository.add(replyNotificationTemplate); final JSONObject subjectOpt = new JSONObject();
subjectOpt.put(Keys.OBJECT_ID, Option.ID_C_REPLY_NOTI_TPL_SUBJECT);
subjectOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
subjectOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("subject"));
optionRepository.add(subjectOpt);
final JSONObject bodyOpt = new JSONObject();
bodyOpt.put(Keys.OBJECT_ID, Option.ID_C_REPLY_NOTI_TPL_BODY);
bodyOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
bodyOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("body"));
optionRepository.add(bodyOpt);
LOGGER.info("Initialized reply notification template"); LOGGER.info("Initialized reply notification template");
} }
...@@ -543,66 +561,221 @@ public class InitService { ...@@ -543,66 +561,221 @@ public class InitService {
* Initializes preference. * Initializes preference.
* *
* @param requestJSONObject the specified json object * @param requestJSONObject the specified json object
* @return preference
* @throws Exception exception * @throws Exception exception
*/ */
private JSONObject initPreference(final JSONObject requestJSONObject) throws Exception { private void initPreference(final JSONObject requestJSONObject) throws Exception {
LOGGER.info("Initializing preference...."); LOGGER.info("Initializing preference....");
final JSONObject ret = new JSONObject(); final JSONObject noticeBoardOpt = new JSONObject();
noticeBoardOpt.put(Keys.OBJECT_ID, Option.ID_C_NOTICE_BOARD);
ret.put(NOTICE_BOARD, Default.DEFAULT_NOTICE_BOARD); noticeBoardOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
ret.put(META_DESCRIPTION, Default.DEFAULT_META_DESCRIPTION); noticeBoardOpt.put(Option.OPTION_VALUE, Default.DEFAULT_NOTICE_BOARD);
ret.put(META_KEYWORDS, Default.DEFAULT_META_KEYWORDS); optionRepository.add(noticeBoardOpt);
ret.put(HTML_HEAD, Default.DEFAULT_HTML_HEAD);
ret.put(Preference.RELEVANT_ARTICLES_DISPLAY_CNT, Default.DEFAULT_RELEVANT_ARTICLES_DISPLAY_COUNT); final JSONObject metaDescriptionOpt = new JSONObject();
ret.put(Preference.RANDOM_ARTICLES_DISPLAY_CNT, Default.DEFAULT_RANDOM_ARTICLES_DISPLAY_COUNT); metaDescriptionOpt.put(Keys.OBJECT_ID, Option.ID_C_META_DESCRIPTION);
ret.put(Preference.EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT, Default.DEFAULT_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_COUNT); metaDescriptionOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
ret.put(Preference.MOST_VIEW_ARTICLE_DISPLAY_CNT, Default.DEFAULT_MOST_VIEW_ARTICLES_DISPLAY_COUNT); metaDescriptionOpt.put(Option.OPTION_VALUE, Default.DEFAULT_META_DESCRIPTION);
ret.put(ARTICLE_LIST_DISPLAY_COUNT, Default.DEFAULT_ARTICLE_LIST_DISPLAY_COUNT); optionRepository.add(metaDescriptionOpt);
ret.put(ARTICLE_LIST_PAGINATION_WINDOW_SIZE, Default.DEFAULT_ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
ret.put(MOST_USED_TAG_DISPLAY_CNT, Default.DEFAULT_MOST_USED_TAG_DISPLAY_COUNT); final JSONObject metaKeywordsOpt = new JSONObject();
ret.put(MOST_COMMENT_ARTICLE_DISPLAY_CNT, Default.DEFAULT_MOST_COMMENT_ARTICLE_DISPLAY_COUNT); metaKeywordsOpt.put(Keys.OBJECT_ID, Option.ID_C_META_KEYWORDS);
ret.put(RECENT_ARTICLE_DISPLAY_CNT, Default.DEFAULT_RECENT_ARTICLE_DISPLAY_COUNT); metaKeywordsOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
ret.put(RECENT_COMMENT_DISPLAY_CNT, Default.DEFAULT_RECENT_COMMENT_DISPLAY_COUNT); metaKeywordsOpt.put(Option.OPTION_VALUE, Default.DEFAULT_META_KEYWORDS);
ret.put(BLOG_TITLE, Default.DEFAULT_BLOG_TITLE); optionRepository.add(metaKeywordsOpt);
ret.put(BLOG_SUBTITLE, Default.DEFAULT_BLOG_SUBTITLE);
ret.put(ADMIN_EMAIL, requestJSONObject.getString(User.USER_EMAIL)); final JSONObject htmlHeadOpt = new JSONObject();
ret.put(LOCALE_STRING, Default.DEFAULT_LANGUAGE); htmlHeadOpt.put(Keys.OBJECT_ID, Option.ID_C_HTML_HEAD);
ret.put(ENABLE_ARTICLE_UPDATE_HINT, Default.DEFAULT_ENABLE_ARTICLE_UPDATE_HINT); htmlHeadOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
ret.put(SIGNS, Default.DEFAULT_SIGNS); htmlHeadOpt.put(Option.OPTION_VALUE, Default.DEFAULT_HTML_HEAD);
ret.put(TIME_ZONE_ID, Default.DEFAULT_TIME_ZONE); optionRepository.add(htmlHeadOpt);
ret.put(ALLOW_VISIT_DRAFT_VIA_PERMALINK, Default.DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK);
ret.put(COMMENTABLE, Default.DEFAULT_COMMENTABLE); final JSONObject relevantArticlesDisplayCountOpt = new JSONObject();
ret.put(VERSION, SoloServletListener.VERSION); relevantArticlesDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_RELEVANT_ARTICLES_DISPLAY_CNT);
ret.put(ARTICLE_LIST_STYLE, Default.DEFAULT_ARTICLE_LIST_STYLE); relevantArticlesDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
// ret.put(KEY_OF_SOLO, Default.DEFAULT_KEY_OF_SOLO); relevantArticlesDisplayCountOpt.put(Option.OPTION_VALUE, Default.DEFAULT_RELEVANT_ARTICLES_DISPLAY_COUNT);
ret.put(KEY_OF_SOLO, Ids.genTimeMillisId()); optionRepository.add(relevantArticlesDisplayCountOpt);
ret.put(FEED_OUTPUT_MODE, Default.DEFAULT_FEED_OUTPUT_MODE);
ret.put(FEED_OUTPUT_CNT, Default.DEFAULT_FEED_OUTPUT_CNT); final JSONObject randomArticlesDisplayCountOpt = new JSONObject();
ret.put(EDITOR_TYPE, Default.DEFAULT_EDITOR_TYPE); randomArticlesDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_RANDOM_ARTICLES_DISPLAY_CNT);
randomArticlesDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
randomArticlesDisplayCountOpt.put(Option.OPTION_VALUE, Default.DEFAULT_RANDOM_ARTICLES_DISPLAY_COUNT);
optionRepository.add(randomArticlesDisplayCountOpt);
final JSONObject externalRelevantArticlesDisplayCountOpt = new JSONObject();
externalRelevantArticlesDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT);
externalRelevantArticlesDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
externalRelevantArticlesDisplayCountOpt.put(Option.OPTION_VALUE, Default.DEFAULT_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_COUNT);
optionRepository.add(externalRelevantArticlesDisplayCountOpt);
final JSONObject mostViewArticleDisplayCountOpt = new JSONObject();
mostViewArticleDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT);
mostViewArticleDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
mostViewArticleDisplayCountOpt.put(Option.OPTION_VALUE, Default.DEFAULT_MOST_VIEW_ARTICLES_DISPLAY_COUNT);
optionRepository.add(mostViewArticleDisplayCountOpt);
final JSONObject articleListDisplayCountOpt = new JSONObject();
articleListDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT);
articleListDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
articleListDisplayCountOpt.put(Option.OPTION_VALUE, Default.DEFAULT_ARTICLE_LIST_DISPLAY_COUNT);
optionRepository.add(articleListDisplayCountOpt);
final JSONObject articleListPaginationWindowSizeOpt = new JSONObject();
articleListPaginationWindowSizeOpt.put(Keys.OBJECT_ID, Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
articleListPaginationWindowSizeOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
articleListPaginationWindowSizeOpt.put(Option.OPTION_VALUE, Default.DEFAULT_ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
optionRepository.add(articleListPaginationWindowSizeOpt);
final JSONObject mostUsedTagDisplayCountOpt = new JSONObject();
mostUsedTagDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_MOST_USED_TAG_DISPLAY_CNT);
mostUsedTagDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
mostUsedTagDisplayCountOpt.put(Option.OPTION_VALUE, Default.DEFAULT_MOST_USED_TAG_DISPLAY_COUNT);
optionRepository.add(mostUsedTagDisplayCountOpt);
final JSONObject mostCommentArticleDisplayCountOpt = new JSONObject();
mostCommentArticleDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT);
mostCommentArticleDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
mostCommentArticleDisplayCountOpt.put(Option.OPTION_VALUE, Default.DEFAULT_MOST_COMMENT_ARTICLE_DISPLAY_COUNT);
optionRepository.add(mostCommentArticleDisplayCountOpt);
final JSONObject recentArticleDisplayCountOpt = new JSONObject();
recentArticleDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_RECENT_ARTICLE_DISPLAY_CNT);
recentArticleDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
recentArticleDisplayCountOpt.put(Option.OPTION_VALUE, Default.DEFAULT_RECENT_ARTICLE_DISPLAY_COUNT);
optionRepository.add(recentArticleDisplayCountOpt);
final JSONObject recentCommentDisplayCountOpt = new JSONObject();
recentCommentDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_RECENT_COMMENT_DISPLAY_CNT);
recentCommentDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
recentCommentDisplayCountOpt.put(Option.OPTION_VALUE, Default.DEFAULT_RECENT_COMMENT_DISPLAY_COUNT);
optionRepository.add(recentCommentDisplayCountOpt);
final JSONObject blogTitleOpt = new JSONObject();
blogTitleOpt.put(Keys.OBJECT_ID, Option.ID_C_BLOG_TITLE);
blogTitleOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
blogTitleOpt.put(Option.OPTION_VALUE, Default.DEFAULT_BLOG_TITLE);
optionRepository.add(blogTitleOpt);
final JSONObject blogSubtitleOpt = new JSONObject();
blogSubtitleOpt.put(Keys.OBJECT_ID, Option.ID_C_BLOG_SUBTITLE);
blogSubtitleOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
blogSubtitleOpt.put(Option.OPTION_VALUE, Default.DEFAULT_BLOG_SUBTITLE);
optionRepository.add(blogSubtitleOpt);
final JSONObject adminEmailOpt = new JSONObject();
adminEmailOpt.put(Keys.OBJECT_ID, Option.ID_C_ADMIN_EMAIL);
adminEmailOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
adminEmailOpt.put(Option.OPTION_VALUE, requestJSONObject.getString(User.USER_EMAIL));
optionRepository.add(adminEmailOpt);
final JSONObject localeStringOpt = new JSONObject();
localeStringOpt.put(Keys.OBJECT_ID, Option.ID_C_LOCALE_STRING);
localeStringOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
localeStringOpt.put(Option.OPTION_VALUE, Default.DEFAULT_LANGUAGE);
optionRepository.add(localeStringOpt);
final JSONObject enableArticleUpdateHintOpt = new JSONObject();
enableArticleUpdateHintOpt.put(Keys.OBJECT_ID, Option.ID_C_ENABLE_ARTICLE_UPDATE_HINT);
enableArticleUpdateHintOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
enableArticleUpdateHintOpt.put(Option.OPTION_VALUE, Default.DEFAULT_ENABLE_ARTICLE_UPDATE_HINT);
optionRepository.add(enableArticleUpdateHintOpt);
final JSONObject signsOpt = new JSONObject();
signsOpt.put(Keys.OBJECT_ID, Option.ID_C_SIGNS);
signsOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
signsOpt.put(Option.OPTION_VALUE, Default.DEFAULT_SIGNS);
optionRepository.add(signsOpt);
final JSONObject timeZoneIdOpt = new JSONObject();
timeZoneIdOpt.put(Keys.OBJECT_ID, Option.ID_C_TIME_ZONE_ID);
timeZoneIdOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
timeZoneIdOpt.put(Option.OPTION_VALUE, Default.DEFAULT_TIME_ZONE);
optionRepository.add(timeZoneIdOpt);
final JSONObject allowVisitDraftViaPermalinkOpt = new JSONObject();
allowVisitDraftViaPermalinkOpt.put(Keys.OBJECT_ID, Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK);
allowVisitDraftViaPermalinkOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
allowVisitDraftViaPermalinkOpt.put(Option.OPTION_VALUE, Default.DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK);
optionRepository.add(allowVisitDraftViaPermalinkOpt);
final JSONObject commentableOpt = new JSONObject();
commentableOpt.put(Keys.OBJECT_ID, Option.ID_C_COMMENTABLE);
commentableOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
commentableOpt.put(Option.OPTION_VALUE, Default.DEFAULT_COMMENTABLE);
optionRepository.add(commentableOpt);
final JSONObject versionOpt = new JSONObject();
versionOpt.put(Keys.OBJECT_ID, Option.ID_C_VERSION);
versionOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
versionOpt.put(Option.OPTION_VALUE, SoloServletListener.VERSION);
optionRepository.add(versionOpt);
final JSONObject articleListStyleOpt = new JSONObject();
articleListStyleOpt.put(Keys.OBJECT_ID, Option.ID_C_ARTICLE_LIST_STYLE);
articleListStyleOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
articleListStyleOpt.put(Option.OPTION_VALUE, Default.DEFAULT_ARTICLE_LIST_STYLE);
optionRepository.add(articleListStyleOpt);
final JSONObject keyOfSoloOpt = new JSONObject();
keyOfSoloOpt.put(Keys.OBJECT_ID, Option.ID_C_KEY_OF_SOLO);
keyOfSoloOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
keyOfSoloOpt.put(Option.OPTION_VALUE, Ids.genTimeMillisId());
optionRepository.add(keyOfSoloOpt);
final JSONObject feedOutputModeOpt = new JSONObject();
feedOutputModeOpt.put(Keys.OBJECT_ID, Option.ID_C_FEED_OUTPUT_MODE);
feedOutputModeOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
feedOutputModeOpt.put(Option.OPTION_VALUE, Default.DEFAULT_FEED_OUTPUT_MODE);
optionRepository.add(feedOutputModeOpt);
final JSONObject feedOutputCntOpt = new JSONObject();
feedOutputCntOpt.put(Keys.OBJECT_ID, Option.ID_C_FEED_OUTPUT_CNT);
feedOutputCntOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
feedOutputCntOpt.put(Option.OPTION_VALUE, Default.DEFAULT_FEED_OUTPUT_CNT);
optionRepository.add(feedOutputCntOpt);
final JSONObject editorTypeOpt = new JSONObject();
editorTypeOpt.put(Keys.OBJECT_ID, Option.ID_C_EDITOR_TYPE);
editorTypeOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
editorTypeOpt.put(Option.OPTION_VALUE, Default.DEFAULT_EDITOR_TYPE);
optionRepository.add(editorTypeOpt);
final JSONObject footerContentOpt = new JSONObject();
footerContentOpt.put(Keys.OBJECT_ID, Option.ID_C_FOOTER_CONTENT);
footerContentOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
footerContentOpt.put(Option.OPTION_VALUE, Default.DEFAULT_FOOTER_CONTENT);
optionRepository.add(footerContentOpt);
final String skinDirName = Default.DEFAULT_SKIN_DIR_NAME; final String skinDirName = Default.DEFAULT_SKIN_DIR_NAME;
ret.put(Skin.SKIN_DIR_NAME, skinDirName); final JSONObject skinDirNameOpt = new JSONObject();
skinDirNameOpt.put(Keys.OBJECT_ID, Option.ID_C_SKIN_DIR_NAME);
skinDirNameOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
skinDirNameOpt.put(Option.OPTION_VALUE, skinDirName);
optionRepository.add(skinDirNameOpt);
final String skinName = Latkes.getSkinName(skinDirName); final String skinName = Latkes.getSkinName(skinDirName);
ret.put(Skin.SKIN_NAME, skinName); final JSONObject skinNameOpt = new JSONObject();
skinNameOpt.put(Keys.OBJECT_ID, Option.ID_C_SKIN_NAME);
skinNameOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
skinNameOpt.put(Option.OPTION_VALUE, skinName);
optionRepository.add(skinNameOpt);
final Set<String> skinDirNames = Skins.getSkinDirNames(); final Set<String> skinDirNames = Skins.getSkinDirNames();
final JSONArray skinArray = new JSONArray(); final JSONArray skinArray = new JSONArray();
for (final String dirName : skinDirNames) { for (final String dirName : skinDirNames) {
final JSONObject skin = new JSONObject(); final JSONObject skin = new JSONObject();
skinArray.put(skin); skinArray.put(skin);
final String name = Latkes.getSkinName(dirName); final String name = Latkes.getSkinName(dirName);
skin.put(Skin.SKIN_NAME, name); skin.put(Skin.SKIN_NAME, name);
skin.put(Skin.SKIN_DIR_NAME, dirName); skin.put(Skin.SKIN_DIR_NAME, dirName);
} }
ret.put(Skin.SKINS, skinArray.toString()); final JSONObject skinsOpt = new JSONObject();
skinsOpt.put(Keys.OBJECT_ID, Option.ID_C_SKINS);
skinsOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
skinsOpt.put(Option.OPTION_VALUE, skinArray.toString());
optionRepository.add(skinsOpt);
final ServletContext servletContext = SoloServletListener.getServletContext(); final ServletContext servletContext = SoloServletListener.getServletContext();
...@@ -610,12 +783,7 @@ public class InitService { ...@@ -610,12 +783,7 @@ public class InitService {
TimeZones.setTimeZone(INIT_TIME_ZONE_ID); TimeZones.setTimeZone(INIT_TIME_ZONE_ID);
ret.put(Keys.OBJECT_ID, PREFERENCE);
preferenceRepository.add(ret);
LOGGER.info("Initialized preference"); LOGGER.info("Initialized preference");
return ret;
} }
/** /**
...@@ -654,15 +822,6 @@ public class InitService { ...@@ -654,15 +822,6 @@ public class InitService {
this.userRepository = userRepository; this.userRepository = userRepository;
} }
/**
* Sets the preference repository with the specified preference repository.
*
* @param preferenceRepository the specified preference repository
*/
public void setPreferenceRepository(final PreferenceRepository preferenceRepository) {
this.preferenceRepository = preferenceRepository;
}
/** /**
* Sets the statistic repository with the specified statistic repository. * Sets the statistic repository with the specified statistic repository.
* *
......
...@@ -23,7 +23,6 @@ import java.util.Locale; ...@@ -23,7 +23,6 @@ import java.util.Locale;
import java.util.Set; import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes; import org.b3log.latke.Latkes;
import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger; import org.b3log.latke.logging.Logger;
...@@ -32,13 +31,11 @@ import org.b3log.latke.service.ServiceException; ...@@ -32,13 +31,11 @@ import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service; import org.b3log.latke.service.annotation.Service;
import org.b3log.latke.util.Locales; import org.b3log.latke.util.Locales;
import org.b3log.latke.util.Stopwatchs; import org.b3log.latke.util.Stopwatchs;
import org.b3log.latke.util.Strings;
import org.b3log.latke.util.freemarker.Templates; import org.b3log.latke.util.freemarker.Templates;
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.model.Preference;
import org.b3log.solo.model.Skin; import org.b3log.solo.model.Skin;
import org.b3log.solo.repository.PreferenceRepository;
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.Preference.*;
...@@ -53,7 +50,7 @@ import static org.b3log.solo.util.Skins.setDirectoryForTemplateLoading; ...@@ -53,7 +50,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.1.1.9, Nov 7, 2015 * @version 1.2.1.9, Nov 8, 2015
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -65,10 +62,10 @@ public class PreferenceMgmtService { ...@@ -65,10 +62,10 @@ public class PreferenceMgmtService {
private static final Logger LOGGER = Logger.getLogger(PreferenceMgmtService.class.getName()); private static final Logger LOGGER = Logger.getLogger(PreferenceMgmtService.class.getName());
/** /**
* Preference repository. * Preference query service.
*/ */
@Inject @Inject
private PreferenceRepository preferenceRepository; private PreferenceQueryService preferenceQueryService;
/** /**
* Option repository. * Option repository.
...@@ -169,10 +166,17 @@ public class PreferenceMgmtService { ...@@ -169,10 +166,17 @@ public class PreferenceMgmtService {
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public void updateReplyNotificationTemplate(final JSONObject replyNotificationTemplate) throws ServiceException { public void updateReplyNotificationTemplate(final JSONObject replyNotificationTemplate) throws ServiceException {
final Transaction transaction = preferenceRepository.beginTransaction(); final Transaction transaction = optionRepository.beginTransaction();
try { try {
preferenceRepository.update(Preference.REPLY_NOTIFICATION_TEMPLATE, replyNotificationTemplate); final JSONObject bodyOpt = optionRepository.get(Option.ID_C_REPLY_NOTI_TPL_BODY);
bodyOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("body"));
optionRepository.update(Option.ID_C_REPLY_NOTI_TPL_BODY, bodyOpt);
final JSONObject subjectOpt = optionRepository.get(Option.ID_C_REPLY_NOTI_TPL_SUBJECT);
subjectOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("subject"));
optionRepository.update(Option.ID_C_REPLY_NOTI_TPL_SUBJECT, subjectOpt);
transaction.commit(); transaction.commit();
} catch (final Exception e) { } catch (final Exception e) {
if (transaction.isActive()) { if (transaction.isActive()) {
...@@ -202,7 +206,7 @@ public class PreferenceMgmtService { ...@@ -202,7 +206,7 @@ public class PreferenceMgmtService {
} }
} }
final Transaction transaction = preferenceRepository.beginTransaction(); final Transaction transaction = optionRepository.beginTransaction();
try { try {
final String skinDirName = preference.getString(Skin.SKIN_DIR_NAME); final String skinDirName = preference.getString(Skin.SKIN_DIR_NAME);
...@@ -226,44 +230,160 @@ public class PreferenceMgmtService { ...@@ -226,44 +230,160 @@ 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(TIME_ZONE_ID);
TimeZones.setTimeZone(timeZoneId); TimeZones.setTimeZone(timeZoneId);
preference.put(Preference.SIGNS, preference.get(Preference.SIGNS).toString()); preference.put(Preference.SIGNS, preference.get(Preference.SIGNS).toString());
final JSONObject oldPreference = preferenceRepository.get(Preference.PREFERENCE); final JSONObject oldPreference = preferenceQueryService.getPreference();
final String adminEmail = oldPreference.getString(ADMIN_EMAIL); final String adminEmail = oldPreference.getString(ADMIN_EMAIL);
preference.put(ADMIN_EMAIL, adminEmail); preference.put(ADMIN_EMAIL, adminEmail);
final String version = oldPreference.optString(VERSION); final String version = oldPreference.optString(VERSION);
if (!Strings.isEmptyOrNull(version)) {
preference.put(VERSION, version); preference.put(VERSION, version);
}
final String localeString = preference.getString(Preference.LOCALE_STRING); final String localeString = preference.getString(Preference.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)));
final String footerContent = preference.optString(Option.ID_C_FOOTER_CONTENT); final JSONObject adminEmailOpt = optionRepository.get(Option.ID_C_ADMIN_EMAIL);
JSONObject opt = optionRepository.get(Option.ID_C_FOOTER_CONTENT); adminEmailOpt.put(Option.OPTION_VALUE, adminEmail);
if (null == opt) { optionRepository.update(Option.ID_C_ADMIN_EMAIL, adminEmailOpt);
opt = new JSONObject();
opt.put(Keys.OBJECT_ID, Option.ID_C_FOOTER_CONTENT); final JSONObject allowVisitDraftViaPermalinkOpt = optionRepository.get(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK);
opt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE); allowVisitDraftViaPermalinkOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK));
opt.put(Option.OPTION_VALUE, footerContent); optionRepository.update(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK, allowVisitDraftViaPermalinkOpt);
optionRepository.add(opt); final JSONObject articleListDisplayCountOpt = optionRepository.get(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT);
} else { articleListDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT));
opt.put(Option.OPTION_VALUE, footerContent); optionRepository.update(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT, articleListDisplayCountOpt);
optionRepository.update(Option.ID_C_FOOTER_CONTENT, opt);
} final JSONObject articleListPaginationWindowSizeOpt = optionRepository.get(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
articleListPaginationWindowSizeOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE));
optionRepository.update(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE, articleListPaginationWindowSizeOpt);
final JSONObject articleListStyleOpt = optionRepository.get(Option.ID_C_ARTICLE_LIST_STYLE);
articleListStyleOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ARTICLE_LIST_STYLE));
optionRepository.update(Option.ID_C_ARTICLE_LIST_STYLE, articleListStyleOpt);
final JSONObject blogSubtitleOpt = optionRepository.get(Option.ID_C_BLOG_SUBTITLE);
blogSubtitleOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_BLOG_SUBTITLE));
optionRepository.update(Option.ID_C_BLOG_SUBTITLE, blogSubtitleOpt);
final JSONObject blogTitleOpt = optionRepository.get(Option.ID_C_BLOG_TITLE);
blogTitleOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_BLOG_TITLE));
optionRepository.update(Option.ID_C_BLOG_TITLE, blogTitleOpt);
final JSONObject commentableOpt = optionRepository.get(Option.ID_C_COMMENTABLE);
commentableOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_COMMENTABLE));
optionRepository.update(Option.ID_C_COMMENTABLE, commentableOpt);
final JSONObject editorTypeOpt = optionRepository.get(Option.ID_C_EDITOR_TYPE);
editorTypeOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_EDITOR_TYPE));
optionRepository.update(Option.ID_C_EDITOR_TYPE, editorTypeOpt);
final JSONObject enableArticleUpdateHintOpt = optionRepository.get(Option.ID_C_ENABLE_ARTICLE_UPDATE_HINT);
enableArticleUpdateHintOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ENABLE_ARTICLE_UPDATE_HINT));
optionRepository.update(Option.ID_C_ENABLE_ARTICLE_UPDATE_HINT, enableArticleUpdateHintOpt);
final JSONObject externalRelevantArticlesDisplayCountOpt = optionRepository.get(Option.ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT);
externalRelevantArticlesDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT));
optionRepository.update(Option.ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT, externalRelevantArticlesDisplayCountOpt);
final JSONObject feedOutputCntOpt = optionRepository.get(Option.ID_C_FEED_OUTPUT_CNT);
feedOutputCntOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_FEED_OUTPUT_CNT));
optionRepository.update(Option.ID_C_FEED_OUTPUT_CNT, feedOutputCntOpt);
final JSONObject feedOutputModeOpt = optionRepository.get(Option.ID_C_FEED_OUTPUT_MODE);
feedOutputModeOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_FEED_OUTPUT_MODE));
optionRepository.update(Option.ID_C_FEED_OUTPUT_MODE, feedOutputModeOpt);
final JSONObject footerContentOpt = optionRepository.get(Option.ID_C_FOOTER_CONTENT);
footerContentOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_FOOTER_CONTENT));
optionRepository.update(Option.ID_C_FOOTER_CONTENT, footerContentOpt);
final JSONObject htmlHeadOpt = optionRepository.get(Option.ID_C_HTML_HEAD);
htmlHeadOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_HTML_HEAD));
optionRepository.update(Option.ID_C_HTML_HEAD, htmlHeadOpt);
final JSONObject keyOfSoloOpt = optionRepository.get(Option.ID_C_KEY_OF_SOLO);
keyOfSoloOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_KEY_OF_SOLO));
optionRepository.update(Option.ID_C_KEY_OF_SOLO, keyOfSoloOpt);
preference.remove(Option.ID_C_FOOTER_CONTENT); final JSONObject localeStringOpt = optionRepository.get(Option.ID_C_LOCALE_STRING);
localeStringOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_LOCALE_STRING));
optionRepository.update(Option.ID_C_LOCALE_STRING, localeStringOpt);
preferenceRepository.update(Preference.PREFERENCE, preference); final JSONObject metaDescriptionOpt = optionRepository.get(Option.ID_C_META_DESCRIPTION);
metaDescriptionOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_META_DESCRIPTION));
optionRepository.update(Option.ID_C_META_DESCRIPTION, metaDescriptionOpt);
final JSONObject metaKeywordsOpt = optionRepository.get(Option.ID_C_META_KEYWORDS);
metaKeywordsOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_META_KEYWORDS));
optionRepository.update(Option.ID_C_META_KEYWORDS, metaKeywordsOpt);
final JSONObject mostCommentArticleDisplayCountOpt = optionRepository.get(Option.ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT);
mostCommentArticleDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT));
optionRepository.update(Option.ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT, mostCommentArticleDisplayCountOpt);
final JSONObject mostUsedTagDisplayCountOpt = optionRepository.get(Option.ID_C_MOST_USED_TAG_DISPLAY_CNT);
mostUsedTagDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_MOST_USED_TAG_DISPLAY_CNT));
optionRepository.update(Option.ID_C_MOST_USED_TAG_DISPLAY_CNT, mostUsedTagDisplayCountOpt);
final JSONObject mostViewArticleDisplayCountOpt = optionRepository.get(Option.ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT);
mostViewArticleDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT));
optionRepository.update(Option.ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT, mostViewArticleDisplayCountOpt);
final JSONObject noticeBoardOpt = optionRepository.get(Option.ID_C_NOTICE_BOARD);
noticeBoardOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_NOTICE_BOARD));
optionRepository.update(Option.ID_C_NOTICE_BOARD, noticeBoardOpt);
final JSONObject randomArticlesDisplayCountOpt = optionRepository.get(Option.ID_C_RANDOM_ARTICLES_DISPLAY_CNT);
randomArticlesDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_RANDOM_ARTICLES_DISPLAY_CNT));
optionRepository.update(Option.ID_C_RANDOM_ARTICLES_DISPLAY_CNT, randomArticlesDisplayCountOpt);
final JSONObject recentArticleDisplayCountOpt = optionRepository.get(Option.ID_C_RECENT_ARTICLE_DISPLAY_CNT);
recentArticleDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_RECENT_ARTICLE_DISPLAY_CNT));
optionRepository.update(Option.ID_C_RECENT_ARTICLE_DISPLAY_CNT, recentArticleDisplayCountOpt);
final JSONObject recentCommentDisplayCountOpt = optionRepository.get(Option.ID_C_RECENT_COMMENT_DISPLAY_CNT);
recentCommentDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_RECENT_COMMENT_DISPLAY_CNT));
optionRepository.update(Option.ID_C_RECENT_COMMENT_DISPLAY_CNT, recentCommentDisplayCountOpt);
final JSONObject relevantArticlesDisplayCountOpt = optionRepository.get(Option.ID_C_RELEVANT_ARTICLES_DISPLAY_CNT);
relevantArticlesDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_RELEVANT_ARTICLES_DISPLAY_CNT));
optionRepository.update(Option.ID_C_RELEVANT_ARTICLES_DISPLAY_CNT, relevantArticlesDisplayCountOpt);
final JSONObject replyNotiTplBodyOpt = optionRepository.get(Option.ID_C_REPLY_NOTI_TPL_BODY);
replyNotiTplBodyOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_REPLY_NOTI_TPL_BODY));
optionRepository.update(Option.ID_C_REPLY_NOTI_TPL_BODY, replyNotiTplBodyOpt);
final JSONObject replyNotiTplSubjectOpt = optionRepository.get(Option.ID_C_REPLY_NOTI_TPL_SUBJECT);
replyNotiTplSubjectOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_REPLY_NOTI_TPL_SUBJECT));
optionRepository.update(Option.ID_C_REPLY_NOTI_TPL_SUBJECT, replyNotiTplSubjectOpt);
final JSONObject signsOpt = optionRepository.get(Option.ID_C_SIGNS);
signsOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_SIGNS));
optionRepository.update(Option.ID_C_SIGNS, signsOpt);
final JSONObject skinDirNameOpt = optionRepository.get(Option.ID_C_SKIN_DIR_NAME);
skinDirNameOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_SKIN_DIR_NAME));
optionRepository.update(Option.ID_C_SKIN_DIR_NAME, skinDirNameOpt);
final JSONObject skinNameOpt = optionRepository.get(Option.ID_C_SKIN_NAME);
skinNameOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_SKIN_NAME));
optionRepository.update(Option.ID_C_SKIN_NAME, skinNameOpt);
final JSONObject skinsOpt = optionRepository.get(Option.ID_C_SKINS);
skinsOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_SKINS));
optionRepository.update(Option.ID_C_SKINS, skinsOpt);
final JSONObject timeZoneIdOpt = optionRepository.get(Option.ID_C_TIME_ZONE_ID);
timeZoneIdOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_TIME_ZONE_ID));
optionRepository.update(Option.ID_C_TIME_ZONE_ID, timeZoneIdOpt);
final JSONObject versionOpt = optionRepository.get(Option.ID_C_VERSION);
versionOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_VERSION));
optionRepository.update(Option.ID_C_VERSION, versionOpt);
transaction.commit(); transaction.commit();
...@@ -282,15 +402,6 @@ public class PreferenceMgmtService { ...@@ -282,15 +402,6 @@ public class PreferenceMgmtService {
LOGGER.log(Level.DEBUG, "Updates preference successfully"); LOGGER.log(Level.DEBUG, "Updates preference successfully");
} }
/**
* Sets the preference repository with the specified preference repository.
*
* @param preferenceRepository the specified preference repository
*/
public void setPreferenceRepository(final PreferenceRepository preferenceRepository) {
this.preferenceRepository = preferenceRepository;
}
/** /**
* Sets the language service with the specified language service. * Sets the language service with the specified language service.
* *
......
...@@ -15,23 +15,28 @@ ...@@ -15,23 +15,28 @@
*/ */
package org.b3log.solo.service; package org.b3log.solo.service;
import javax.inject.Inject; import javax.inject.Inject;
import org.b3log.latke.Keys;
import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger; import org.b3log.latke.logging.Logger;
import org.b3log.latke.repository.FilterOperator;
import org.b3log.latke.repository.PropertyFilter;
import org.b3log.latke.repository.Query;
import org.b3log.latke.repository.RepositoryException; import org.b3log.latke.repository.RepositoryException;
import org.b3log.latke.service.ServiceException; import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service; import org.b3log.latke.service.annotation.Service;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference; import org.b3log.solo.model.Preference;
import org.b3log.solo.repository.OptionRepository;
import org.b3log.solo.repository.PreferenceRepository; import org.b3log.solo.repository.PreferenceRepository;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* Preference query service. * Preference query service.
* *
* @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, Oct 31, 2011 * @version 1.1.0.1, Nov 8, 2015
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -48,6 +53,12 @@ public class PreferenceQueryService { ...@@ -48,6 +53,12 @@ public class PreferenceQueryService {
@Inject @Inject
private PreferenceRepository preferenceRepository; private PreferenceRepository preferenceRepository;
/**
* Option repository.
*/
@Inject
private OptionRepository optionRepository;
/** /**
* Gets the reply notification template. * Gets the reply notification template.
* *
...@@ -56,7 +67,13 @@ public class PreferenceQueryService { ...@@ -56,7 +67,13 @@ public class PreferenceQueryService {
*/ */
public JSONObject getReplyNotificationTemplate() throws ServiceException { public JSONObject getReplyNotificationTemplate() throws ServiceException {
try { try {
return preferenceRepository.get(Preference.REPLY_NOTIFICATION_TEMPLATE); final JSONObject ret = new JSONObject();
final JSONObject preference = getPreference();
ret.put("subject", preference.optString(Option.ID_C_REPLY_NOTI_TPL_SUBJECT));
ret.put("body", preference.optString(Option.ID_C_REPLY_NOTI_TPL_BODY));
return ret;
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Updates reply notification template failed", e); LOGGER.log(Level.ERROR, "Updates reply notification template failed", e);
throw new ServiceException(e); throw new ServiceException(e);
...@@ -66,26 +83,30 @@ public class PreferenceQueryService { ...@@ -66,26 +83,30 @@ public class PreferenceQueryService {
/** /**
* Gets the user preference. * Gets the user preference.
* *
* <p>
* <b>Note</b>: Invoking the method will not load skin.
* </p>
*
* @return user preference, returns {@code null} if not found * @return user preference, returns {@code null} if not found
* @throws ServiceException if repository exception * @throws ServiceException if repository exception
*/ */
public JSONObject getPreference() throws ServiceException { public JSONObject getPreference() throws ServiceException {
try { try {
final JSONObject ret = preferenceRepository.get(Preference.PREFERENCE); final JSONObject checkInit = optionRepository.get(Option.ID_C_ADMIN_EMAIL);
if (null == checkInit) {
if (null == ret) {
LOGGER.log(Level.WARN, "Can not load preference from datastore");
return null; return null;
} }
final Query query = new Query();
query.setFilter(new PropertyFilter(Option.OPTION_CATEGORY, FilterOperator.EQUAL, Option.CATEGORY_C_PREFERENCE));
final JSONArray opts = optionRepository.get(query).optJSONArray(Keys.RESULTS);
final JSONObject ret = new JSONObject();
for (int i = 0; i < opts.length(); i++) {
final JSONObject opt = opts.optJSONObject(i);
ret.put(opt.optString(Keys.OBJECT_ID), opt.opt(Option.OPTION_VALUE));
}
return ret; return ret;
} catch (final RepositoryException e) { } catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); return null;
throw new IllegalStateException(e);
} }
} }
......
...@@ -44,7 +44,7 @@ import org.json.JSONObject; ...@@ -44,7 +44,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:dongxu.wang@acm.org">Dongxu Wang</a> * @author <a href="mailto:dongxu.wang@acm.org">Dongxu Wang</a>
* @version 1.0.0.0, Nov 5, 2015 * @version 1.0.0.1, Nov 8, 2015
* @since 1.2.0 * @since 1.2.0
*/ */
@Service @Service
...@@ -67,6 +67,12 @@ public class UpgradeService { ...@@ -67,6 +67,12 @@ public class UpgradeService {
@Inject @Inject
private UserRepository userRepository; private UserRepository userRepository;
/**
* Option repository.
*/
@Inject
private OptionRepository optionRepository;
/** /**
* Preference repository. * Preference repository.
*/ */
...@@ -111,15 +117,12 @@ public class UpgradeService { ...@@ -111,15 +117,12 @@ public class UpgradeService {
private static final String TO_VER = SoloServletListener.VERSION; private static final String TO_VER = SoloServletListener.VERSION;
/** /**
* Checks upgrade. * Upgrades if need.
*/ */
public void upgrade() { public void upgrade() {
try { try {
final JSONObject preference = preferenceRepository.get(Preference.PREFERENCE); final JSONObject preference = preferenceRepository.get(Preference.PREFERENCE);
if (null == preference) { if (null == preference) {
LOGGER.log(Level.INFO, "Not init yet");
return; return;
} }
...@@ -179,12 +182,258 @@ public class UpgradeService { ...@@ -179,12 +182,258 @@ public class UpgradeService {
// Upgrades preference model // Upgrades preference model
final JSONObject preference = preferenceRepository.get(Preference.PREFERENCE); final JSONObject preference = preferenceRepository.get(Preference.PREFERENCE);
final String adminEmail = preference.optString(Preference.ADMIN_EMAIL);
final JSONObject adminEmailOpt = new JSONObject();
adminEmailOpt.put(Keys.OBJECT_ID, Option.ID_C_ADMIN_EMAIL);
adminEmailOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
adminEmailOpt.put(Option.OPTION_VALUE, adminEmail);
optionRepository.add(adminEmailOpt);
final boolean allowVisitDraftViaPermalink = preference.optBoolean(Preference.ALLOW_VISIT_DRAFT_VIA_PERMALINK);
final JSONObject allowVisitDraftViaPermalinkOpt = new JSONObject();
allowVisitDraftViaPermalinkOpt.put(Keys.OBJECT_ID, Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK);
allowVisitDraftViaPermalinkOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
allowVisitDraftViaPermalinkOpt.put(Option.OPTION_VALUE, Boolean.toString(allowVisitDraftViaPermalink));
optionRepository.add(allowVisitDraftViaPermalinkOpt);
final boolean commentable = preference.optBoolean(Preference.COMMENTABLE);
final JSONObject commentableOpt = new JSONObject();
commentableOpt.put(Keys.OBJECT_ID, Option.ID_C_COMMENTABLE);
commentableOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
commentableOpt.put(Option.OPTION_VALUE, Boolean.toString(commentable));
optionRepository.add(commentableOpt);
final String feedOutputMode = preference.optString(Preference.FEED_OUTPUT_MODE);
final JSONObject feedOutputModeOpt = new JSONObject();
feedOutputModeOpt.put(Keys.OBJECT_ID, Option.ID_C_FEED_OUTPUT_MODE);
feedOutputModeOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
feedOutputModeOpt.put(Option.OPTION_VALUE, feedOutputMode);
optionRepository.add(feedOutputModeOpt);
final int feedOutputCnt = preference.optInt(Preference.FEED_OUTPUT_CNT);
final JSONObject feedOutputCntOpt = new JSONObject();
feedOutputCntOpt.put(Keys.OBJECT_ID, Option.ID_C_FEED_OUTPUT_CNT);
feedOutputCntOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
feedOutputCntOpt.put(Option.OPTION_VALUE, feedOutputCnt);
optionRepository.add(feedOutputCntOpt);
final int articleListDisplayCount = preference.optInt(Preference.ARTICLE_LIST_DISPLAY_COUNT);
final JSONObject articleListDisplayCountOpt = new JSONObject();
articleListDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT);
articleListDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
articleListDisplayCountOpt.put(Option.OPTION_VALUE, articleListDisplayCount);
optionRepository.add(articleListDisplayCountOpt);
final int relevantArticlesDisplayCount = preference.optInt(Preference.RELEVANT_ARTICLES_DISPLAY_CNT);
final JSONObject relevantArticlesDisplayCountOpt = new JSONObject();
relevantArticlesDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_RELEVANT_ARTICLES_DISPLAY_CNT);
relevantArticlesDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
relevantArticlesDisplayCountOpt.put(Option.OPTION_VALUE, relevantArticlesDisplayCount);
optionRepository.add(relevantArticlesDisplayCountOpt);
final int articleListPaginationWindowSize = preference.optInt(Preference.ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
final JSONObject articleListPaginationWindowSizeOpt = new JSONObject();
articleListPaginationWindowSizeOpt.put(Keys.OBJECT_ID, Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
articleListPaginationWindowSizeOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
articleListPaginationWindowSizeOpt.put(Option.OPTION_VALUE, articleListPaginationWindowSize);
optionRepository.add(articleListPaginationWindowSizeOpt);
final String articleListStyle = preference.optString(Preference.ARTICLE_LIST_STYLE);
final JSONObject articleListStyleOpt = new JSONObject();
articleListStyleOpt.put(Keys.OBJECT_ID, Option.ID_C_ARTICLE_LIST_STYLE);
articleListStyleOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
articleListStyleOpt.put(Option.OPTION_VALUE, articleListStyle);
optionRepository.add(articleListStyleOpt);
final String blogSubtitle = preference.optString(Preference.BLOG_SUBTITLE);
final JSONObject blogSubtitleOpt = new JSONObject();
blogSubtitleOpt.put(Keys.OBJECT_ID, Option.ID_C_BLOG_SUBTITLE);
blogSubtitleOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
blogSubtitleOpt.put(Option.OPTION_VALUE, blogSubtitle);
optionRepository.add(blogSubtitleOpt);
final String blogTitle = preference.optString(Preference.BLOG_TITLE);
final JSONObject blogTitleOpt = new JSONObject();
blogTitleOpt.put(Keys.OBJECT_ID, Option.ID_C_BLOG_TITLE);
blogTitleOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
blogTitleOpt.put(Option.OPTION_VALUE, blogTitle);
optionRepository.add(blogTitleOpt);
final boolean enableArticleUpdateHint = preference.optBoolean(Preference.ENABLE_ARTICLE_UPDATE_HINT);
final JSONObject enableArticleUpdateHintOpt = new JSONObject();
enableArticleUpdateHintOpt.put(Keys.OBJECT_ID, Option.ID_C_ENABLE_ARTICLE_UPDATE_HINT);
enableArticleUpdateHintOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
enableArticleUpdateHintOpt.put(Option.OPTION_VALUE, Boolean.toString(enableArticleUpdateHint));
optionRepository.add(enableArticleUpdateHintOpt);
final int externalRelevantArticlesDisplayCount = preference.optInt(Preference.EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT);
final JSONObject externalRelevantArticlesDisplayCountOpt = new JSONObject();
externalRelevantArticlesDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT);
externalRelevantArticlesDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
externalRelevantArticlesDisplayCountOpt.put(Option.OPTION_VALUE, externalRelevantArticlesDisplayCount);
optionRepository.add(externalRelevantArticlesDisplayCountOpt);
final String htmlHead = preference.optString(Preference.HTML_HEAD);
final JSONObject htmlHeadOpt = new JSONObject();
htmlHeadOpt.put(Keys.OBJECT_ID, Option.ID_C_HTML_HEAD);
htmlHeadOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
htmlHeadOpt.put(Option.OPTION_VALUE, htmlHead);
optionRepository.add(htmlHeadOpt);
final String keyOfSolo = preference.optString(Preference.KEY_OF_SOLO);
final JSONObject keyOfSoloOpt = new JSONObject();
keyOfSoloOpt.put(Keys.OBJECT_ID, Option.ID_C_KEY_OF_SOLO);
keyOfSoloOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
keyOfSoloOpt.put(Option.OPTION_VALUE, keyOfSolo);
optionRepository.add(keyOfSoloOpt);
final String localeString = preference.optString(Preference.LOCALE_STRING);
final JSONObject localeStringOpt = new JSONObject();
localeStringOpt.put(Keys.OBJECT_ID, Option.ID_C_LOCALE_STRING);
localeStringOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
localeStringOpt.put(Option.OPTION_VALUE, localeString);
optionRepository.add(localeStringOpt);
final String metaDescription = preference.optString(Preference.META_DESCRIPTION);
final JSONObject metaDescriptionOpt = new JSONObject();
metaDescriptionOpt.put(Keys.OBJECT_ID, Option.ID_C_META_DESCRIPTION);
metaDescriptionOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
metaDescriptionOpt.put(Option.OPTION_VALUE, metaDescription);
optionRepository.add(metaDescriptionOpt);
final String metaKeywords = preference.optString(Preference.META_KEYWORDS);
final JSONObject metaKeywordsOpt = new JSONObject();
metaKeywordsOpt.put(Keys.OBJECT_ID, Option.ID_C_META_KEYWORDS);
metaKeywordsOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
metaKeywordsOpt.put(Option.OPTION_VALUE, metaKeywords);
optionRepository.add(metaKeywordsOpt);
final int mostCommentArticleDisplayCount = preference.optInt(Preference.MOST_COMMENT_ARTICLE_DISPLAY_CNT);
final JSONObject mostCommentArticleDisplayCountOpt = new JSONObject();
mostCommentArticleDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT);
mostCommentArticleDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
mostCommentArticleDisplayCountOpt.put(Option.OPTION_VALUE, mostCommentArticleDisplayCount);
optionRepository.add(mostCommentArticleDisplayCountOpt);
final int mostUsedTagDisplayCount = preference.optInt(Preference.MOST_USED_TAG_DISPLAY_CNT);
final JSONObject mostUsedTagDisplayCountOpt = new JSONObject();
mostUsedTagDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_MOST_USED_TAG_DISPLAY_CNT);
mostUsedTagDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
mostUsedTagDisplayCountOpt.put(Option.OPTION_VALUE, mostUsedTagDisplayCount);
optionRepository.add(mostUsedTagDisplayCountOpt);
final int mostViewArticleDisplayCount = preference.optInt(Preference.MOST_VIEW_ARTICLE_DISPLAY_CNT);
final JSONObject mostViewArticleDisplayCountOpt = new JSONObject();
mostViewArticleDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT);
mostViewArticleDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
mostViewArticleDisplayCountOpt.put(Option.OPTION_VALUE, mostViewArticleDisplayCount);
optionRepository.add(mostViewArticleDisplayCountOpt);
final String noticeBoard = preference.optString(Preference.NOTICE_BOARD);
final JSONObject noticeBoardOpt = new JSONObject();
noticeBoardOpt.put(Keys.OBJECT_ID, Option.ID_C_NOTICE_BOARD);
noticeBoardOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
noticeBoardOpt.put(Option.OPTION_VALUE, noticeBoard);
optionRepository.add(noticeBoardOpt);
final int randomArticlesDisplayCount = preference.optInt(Preference.RANDOM_ARTICLES_DISPLAY_CNT);
final JSONObject randomArticlesDisplayCountOpt = new JSONObject();
randomArticlesDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_RANDOM_ARTICLES_DISPLAY_CNT);
randomArticlesDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
randomArticlesDisplayCountOpt.put(Option.OPTION_VALUE, randomArticlesDisplayCount);
optionRepository.add(randomArticlesDisplayCountOpt);
final int recentCommentDisplayCount = preference.optInt(Preference.RECENT_COMMENT_DISPLAY_CNT);
final JSONObject recentCommentDisplayCountOpt = new JSONObject();
recentCommentDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_RECENT_COMMENT_DISPLAY_CNT);
recentCommentDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
recentCommentDisplayCountOpt.put(Option.OPTION_VALUE, recentCommentDisplayCount);
optionRepository.add(recentCommentDisplayCountOpt);
final int recentArticleDisplayCount = preference.optInt(Preference.RECENT_ARTICLE_DISPLAY_CNT);
final JSONObject recentArticleDisplayCountOpt = new JSONObject();
recentArticleDisplayCountOpt.put(Keys.OBJECT_ID, Option.ID_C_RECENT_ARTICLE_DISPLAY_CNT);
recentArticleDisplayCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
recentArticleDisplayCountOpt.put(Option.OPTION_VALUE, recentArticleDisplayCount);
optionRepository.add(recentArticleDisplayCountOpt);
final String signs = preference.optString(Preference.SIGNS);
final JSONObject signsOpt = new JSONObject();
signsOpt.put(Keys.OBJECT_ID, Option.ID_C_SIGNS);
signsOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
signsOpt.put(Option.OPTION_VALUE, signs);
optionRepository.add(signsOpt);
final String skinDirName = preference.optString(Skin.SKIN_DIR_NAME);
final JSONObject skinDirNameOpt = new JSONObject();
skinDirNameOpt.put(Keys.OBJECT_ID, Option.ID_C_SKIN_DIR_NAME);
skinDirNameOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
skinDirNameOpt.put(Option.OPTION_VALUE, skinDirName);
optionRepository.add(skinDirNameOpt);
final String skinName = preference.optString(Skin.SKIN_NAME);
final JSONObject skinNameOpt = new JSONObject();
skinNameOpt.put(Keys.OBJECT_ID, Option.ID_C_SKIN_NAME);
skinNameOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
skinNameOpt.put(Option.OPTION_VALUE, skinName);
optionRepository.add(skinNameOpt);
final String skins = preference.optString(Skin.SKINS);
final JSONObject skinsOpt = new JSONObject();
skinsOpt.put(Keys.OBJECT_ID, Option.ID_C_SKINS);
skinsOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
skinsOpt.put(Option.OPTION_VALUE, skins);
optionRepository.add(skinsOpt);
final String timeZoneId = preference.optString(Preference.TIME_ZONE_ID);
final JSONObject timeZoneIdOpt = new JSONObject();
timeZoneIdOpt.put(Keys.OBJECT_ID, Option.ID_C_TIME_ZONE_ID);
timeZoneIdOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
timeZoneIdOpt.put(Option.OPTION_VALUE, timeZoneId);
optionRepository.add(timeZoneIdOpt);
final String version = preference.optString(Preference.VERSION);
final JSONObject versionOpt = new JSONObject();
versionOpt.put(Keys.OBJECT_ID, Option.ID_C_VERSION);
versionOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
versionOpt.put(Option.OPTION_VALUE, TO_VER);
optionRepository.add(versionOpt);
final String editorType = preference.optString(Preference.EDITOR_TYPE);
final JSONObject editorTypeOpt = new JSONObject();
editorTypeOpt.put(Keys.OBJECT_ID, Option.ID_C_EDITOR_TYPE);
editorTypeOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
editorTypeOpt.put(Option.OPTION_VALUE, editorType);
optionRepository.add(editorTypeOpt);
final JSONObject footerContentOpt = new JSONObject();
footerContentOpt.put(Keys.OBJECT_ID, Option.ID_C_FOOTER_CONTENT);
footerContentOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
footerContentOpt.put(Option.OPTION_VALUE, Preference.Default.DEFAULT_FOOTER_CONTENT);
optionRepository.add(footerContentOpt);
final JSONObject replyNotificationTemplate = preferenceRepository.get(Preference.REPLY_NOTIFICATION_TEMPLATE);
final String body = replyNotificationTemplate.optString("body");
final JSONObject bodyOpt = new JSONObject();
bodyOpt.put(Keys.OBJECT_ID, Option.ID_C_REPLY_NOTI_TPL_BODY);
bodyOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
bodyOpt.put(Option.OPTION_VALUE, body);
optionRepository.add(bodyOpt);
final String subject = replyNotificationTemplate.optString("subject");
final JSONObject subjectOpt = new JSONObject();
subjectOpt.put(Keys.OBJECT_ID, Option.ID_C_REPLY_NOTI_TPL_SUBJECT);
subjectOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
subjectOpt.put(Option.OPTION_VALUE, subject);
optionRepository.add(subjectOpt);
preference.put(Preference.VERSION, TO_VER); preference.put(Preference.VERSION, TO_VER);
preferenceRepository.update(Preference.PREFERENCE, preference); preferenceRepository.update(Preference.PREFERENCE, preference);
transaction.commit(); transaction.commit();
LOGGER.log(Level.TRACE, "Updated preference"); LOGGER.log(Level.INFO, "Updated preference");
} catch (final Exception e) { } catch (final Exception e) {
if (null != transaction && transaction.isActive()) { if (null != transaction && transaction.isActive()) {
transaction.rollback(); transaction.rollback();
...@@ -213,7 +462,7 @@ public class UpgradeService { ...@@ -213,7 +462,7 @@ public class UpgradeService {
final JSONObject user = users.getJSONObject(i); final JSONObject user = users.getJSONObject(i);
final String email = user.optString(User.USER_EMAIL); final String email = user.optString(User.USER_EMAIL);
user.put(UserExt.USER_AVATAR, Thumbnails.getGravatarURL(email, "60")); user.put(UserExt.USER_AVATAR, Thumbnails.getGravatarURL(email, "128"));
userRepository.update(user.optString(Keys.OBJECT_ID), user); userRepository.update(user.optString(Keys.OBJECT_ID), user);
......
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
return; return;
} }
window.location.href = "${servePath}/admin-index.do#tools/user-list"; window.location.href = "${servePath}/admin-index.do#main";
} }
}); });
} }
......
...@@ -58,10 +58,8 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase { ...@@ -58,10 +58,8 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
*/ */
@Test(dependsOnMethods = "init") @Test(dependsOnMethods = "init")
public void updatePreference() throws Exception { public void updatePreference() throws Exception {
final PreferenceMgmtService preferenceMgmtService = final PreferenceMgmtService preferenceMgmtService = getPreferenceMgmtService();
getPreferenceMgmtService(); 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(Preference.BLOG_TITLE),
...@@ -71,8 +69,7 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase { ...@@ -71,8 +69,7 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
preferenceMgmtService.updatePreference(preference); preferenceMgmtService.updatePreference(preference);
preference = preferenceQueryService.getPreference(); preference = preferenceQueryService.getPreference();
Assert.assertEquals(preference.getString(Preference.BLOG_TITLE), Assert.assertEquals(preference.getString(Preference.BLOG_TITLE), "updated blog title");
"updated blog title");
} }
/** /**
...@@ -82,12 +79,12 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase { ...@@ -82,12 +79,12 @@ 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 = final PreferenceQueryService preferenceQueryService
getPreferenceQueryService(); = getPreferenceQueryService();
JSONObject replyNotificationTemplate = 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);
...@@ -96,8 +93,8 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase { ...@@ -96,8 +93,8 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
preferenceMgmtService.updateReplyNotificationTemplate( preferenceMgmtService.updateReplyNotificationTemplate(
replyNotificationTemplate); replyNotificationTemplate);
replyNotificationTemplate = replyNotificationTemplate
preferenceQueryService.getReplyNotificationTemplate(); = preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.getString( Assert.assertEquals(replyNotificationTemplate.getString(
"subject"), "updated subject"); "subject"), "updated subject");
} }
......
...@@ -31,3 +31,5 @@ helloWorld.content=\u6b22\u8fce\u4f7f\u7528 \ ...@@ -31,3 +31,5 @@ helloWorld.content=\u6b22\u8fce\u4f7f\u7528 \
<span style="color: orangered; font-weight: bold;">Solo</span></a>\ <span style="color: orangered; font-weight: bold;">Solo</span></a>\
\u3002\u8fd9\u662f\u7cfb\u7edf\u81ea\u52a8\u751f\u6210\u7684\u6f14\u793a\u6587\u7ae0\u3002\u7f16\u8f91\u6216\u8005\u5220\u9664\u5b83\uff0c\u7136\u540e\u5f00\u59cb\u60a8\u7684\u535a\u5ba2\uff01 \u3002\u8fd9\u662f\u7cfb\u7edf\u81ea\u52a8\u751f\u6210\u7684\u6f14\u793a\u6587\u7ae0\u3002\u7f16\u8f91\u6216\u8005\u5220\u9664\u5b83\uff0c\u7136\u540e\u5f00\u59cb\u60a8\u7684\u535a\u5ba2\uff01
helloWorld.comment.content=\u60a8\u597d\uff0c\u8fd9\u662f\u4e00\u6761\u8bc4\u8bba\u3002_esc_enter_88250_\u8981\u5220\u9664\u8bc4\u8bba\uff0c\u8bf7\u5148\u767b\u5f55\uff0c\u7136\u540e\u518d\u67e5\u770b\u8fd9\u7bc7\u6587\u7ae0\u7684\u8bc4\u8bba\u3002\u5728\u90a3\u91cc\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u7f16\u8f91\u6216\u8005\u5220\u9664\u8bc4\u8bba\u7684\u9009\u9879\u3002 helloWorld.comment.content=\u60a8\u597d\uff0c\u8fd9\u662f\u4e00\u6761\u8bc4\u8bba\u3002_esc_enter_88250_\u8981\u5220\u9664\u8bc4\u8bba\uff0c\u8bf7\u5148\u767b\u5f55\uff0c\u7136\u540e\u518d\u67e5\u770b\u8fd9\u7bc7\u6587\u7ae0\u7684\u8bc4\u8bba\u3002\u5728\u90a3\u91cc\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u7f16\u8f91\u6216\u8005\u5220\u9664\u8bc4\u8bba\u7684\u9009\u9879\u3002
updateFailLabel=\u66f4\u65b0\u5931\u8d25
\ No newline at end of file
#
# Copyright (c) 2010-2015, b3log.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Description: Finding skin.
# Version: 1.1.0.0, Sep 16, 2015
# Author: Liyuan Li
#
name=Finding
version=1.0.1
forSolo=1.1.0
memo=http://demo.ghost.io
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