Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo
Commits
c9e1e51e
Commit
c9e1e51e
authored
Nov 20, 2015
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#12042
重构代码引用的 key
parent
7c1b49c2
Changes
33
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
339 additions
and
556 deletions
+339
-556
src/main/java/org/b3log/solo/api/metaweblog/MetaWeblogAPI.java
...ain/java/org/b3log/solo/api/metaweblog/MetaWeblogAPI.java
+3
-3
src/main/java/org/b3log/solo/api/symphony/ArticleReceiver.java
...ain/java/org/b3log/solo/api/symphony/ArticleReceiver.java
+4
-4
src/main/java/org/b3log/solo/api/symphony/CommentReceiver.java
...ain/java/org/b3log/solo/api/symphony/CommentReceiver.java
+3
-8
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
...b3log/solo/event/comment/ArticleCommentReplyNotifier.java
+4
-4
src/main/java/org/b3log/solo/event/comment/PageCommentReplyNotifier.java
...rg/b3log/solo/event/comment/PageCommentReplyNotifier.java
+4
-4
src/main/java/org/b3log/solo/event/ping/AddArticleGoogleBlogSearchPinger.java
...log/solo/event/ping/AddArticleGoogleBlogSearchPinger.java
+3
-3
src/main/java/org/b3log/solo/event/ping/UpdateArticleGoogleBlogSearchPinger.java
.../solo/event/ping/UpdateArticleGoogleBlogSearchPinger.java
+3
-3
src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
+5
-5
src/main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
...main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
+5
-5
src/main/java/org/b3log/solo/event/symphony/CommentSender.java
...ain/java/org/b3log/solo/event/symphony/CommentSender.java
+4
-4
src/main/java/org/b3log/solo/model/Preference.java
src/main/java/org/b3log/solo/model/Preference.java
+0
-180
src/main/java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
...java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
+4
-5
src/main/java/org/b3log/solo/processor/ArticleProcessor.java
src/main/java/org/b3log/solo/processor/ArticleProcessor.java
+40
-48
src/main/java/org/b3log/solo/processor/BlogProcessor.java
src/main/java/org/b3log/solo/processor/BlogProcessor.java
+3
-3
src/main/java/org/b3log/solo/processor/FeedProcessor.java
src/main/java/org/b3log/solo/processor/FeedProcessor.java
+42
-44
src/main/java/org/b3log/solo/processor/IndexProcessor.java
src/main/java/org/b3log/solo/processor/IndexProcessor.java
+3
-3
src/main/java/org/b3log/solo/processor/LoginProcessor.java
src/main/java/org/b3log/solo/processor/LoginProcessor.java
+4
-5
src/main/java/org/b3log/solo/processor/PageProcessor.java
src/main/java/org/b3log/solo/processor/PageProcessor.java
+4
-4
src/main/java/org/b3log/solo/processor/RepairProcessor.java
src/main/java/org/b3log/solo/processor/RepairProcessor.java
+5
-5
src/main/java/org/b3log/solo/processor/TagProcessor.java
src/main/java/org/b3log/solo/processor/TagProcessor.java
+5
-5
src/main/java/org/b3log/solo/processor/UserTemplateProcessor.java
.../java/org/b3log/solo/processor/UserTemplateProcessor.java
+3
-3
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
...n/java/org/b3log/solo/processor/console/AdminConsole.java
+11
-12
src/main/java/org/b3log/solo/processor/console/PreferenceConsole.java
...a/org/b3log/solo/processor/console/PreferenceConsole.java
+14
-14
src/main/java/org/b3log/solo/processor/util/Filler.java
src/main/java/org/b3log/solo/processor/util/Filler.java
+42
-45
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
+10
-4
src/main/java/org/b3log/solo/service/ArticleQueryService.java
...main/java/org/b3log/solo/service/ArticleQueryService.java
+33
-47
src/main/java/org/b3log/solo/service/CommentMgmtService.java
src/main/java/org/b3log/solo/service/CommentMgmtService.java
+6
-6
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+1
-1
src/main/java/org/b3log/solo/service/PageMgmtService.java
src/main/java/org/b3log/solo/service/PageMgmtService.java
+4
-4
src/main/java/org/b3log/solo/service/PreferenceMgmtService.java
...in/java/org/b3log/solo/service/PreferenceMgmtService.java
+9
-10
src/main/java/org/b3log/solo/service/UpgradeService.java
src/main/java/org/b3log/solo/service/UpgradeService.java
+33
-33
src/test/java/org/b3log/solo/service/PreferenceMgmtServiceTestCase.java
...org/b3log/solo/service/PreferenceMgmtServiceTestCase.java
+12
-18
src/test/java/org/b3log/solo/service/PreferenceQueryServiceTestCase.java
...rg/b3log/solo/service/PreferenceQueryServiceTestCase.java
+13
-14
No files found.
src/main/java/org/b3log/solo/api/metaweblog/MetaWeblogAPI.java
View file @
c9e1e51e
...
@@ -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.1
1, May 17, 2013
* @version 1.0.0.1
2, 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>"
);
...
...
src/main/java/org/b3log/solo/api/symphony/ArticleReceiver.java
View file @
c9e1e51e
...
@@ -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
;
...
...
src/main/java/org/b3log/solo/api/symphony/CommentReceiver.java
View file @
c9e1e51e
...
@@ -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
))
{
...
...
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
View file @
c9e1e51e
...
@@ -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
);
...
...
src/main/java/org/b3log/solo/event/comment/PageCommentReplyNotifier.java
View file @
c9e1e51e
...
@@ -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
);
...
...
src/main/java/org/b3log/solo/event/ping/AddArticleGoogleBlogSearchPinger.java
View file @
c9e1e51e
...
@@ -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
,
...
...
src/main/java/org/b3log/solo/event/ping/UpdateArticleGoogleBlogSearchPinger.java
View file @
c9e1e51e
...
@@ -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
,
...
...
src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
View file @
c9e1e51e
...
@@ -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"
));
...
...
src/main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
View file @
c9e1e51e
...
@@ -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"
));
...
...
src/main/java/org/b3log/solo/event/symphony/CommentSender.java
View file @
c9e1e51e
...
@@ -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"
));
...
...
src/main/java/org/b3log/solo/model/Preference.java
View file @
c9e1e51e
...
@@ -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.
*/
*/
...
...
src/main/java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
View file @
c9e1e51e
...
@@ -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
();
...
...
src/main/java/org/b3log/solo/processor/ArticleProcessor.java
View file @
c9e1e51e
...
@@ -68,7 +68,7 @@ import org.jsoup.Jsoup;
...
@@ -68,7 +68,7 @@ import org.jsoup.Jsoup;
* Article processor.
* Article processor.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.2.1
4, Jun 13
, 2015
* @version 1.4.2.1
5, Nov 20
, 2015
* @since 0.3.1
* @since 0.3.1
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -193,7 +193,7 @@ public class ArticleProcessor {
...
@@ -193,7 +193,7 @@ public class ArticleProcessor {
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
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
(
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
)));
...
@@ -259,7 +259,7 @@ public class ArticleProcessor {
...
@@ -259,7 +259,7 @@ public class ArticleProcessor {
final
JSONObject
jsonObject
=
new
JSONObject
();
final
JSONObject
jsonObject
=
new
JSONObject
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
displayCnt
=
preference
.
getInt
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
);
final
int
displayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RANDOM_ARTICLES_DISPLAY_CNT
);
if
(
0
==
displayCnt
)
{
if
(
0
==
displayCnt
)
{
jsonObject
.
put
(
Common
.
RANDOM_ARTICLES
,
new
ArrayList
<
JSONObject
>());
jsonObject
.
put
(
Common
.
RANDOM_ARTICLES
,
new
ArrayList
<
JSONObject
>());
...
@@ -300,7 +300,7 @@ public class ArticleProcessor {
...
@@ -300,7 +300,7 @@ public class ArticleProcessor {
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
displayCnt
=
preference
.
getInt
(
Preference
.
RELEVANT_ARTICLES_DISPLAY_CNT
);
final
int
displayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RELEVANT_ARTICLES_DISPLAY_CNT
);
if
(
0
==
displayCnt
)
{
if
(
0
==
displayCnt
)
{
jsonObject
.
put
(
Common
.
RANDOM_ARTICLES
,
new
ArrayList
<
JSONObject
>());
jsonObject
.
put
(
Common
.
RANDOM_ARTICLES
,
new
ArrayList
<
JSONObject
>());
...
@@ -395,8 +395,8 @@ public class ArticleProcessor {
...
@@ -395,8 +395,8 @@ public class ArticleProcessor {
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
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
StringBuilder
pathBuilder
=
new
StringBuilder
();
final
StringBuilder
pathBuilder
=
new
StringBuilder
();
...
@@ -413,12 +413,10 @@ public class ArticleProcessor {
...
@@ -413,12 +413,10 @@ public class ArticleProcessor {
if
(
hasMultipleUsers
)
{
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
}
else
if
(!
articles
.
isEmpty
())
{
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
}
jsonObject
.
put
(
Keys
.
RESULTS
,
result
);
jsonObject
.
put
(
Keys
.
RESULTS
,
result
);
...
@@ -462,7 +460,7 @@ public class ArticleProcessor {
...
@@ -462,7 +460,7 @@ public class ArticleProcessor {
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
JSONObject
tagQueryResult
=
tagQueryService
.
getTagByTitle
(
tagTitle
);
final
JSONObject
tagQueryResult
=
tagQueryService
.
getTagByTitle
(
tagTitle
);
...
@@ -481,12 +479,10 @@ public class ArticleProcessor {
...
@@ -481,12 +479,10 @@ public class ArticleProcessor {
if
(
hasMultipleUsers
)
{
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
}
else
if
(!
articles
.
isEmpty
())
{
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
}
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
...
@@ -532,7 +528,7 @@ public class ArticleProcessor {
...
@@ -532,7 +528,7 @@ public class ArticleProcessor {
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
JSONObject
archiveQueryResult
=
archiveDateQueryService
.
getByArchiveDateString
(
archiveDateString
);
final
JSONObject
archiveQueryResult
=
archiveDateQueryService
.
getByArchiveDateString
(
archiveDateString
);
...
@@ -552,12 +548,10 @@ public class ArticleProcessor {
...
@@ -552,12 +548,10 @@ public class ArticleProcessor {
if
(
hasMultipleUsers
)
{
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
}
else
if
(!
articles
.
isEmpty
())
{
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
}
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
...
@@ -604,7 +598,7 @@ public class ArticleProcessor {
...
@@ -604,7 +598,7 @@ public class ArticleProcessor {
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
JSONObject
authorRet
=
userQueryService
.
getUser
(
authorId
);
final
JSONObject
authorRet
=
userQueryService
.
getUser
(
authorId
);
...
@@ -694,8 +688,8 @@ public class ArticleProcessor {
...
@@ -694,8 +688,8 @@ public class ArticleProcessor {
return
;
return
;
}
}
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
JSONObject
result
=
userQueryService
.
getUser
(
authorId
);
final
JSONObject
result
=
userQueryService
.
getUser
(
authorId
);
...
@@ -720,7 +714,7 @@ public class ArticleProcessor {
...
@@ -720,7 +714,7 @@ public class ArticleProcessor {
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
if
(
preference
.
optBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
if
(
preference
.
optBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
))
{
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_UPDATE_DATE_COMPARATOR
);
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_UPDATE_DATE_COMPARATOR
);
}
else
{
}
else
{
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
...
@@ -737,7 +731,7 @@ public class ArticleProcessor {
...
@@ -737,7 +731,7 @@ public class ArticleProcessor {
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
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
ServiceException
e
)
{
}
catch
(
final
ServiceException
e
)
{
...
@@ -795,7 +789,7 @@ public class ArticleProcessor {
...
@@ -795,7 +789,7 @@ public class ArticleProcessor {
final
String
archiveDateId
=
archiveDate
.
getString
(
Keys
.
OBJECT_ID
);
final
String
archiveDateId
=
archiveDate
.
getString
(
Keys
.
OBJECT_ID
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
articleCount
=
archiveDate
.
getInt
(
ArchiveDate
.
ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT
);
final
int
articleCount
=
archiveDate
.
getInt
(
ArchiveDate
.
ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT
);
final
int
pageCount
=
(
int
)
Math
.
ceil
((
double
)
articleCount
/
(
double
)
pageSize
);
final
int
pageCount
=
(
int
)
Math
.
ceil
((
double
)
articleCount
/
(
double
)
pageSize
);
...
@@ -815,19 +809,17 @@ public class ArticleProcessor {
...
@@ -815,19 +809,17 @@ public class ArticleProcessor {
if
(
hasMultipleUsers
)
{
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
}
else
if
(!
articles
.
isEmpty
())
{
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
}
sort
(
preference
,
articles
);
sort
(
preference
,
articles
);
final
Map
<
String
,
Object
>
dataModel
=
renderer
.
getDataModel
();
final
Map
<
String
,
Object
>
dataModel
=
renderer
.
getDataModel
();
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
);
prepareShowArchiveArticles
(
preference
,
dataModel
,
articles
,
currentPageNum
,
pageCount
,
archiveDateString
,
archiveDate
);
prepareShowArchiveArticles
(
preference
,
dataModel
,
articles
,
currentPageNum
,
pageCount
,
archiveDateString
,
archiveDate
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
...
@@ -899,7 +891,7 @@ public class ArticleProcessor {
...
@@ -899,7 +891,7 @@ public class ArticleProcessor {
try
{
try
{
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
boolean
allowVisitDraftViaPermalink
=
preference
.
getBoolean
(
Preference
.
ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
final
boolean
allowVisitDraftViaPermalink
=
preference
.
getBoolean
(
Option
.
ID_C_
ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
if
(!
article
.
optBoolean
(
Article
.
ARTICLE_IS_PUBLISHED
)
&&
!
allowVisitDraftViaPermalink
)
{
if
(!
article
.
optBoolean
(
Article
.
ARTICLE_IS_PUBLISHED
)
&&
!
allowVisitDraftViaPermalink
)
{
response
.
sendError
(
HttpServletResponse
.
SC_NOT_FOUND
);
response
.
sendError
(
HttpServletResponse
.
SC_NOT_FOUND
);
...
@@ -916,7 +908,7 @@ public class ArticleProcessor {
...
@@ -916,7 +908,7 @@ public class ArticleProcessor {
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
metaDescription
);
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
metaDescription
);
if
(
preference
.
getBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
if
(
preference
.
getBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
))
{
article
.
put
(
Common
.
HAS_UPDATED
,
articleQueryService
.
hasUpdated
(
article
));
article
.
put
(
Common
.
HAS_UPDATED
,
articleQueryService
.
hasUpdated
(
article
));
}
else
{
}
else
{
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
...
@@ -945,7 +937,7 @@ public class ArticleProcessor {
...
@@ -945,7 +937,7 @@ public class ArticleProcessor {
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
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
);
if
(!
Requests
.
hasBeenServed
(
request
,
response
))
{
if
(!
Requests
.
hasBeenServed
(
request
,
response
))
{
articleMgmtService
.
incViewCount
(
articleId
);
articleMgmtService
.
incViewCount
(
articleId
);
...
@@ -983,7 +975,7 @@ public class ArticleProcessor {
...
@@ -983,7 +975,7 @@ public class ArticleProcessor {
* @see Comparators#ARTICLE_CREATE_DATE_COMPARATOR
* @see Comparators#ARTICLE_CREATE_DATE_COMPARATOR
*/
*/
private
void
sort
(
final
JSONObject
preference
,
final
List
<
JSONObject
>
articles
)
throws
JSONException
{
private
void
sort
(
final
JSONObject
preference
,
final
List
<
JSONObject
>
articles
)
throws
JSONException
{
// if (preference.getBoolean(
Preference.
ENABLE_ARTICLE_UPDATE_HINT)) {
// if (preference.getBoolean(
Option.ID_C_
ENABLE_ARTICLE_UPDATE_HINT)) {
// Collections.sort(articles, Comparators.ARTICLE_UPDATE_DATE_COMPARATOR);
// Collections.sort(articles, Comparators.ARTICLE_UPDATE_DATE_COMPARATOR);
// } else {
// } else {
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
...
@@ -1143,7 +1135,7 @@ public class ArticleProcessor {
...
@@ -1143,7 +1135,7 @@ public class ArticleProcessor {
*/
*/
private
List
<
JSONObject
>
getRandomArticles
(
final
JSONObject
preference
)
{
private
List
<
JSONObject
>
getRandomArticles
(
final
JSONObject
preference
)
{
try
{
try
{
final
int
displayCnt
=
preference
.
getInt
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
);
final
int
displayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RANDOM_ARTICLES_DISPLAY_CNT
);
final
List
<
JSONObject
>
ret
=
articleQueryService
.
getArticlesRandomly
(
displayCnt
);
final
List
<
JSONObject
>
ret
=
articleQueryService
.
getArticlesRandomly
(
displayCnt
);
return
ret
;
return
ret
;
...
@@ -1227,8 +1219,8 @@ public class ArticleProcessor {
...
@@ -1227,8 +1219,8 @@ public class ArticleProcessor {
final
int
pageCount
,
final
int
pageCount
,
final
String
archiveDateString
,
final
String
archiveDateString
,
final
JSONObject
archiveDate
)
throws
Exception
{
final
JSONObject
archiveDate
)
throws
Exception
{
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
<
Integer
>
pageNums
=
Paginator
.
paginate
(
currentPageNum
,
pageSize
,
pageCount
,
windowSize
);
final
List
<
Integer
>
pageNums
=
Paginator
.
paginate
(
currentPageNum
,
pageSize
,
pageCount
,
windowSize
);
...
@@ -1256,7 +1248,7 @@ public class ArticleProcessor {
...
@@ -1256,7 +1248,7 @@ public class ArticleProcessor {
final
String
month
=
dateStrings
[
1
];
final
String
month
=
dateStrings
[
1
];
archiveDate
.
put
(
ArchiveDate
.
ARCHIVE_DATE_YEAR
,
year
);
archiveDate
.
put
(
ArchiveDate
.
ARCHIVE_DATE_YEAR
,
year
);
final
String
language
=
Locales
.
getLanguage
(
preference
.
getString
(
Preference
.
LOCALE_STRING
));
final
String
language
=
Locales
.
getLanguage
(
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
));
String
ret
;
String
ret
;
if
(
"en"
.
equals
(
language
))
{
if
(
"en"
.
equals
(
language
))
{
...
@@ -1281,7 +1273,7 @@ public class ArticleProcessor {
...
@@ -1281,7 +1273,7 @@ public class ArticleProcessor {
*/
*/
private
void
prepareShowArticle
(
final
JSONObject
preference
,
final
Map
<
String
,
Object
>
dataModel
,
final
JSONObject
article
)
private
void
prepareShowArticle
(
final
JSONObject
preference
,
final
Map
<
String
,
Object
>
dataModel
,
final
JSONObject
article
)
throws
Exception
{
throws
Exception
{
article
.
put
(
Common
.
COMMENTABLE
,
preference
.
getBoolean
(
Preference
.
COMMENTABLE
)
&&
article
.
getBoolean
(
Article
.
ARTICLE_COMMENTABLE
));
article
.
put
(
Common
.
COMMENTABLE
,
preference
.
getBoolean
(
Option
.
ID_C_
COMMENTABLE
)
&&
article
.
getBoolean
(
Article
.
ARTICLE_COMMENTABLE
));
article
.
put
(
Common
.
PERMALINK
,
article
.
getString
(
Article
.
ARTICLE_PERMALINK
));
article
.
put
(
Common
.
PERMALINK
,
article
.
getString
(
Article
.
ARTICLE_PERMALINK
));
dataModel
.
put
(
Article
.
ARTICLE
,
article
);
dataModel
.
put
(
Article
.
ARTICLE
,
article
);
final
String
articleId
=
article
.
getString
(
Keys
.
OBJECT_ID
);
final
String
articleId
=
article
.
getString
(
Keys
.
OBJECT_ID
);
...
@@ -1330,9 +1322,9 @@ public class ArticleProcessor {
...
@@ -1330,9 +1322,9 @@ public class ArticleProcessor {
LOGGER
.
debug
(
"Got article's comments"
);
LOGGER
.
debug
(
"Got article's comments"
);
Stopwatchs
.
end
();
Stopwatchs
.
end
();
dataModel
.
put
(
Preference
.
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
,
dataModel
.
put
(
Option
.
ID_C_
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Preference
.
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
));
preference
.
getInt
(
Option
.
ID_C_
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
));
dataModel
.
put
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
));
dataModel
.
put
(
Option
.
ID_C_RANDOM_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Option
.
ID_C_
RANDOM_ARTICLES_DISPLAY_CNT
));
dataModel
.
put
(
Preference
.
RELEVANT_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Preference
.
RELEVANT_ARTICLES_DISPLAY_CNT
));
dataModel
.
put
(
Option
.
ID_C_RELEVANT_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Option
.
ID_C_
RELEVANT_ARTICLES_DISPLAY_CNT
));
}
}
}
}
src/main/java/org/b3log/solo/processor/BlogProcessor.java
View file @
c9e1e51e
...
@@ -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"
));
...
...
src/main/java/org/b3log/solo/processor/FeedProcessor.java
View file @
c9e1e51e
...
@@ -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
...
@@ -116,10 +114,10 @@ public class FeedProcessor {
...
@@ -116,10 +114,10 @@ public class FeedProcessor {
/**
/**
* Blog articles Atom output.
* Blog articles Atom output.
*
*
* @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
));
...
@@ -146,7 +144,7 @@ public class FeedProcessor {
...
@@ -146,7 +144,7 @@ public class FeedProcessor {
filters
.
add
(
new
PropertyFilter
(
Article
.
ARTICLE_IS_PUBLISHED
,
FilterOperator
.
EQUAL
,
true
));
filters
.
add
(
new
PropertyFilter
(
Article
.
ARTICLE_IS_PUBLISHED
,
FilterOperator
.
EQUAL
,
true
));
filters
.
add
(
new
PropertyFilter
(
Article
.
ARTICLE_VIEW_PWD
,
FilterOperator
.
EQUAL
,
""
));
filters
.
add
(
new
PropertyFilter
(
Article
.
ARTICLE_VIEW_PWD
,
FilterOperator
.
EQUAL
,
""
));
final
Query
query
=
new
Query
().
setCurrentPageNum
(
1
).
setPageSize
(
outputCnt
).
setFilter
(
new
CompositeFilter
(
CompositeFilterOperator
.
AND
,
filters
)).
addSort
(
Article
.
ARTICLE_UPDATE_DATE
,
SortDirection
.
DESCENDING
).
setPageCount
(
final
Query
query
=
new
Query
().
setCurrentPageNum
(
1
).
setPageSize
(
outputCnt
).
setFilter
(
new
CompositeFilter
(
CompositeFilterOperator
.
AND
,
filters
)).
addSort
(
Article
.
ARTICLE_UPDATE_DATE
,
SortDirection
.
DESCENDING
).
setPageCount
(
1
);
1
);
final
boolean
hasMultipleUsers
=
userQueryService
.
hasMultipleUsers
();
final
boolean
hasMultipleUsers
=
userQueryService
.
hasMultipleUsers
();
String
authorName
=
""
;
String
authorName
=
""
;
...
@@ -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
);
...
@@ -169,8 +167,8 @@ public class FeedProcessor {
...
@@ -169,8 +167,8 @@ public class FeedProcessor {
entry
.
setTitle
(
title
);
entry
.
setTitle
(
title
);
final
String
summary
=
isFullContent
final
String
summary
=
isFullContent
?
StringEscapeUtils
.
escapeXml
(
article
.
getString
(
Article
.
ARTICLE_CONTENT
))
?
StringEscapeUtils
.
escapeXml
(
article
.
getString
(
Article
.
ARTICLE_CONTENT
))
:
StringEscapeUtils
.
escapeXml
(
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
));
:
StringEscapeUtils
.
escapeXml
(
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
));
entry
.
setSummary
(
summary
);
entry
.
setSummary
(
summary
);
final
Date
updated
=
(
Date
)
article
.
get
(
Article
.
ARTICLE_UPDATE_DATE
);
final
Date
updated
=
(
Date
)
article
.
get
(
Article
.
ARTICLE_UPDATE_DATE
);
...
@@ -214,11 +212,11 @@ public class FeedProcessor {
...
@@ -214,11 +212,11 @@ public class FeedProcessor {
/**
/**
* Tag articles Atom output.
* Tag articles Atom output.
*
*
* @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
));
...
@@ -283,7 +281,7 @@ public class FeedProcessor {
...
@@ -283,7 +281,7 @@ public class FeedProcessor {
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
if
(
article
.
getBoolean
(
Article
.
ARTICLE_IS_PUBLISHED
)
// Skips the unpublished article
if
(
article
.
getBoolean
(
Article
.
ARTICLE_IS_PUBLISHED
)
// Skips the unpublished article
&&
Strings
.
isEmptyOrNull
(
article
.
optString
(
Article
.
ARTICLE_VIEW_PWD
)))
{
// Skips article with password
&&
Strings
.
isEmptyOrNull
(
article
.
optString
(
Article
.
ARTICLE_VIEW_PWD
)))
{
// Skips article with password
articles
.
add
(
article
);
articles
.
add
(
article
);
}
}
}
}
...
@@ -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
);
...
@@ -306,8 +304,8 @@ public class FeedProcessor {
...
@@ -306,8 +304,8 @@ public class FeedProcessor {
entry
.
setTitle
(
title
);
entry
.
setTitle
(
title
);
final
String
summary
=
isFullContent
final
String
summary
=
isFullContent
?
StringEscapeUtils
.
escapeXml
(
article
.
getString
(
Article
.
ARTICLE_CONTENT
))
?
StringEscapeUtils
.
escapeXml
(
article
.
getString
(
Article
.
ARTICLE_CONTENT
))
:
StringEscapeUtils
.
escapeXml
(
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
));
:
StringEscapeUtils
.
escapeXml
(
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
));
entry
.
setSummary
(
summary
);
entry
.
setSummary
(
summary
);
final
Date
updated
=
(
Date
)
article
.
get
(
Article
.
ARTICLE_UPDATE_DATE
);
final
Date
updated
=
(
Date
)
article
.
get
(
Article
.
ARTICLE_UPDATE_DATE
);
...
@@ -349,10 +347,10 @@ public class FeedProcessor {
...
@@ -349,10 +347,10 @@ public class FeedProcessor {
/**
/**
* Blog articles RSS output.
* Blog articles RSS output.
*
*
* @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
();
...
@@ -390,7 +388,7 @@ public class FeedProcessor {
...
@@ -390,7 +388,7 @@ public class FeedProcessor {
filters
.
add
(
new
PropertyFilter
(
Article
.
ARTICLE_IS_PUBLISHED
,
FilterOperator
.
EQUAL
,
true
));
filters
.
add
(
new
PropertyFilter
(
Article
.
ARTICLE_IS_PUBLISHED
,
FilterOperator
.
EQUAL
,
true
));
filters
.
add
(
new
PropertyFilter
(
Article
.
ARTICLE_VIEW_PWD
,
FilterOperator
.
EQUAL
,
""
));
filters
.
add
(
new
PropertyFilter
(
Article
.
ARTICLE_VIEW_PWD
,
FilterOperator
.
EQUAL
,
""
));
final
Query
query
=
new
Query
().
setCurrentPageNum
(
1
).
setPageSize
(
outputCnt
).
setFilter
(
new
CompositeFilter
(
CompositeFilterOperator
.
AND
,
filters
)).
addSort
(
Article
.
ARTICLE_UPDATE_DATE
,
SortDirection
.
DESCENDING
).
setPageCount
(
final
Query
query
=
new
Query
().
setCurrentPageNum
(
1
).
setPageSize
(
outputCnt
).
setFilter
(
new
CompositeFilter
(
CompositeFilterOperator
.
AND
,
filters
)).
addSort
(
Article
.
ARTICLE_UPDATE_DATE
,
SortDirection
.
DESCENDING
).
setPageCount
(
1
);
1
);
final
JSONObject
articleResult
=
articleRepository
.
get
(
query
);
final
JSONObject
articleResult
=
articleRepository
.
get
(
query
);
final
JSONArray
articles
=
articleResult
.
getJSONArray
(
Keys
.
RESULTS
);
final
JSONArray
articles
=
articleResult
.
getJSONArray
(
Keys
.
RESULTS
);
...
@@ -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
);
...
@@ -413,8 +411,8 @@ public class FeedProcessor {
...
@@ -413,8 +411,8 @@ public class FeedProcessor {
item
.
setTitle
(
title
);
item
.
setTitle
(
title
);
final
String
description
=
isFullContent
final
String
description
=
isFullContent
?
StringEscapeUtils
.
escapeXml
(
article
.
getString
(
Article
.
ARTICLE_CONTENT
))
?
StringEscapeUtils
.
escapeXml
(
article
.
getString
(
Article
.
ARTICLE_CONTENT
))
:
StringEscapeUtils
.
escapeXml
(
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
));
:
StringEscapeUtils
.
escapeXml
(
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
));
item
.
setDescription
(
description
);
item
.
setDescription
(
description
);
final
Date
pubDate
=
(
Date
)
article
.
get
(
Article
.
ARTICLE_UPDATE_DATE
);
final
Date
pubDate
=
(
Date
)
article
.
get
(
Article
.
ARTICLE_UPDATE_DATE
);
...
@@ -460,11 +458,11 @@ public class FeedProcessor {
...
@@ -460,11 +458,11 @@ public class FeedProcessor {
/**
/**
* Tag articles RSS output.
* Tag articles RSS output.
*
*
* @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
();
...
@@ -534,7 +532,7 @@ public class FeedProcessor {
...
@@ -534,7 +532,7 @@ public class FeedProcessor {
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
if
(
article
.
getBoolean
(
Article
.
ARTICLE_IS_PUBLISHED
)
// Skips the unpublished article
if
(
article
.
getBoolean
(
Article
.
ARTICLE_IS_PUBLISHED
)
// Skips the unpublished article
&&
Strings
.
isEmptyOrNull
(
article
.
optString
(
Article
.
ARTICLE_VIEW_PWD
)))
{
// Skips article with password
&&
Strings
.
isEmptyOrNull
(
article
.
optString
(
Article
.
ARTICLE_VIEW_PWD
)))
{
// Skips article with password
articles
.
add
(
article
);
articles
.
add
(
article
);
}
}
}
}
...
@@ -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
);
...
@@ -557,8 +555,8 @@ public class FeedProcessor {
...
@@ -557,8 +555,8 @@ public class FeedProcessor {
item
.
setTitle
(
title
);
item
.
setTitle
(
title
);
final
String
description
=
isFullContent
final
String
description
=
isFullContent
?
StringEscapeUtils
.
escapeXml
(
article
.
getString
(
Article
.
ARTICLE_CONTENT
))
?
StringEscapeUtils
.
escapeXml
(
article
.
getString
(
Article
.
ARTICLE_CONTENT
))
:
StringEscapeUtils
.
escapeXml
(
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
));
:
StringEscapeUtils
.
escapeXml
(
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
));
item
.
setDescription
(
description
);
item
.
setDescription
(
description
);
final
Date
pubDate
=
(
Date
)
article
.
get
(
Article
.
ARTICLE_UPDATE_DATE
);
final
Date
pubDate
=
(
Date
)
article
.
get
(
Article
.
ARTICLE_UPDATE_DATE
);
...
...
src/main/java/org/b3log/solo/processor/IndexProcessor.java
View file @
c9e1e51e
...
@@ -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
);
...
...
src/main/java/org/b3log/solo/processor/LoginProcessor.java
View file @
c9e1e51e
...
@@ -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"
);
...
...
src/main/java/org/b3log/solo/processor/PageProcessor.java
View file @
c9e1e51e
...
@@ -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
);
...
...
src/main/java/org/b3log/solo/processor/RepairProcessor.java
View file @
c9e1e51e
...
@@ -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.1
0, Nov 8
, 2015
* @version 1.2.0.1
1, 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."
);
...
...
src/main/java/org/b3log/solo/processor/TagProcessor.java
View file @
c9e1e51e
...
@@ -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
);
...
...
src/main/java/org/b3log/solo/processor/UserTemplateProcessor.java
View file @
c9e1e51e
...
@@ -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
)
{
...
...
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
View file @
c9e1e51e
...
@@ -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>"
;
...
...
src/main/java/org/b3log/solo/processor/console/PreferenceConsole.java
View file @
c9e1e51e
...
@@ -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"
));
...
...
src/main/java/org/b3log/solo/processor/util/Filler.java
View file @
c9e1e51e
...
@@ -71,7 +71,7 @@ import org.json.JSONObject;
...
@@ -71,7 +71,7 @@ import org.json.JSONObject;
* Filler utilities.
* Filler utilities.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.11.1
1, Nov 7
, 2015
* @version 1.5.11.1
2, Nov 20
, 2015
* @since 0.3.1
* @since 0.3.1
*/
*/
@Service
@Service
...
@@ -203,8 +203,8 @@ public class Filler {
...
@@ -203,8 +203,8 @@ public class Filler {
Stopwatchs
.
start
(
"Fill Index Articles"
);
Stopwatchs
.
start
(
"Fill Index Articles"
);
try
{
try
{
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
JSONObject
statistic
=
statisticQueryService
.
getStatistic
();
final
JSONObject
statistic
=
statisticQueryService
.
getStatistic
();
final
int
publishedArticleCnt
=
statistic
.
getInt
(
Statistic
.
STATISTIC_PUBLISHED_ARTICLE_COUNT
);
final
int
publishedArticleCnt
=
statistic
.
getInt
(
Statistic
.
STATISTIC_PUBLISHED_ARTICLE_COUNT
);
...
@@ -219,19 +219,18 @@ public class Filler {
...
@@ -219,19 +219,18 @@ public class Filler {
if
(
null
==
template
)
{
if
(
null
==
template
)
{
LOGGER
.
debug
(
"The skin dose not contain [index.ftl] template"
);
LOGGER
.
debug
(
"The skin dose not contain [index.ftl] template"
);
}
else
{
// See https://github.com/b3log/solo/issues/179 for more details
}
else
// See https://github.com/b3log/solo/issues/179 for more details
if
(
Templates
.
hasExpression
(
template
,
"<#list articles1 as article>"
))
{
if
(
Templates
.
hasExpression
(
template
,
"<#list articles1 as article>"
))
{
isArticles1
=
true
;
isArticles1
=
true
;
query
.
addSort
(
Article
.
ARTICLE_CREATE_DATE
,
SortDirection
.
DESCENDING
);
LOGGER
.
trace
(
"Query ${articles1} in index.ftl"
);
}
else
{
// <#list articles as article>
query
.
addSort
(
Article
.
ARTICLE_PUT_TOP
,
SortDirection
.
DESCENDING
);
if
(
preference
.
getBoolean
(
Option
.
ID_C_ENABLE_ARTICLE_UPDATE_HINT
))
{
query
.
addSort
(
Article
.
ARTICLE_UPDATE_DATE
,
SortDirection
.
DESCENDING
);
}
else
{
query
.
addSort
(
Article
.
ARTICLE_CREATE_DATE
,
SortDirection
.
DESCENDING
);
query
.
addSort
(
Article
.
ARTICLE_CREATE_DATE
,
SortDirection
.
DESCENDING
);
LOGGER
.
trace
(
"Query ${articles1} in index.ftl"
);
}
else
{
// <#list articles as article>
query
.
addSort
(
Article
.
ARTICLE_PUT_TOP
,
SortDirection
.
DESCENDING
);
if
(
preference
.
getBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
query
.
addSort
(
Article
.
ARTICLE_UPDATE_DATE
,
SortDirection
.
DESCENDING
);
}
else
{
query
.
addSort
(
Article
.
ARTICLE_CREATE_DATE
,
SortDirection
.
DESCENDING
);
}
}
}
}
}
...
@@ -254,12 +253,10 @@ public class Filler {
...
@@ -254,12 +253,10 @@ public class Filler {
if
(
hasMultipleUsers
)
{
if
(
hasMultipleUsers
)
{
setArticlesExProperties
(
request
,
articles
,
preference
);
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
}
else
if
(!
articles
.
isEmpty
())
{
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
}
if
(!
isArticles1
)
{
if
(!
isArticles1
)
{
...
@@ -347,7 +344,7 @@ public class Filler {
...
@@ -347,7 +344,7 @@ public class Filler {
try
{
try
{
LOGGER
.
debug
(
"Filling most used tags...."
);
LOGGER
.
debug
(
"Filling most used tags...."
);
final
int
mostUsedTagDisplayCnt
=
preference
.
getInt
(
Preference
.
MOST_USED_TAG_DISPLAY_CNT
);
final
int
mostUsedTagDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_
MOST_USED_TAG_DISPLAY_CNT
);
final
List
<
JSONObject
>
tags
=
tagRepository
.
getMostUsedTags
(
mostUsedTagDisplayCnt
);
final
List
<
JSONObject
>
tags
=
tagRepository
.
getMostUsedTags
(
mostUsedTagDisplayCnt
);
...
@@ -406,7 +403,7 @@ public class Filler {
...
@@ -406,7 +403,7 @@ public class Filler {
}
}
}
}
final
String
localeString
=
preference
.
getString
(
Preference
.
LOCALE_STRING
);
final
String
localeString
=
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
);
final
String
language
=
Locales
.
getLanguage
(
localeString
);
final
String
language
=
Locales
.
getLanguage
(
localeString
);
for
(
final
JSONObject
archiveDate
:
archiveDates2
)
{
for
(
final
JSONObject
archiveDate
:
archiveDates2
)
{
...
@@ -449,7 +446,7 @@ public class Filler {
...
@@ -449,7 +446,7 @@ public class Filler {
Stopwatchs
.
start
(
"Fill Most View Articles"
);
Stopwatchs
.
start
(
"Fill Most View Articles"
);
try
{
try
{
LOGGER
.
debug
(
"Filling the most view count articles...."
);
LOGGER
.
debug
(
"Filling the most view count articles...."
);
final
int
mostCommentArticleDisplayCnt
=
preference
.
getInt
(
Preference
.
MOST_VIEW_ARTICLE_DISPLAY_CNT
);
final
int
mostCommentArticleDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_
MOST_VIEW_ARTICLE_DISPLAY_CNT
);
final
List
<
JSONObject
>
mostViewCountArticles
=
articleRepository
.
getMostViewCountArticles
(
mostCommentArticleDisplayCnt
);
final
List
<
JSONObject
>
mostViewCountArticles
=
articleRepository
.
getMostViewCountArticles
(
mostCommentArticleDisplayCnt
);
dataModel
.
put
(
Common
.
MOST_VIEW_COUNT_ARTICLES
,
mostViewCountArticles
);
dataModel
.
put
(
Common
.
MOST_VIEW_COUNT_ARTICLES
,
mostViewCountArticles
);
...
@@ -474,7 +471,7 @@ public class Filler {
...
@@ -474,7 +471,7 @@ public class Filler {
try
{
try
{
LOGGER
.
debug
(
"Filling most comment articles...."
);
LOGGER
.
debug
(
"Filling most comment articles...."
);
final
int
mostCommentArticleDisplayCnt
=
preference
.
getInt
(
Preference
.
MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
final
int
mostCommentArticleDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_
MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
final
List
<
JSONObject
>
mostCommentArticles
=
articleRepository
.
getMostCommentArticles
(
mostCommentArticleDisplayCnt
);
final
List
<
JSONObject
>
mostCommentArticles
=
articleRepository
.
getMostCommentArticles
(
mostCommentArticleDisplayCnt
);
dataModel
.
put
(
Common
.
MOST_COMMENT_ARTICLES
,
mostCommentArticles
);
dataModel
.
put
(
Common
.
MOST_COMMENT_ARTICLES
,
mostCommentArticles
);
...
@@ -497,7 +494,7 @@ public class Filler {
...
@@ -497,7 +494,7 @@ public class Filler {
Stopwatchs
.
start
(
"Fill Recent Articles"
);
Stopwatchs
.
start
(
"Fill Recent Articles"
);
try
{
try
{
final
int
recentArticleDisplayCnt
=
preference
.
getInt
(
Preference
.
RECENT_ARTICLE_DISPLAY_CNT
);
final
int
recentArticleDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RECENT_ARTICLE_DISPLAY_CNT
);
final
List
<
JSONObject
>
recentArticles
=
articleRepository
.
getRecentArticles
(
recentArticleDisplayCnt
);
final
List
<
JSONObject
>
recentArticles
=
articleRepository
.
getRecentArticles
(
recentArticleDisplayCnt
);
...
@@ -525,7 +522,7 @@ public class Filler {
...
@@ -525,7 +522,7 @@ public class Filler {
Stopwatchs
.
start
(
"Fill Recent Comments"
);
Stopwatchs
.
start
(
"Fill Recent Comments"
);
try
{
try
{
LOGGER
.
debug
(
"Filling recent comments...."
);
LOGGER
.
debug
(
"Filling recent comments...."
);
final
int
recentCommentDisplayCnt
=
preference
.
getInt
(
Preference
.
RECENT_COMMENT_DISPLAY_CNT
);
final
int
recentCommentDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RECENT_COMMENT_DISPLAY_CNT
);
final
List
<
JSONObject
>
recentComments
=
commentRepository
.
getRecentComments
(
recentCommentDisplayCnt
);
final
List
<
JSONObject
>
recentComments
=
commentRepository
.
getRecentComments
(
recentCommentDisplayCnt
);
...
@@ -565,9 +562,9 @@ public class Filler {
...
@@ -565,9 +562,9 @@ public class Filler {
Stopwatchs
.
start
(
"Fill Footer"
);
Stopwatchs
.
start
(
"Fill Footer"
);
try
{
try
{
LOGGER
.
debug
(
"Filling footer...."
);
LOGGER
.
debug
(
"Filling footer...."
);
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
dataModel
.
put
(
Preference
.
BLOG_TITLE
,
blogTitle
);
dataModel
.
put
(
Option
.
ID_C_
BLOG_TITLE
,
blogTitle
);
dataModel
.
put
(
"blogHost"
,
Latkes
.
getServerHost
()
+
":"
+
Latkes
.
getServerPort
());
dataModel
.
put
(
"blogHost"
,
Latkes
.
getServerHost
()
+
":"
+
Latkes
.
getServerPort
());
dataModel
.
put
(
Common
.
VERSION
,
SoloServletListener
.
VERSION
);
dataModel
.
put
(
Common
.
VERSION
,
SoloServletListener
.
VERSION
);
...
@@ -645,32 +642,32 @@ public class Filler {
...
@@ -645,32 +642,32 @@ public class Filler {
dataModel
.
put
(
Common
.
TOP_BAR
,
topBarHTML
);
dataModel
.
put
(
Common
.
TOP_BAR
,
topBarHTML
);
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
.
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
(
Preference
.
HTML_HEAD
,
preference
.
getString
(
Preference
.
HTML_HEAD
));
dataModel
.
put
(
Option
.
ID_C_HTML_HEAD
,
preference
.
getString
(
Option
.
ID_C_
HTML_HEAD
));
String
metaKeywords
=
preference
.
getString
(
Preference
.
META_KEYWORDS
);
String
metaKeywords
=
preference
.
getString
(
Option
.
ID_C_
META_KEYWORDS
);
if
(
Strings
.
isEmptyOrNull
(
metaKeywords
))
{
if
(
Strings
.
isEmptyOrNull
(
metaKeywords
))
{
metaKeywords
=
""
;
metaKeywords
=
""
;
}
}
dataModel
.
put
(
Preference
.
META_KEYWORDS
,
metaKeywords
);
dataModel
.
put
(
Option
.
ID_C_
META_KEYWORDS
,
metaKeywords
);
String
metaDescription
=
preference
.
getString
(
Preference
.
META_DESCRIPTION
);
String
metaDescription
=
preference
.
getString
(
Option
.
ID_C_
META_DESCRIPTION
);
if
(
Strings
.
isEmptyOrNull
(
metaDescription
))
{
if
(
Strings
.
isEmptyOrNull
(
metaDescription
))
{
metaDescription
=
""
;
metaDescription
=
""
;
}
}
dataModel
.
put
(
Preference
.
META_DESCRIPTION
,
metaDescription
);
dataModel
.
put
(
Option
.
ID_C_
META_DESCRIPTION
,
metaDescription
);
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
.
IS_LOGGED_IN
,
null
!=
userQueryService
.
getCurrentUser
(
request
));
dataModel
.
put
(
Common
.
IS_LOGGED_IN
,
null
!=
userQueryService
.
getCurrentUser
(
request
));
dataModel
.
put
(
Common
.
FAVICON_API
,
SoloServletListener
.
FAVICON_API
);
dataModel
.
put
(
Common
.
FAVICON_API
,
SoloServletListener
.
FAVICON_API
);
final
String
noticeBoard
=
preference
.
getString
(
Preference
.
NOTICE_BOARD
);
final
String
noticeBoard
=
preference
.
getString
(
Option
.
ID_C_
NOTICE_BOARD
);
dataModel
.
put
(
Preference
.
NOTICE_BOARD
,
noticeBoard
);
dataModel
.
put
(
Option
.
ID_C_
NOTICE_BOARD
,
noticeBoard
);
final
Query
query
=
new
Query
().
setPageCount
(
1
);
final
Query
query
=
new
Query
().
setPageCount
(
1
);
final
JSONObject
result
=
userRepository
.
get
(
query
);
final
JSONObject
result
=
userRepository
.
get
(
query
);
...
@@ -831,9 +828,9 @@ public class Filler {
...
@@ -831,9 +828,9 @@ public class Filler {
fillSide
(
request
,
dataModel
,
preference
);
fillSide
(
request
,
dataModel
,
preference
);
}
}
final
String
noticeBoard
=
preference
.
getString
(
Preference
.
NOTICE_BOARD
);
final
String
noticeBoard
=
preference
.
getString
(
Option
.
ID_C_
NOTICE_BOARD
);
dataModel
.
put
(
Preference
.
NOTICE_BOARD
,
noticeBoard
);
dataModel
.
put
(
Option
.
ID_C_
NOTICE_BOARD
,
noticeBoard
);
}
catch
(
final
JSONException
e
)
{
}
catch
(
final
JSONException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Fills user template failed"
,
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Fills user template failed"
,
e
);
throw
new
ServiceException
(
e
);
throw
new
ServiceException
(
e
);
...
@@ -934,7 +931,7 @@ public class Filler {
...
@@ -934,7 +931,7 @@ public class Filler {
article
.
put
(
Common
.
AUTHOR_THUMBNAIL_URL
,
thumbnailURL
);
article
.
put
(
Common
.
AUTHOR_THUMBNAIL_URL
,
thumbnailURL
);
}
}
if
(
preference
.
getBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
if
(
preference
.
getBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
))
{
article
.
put
(
Common
.
HAS_UPDATED
,
articleQueryService
.
hasUpdated
(
article
));
article
.
put
(
Common
.
HAS_UPDATED
,
articleQueryService
.
hasUpdated
(
article
));
}
else
{
}
else
{
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
...
@@ -996,7 +993,7 @@ public class Filler {
...
@@ -996,7 +993,7 @@ public class Filler {
article
.
put
(
Common
.
AUTHOR_THUMBNAIL_URL
,
thumbnailURL
);
article
.
put
(
Common
.
AUTHOR_THUMBNAIL_URL
,
thumbnailURL
);
}
}
if
(
preference
.
getBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
if
(
preference
.
getBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
))
{
article
.
put
(
Common
.
HAS_UPDATED
,
articleQueryService
.
hasUpdated
(
article
));
article
.
put
(
Common
.
HAS_UPDATED
,
articleQueryService
.
hasUpdated
(
article
));
}
else
{
}
else
{
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
...
@@ -1103,7 +1100,7 @@ public class Filler {
...
@@ -1103,7 +1100,7 @@ public class Filler {
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
""
);
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
""
);
}
}
final
String
articleListStyle
=
preference
.
optString
(
Preference
.
ARTICLE_LIST_STYLE
);
final
String
articleListStyle
=
preference
.
optString
(
Option
.
ID_C_
ARTICLE_LIST_STYLE
);
if
(
"titleOnly"
.
equals
(
articleListStyle
))
{
if
(
"titleOnly"
.
equals
(
articleListStyle
))
{
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
""
);
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
""
);
...
...
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
View file @
c9e1e51e
...
@@ -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
);
...
...
src/main/java/org/b3log/solo/service/ArticleQueryService.java
View file @
c9e1e51e
...
@@ -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
...
@@ -256,7 +252,7 @@ public class ArticleQueryService {
...
@@ -256,7 +252,7 @@ public class ArticleQueryService {
if
(
null
==
ret
)
{
if
(
null
==
ret
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Gets author of article failed, assumes the administrator is the author of this article[id={0}]"
,
LOGGER
.
log
(
Level
.
WARN
,
"Gets author of article failed, assumes the administrator is the author of this article[id={0}]"
,
article
.
getString
(
Keys
.
OBJECT_ID
));
article
.
getString
(
Keys
.
OBJECT_ID
));
// This author may be deleted by admin, use admin as the author
// This author may be deleted by admin, use admin as the author
// of this article
// of this article
ret
=
userRepository
.
getAdmin
();
ret
=
userRepository
.
getAdmin
();
...
@@ -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,
...
@@ -512,7 +503,7 @@ public class ArticleQueryService {
...
@@ -512,7 +503,7 @@ public class ArticleQueryService {
final
boolean
articleIsPublished
=
requestJSONObject
.
optBoolean
(
ARTICLE_IS_PUBLISHED
,
true
);
final
boolean
articleIsPublished
=
requestJSONObject
.
optBoolean
(
ARTICLE_IS_PUBLISHED
,
true
);
final
Query
query
=
new
Query
().
setCurrentPageNum
(
currentPageNum
).
setPageSize
(
pageSize
).
addSort
(
ARTICLE_PUT_TOP
,
SortDirection
.
DESCENDING
).
addSort
(
ARTICLE_CREATE_DATE
,
SortDirection
.
DESCENDING
).
setFilter
(
final
Query
query
=
new
Query
().
setCurrentPageNum
(
currentPageNum
).
setPageSize
(
pageSize
).
addSort
(
ARTICLE_PUT_TOP
,
SortDirection
.
DESCENDING
).
addSort
(
ARTICLE_CREATE_DATE
,
SortDirection
.
DESCENDING
).
setFilter
(
new
PropertyFilter
(
ARTICLE_IS_PUBLISHED
,
FilterOperator
.
EQUAL
,
articleIsPublished
));
new
PropertyFilter
(
ARTICLE_IS_PUBLISHED
,
FilterOperator
.
EQUAL
,
articleIsPublished
));
int
articleCount
=
statisticQueryService
.
getBlogArticleCount
();
int
articleCount
=
statisticQueryService
.
getBlogArticleCount
();
...
@@ -580,7 +571,7 @@ public class ArticleQueryService {
...
@@ -580,7 +571,7 @@ public class ArticleQueryService {
* @throws ServiceException service exception
* @throws ServiceException service exception
*/
*/
public
List
<
JSONObject
>
getArticlesByTag
(
final
String
tagId
,
final
int
currentPageNum
,
final
int
pageSize
)
public
List
<
JSONObject
>
getArticlesByTag
(
final
String
tagId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
ServiceException
{
throws
ServiceException
{
try
{
try
{
JSONObject
result
=
tagArticleRepository
.
getByTagId
(
tagId
,
currentPageNum
,
pageSize
);
JSONObject
result
=
tagArticleRepository
.
getByTagId
(
tagId
,
currentPageNum
,
pageSize
);
final
JSONArray
tagArticleRelations
=
result
.
getJSONArray
(
Keys
.
RESULTS
);
final
JSONArray
tagArticleRelations
=
result
.
getJSONArray
(
Keys
.
RESULTS
);
...
@@ -601,7 +592,7 @@ public class ArticleQueryService {
...
@@ -601,7 +592,7 @@ public class ArticleQueryService {
final
List
<
JSONObject
>
ret
=
new
ArrayList
<
JSONObject
>();
final
List
<
JSONObject
>
ret
=
new
ArrayList
<
JSONObject
>();
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Keys
.
OBJECT_ID
,
FilterOperator
.
IN
,
articleIds
)).
setPageCount
(
1
).
index
(
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Keys
.
OBJECT_ID
,
FilterOperator
.
IN
,
articleIds
)).
setPageCount
(
1
).
index
(
Article
.
ARTICLE_PERMALINK
);
Article
.
ARTICLE_PERMALINK
);
result
=
articleRepository
.
get
(
query
);
result
=
articleRepository
.
get
(
query
);
final
JSONArray
articles
=
result
.
getJSONArray
(
Keys
.
RESULTS
);
final
JSONArray
articles
=
result
.
getJSONArray
(
Keys
.
RESULTS
);
...
@@ -639,7 +630,7 @@ public class ArticleQueryService {
...
@@ -639,7 +630,7 @@ public class ArticleQueryService {
* @throws ServiceException service exception
* @throws ServiceException service exception
*/
*/
public
List
<
JSONObject
>
getArticlesByArchiveDate
(
final
String
archiveDateId
,
final
int
currentPageNum
,
final
int
pageSize
)
public
List
<
JSONObject
>
getArticlesByArchiveDate
(
final
String
archiveDateId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
ServiceException
{
throws
ServiceException
{
try
{
try
{
JSONObject
result
=
archiveDateArticleRepository
.
getByArchiveDateId
(
archiveDateId
,
currentPageNum
,
pageSize
);
JSONObject
result
=
archiveDateArticleRepository
.
getByArchiveDateId
(
archiveDateId
,
currentPageNum
,
pageSize
);
...
@@ -661,7 +652,7 @@ public class ArticleQueryService {
...
@@ -661,7 +652,7 @@ public class ArticleQueryService {
final
List
<
JSONObject
>
ret
=
new
ArrayList
<
JSONObject
>();
final
List
<
JSONObject
>
ret
=
new
ArrayList
<
JSONObject
>();
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Keys
.
OBJECT_ID
,
FilterOperator
.
IN
,
articleIds
)).
setPageCount
(
1
).
index
(
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Keys
.
OBJECT_ID
,
FilterOperator
.
IN
,
articleIds
)).
setPageCount
(
1
).
index
(
Article
.
ARTICLE_PERMALINK
);
Article
.
ARTICLE_PERMALINK
);
result
=
articleRepository
.
get
(
query
);
result
=
articleRepository
.
get
(
query
);
final
JSONArray
articles
=
result
.
getJSONArray
(
Keys
.
RESULTS
);
final
JSONArray
articles
=
result
.
getJSONArray
(
Keys
.
RESULTS
);
...
@@ -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
{
...
@@ -727,9 +717,9 @@ public class ArticleQueryService {
...
@@ -727,9 +717,9 @@ public class ArticleQueryService {
* @throws ServiceException service exception
* @throws ServiceException service exception
*/
*/
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
*/
*/
...
@@ -919,7 +905,7 @@ public class ArticleQueryService {
...
@@ -919,7 +905,7 @@ public class ArticleQueryService {
* @throws ServiceException service exception
* @throws ServiceException service exception
*/
*/
public
List
<
JSONObject
>
getArticlesByAuthorEmail
(
final
String
authorEmail
,
final
int
currentPageNum
,
final
int
pageSize
)
public
List
<
JSONObject
>
getArticlesByAuthorEmail
(
final
String
authorEmail
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
ServiceException
{
throws
ServiceException
{
try
{
try
{
final
JSONObject
result
=
articleRepository
.
getByAuthorEmail
(
authorEmail
,
currentPageNum
,
pageSize
);
final
JSONObject
result
=
articleRepository
.
getByAuthorEmail
(
authorEmail
,
currentPageNum
,
pageSize
);
final
JSONArray
articles
=
result
.
getJSONArray
(
Keys
.
RESULTS
);
final
JSONArray
articles
=
result
.
getJSONArray
(
Keys
.
RESULTS
);
...
@@ -939,9 +925,9 @@ public class ArticleQueryService {
...
@@ -939,9 +925,9 @@ public class ArticleQueryService {
return
ret
;
return
ret
;
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
LOGGER
.
log
(
Level
.
ERROR
,
"Gets articles by author email failed[authorEmail="
+
authorEmail
+
", currentPageNum="
+
currentPageNum
+
", pageSize="
"Gets articles by author email failed[authorEmail="
+
authorEmail
+
", currentPageNum="
+
currentPageNum
+
", pageSize="
+
pageSize
+
"]"
,
+
pageSize
+
"]"
,
e
);
e
);
throw
new
ServiceException
(
e
);
throw
new
ServiceException
(
e
);
}
}
...
...
src/main/java/org/b3log/solo/service/CommentMgmtService.java
View file @
c9e1e51e
...
@@ -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
;
...
@@ -728,14 +728,14 @@ public class CommentMgmtService {
...
@@ -728,14 +728,14 @@ public class CommentMgmtService {
*/
*/
public
void
setCommentThumbnailURL
(
final
JSONObject
comment
)
throws
Exception
{
public
void
setCommentThumbnailURL
(
final
JSONObject
comment
)
throws
Exception
{
final
String
commentEmail
=
comment
.
getString
(
Comment
.
COMMENT_EMAIL
);
final
String
commentEmail
=
comment
.
getString
(
Comment
.
COMMENT_EMAIL
);
// 1. user avatar
// 1. user avatar
final
JSONObject
user
=
userRepository
.
getByEmail
(
commentEmail
);
final
JSONObject
user
=
userRepository
.
getByEmail
(
commentEmail
);
if
(
null
!=
user
)
{
if
(
null
!=
user
)
{
final
String
avatar
=
user
.
optString
(
UserExt
.
USER_AVATAR
);
final
String
avatar
=
user
.
optString
(
UserExt
.
USER_AVATAR
);
if
(!
Strings
.
isEmptyOrNull
(
avatar
))
{
if
(!
Strings
.
isEmptyOrNull
(
avatar
))
{
comment
.
put
(
Comment
.
COMMENT_THUMBNAIL_URL
,
avatar
);
comment
.
put
(
Comment
.
COMMENT_THUMBNAIL_URL
,
avatar
);
return
;
return
;
}
}
}
}
...
...
src/main/java/org/b3log/solo/service/InitService.java
View file @
c9e1e51e
...
@@ -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
);
...
...
src/main/java/org/b3log/solo/service/PageMgmtService.java
View file @
c9e1e51e
...
@@ -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 3
0, 2015
* @version 1.1.0.
8, Nov 2
0, 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
);
...
...
src/main/java/org/b3log/solo/service/PreferenceMgmtService.java
View file @
c9e1e51e
...
@@ -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
)));
...
...
src/main/java/org/b3log/solo/service/UpgradeService.java
View file @
c9e1e51e
...
@@ -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.1.0.
1
, Nov 20, 2015
* @version 1.1.0.
2
, Nov 20, 2015
* @since 1.2.0
* @since 1.2.0
*/
*/
@Service
@Service
...
@@ -126,7 +126,7 @@ public class UpgradeService {
...
@@ -126,7 +126,7 @@ public class UpgradeService {
return
;
return
;
}
}
final
String
currentVer
=
preference
.
getString
(
Preference
.
VERSION
);
final
String
currentVer
=
preference
.
getString
(
Option
.
ID_C_
VERSION
);
if
(
SoloServletListener
.
VERSION
.
equals
(
currentVer
))
{
if
(
SoloServletListener
.
VERSION
.
equals
(
currentVer
))
{
return
;
return
;
...
@@ -182,182 +182,182 @@ public class UpgradeService {
...
@@ -182,182 +182,182 @@ 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
String
adminEmail
=
preference
.
optString
(
Option
.
ID_C_
ADMIN_EMAIL
);
final
JSONObject
adminEmailOpt
=
new
JSONObject
();
final
JSONObject
adminEmailOpt
=
new
JSONObject
();
adminEmailOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ADMIN_EMAIL
);
adminEmailOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ADMIN_EMAIL
);
adminEmailOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
adminEmailOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
adminEmailOpt
.
put
(
Option
.
OPTION_VALUE
,
adminEmail
);
adminEmailOpt
.
put
(
Option
.
OPTION_VALUE
,
adminEmail
);
optionRepository
.
add
(
adminEmailOpt
);
optionRepository
.
add
(
adminEmailOpt
);
final
boolean
allowVisitDraftViaPermalink
=
preference
.
optBoolean
(
Preference
.
ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
final
boolean
allowVisitDraftViaPermalink
=
preference
.
optBoolean
(
Option
.
ID_C_
ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
final
JSONObject
allowVisitDraftViaPermalinkOpt
=
new
JSONObject
();
final
JSONObject
allowVisitDraftViaPermalinkOpt
=
new
JSONObject
();
allowVisitDraftViaPermalinkOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
allowVisitDraftViaPermalinkOpt
.
put
(
Option
.
OPTION_VALUE
,
Boolean
.
toString
(
allowVisitDraftViaPermalink
));
allowVisitDraftViaPermalinkOpt
.
put
(
Option
.
OPTION_VALUE
,
Boolean
.
toString
(
allowVisitDraftViaPermalink
));
optionRepository
.
add
(
allowVisitDraftViaPermalinkOpt
);
optionRepository
.
add
(
allowVisitDraftViaPermalinkOpt
);
final
boolean
commentable
=
preference
.
optBoolean
(
Preference
.
COMMENTABLE
);
final
boolean
commentable
=
preference
.
optBoolean
(
Option
.
ID_C_
COMMENTABLE
);
final
JSONObject
commentableOpt
=
new
JSONObject
();
final
JSONObject
commentableOpt
=
new
JSONObject
();
commentableOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_COMMENTABLE
);
commentableOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_COMMENTABLE
);
commentableOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
commentableOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
commentableOpt
.
put
(
Option
.
OPTION_VALUE
,
Boolean
.
toString
(
commentable
));
commentableOpt
.
put
(
Option
.
OPTION_VALUE
,
Boolean
.
toString
(
commentable
));
optionRepository
.
add
(
commentableOpt
);
optionRepository
.
add
(
commentableOpt
);
final
String
feedOutputMode
=
preference
.
optString
(
Preference
.
FEED_OUTPUT_MODE
);
final
String
feedOutputMode
=
preference
.
optString
(
Option
.
ID_C_
FEED_OUTPUT_MODE
);
final
JSONObject
feedOutputModeOpt
=
new
JSONObject
();
final
JSONObject
feedOutputModeOpt
=
new
JSONObject
();
feedOutputModeOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_FEED_OUTPUT_MODE
);
feedOutputModeOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_FEED_OUTPUT_MODE
);
feedOutputModeOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
feedOutputModeOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
feedOutputModeOpt
.
put
(
Option
.
OPTION_VALUE
,
feedOutputMode
);
feedOutputModeOpt
.
put
(
Option
.
OPTION_VALUE
,
feedOutputMode
);
optionRepository
.
add
(
feedOutputModeOpt
);
optionRepository
.
add
(
feedOutputModeOpt
);
final
int
feedOutputCnt
=
preference
.
optInt
(
Preference
.
FEED_OUTPUT_CNT
);
final
int
feedOutputCnt
=
preference
.
optInt
(
Option
.
ID_C_
FEED_OUTPUT_CNT
);
final
JSONObject
feedOutputCntOpt
=
new
JSONObject
();
final
JSONObject
feedOutputCntOpt
=
new
JSONObject
();
feedOutputCntOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_FEED_OUTPUT_CNT
);
feedOutputCntOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_FEED_OUTPUT_CNT
);
feedOutputCntOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
feedOutputCntOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
feedOutputCntOpt
.
put
(
Option
.
OPTION_VALUE
,
feedOutputCnt
);
feedOutputCntOpt
.
put
(
Option
.
OPTION_VALUE
,
feedOutputCnt
);
optionRepository
.
add
(
feedOutputCntOpt
);
optionRepository
.
add
(
feedOutputCntOpt
);
final
int
articleListDisplayCount
=
preference
.
optInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
articleListDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
JSONObject
articleListDisplayCountOpt
=
new
JSONObject
();
final
JSONObject
articleListDisplayCountOpt
=
new
JSONObject
();
articleListDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ARTICLE_LIST_DISPLAY_COUNT
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
articleListDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
articleListDisplayCount
);
articleListDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
articleListDisplayCount
);
optionRepository
.
add
(
articleListDisplayCountOpt
);
optionRepository
.
add
(
articleListDisplayCountOpt
);
final
int
relevantArticlesDisplayCount
=
preference
.
optInt
(
Preference
.
RELEVANT_ARTICLES_DISPLAY_CNT
);
final
int
relevantArticlesDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
RELEVANT_ARTICLES_DISPLAY_CNT
);
final
JSONObject
relevantArticlesDisplayCountOpt
=
new
JSONObject
();
final
JSONObject
relevantArticlesDisplayCountOpt
=
new
JSONObject
();
relevantArticlesDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_RELEVANT_ARTICLES_DISPLAY_CNT
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
relevantArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
relevantArticlesDisplayCount
);
relevantArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
relevantArticlesDisplayCount
);
optionRepository
.
add
(
relevantArticlesDisplayCountOpt
);
optionRepository
.
add
(
relevantArticlesDisplayCountOpt
);
final
int
articleListPaginationWindowSize
=
preference
.
optInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
int
articleListPaginationWindowSize
=
preference
.
optInt
(
Option
.
ID_C_
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
JSONObject
articleListPaginationWindowSizeOpt
=
new
JSONObject
();
final
JSONObject
articleListPaginationWindowSizeOpt
=
new
JSONObject
();
articleListPaginationWindowSizeOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
articleListPaginationWindowSizeOpt
.
put
(
Option
.
OPTION_VALUE
,
articleListPaginationWindowSize
);
articleListPaginationWindowSizeOpt
.
put
(
Option
.
OPTION_VALUE
,
articleListPaginationWindowSize
);
optionRepository
.
add
(
articleListPaginationWindowSizeOpt
);
optionRepository
.
add
(
articleListPaginationWindowSizeOpt
);
final
String
articleListStyle
=
preference
.
optString
(
Preference
.
ARTICLE_LIST_STYLE
);
final
String
articleListStyle
=
preference
.
optString
(
Option
.
ID_C_
ARTICLE_LIST_STYLE
);
final
JSONObject
articleListStyleOpt
=
new
JSONObject
();
final
JSONObject
articleListStyleOpt
=
new
JSONObject
();
articleListStyleOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ARTICLE_LIST_STYLE
);
articleListStyleOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ARTICLE_LIST_STYLE
);
articleListStyleOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
articleListStyleOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
articleListStyleOpt
.
put
(
Option
.
OPTION_VALUE
,
articleListStyle
);
articleListStyleOpt
.
put
(
Option
.
OPTION_VALUE
,
articleListStyle
);
optionRepository
.
add
(
articleListStyleOpt
);
optionRepository
.
add
(
articleListStyleOpt
);
final
String
blogSubtitle
=
preference
.
optString
(
Preference
.
BLOG_SUBTITLE
);
final
String
blogSubtitle
=
preference
.
optString
(
Option
.
ID_C_
BLOG_SUBTITLE
);
final
JSONObject
blogSubtitleOpt
=
new
JSONObject
();
final
JSONObject
blogSubtitleOpt
=
new
JSONObject
();
blogSubtitleOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BLOG_SUBTITLE
);
blogSubtitleOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BLOG_SUBTITLE
);
blogSubtitleOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
blogSubtitleOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
blogSubtitleOpt
.
put
(
Option
.
OPTION_VALUE
,
blogSubtitle
);
blogSubtitleOpt
.
put
(
Option
.
OPTION_VALUE
,
blogSubtitle
);
optionRepository
.
add
(
blogSubtitleOpt
);
optionRepository
.
add
(
blogSubtitleOpt
);
final
String
blogTitle
=
preference
.
optString
(
Preference
.
BLOG_TITLE
);
final
String
blogTitle
=
preference
.
optString
(
Option
.
ID_C_
BLOG_TITLE
);
final
JSONObject
blogTitleOpt
=
new
JSONObject
();
final
JSONObject
blogTitleOpt
=
new
JSONObject
();
blogTitleOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BLOG_TITLE
);
blogTitleOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BLOG_TITLE
);
blogTitleOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
blogTitleOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
blogTitleOpt
.
put
(
Option
.
OPTION_VALUE
,
blogTitle
);
blogTitleOpt
.
put
(
Option
.
OPTION_VALUE
,
blogTitle
);
optionRepository
.
add
(
blogTitleOpt
);
optionRepository
.
add
(
blogTitleOpt
);
final
boolean
enableArticleUpdateHint
=
preference
.
optBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
);
final
boolean
enableArticleUpdateHint
=
preference
.
optBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
);
final
JSONObject
enableArticleUpdateHintOpt
=
new
JSONObject
();
final
JSONObject
enableArticleUpdateHintOpt
=
new
JSONObject
();
enableArticleUpdateHintOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ENABLE_ARTICLE_UPDATE_HINT
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
enableArticleUpdateHintOpt
.
put
(
Option
.
OPTION_VALUE
,
Boolean
.
toString
(
enableArticleUpdateHint
));
enableArticleUpdateHintOpt
.
put
(
Option
.
OPTION_VALUE
,
Boolean
.
toString
(
enableArticleUpdateHint
));
optionRepository
.
add
(
enableArticleUpdateHintOpt
);
optionRepository
.
add
(
enableArticleUpdateHintOpt
);
final
int
externalRelevantArticlesDisplayCount
=
preference
.
optInt
(
Preference
.
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
);
final
int
externalRelevantArticlesDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
);
final
JSONObject
externalRelevantArticlesDisplayCountOpt
=
new
JSONObject
();
final
JSONObject
externalRelevantArticlesDisplayCountOpt
=
new
JSONObject
();
externalRelevantArticlesDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
externalRelevantArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
externalRelevantArticlesDisplayCount
);
externalRelevantArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
externalRelevantArticlesDisplayCount
);
optionRepository
.
add
(
externalRelevantArticlesDisplayCountOpt
);
optionRepository
.
add
(
externalRelevantArticlesDisplayCountOpt
);
final
String
htmlHead
=
preference
.
optString
(
Preference
.
HTML_HEAD
);
final
String
htmlHead
=
preference
.
optString
(
Option
.
ID_C_
HTML_HEAD
);
final
JSONObject
htmlHeadOpt
=
new
JSONObject
();
final
JSONObject
htmlHeadOpt
=
new
JSONObject
();
htmlHeadOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_HTML_HEAD
);
htmlHeadOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_HTML_HEAD
);
htmlHeadOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
htmlHeadOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
htmlHeadOpt
.
put
(
Option
.
OPTION_VALUE
,
htmlHead
);
htmlHeadOpt
.
put
(
Option
.
OPTION_VALUE
,
htmlHead
);
optionRepository
.
add
(
htmlHeadOpt
);
optionRepository
.
add
(
htmlHeadOpt
);
final
String
keyOfSolo
=
preference
.
optString
(
Preference
.
KEY_OF_SOLO
);
final
String
keyOfSolo
=
preference
.
optString
(
Option
.
ID_C_
KEY_OF_SOLO
);
final
JSONObject
keyOfSoloOpt
=
new
JSONObject
();
final
JSONObject
keyOfSoloOpt
=
new
JSONObject
();
keyOfSoloOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_KEY_OF_SOLO
);
keyOfSoloOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_KEY_OF_SOLO
);
keyOfSoloOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
keyOfSoloOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
keyOfSoloOpt
.
put
(
Option
.
OPTION_VALUE
,
keyOfSolo
);
keyOfSoloOpt
.
put
(
Option
.
OPTION_VALUE
,
keyOfSolo
);
optionRepository
.
add
(
keyOfSoloOpt
);
optionRepository
.
add
(
keyOfSoloOpt
);
final
String
localeString
=
preference
.
optString
(
Preference
.
LOCALE_STRING
);
final
String
localeString
=
preference
.
optString
(
Option
.
ID_C_
LOCALE_STRING
);
final
JSONObject
localeStringOpt
=
new
JSONObject
();
final
JSONObject
localeStringOpt
=
new
JSONObject
();
localeStringOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_LOCALE_STRING
);
localeStringOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_LOCALE_STRING
);
localeStringOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
localeStringOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
localeStringOpt
.
put
(
Option
.
OPTION_VALUE
,
localeString
);
localeStringOpt
.
put
(
Option
.
OPTION_VALUE
,
localeString
);
optionRepository
.
add
(
localeStringOpt
);
optionRepository
.
add
(
localeStringOpt
);
final
String
metaDescription
=
preference
.
optString
(
Preference
.
META_DESCRIPTION
);
final
String
metaDescription
=
preference
.
optString
(
Option
.
ID_C_
META_DESCRIPTION
);
final
JSONObject
metaDescriptionOpt
=
new
JSONObject
();
final
JSONObject
metaDescriptionOpt
=
new
JSONObject
();
metaDescriptionOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_META_DESCRIPTION
);
metaDescriptionOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_META_DESCRIPTION
);
metaDescriptionOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
metaDescriptionOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
metaDescriptionOpt
.
put
(
Option
.
OPTION_VALUE
,
metaDescription
);
metaDescriptionOpt
.
put
(
Option
.
OPTION_VALUE
,
metaDescription
);
optionRepository
.
add
(
metaDescriptionOpt
);
optionRepository
.
add
(
metaDescriptionOpt
);
final
String
metaKeywords
=
preference
.
optString
(
Preference
.
META_KEYWORDS
);
final
String
metaKeywords
=
preference
.
optString
(
Option
.
ID_C_
META_KEYWORDS
);
final
JSONObject
metaKeywordsOpt
=
new
JSONObject
();
final
JSONObject
metaKeywordsOpt
=
new
JSONObject
();
metaKeywordsOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_META_KEYWORDS
);
metaKeywordsOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_META_KEYWORDS
);
metaKeywordsOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
metaKeywordsOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
metaKeywordsOpt
.
put
(
Option
.
OPTION_VALUE
,
metaKeywords
);
metaKeywordsOpt
.
put
(
Option
.
OPTION_VALUE
,
metaKeywords
);
optionRepository
.
add
(
metaKeywordsOpt
);
optionRepository
.
add
(
metaKeywordsOpt
);
final
int
mostCommentArticleDisplayCount
=
preference
.
optInt
(
Preference
.
MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
final
int
mostCommentArticleDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
final
JSONObject
mostCommentArticleDisplayCountOpt
=
new
JSONObject
();
final
JSONObject
mostCommentArticleDisplayCountOpt
=
new
JSONObject
();
mostCommentArticleDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
mostCommentArticleDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
mostCommentArticleDisplayCount
);
mostCommentArticleDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
mostCommentArticleDisplayCount
);
optionRepository
.
add
(
mostCommentArticleDisplayCountOpt
);
optionRepository
.
add
(
mostCommentArticleDisplayCountOpt
);
final
int
mostUsedTagDisplayCount
=
preference
.
optInt
(
Preference
.
MOST_USED_TAG_DISPLAY_CNT
);
final
int
mostUsedTagDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
MOST_USED_TAG_DISPLAY_CNT
);
final
JSONObject
mostUsedTagDisplayCountOpt
=
new
JSONObject
();
final
JSONObject
mostUsedTagDisplayCountOpt
=
new
JSONObject
();
mostUsedTagDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_MOST_USED_TAG_DISPLAY_CNT
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
mostUsedTagDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
mostUsedTagDisplayCount
);
mostUsedTagDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
mostUsedTagDisplayCount
);
optionRepository
.
add
(
mostUsedTagDisplayCountOpt
);
optionRepository
.
add
(
mostUsedTagDisplayCountOpt
);
final
int
mostViewArticleDisplayCount
=
preference
.
optInt
(
Preference
.
MOST_VIEW_ARTICLE_DISPLAY_CNT
);
final
int
mostViewArticleDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
MOST_VIEW_ARTICLE_DISPLAY_CNT
);
final
JSONObject
mostViewArticleDisplayCountOpt
=
new
JSONObject
();
final
JSONObject
mostViewArticleDisplayCountOpt
=
new
JSONObject
();
mostViewArticleDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
mostViewArticleDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
mostViewArticleDisplayCount
);
mostViewArticleDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
mostViewArticleDisplayCount
);
optionRepository
.
add
(
mostViewArticleDisplayCountOpt
);
optionRepository
.
add
(
mostViewArticleDisplayCountOpt
);
final
String
noticeBoard
=
preference
.
optString
(
Preference
.
NOTICE_BOARD
);
final
String
noticeBoard
=
preference
.
optString
(
Option
.
ID_C_
NOTICE_BOARD
);
final
JSONObject
noticeBoardOpt
=
new
JSONObject
();
final
JSONObject
noticeBoardOpt
=
new
JSONObject
();
noticeBoardOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_NOTICE_BOARD
);
noticeBoardOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_NOTICE_BOARD
);
noticeBoardOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
noticeBoardOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
noticeBoardOpt
.
put
(
Option
.
OPTION_VALUE
,
noticeBoard
);
noticeBoardOpt
.
put
(
Option
.
OPTION_VALUE
,
noticeBoard
);
optionRepository
.
add
(
noticeBoardOpt
);
optionRepository
.
add
(
noticeBoardOpt
);
final
int
randomArticlesDisplayCount
=
preference
.
optInt
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
);
final
int
randomArticlesDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
RANDOM_ARTICLES_DISPLAY_CNT
);
final
JSONObject
randomArticlesDisplayCountOpt
=
new
JSONObject
();
final
JSONObject
randomArticlesDisplayCountOpt
=
new
JSONObject
();
randomArticlesDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_RANDOM_ARTICLES_DISPLAY_CNT
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
randomArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
randomArticlesDisplayCount
);
randomArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
randomArticlesDisplayCount
);
optionRepository
.
add
(
randomArticlesDisplayCountOpt
);
optionRepository
.
add
(
randomArticlesDisplayCountOpt
);
final
int
recentCommentDisplayCount
=
preference
.
optInt
(
Preference
.
RECENT_COMMENT_DISPLAY_CNT
);
final
int
recentCommentDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
RECENT_COMMENT_DISPLAY_CNT
);
final
JSONObject
recentCommentDisplayCountOpt
=
new
JSONObject
();
final
JSONObject
recentCommentDisplayCountOpt
=
new
JSONObject
();
recentCommentDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_RECENT_COMMENT_DISPLAY_CNT
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
recentCommentDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
recentCommentDisplayCount
);
recentCommentDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
recentCommentDisplayCount
);
optionRepository
.
add
(
recentCommentDisplayCountOpt
);
optionRepository
.
add
(
recentCommentDisplayCountOpt
);
final
int
recentArticleDisplayCount
=
preference
.
optInt
(
Preference
.
RECENT_ARTICLE_DISPLAY_CNT
);
final
int
recentArticleDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
RECENT_ARTICLE_DISPLAY_CNT
);
final
JSONObject
recentArticleDisplayCountOpt
=
new
JSONObject
();
final
JSONObject
recentArticleDisplayCountOpt
=
new
JSONObject
();
recentArticleDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_RECENT_ARTICLE_DISPLAY_CNT
);
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_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
recentArticleDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
recentArticleDisplayCount
);
recentArticleDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
recentArticleDisplayCount
);
optionRepository
.
add
(
recentArticleDisplayCountOpt
);
optionRepository
.
add
(
recentArticleDisplayCountOpt
);
final
String
signs
=
preference
.
optString
(
Preference
.
SIGNS
);
final
String
signs
=
preference
.
optString
(
Option
.
ID_C_
SIGNS
);
final
JSONObject
signsOpt
=
new
JSONObject
();
final
JSONObject
signsOpt
=
new
JSONObject
();
signsOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_SIGNS
);
signsOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_SIGNS
);
signsOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
signsOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
...
@@ -385,14 +385,14 @@ public class UpgradeService {
...
@@ -385,14 +385,14 @@ public class UpgradeService {
skinsOpt
.
put
(
Option
.
OPTION_VALUE
,
skins
);
skinsOpt
.
put
(
Option
.
OPTION_VALUE
,
skins
);
optionRepository
.
add
(
skinsOpt
);
optionRepository
.
add
(
skinsOpt
);
final
String
timeZoneId
=
preference
.
optString
(
Preference
.
TIME_ZONE_ID
);
final
String
timeZoneId
=
preference
.
optString
(
Option
.
ID_C_
TIME_ZONE_ID
);
final
JSONObject
timeZoneIdOpt
=
new
JSONObject
();
final
JSONObject
timeZoneIdOpt
=
new
JSONObject
();
timeZoneIdOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_TIME_ZONE_ID
);
timeZoneIdOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_TIME_ZONE_ID
);
timeZoneIdOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
timeZoneIdOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
timeZoneIdOpt
.
put
(
Option
.
OPTION_VALUE
,
timeZoneId
);
timeZoneIdOpt
.
put
(
Option
.
OPTION_VALUE
,
timeZoneId
);
optionRepository
.
add
(
timeZoneIdOpt
);
optionRepository
.
add
(
timeZoneIdOpt
);
final
String
editorType
=
preference
.
optString
(
Preference
.
EDITOR_TYPE
);
final
String
editorType
=
preference
.
optString
(
Option
.
ID_C_
EDITOR_TYPE
);
final
JSONObject
editorTypeOpt
=
new
JSONObject
();
final
JSONObject
editorTypeOpt
=
new
JSONObject
();
editorTypeOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_EDITOR_TYPE
);
editorTypeOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_EDITOR_TYPE
);
editorTypeOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
editorTypeOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
...
@@ -405,7 +405,7 @@ public class UpgradeService {
...
@@ -405,7 +405,7 @@ public class UpgradeService {
footerContentOpt
.
put
(
Option
.
OPTION_VALUE
,
Preference
.
Default
.
DEFAULT_FOOTER_CONTENT
);
footerContentOpt
.
put
(
Option
.
OPTION_VALUE
,
Preference
.
Default
.
DEFAULT_FOOTER_CONTENT
);
optionRepository
.
add
(
footerContentOpt
);
optionRepository
.
add
(
footerContentOpt
);
final
JSONObject
replyNotificationTemplate
=
preferenceRepository
.
get
(
Preference
.
REPLY_NOTIFICATION_TEMPLATE
);
final
JSONObject
replyNotificationTemplate
=
preferenceRepository
.
get
(
"replyNotificationTemplate"
);
final
String
body
=
replyNotificationTemplate
.
optString
(
"body"
);
final
String
body
=
replyNotificationTemplate
.
optString
(
"body"
);
final
JSONObject
bodyOpt
=
new
JSONObject
();
final
JSONObject
bodyOpt
=
new
JSONObject
();
...
@@ -433,7 +433,7 @@ public class UpgradeService {
...
@@ -433,7 +433,7 @@ public class UpgradeService {
allowRegisterOpt
.
put
(
Option
.
OPTION_VALUE
,
Preference
.
Default
.
DEFAULT_ALLOW_REGISTER
);
allowRegisterOpt
.
put
(
Option
.
OPTION_VALUE
,
Preference
.
Default
.
DEFAULT_ALLOW_REGISTER
);
optionRepository
.
add
(
allowRegisterOpt
);
optionRepository
.
add
(
allowRegisterOpt
);
preference
.
put
(
Preference
.
VERSION
,
TO_VER
);
preference
.
put
(
Option
.
ID_C_
VERSION
,
TO_VER
);
preferenceRepository
.
update
(
Preference
.
PREFERENCE
,
preference
);
preferenceRepository
.
update
(
Preference
.
PREFERENCE
,
preference
);
transaction
.
commit
();
transaction
.
commit
();
...
@@ -535,7 +535,7 @@ public class UpgradeService {
...
@@ -535,7 +535,7 @@ public class UpgradeService {
* @throws IOException IOException
* @throws IOException IOException
*/
*/
private
void
notifyUserByEmail
()
throws
ServiceException
,
JSONException
,
IOException
{
private
void
notifyUserByEmail
()
throws
ServiceException
,
JSONException
,
IOException
{
final
String
adminEmail
=
preferenceQueryService
.
getPreference
().
getString
(
Preference
.
ADMIN_EMAIL
);
final
String
adminEmail
=
preferenceQueryService
.
getPreference
().
getString
(
Option
.
ID_C_
ADMIN_EMAIL
);
final
MailService
.
Message
message
=
new
MailService
.
Message
();
final
MailService
.
Message
message
=
new
MailService
.
Message
();
message
.
setFrom
(
adminEmail
);
message
.
setFrom
(
adminEmail
);
...
...
src/test/java/org/b3log/solo/service/PreferenceMgmtServiceTestCase.java
View file @
c9e1e51e
...
@@ -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"
);
}
}
}
}
src/test/java/org/b3log/solo/service/PreferenceQueryServiceTestCase.java
View file @
c9e1e51e
...
@@ -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,14 +27,14 @@ import org.testng.annotations.Test;
...
@@ -26,14 +27,14 @@ 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
{
/**
/**
* Init.
* Init.
*
*
* @throws Exception exception
* @throws Exception exception
*/
*/
@Test
@Test
...
@@ -53,32 +54,30 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase {
...
@@ -53,32 +54,30 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase {
/**
/**
* Get Preference.
* Get Preference.
*
*
* @throws Exception exception
* @throws Exception exception
*/
*/
@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
);
}
}
/**
/**
* Get Reply Notification Template.
* Get Reply Notification Template.
*
*
* @throws Exception exception
* @throws Exception exception
*/
*/
@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
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment