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
833e48c8
Commit
833e48c8
authored
Jan 15, 2017
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐛
Fix #12207
parent
f0e02a93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
45 deletions
+31
-45
src/main/java/org/b3log/solo/api/symphony/ArticleReceiver.java
...ain/java/org/b3log/solo/api/symphony/ArticleReceiver.java
+31
-45
No files found.
src/main/java/org/b3log/solo/api/symphony/ArticleReceiver.java
View file @
833e48c8
...
@@ -15,9 +15,6 @@
...
@@ -15,9 +15,6 @@
*/
*/
package
org
.
b3log
.
solo
.
api
.
symphony
;
package
org
.
b3log
.
solo
.
api
.
symphony
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
...
@@ -42,11 +39,15 @@ import org.json.JSONObject;
...
@@ -42,11 +39,15 @@ import org.json.JSONObject;
import
org.jsoup.Jsoup
;
import
org.jsoup.Jsoup
;
import
org.jsoup.safety.Whitelist
;
import
org.jsoup.safety.Whitelist
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
/**
* 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.
2.7, Nov 8, 2016
* @version 1.0.
3.7, Jan 15, 2017
* @since 0.5.5
* @since 0.5.5
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -56,39 +57,33 @@ public class ArticleReceiver {
...
@@ -56,39 +57,33 @@ public class ArticleReceiver {
* Logger.
* Logger.
*/
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ArticleReceiver
.
class
.
getName
());
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ArticleReceiver
.
class
.
getName
());
/**
* Article abstract length.
*/
private
static
final
int
ARTICLE_ABSTRACT_LENGTH
=
500
;
/**
/**
* Preference query service.
* Preference query service.
*/
*/
@Inject
@Inject
private
PreferenceQueryService
preferenceQueryService
;
private
PreferenceQueryService
preferenceQueryService
;
/**
/**
* Article management service.
* Article management service.
*/
*/
@Inject
@Inject
private
ArticleMgmtService
articleMgmtService
;
private
ArticleMgmtService
articleMgmtService
;
/**
/**
* Article query service.
* Article query service.
*/
*/
@Inject
@Inject
private
ArticleQueryService
articleQueryService
;
private
ArticleQueryService
articleQueryService
;
/**
/**
* User query service.
* User query service.
*/
*/
@Inject
@Inject
private
UserQueryService
userQueryService
;
private
UserQueryService
userQueryService
;
/**
* Article abstract length.
*/
private
static
final
int
ARTICLE_ABSTRACT_LENGTH
=
500
;
/**
/**
* Adds an article with the specified request.
* Adds an article with the specified request.
*
* <p>
* <p>
* Renders the response with a json object, for example,
* Renders the response with a json object, for example,
* <pre>
* <pre>
...
@@ -100,21 +95,17 @@ public class ArticleReceiver {
...
@@ -100,21 +95,17 @@ public class ArticleReceiver {
* </pre>
* </pre>
* </p>
* </p>
*
*
* @param request the specified http servlet request, for example, <pre>
* @param request the specified http servlet request, for example,
* {
* "article": {
* "article": {
* "oId": "",
* "oId": "",
* "articleTitle": "",
* "articleTitle": "",
* "articleContent": "",
* "articleContent": "",
* "articleTags": "tag1,tag2,tag3",
* "articleTags": "tag1,tag2,tag3",
* "userB3Key": "",
* "userB3Key": "",
* "articleEditorType": ""
* "articleEditorType": ""
* }
* }
* }
* </pre>
*
* @param response the specified http servlet response
* @param response the specified http servlet response
* @param context the specified http request context
* @param context
the specified http request context
* @throws Exception exception
* @throws Exception exception
*/
*/
@RequestProcessing
(
value
=
"/apis/symphony/article"
,
method
=
HTTPRequestMethod
.
POST
)
@RequestProcessing
(
value
=
"/apis/symphony/article"
,
method
=
HTTPRequestMethod
.
POST
)
...
@@ -179,7 +170,6 @@ public class ArticleReceiver {
...
@@ -179,7 +170,6 @@ public class ArticleReceiver {
/**
/**
* Updates an article with the specified request.
* Updates an article with the specified request.
*
* <p>
* <p>
* Renders the response with a json object, for example,
* Renders the response with a json object, for example,
* <pre>
* <pre>
...
@@ -190,21 +180,17 @@ public class ArticleReceiver {
...
@@ -190,21 +180,17 @@ public class ArticleReceiver {
* </pre>
* </pre>
* </p>
* </p>
*
*
* @param request the specified http servlet request, for example, <pre>
* @param request the specified http servlet request, for example,
* {
* "article": {
* "article": {
* "oId": "", // Symphony Article#clientArticleId
* "oId": "", // Symphony Article#clientArticleId
* "articleTitle": "",
* "articleTitle": "",
* "articleContent": "",
* "articleContent": "",
* "articleTags": "tag1,tag2,tag3",
* "articleTags": "tag1,tag2,tag3",
* "userB3Key": "",
* "userB3Key": "",
* "articleEditorType": ""
* "articleEditorType": ""
* }
* }
* }
* </pre>
*
* @param response the specified http servlet response
* @param response the specified http servlet response
* @param context the specified http request context
* @param context
the specified http request context
* @throws Exception exception
* @throws Exception exception
*/
*/
@RequestProcessing
(
value
=
"/apis/symphony/article"
,
method
=
HTTPRequestMethod
.
PUT
)
@RequestProcessing
(
value
=
"/apis/symphony/article"
,
method
=
HTTPRequestMethod
.
PUT
)
...
@@ -240,8 +226,8 @@ public class ArticleReceiver {
...
@@ -240,8 +226,8 @@ public class ArticleReceiver {
return
;
return
;
}
}
final
String
plainTextContent
=
Jsoup
.
parse
(
article
.
optString
(
Article
.
ARTICLE_CONTENT
)).
text
(
);
final
String
articleContent
=
article
.
optString
(
Article
.
ARTICLE_CONTENT
);
final
String
plainTextContent
=
Jsoup
.
clean
(
Markdowns
.
toHTML
(
articleContent
),
Whitelist
.
none
());
if
(
plainTextContent
.
length
()
>
ARTICLE_ABSTRACT_LENGTH
)
{
if
(
plainTextContent
.
length
()
>
ARTICLE_ABSTRACT_LENGTH
)
{
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
plainTextContent
.
substring
(
0
,
ARTICLE_ABSTRACT_LENGTH
)
+
"...."
);
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
plainTextContent
.
substring
(
0
,
ARTICLE_ABSTRACT_LENGTH
)
+
"...."
);
}
else
{
}
else
{
...
...
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