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
848a0417
Commit
848a0417
authored
Feb 17, 2017
by
Van
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/1.9.0-dev' into 1.9.0-dev
parents
f3484c4d
f4ffbde5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
45 deletions
+54
-45
src/main/java/org/b3log/solo/processor/CommentProcessor.java
src/main/java/org/b3log/solo/processor/CommentProcessor.java
+54
-45
No files found.
src/main/java/org/b3log/solo/processor/CommentProcessor.java
View file @
848a0417
...
...
@@ -16,12 +16,7 @@
package
org
.
b3log
.
solo
.
processor
;
import
java.io.IOException
;
import
javax.inject.Inject
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
freemarker.template.Template
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
...
...
@@ -33,6 +28,7 @@ import org.b3log.latke.servlet.annotation.RequestProcessing;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.JSONRenderer
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.freemarker.Templates
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.Common
;
...
...
@@ -42,13 +38,23 @@ import org.b3log.solo.service.UserMgmtService;
import
org.b3log.solo.service.UserQueryService
;
import
org.json.JSONObject
;
import
javax.inject.Inject
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
java.io.IOException
;
import
java.io.StringWriter
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Comment processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author ArmstrongCN
* @version 1.
2.2.12, Dec 29, 2015
* @version 1.
3.2.12, Feb 17, 2017
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -85,8 +91,8 @@ public class CommentProcessor {
/**
* Adds a comment to a page.
*
*
<p>
Renders the response with a json object, for example,
*
<p>
* Renders the response with a json object, for example,
* <pre>
* {
* "oId": generatedCommentId,
...
...
@@ -96,11 +102,10 @@ public class CommentProcessor {
* "commentThumbnailURL": "",
* "commentOriginalCommentName": "" // if exists this key, the comment is an reply
* }
* </pre> </p>
* </pre>
* </p>
*
* @param context the specified context, including a request json object, for example,
* <pre>
* {
* "captcha": "",
* "oId": pageId,
* "commentName": "",
...
...
@@ -108,8 +113,6 @@ public class CommentProcessor {
* "commentURL": "",
* "commentContent": "", // HTML
* "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply
* }
* </pre>
* @throws ServletException servlet exception
* @throws IOException io exception
*/
...
...
@@ -165,6 +168,16 @@ public class CommentProcessor {
try
{
final
JSONObject
addResult
=
commentMgmtService
.
addPageComment
(
requestJSONObject
);
final
Map
<
String
,
Object
>
dataModel
=
new
HashMap
<>();
dataModel
.
put
(
Comment
.
COMMENT
,
addResult
);
final
String
skinDirName
=
(
String
)
httpServletRequest
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
);
final
Template
template
=
Templates
.
MAIN_CFG
.
getTemplate
(
"common-comment.ftl"
);
final
StringWriter
stringWriter
=
new
StringWriter
();
template
.
process
(
dataModel
,
stringWriter
);
stringWriter
.
close
();
addResult
.
put
(
"cmtTpl"
,
stringWriter
.
toString
());
addResult
.
put
(
Keys
.
STATUS_CODE
,
true
);
renderer
.
setJSONObject
(
addResult
);
...
...
@@ -178,9 +191,8 @@ public class CommentProcessor {
/**
* Adds a comment to an article.
*
*
* <p> Renders the response with a json object, for example,
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "oId": generatedCommentId,
...
...
@@ -192,10 +204,9 @@ public class CommentProcessor {
* "commentContent": "" // HTML
* }
* </pre>
* </p>
*
* @param context the specified context, including a request json object, for example,
* <pre>
* {
* "captcha": "",
* "oId": articleId,
* "commentName": "",
...
...
@@ -203,8 +214,6 @@ public class CommentProcessor {
* "commentURL": "",
* "commentContent": "",
* "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply
* }
* </pre>
* @throws ServletException servlet exception
* @throws IOException io exception
*/
...
...
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