Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
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-1
Commits
0fa0d09f
Unverified
Commit
0fa0d09f
authored
Apr 18, 2019
by
Van
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/3.6.0-dev' into 3.6.0-dev
parents
5948b363
4ff35443
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
157 additions
and
441 deletions
+157
-441
src/main/java/org/b3log/solo/SoloServletListener.java
src/main/java/org/b3log/solo/SoloServletListener.java
+1
-3
src/main/java/org/b3log/solo/model/Page.java
src/main/java/org/b3log/solo/model/Page.java
+3
-1
src/main/java/org/b3log/solo/processor/CommentProcessor.java
src/main/java/org/b3log/solo/processor/CommentProcessor.java
+5
-99
src/main/java/org/b3log/solo/processor/console/CommentConsole.java
...java/org/b3log/solo/processor/console/CommentConsole.java
+1
-87
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
+1
-1
src/main/java/org/b3log/solo/service/CommentMgmtService.java
src/main/java/org/b3log/solo/service/CommentMgmtService.java
+4
-192
src/main/java/org/b3log/solo/upgrade/V340_350.java
src/main/java/org/b3log/solo/upgrade/V340_350.java
+2
-2
src/main/java/org/b3log/solo/upgrade/V350_360.java
src/main/java/org/b3log/solo/upgrade/V350_360.java
+139
-0
src/test/java/org/b3log/solo/service/CommentMgmtServiceTestCase.java
...va/org/b3log/solo/service/CommentMgmtServiceTestCase.java
+1
-56
No files found.
src/main/java/org/b3log/solo/SoloServletListener.java
View file @
0fa0d09f
...
...
@@ -58,7 +58,7 @@ import javax.servlet.http.HttpSessionEvent;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</a>
* @version 1.11.0.1
4, Mar 31
, 2019
* @version 1.11.0.1
5, Apr 18
, 2019
* @since 0.3.1
*/
public
final
class
SoloServletListener
extends
AbstractServletListener
{
...
...
@@ -361,11 +361,9 @@ public final class SoloServletListener extends AbstractServletListener {
DispatcherServlet
.
get
(
"/console/categories/{page}/{pageSize}/{windowSize}"
,
categoryConsole:
:
getCategories
);
final
CommentConsole
commentConsole
=
beanManager
.
getReference
(
CommentConsole
.
class
);
DispatcherServlet
.
delete
(
"/console/page/comment/{id}"
,
commentConsole:
:
removePageComment
);
DispatcherServlet
.
delete
(
"/console/article/comment/{id}"
,
commentConsole:
:
removeArticleComment
);
DispatcherServlet
.
get
(
"/console/comments/{page}/{pageSize}/{windowSize}"
,
commentConsole:
:
getComments
);
DispatcherServlet
.
get
(
"/console/comments/article/{id}"
,
commentConsole:
:
getArticleComments
);
DispatcherServlet
.
get
(
"/console/comments/page/{id}"
,
commentConsole:
:
getPageComments
);
final
LinkConsole
linkConsole
=
beanManager
.
getReference
(
LinkConsole
.
class
);
DispatcherServlet
.
delete
(
"/console/link/{id}"
,
linkConsole:
:
removeLink
);
...
...
src/main/java/org/b3log/solo/model/Page.java
View file @
0fa0d09f
...
...
@@ -21,7 +21,7 @@ package org.b3log.solo.model;
* This class defines all page model relevant keys.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
1, Feb 6
, 2019
* @version 1.1.0.
2, Apr 18
, 2019
* @since 0.3.1
*/
public
final
class
Page
{
...
...
@@ -82,6 +82,8 @@ public final class Page {
* A normal customized page.
* </ul>
* </p>
* <p>
* "page" 类型已经废除 https://github.com/b3log/solo/issues/12764
*/
public
static
final
String
PAGE_TYPE
=
"pageType"
;
...
...
src/main/java/org/b3log/solo/processor/CommentProcessor.java
View file @
0fa0d09f
...
...
@@ -29,12 +29,14 @@ import org.b3log.latke.servlet.RequestContext;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.JsonRenderer
;
import
org.b3log.solo.model.*
;
import
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.service.CommentMgmtService
;
import
org.b3log.solo.service.OptionQueryService
;
import
org.b3log.solo.service.UserMgmtService
;
import
org.b3log.solo.service.UserQueryService
;
import
org.b3log.solo.util.Emotions
;
import
org.b3log.solo.util.Skins
;
import
org.b3log.solo.util.Solos
;
import
org.json.JSONObject
;
...
...
@@ -48,7 +50,7 @@ import java.util.Map;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/armstrong">ArmstrongCN</a>
* @version 1.
3.3.7, Mar 17
, 2019
* @version 1.
4.0.0, Apr 18
, 2019
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -89,102 +91,6 @@ public class CommentProcessor {
@Inject
private
OptionQueryService
optionQueryService
;
/**
* Adds a comment to a page.
*
* <p>
* Request json:
* <pre>
* {
* "captcha": "",
* "oId": pageId,
* "commentName": "",
* "commentURL": "",
* "commentContent": "",
* "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply
* }
* </pre>
* </p>
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "oId": generatedCommentId,
* "sc": "COMMENT_PAGE_SUCC"
* "commentDate": "", // yyyy/MM/dd HH:mm:ss
* "commentSharpURL": "",
* "commentThumbnailURL": "",
* "commentOriginalCommentName": "" // if exists this key, the comment is an reply
* }
* </pre>
* </p>
*
* @param context the specified context
*/
@RequestProcessing
(
value
=
"/page/comments"
,
method
=
HttpMethod
.
POST
)
public
void
addPageComment
(
final
RequestContext
context
)
{
final
JSONObject
requestJSONObject
=
context
.
requestJSON
();
requestJSONObject
.
put
(
Common
.
TYPE
,
Page
.
PAGE
);
fillCommenter
(
requestJSONObject
,
context
);
final
JSONObject
jsonObject
=
commentMgmtService
.
checkAddCommentRequest
(
requestJSONObject
);
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
renderer
.
setJSONObject
(
jsonObject
);
if
(!
jsonObject
.
optBoolean
(
Keys
.
STATUS_CODE
))
{
LOGGER
.
log
(
Level
.
WARN
,
"Can't add comment[msg={0}]"
,
jsonObject
.
optString
(
Keys
.
MSG
));
return
;
}
if
(!
Solos
.
isLoggedIn
(
context
))
{
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
false
);
jsonObject
.
put
(
Keys
.
MSG
,
"Need login"
);
return
;
}
try
{
final
JSONObject
addResult
=
commentMgmtService
.
addPageComment
(
requestJSONObject
);
final
Map
<
String
,
Object
>
dataModel
=
new
HashMap
<>();
dataModel
.
put
(
Comment
.
COMMENT
,
addResult
);
final
JSONObject
page
=
addResult
.
optJSONObject
(
Page
.
PAGE
);
page
.
put
(
Common
.
COMMENTABLE
,
addResult
.
opt
(
Common
.
COMMENTABLE
));
page
.
put
(
Common
.
PERMALINK
,
addResult
.
opt
(
Common
.
PERMALINK
));
dataModel
.
put
(
Article
.
ARTICLE
,
page
);
// 添加评论优化 https://github.com/b3log/solo/issues/12246
try
{
final
String
skinDirName
=
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
);
final
Template
template
=
Skins
.
getSkinTemplate
(
context
,
"common-comment.ftl"
);
final
JSONObject
preference
=
optionQueryService
.
getPreference
();
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
skinDirName
,
dataModel
);
Keys
.
fillServer
(
dataModel
);
final
StringWriter
stringWriter
=
new
StringWriter
();
template
.
process
(
dataModel
,
stringWriter
);
stringWriter
.
close
();
String
cmtTpl
=
stringWriter
.
toString
();
cmtTpl
=
Emotions
.
convert
(
cmtTpl
);
addResult
.
put
(
"cmtTpl"
,
cmtTpl
);
}
catch
(
final
Exception
e
)
{
// 1.9.0 向后兼容
}
addResult
.
put
(
Keys
.
STATUS_CODE
,
true
);
renderer
.
setJSONObject
(
addResult
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Can not add comment on page"
,
e
);
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
false
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"addFailLabel"
));
}
}
/**
* Adds a comment to an article.
*
...
...
src/main/java/org/b3log/solo/processor/console/CommentConsole.java
View file @
0fa0d09f
...
...
@@ -39,7 +39,7 @@ import java.util.List;
* Comment console request processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
0.0.5, Dec 11, 2018
* @version 1.
1.0.0, Apr 18, 2019
* @since 0.4.0
*/
@RequestProcessor
...
...
@@ -69,48 +69,6 @@ public class CommentConsole {
@Inject
private
LangPropsService
langPropsService
;
/**
* Removes a comment of an article by the specified request.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "msg": ""
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
public
void
removePageComment
(
final
RequestContext
context
)
{
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
try
{
final
String
commentId
=
context
.
pathVar
(
"id"
);
final
JSONObject
currentUser
=
Solos
.
getCurrentUser
(
context
.
getRequest
(),
context
.
getResponse
());
if
(!
commentQueryService
.
canAccessComment
(
commentId
,
currentUser
))
{
ret
.
put
(
Keys
.
STATUS_CODE
,
false
);
ret
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"forbiddenLabel"
));
return
;
}
commentMgmtService
.
removePageComment
(
commentId
);
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
ret
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"removeSuccLabel"
));
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
ret
.
put
(
Keys
.
STATUS_CODE
,
false
);
ret
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"removeFailLabel"
));
}
}
/**
* Removes a comment of an article by the specified request.
* <p>
...
...
@@ -251,48 +209,4 @@ public class CommentConsole {
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"getFailLabel"
));
}
}
/**
* Gets comments of a page specified by the article id for administrator.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "comments": [{
* "oId": "",
* "commentName": "",
* "thumbnailUrl": "",
* "commentURL": "",
* "commentContent": "",
* "commentTime": long,
* "commentSharpURL": "",
* "isReply": boolean
* }, ....]
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
public
void
getPageComments
(
final
RequestContext
context
)
{
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
try
{
final
String
pageId
=
context
.
pathVar
(
"id"
);
final
List
<
JSONObject
>
comments
=
commentQueryService
.
getComments
(
pageId
);
ret
.
put
(
Comment
.
COMMENTS
,
comments
);
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
final
JSONObject
jsonObject
=
new
JSONObject
().
put
(
Keys
.
STATUS_CODE
,
false
);
renderer
.
setJSONObject
(
jsonObject
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"getFailLabel"
));
}
}
}
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
View file @
0fa0d09f
...
...
@@ -346,7 +346,7 @@ public class ArticleMgmtService {
* "articleTags": "tag1,tag2,tag3",
* "articleStatus": int, // 0: published, 1: draft
* "articlePermalink": "", // optional
* "postToCommunity": boolean, // optional
, default is true
* "postToCommunity": boolean, // optional
* "articleSignId": "" // optional, default is "0",
* "articleCommentable": boolean,
* "articleViewPwd": "",
...
...
src/main/java/org/b3log/solo/service/CommentMgmtService.java
View file @
0fa0d09f
This diff is collapsed.
Click to expand it.
src/main/java/org/b3log/solo/upgrade/V340_350.java
View file @
0fa0d09f
...
...
@@ -27,7 +27,7 @@ import org.b3log.solo.repository.OptionRepository;
import
org.json.JSONObject
;
/**
* Upgrade script from v3.
3.0 to v3.4
.0.
* Upgrade script from v3.
4.0 to v3.5
.0.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1, Mar 31, 2019
...
...
@@ -41,7 +41,7 @@ public final class V340_350 {
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
V340_350
.
class
);
/**
* Performs upgrade from v3.
3.0 to v3.4
.0.
* Performs upgrade from v3.
4.0 to v3.5
.0.
*
* @throws Exception upgrade fails
*/
...
...
src/main/java/org/b3log/solo/upgrade/V350_360.java
0 → 100644
View file @
0fa0d09f
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-present, b3log.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
upgrade
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.BeanManager
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.FilterOperator
;
import
org.b3log.latke.repository.PropertyFilter
;
import
org.b3log.latke.repository.Query
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.solo.model.*
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.b3log.solo.repository.OptionRepository
;
import
org.b3log.solo.repository.PageRepository
;
import
org.b3log.solo.repository.UserRepository
;
import
org.b3log.solo.service.ArticleMgmtService
;
import
org.json.JSONObject
;
import
java.util.List
;
/**
* Upgrade script from v3.5.0 to v3.6.0.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Apr 18, 2019
* @since 3.6.0
*/
public
final
class
V350_360
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
V350_360
.
class
);
/**
* Performs upgrade from v3.5.0 to v3.6.0.
*
* @throws Exception upgrade fails
*/
public
static
void
perform
()
throws
Exception
{
final
String
fromVer
=
"3.5.0"
;
final
String
toVer
=
"3.6.0"
;
LOGGER
.
log
(
Level
.
INFO
,
"Upgrading from version ["
+
fromVer
+
"] to version ["
+
toVer
+
"]...."
);
final
BeanManager
beanManager
=
BeanManager
.
getInstance
();
final
OptionRepository
optionRepository
=
beanManager
.
getReference
(
OptionRepository
.
class
);
try
{
convertPagesToArticles
();
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
final
JSONObject
versionOpt
=
optionRepository
.
get
(
Option
.
ID_C_VERSION
);
versionOpt
.
put
(
Option
.
OPTION_VALUE
,
toVer
);
optionRepository
.
update
(
Option
.
ID_C_VERSION
,
versionOpt
);
transaction
.
commit
();
LOGGER
.
log
(
Level
.
INFO
,
"Upgraded from version ["
+
fromVer
+
"] to version ["
+
toVer
+
"] successfully"
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Upgrade failed!"
,
e
);
throw
new
Exception
(
"Upgrade failed from version ["
+
fromVer
+
"] to version ["
+
toVer
+
"]"
);
}
}
/**
* 去掉自定义页面 https://github.com/b3log/solo/issues/12764
*/
private
static
void
convertPagesToArticles
()
throws
Exception
{
final
BeanManager
beanManager
=
BeanManager
.
getInstance
();
final
PageRepository
pageRepository
=
beanManager
.
getReference
(
PageRepository
.
class
);
final
CommentRepository
commentRepository
=
beanManager
.
getReference
(
CommentRepository
.
class
);
final
ArticleMgmtService
articleMgmtService
=
beanManager
.
getReference
(
ArticleMgmtService
.
class
);
final
UserRepository
userRepository
=
beanManager
.
getReference
(
UserRepository
.
class
);
final
JSONObject
admin
=
userRepository
.
getAdmin
();
final
List
<
JSONObject
>
pages
=
pageRepository
.
getList
(
new
Query
().
setFilter
(
new
PropertyFilter
(
Page
.
PAGE_TYPE
,
FilterOperator
.
EQUAL
,
Page
.
PAGE
)));
for
(
final
JSONObject
page
:
pages
)
{
final
String
title
=
page
.
optString
(
Page
.
PAGE_TITLE
);
final
String
content
=
page
.
optString
(
Page
.
PAGE_CONTENT
);
final
int
commentCnt
=
page
.
optInt
(
Page
.
PAGE_COMMENT_COUNT
);
final
String
permalink
=
page
.
optString
(
Page
.
PAGE_PERMALINK
);
final
boolean
commentable
=
page
.
optBoolean
(
Page
.
PAGE_COMMENTABLE
);
final
JSONObject
article
=
new
JSONObject
();
article
.
put
(
Article
.
ARTICLE_AUTHOR_ID
,
admin
.
optString
(
Keys
.
OBJECT_ID
));
article
.
put
(
Article
.
ARTICLE_TITLE
,
title
);
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
Article
.
getAbstractText
(
content
));
article
.
put
(
Article
.
ARTICLE_COMMENT_COUNT
,
commentCnt
);
if
(
"/my-github-repos"
.
equals
(
permalink
))
{
article
.
put
(
Article
.
ARTICLE_TAGS_REF
,
"开源,GitHub"
);
}
article
.
put
(
Article
.
ARTICLE_PERMALINK
,
permalink
);
article
.
put
(
Article
.
ARTICLE_COMMENTABLE
,
commentable
);
article
.
put
(
Article
.
ARTICLE_CONTENT
,
content
);
article
.
put
(
Article
.
ARTICLE_VIEW_PWD
,
""
);
article
.
put
(
Article
.
ARTICLE_STATUS
,
Article
.
ARTICLE_STATUS_C_PUBLISHED
);
article
.
put
(
Common
.
POST_TO_COMMUNITY
,
false
);
final
JSONObject
addArticleReq
=
new
JSONObject
();
addArticleReq
.
put
(
Article
.
ARTICLE
,
article
);
final
String
articleId
=
articleMgmtService
.
addArticle
(
addArticleReq
);
final
String
pageId
=
page
.
optString
(
Keys
.
OBJECT_ID
);
final
List
<
JSONObject
>
comments
=
commentRepository
.
getList
(
new
Query
().
setFilter
(
new
PropertyFilter
(
Comment
.
COMMENT_ON_ID
,
FilterOperator
.
EQUAL
,
pageId
)));
final
Transaction
transaction
=
pageRepository
.
beginTransaction
();
for
(
final
JSONObject
comment
:
comments
)
{
comment
.
put
(
Comment
.
COMMENT_ON_ID
,
articleId
);
comment
.
put
(
Comment
.
COMMENT_ON_TYPE
,
Article
.
ARTICLE
);
final
String
commentId
=
comment
.
optString
(
Keys
.
OBJECT_ID
);
commentRepository
.
update
(
commentId
,
comment
);
}
page
.
put
(
Page
.
PAGE_TYPE
,
"link"
);
pageRepository
.
update
(
pageId
,
page
);
transaction
.
commit
();
}
}
}
src/test/java/org/b3log/solo/service/CommentMgmtServiceTestCase.java
View file @
0fa0d09f
...
...
@@ -18,12 +18,10 @@
package
org
.
b3log
.
solo
.
service
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.util.Solos
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
...
...
@@ -34,7 +32,7 @@ import java.util.List;
* {@link CommentMgmtService} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
3, Sep 16, 2018
* @version 1.0.0.
4, Apr 18, 2019
*/
@Test
(
suiteName
=
"service"
)
public
class
CommentMgmtServiceTestCase
extends
AbstractTestCase
{
...
...
@@ -91,59 +89,6 @@ public class CommentMgmtServiceTestCase extends AbstractTestCase {
Assert
.
assertEquals
(
result
.
getJSONArray
(
Comment
.
COMMENTS
).
length
(),
2
);
}
/**
* Add Page Comment.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"addArticleComment"
)
public
void
addPageComment
()
throws
Exception
{
addPage
();
final
PageQueryService
pageQueryService
=
getPageQueryService
();
final
JSONObject
paginationRequest
=
Solos
.
buildPaginationRequest
(
"1/10/20"
);
JSONObject
result
=
pageQueryService
.
getPages
(
paginationRequest
);
Assert
.
assertNotNull
(
result
);
Assert
.
assertEquals
(
result
.
getJSONArray
(
Page
.
PAGES
).
length
(),
1
);
final
JSONArray
pages
=
result
.
getJSONArray
(
Page
.
PAGES
);
final
CommentQueryService
commentQueryService
=
getCommentQueryService
();
result
=
commentQueryService
.
getComments
(
paginationRequest
);
Assert
.
assertNotNull
(
result
);
Assert
.
assertEquals
(
result
.
getJSONArray
(
Comment
.
COMMENTS
).
length
(),
2
);
// 2 article comments
final
CommentMgmtService
commentMgmtService
=
getCommentMgmtService
();
final
JSONObject
requestJSONObject
=
new
JSONObject
();
final
String
pageId
=
pages
.
getJSONObject
(
0
).
getString
(
Keys
.
OBJECT_ID
);
requestJSONObject
.
put
(
Keys
.
OBJECT_ID
,
pageId
);
requestJSONObject
.
put
(
Comment
.
COMMENT_NAME
,
"Solo"
);
requestJSONObject
.
put
(
Comment
.
COMMENT_URL
,
"comment URL"
);
requestJSONObject
.
put
(
Comment
.
COMMENT_CONTENT
,
"comment content"
);
final
JSONObject
addResult
=
commentMgmtService
.
addPageComment
(
requestJSONObject
);
Assert
.
assertNotNull
(
addResult
);
Assert
.
assertNotNull
(
addResult
.
getString
(
Keys
.
OBJECT_ID
));
Assert
.
assertNotNull
(
addResult
.
getString
(
Comment
.
COMMENT_T_DATE
));
Assert
.
assertNotNull
(
addResult
.
getString
(
Comment
.
COMMENT_THUMBNAIL_URL
));
Assert
.
assertNotNull
(
addResult
.
getString
(
Comment
.
COMMENT_SHARP_URL
));
result
=
commentQueryService
.
getComments
(
paginationRequest
);
Assert
.
assertNotNull
(
result
);
Assert
.
assertEquals
(
result
.
getJSONArray
(
Comment
.
COMMENTS
).
length
(),
3
);
// 2 article comments + 1 page comment
final
List
<
JSONObject
>
pageComments
=
commentQueryService
.
getComments
(
pageId
);
Assert
.
assertNotNull
(
pageComments
);
Assert
.
assertEquals
(
pageComments
.
size
(),
1
);
}
/**
* Adds a page.
*
...
...
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