Commit 0168859e authored by Liang Ding's avatar Liang Ding

#12401

parent 32cef8b2
...@@ -26,7 +26,6 @@ import org.b3log.latke.servlet.HTTPRequestMethod; ...@@ -26,7 +26,6 @@ import org.b3log.latke.servlet.HTTPRequestMethod;
import org.b3log.latke.servlet.annotation.RequestProcessing; import org.b3log.latke.servlet.annotation.RequestProcessing;
import org.b3log.latke.servlet.annotation.RequestProcessor; import org.b3log.latke.servlet.annotation.RequestProcessor;
import org.b3log.latke.servlet.renderer.JSONRenderer; import org.b3log.latke.servlet.renderer.JSONRenderer;
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.Option; import org.b3log.solo.model.Option;
...@@ -37,14 +36,11 @@ import org.b3log.solo.service.UserQueryService; ...@@ -37,14 +36,11 @@ import org.b3log.solo.service.UserQueryService;
import org.b3log.solo.util.QueryResults; import org.b3log.solo.util.QueryResults;
import org.json.JSONObject; import org.json.JSONObject;
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.4.0, Nov 20, 2017 * @version 1.0.4.1, Mar 3, 2018
* @since 0.5.5 * @since 0.5.5
*/ */
@RequestProcessor @RequestProcessor
...@@ -92,7 +88,8 @@ public class ArticleReceiver { ...@@ -92,7 +88,8 @@ public class ArticleReceiver {
* </pre> * </pre>
* </p> * </p>
* *
* @param request the specified http servlet request, for example, * @param context the specified http request context
* @param requestJSONObject the specified http servlet request, for example,
* "article": { * "article": {
* "oId": "", * "oId": "",
* "articleTitle": "", * "articleTitle": "",
...@@ -101,19 +98,16 @@ public class ArticleReceiver { ...@@ -101,19 +98,16 @@ public class ArticleReceiver {
* "userB3Key": "", * "userB3Key": "",
* "articleEditorType": "" * "articleEditorType": ""
* } * }
* @param response the specified http servlet response
* @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)
public void addArticle(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context) public void addArticle(final HTTPRequestContext context, final JSONObject requestJSONObject)
throws Exception { throws Exception {
final JSONRenderer renderer = new JSONRenderer(); final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer); context.setRenderer(renderer);
final JSONObject ret = new JSONObject(); final JSONObject ret = new JSONObject();
try { try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
final JSONObject article = requestJSONObject.optJSONObject(Article.ARTICLE); final JSONObject article = requestJSONObject.optJSONObject(Article.ARTICLE);
final String userB3Key = article.optString("userB3Key"); final String userB3Key = article.optString("userB3Key");
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
...@@ -167,7 +161,8 @@ public class ArticleReceiver { ...@@ -167,7 +161,8 @@ public class ArticleReceiver {
* </pre> * </pre>
* </p> * </p>
* *
* @param request the specified http servlet request, for example, * @param context the specified http request context
* @param requestJSONObject the specified http servlet request, for example,
* "article": { * "article": {
* "oId": "", // Symphony Article#clientArticleId * "oId": "", // Symphony Article#clientArticleId
* "articleTitle": "", * "articleTitle": "",
...@@ -176,23 +171,17 @@ public class ArticleReceiver { ...@@ -176,23 +171,17 @@ public class ArticleReceiver {
* "userB3Key": "", * "userB3Key": "",
* "articleEditorType": "" * "articleEditorType": ""
* } * }
* @param response the specified http servlet response
* @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)
public void updateArticle(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context) public void updateArticle(final HTTPRequestContext context, final JSONObject requestJSONObject)
throws Exception { throws Exception {
final JSONRenderer renderer = new JSONRenderer(); final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer); context.setRenderer(renderer);
final JSONObject ret = new JSONObject(); final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret); renderer.setJSONObject(ret);
try { try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
final JSONObject article = requestJSONObject.optJSONObject(Article.ARTICLE); final JSONObject article = requestJSONObject.optJSONObject(Article.ARTICLE);
final String userB3Key = article.optString("userB3Key"); final String userB3Key = article.optString("userB3Key");
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
......
...@@ -31,7 +31,6 @@ import org.b3log.latke.servlet.annotation.RequestProcessor; ...@@ -31,7 +31,6 @@ import org.b3log.latke.servlet.annotation.RequestProcessor;
import org.b3log.latke.servlet.renderer.JSONRenderer; import org.b3log.latke.servlet.renderer.JSONRenderer;
import org.b3log.latke.urlfetch.URLFetchService; import org.b3log.latke.urlfetch.URLFetchService;
import org.b3log.latke.urlfetch.URLFetchServiceFactory; import org.b3log.latke.urlfetch.URLFetchServiceFactory;
import org.b3log.latke.util.Requests;
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.Article; import org.b3log.solo.model.Article;
...@@ -47,7 +46,6 @@ import org.b3log.solo.util.Comments; ...@@ -47,7 +46,6 @@ import org.b3log.solo.util.Comments;
import org.b3log.solo.util.QueryResults; import org.b3log.solo.util.QueryResults;
import org.json.JSONObject; import org.json.JSONObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
...@@ -57,7 +55,7 @@ import java.util.Date; ...@@ -57,7 +55,7 @@ import java.util.Date;
* 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.1.12, Apr 25, 2017 * @version 1.1.1.13, Mar 3, 2018
* @since 0.5.5 * @since 0.5.5
*/ */
@RequestProcessor @RequestProcessor
...@@ -117,7 +115,7 @@ public class CommentReceiver { ...@@ -117,7 +115,7 @@ public class CommentReceiver {
/** /**
* Adds an article with the specified request. * Adds an article with the specified request.
* * <p>
* <p> * <p>
* Renders the response with a json object, for example, * Renders the response with a json object, for example,
* <pre> * <pre>
...@@ -127,7 +125,8 @@ public class CommentReceiver { ...@@ -127,7 +125,8 @@ public class CommentReceiver {
* </pre> * </pre>
* </p> * </p>
* *
* @param request the specified http servlet request, for example, <pre> * @param context the specified http request context
* @param requestJSONObject the specified http servlet request, for example,
* { * {
* "comment": { * "comment": {
* "userB3Key": "", * "userB3Key": "",
...@@ -142,26 +141,18 @@ public class CommentReceiver { ...@@ -142,26 +141,18 @@ public class CommentReceiver {
* "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply * "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply
* } * }
* } * }
* </pre>
*
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception * @throws Exception exception
*/ */
@RequestProcessing(value = "/apis/symphony/comment", method = HTTPRequestMethod.PUT) @RequestProcessing(value = "/apis/symphony/comment", method = HTTPRequestMethod.PUT)
public void addComment(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context) public void addComment(final HTTPRequestContext context, final JSONObject requestJSONObject)
throws Exception { throws Exception {
final JSONRenderer renderer = new JSONRenderer(); final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer); context.setRenderer(renderer);
final JSONObject ret = new JSONObject(); final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret); renderer.setJSONObject(ret);
final Transaction transaction = commentRepository.beginTransaction(); final Transaction transaction = commentRepository.beginTransaction();
try { try {
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(Option.ID_C_KEY_OF_SOLO); final String keyOfSolo = preference.optString(Option.ID_C_KEY_OF_SOLO);
......
...@@ -133,7 +133,10 @@ public class LinkConsole { ...@@ -133,7 +133,10 @@ public class LinkConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param request the specified http servlet request, for example, * @param request the specified http servlet request
* @param context the specified http request context
* @param response the specified http servlet response
* @param requestJSONObject the specified request json object, for example,
* { * {
* "link": { * "link": {
* "oId": "", * "oId": "",
...@@ -142,12 +145,11 @@ public class LinkConsole { ...@@ -142,12 +145,11 @@ public class LinkConsole {
* "linkDescription": "" * "linkDescription": ""
* } * }
* }, see {@link org.b3log.solo.model.Link} for more details * }, see {@link org.b3log.solo.model.Link} for more details
* @param context the specified http request context
* @param response the specified http servlet response
* @throws Exception exception * @throws Exception exception
*/ */
@RequestProcessing(value = "/console/link/", method = HTTPRequestMethod.PUT) @RequestProcessing(value = "/console/link/", method = HTTPRequestMethod.PUT)
public void updateLink(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context) public void updateLink(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context,
final JSONObject requestJSONObject)
throws Exception { throws Exception {
if (!userQueryService.isAdminLoggedIn(request)) { if (!userQueryService.isAdminLoggedIn(request)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN); response.sendError(HttpServletResponse.SC_FORBIDDEN);
...@@ -160,8 +162,6 @@ public class LinkConsole { ...@@ -160,8 +162,6 @@ public class LinkConsole {
final JSONObject ret = new JSONObject(); final JSONObject ret = new JSONObject();
try { try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
linkMgmtService.updateLink(requestJSONObject); linkMgmtService.updateLink(requestJSONObject);
ret.put(Keys.STATUS_CODE, true); ret.put(Keys.STATUS_CODE, true);
......
...@@ -91,7 +91,10 @@ public class PageConsole { ...@@ -91,7 +91,10 @@ public class PageConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param request the specified http servlet request, for example, * @param request the specified http servlet request
* @param response the specified http servlet response
* @param context the specified http request context
* @param requestJSONObject the specified reuqest json object, for example,
* { * {
* "page": { * "page": {
* "oId": "", * "oId": "",
...@@ -106,9 +109,6 @@ public class PageConsole { ...@@ -106,9 +109,6 @@ public class PageConsole {
* "pageIcon": "" * "pageIcon": ""
* } * }
* }, see {@link org.b3log.solo.model.Page} for more details * }, see {@link org.b3log.solo.model.Page} for more details
* @param response the specified http servlet response
* @param context the specified http request context
* @param requestJSONObject the specified reuqest json object
* @throws Exception exception * @throws Exception exception
*/ */
@RequestProcessing(value = "/console/page/", method = HTTPRequestMethod.PUT) @RequestProcessing(value = "/console/page/", method = HTTPRequestMethod.PUT)
...@@ -204,7 +204,9 @@ public class PageConsole { ...@@ -204,7 +204,9 @@ public class PageConsole {
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified http request context
* @param request the specified http servlet request, for example, * @param request the specified http servlet request
* @param response the specified http servlet response
* @param requestJSONObject the specified request json object, for example,
* { * {
* "page": { * "page": {
* "pageTitle": "", * "pageTitle": "",
...@@ -216,8 +218,6 @@ public class PageConsole { ...@@ -216,8 +218,6 @@ public class PageConsole {
* "pageIcon": "" * "pageIcon": ""
* } * }
* }, see {@link org.b3log.solo.model.Page} for more details * }, see {@link org.b3log.solo.model.Page} for more details
* @param response the specified http servlet response
* @param requestJSONObject the specified request json object
* @throws Exception exception * @throws Exception exception
*/ */
@RequestProcessing(value = "/console/page/", method = HTTPRequestMethod.POST) @RequestProcessing(value = "/console/page/", method = HTTPRequestMethod.POST)
...@@ -265,14 +265,14 @@ public class PageConsole { ...@@ -265,14 +265,14 @@ public class PageConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param request the specified http servlet request, for example, * @param request the specified http servlet request
* @param response the specified http servlet response
* @param context the specified http request context
* @param requestJSONObject the specified request json object, for example,
* { * {
* "oId": "", * "oId": "",
* "direction": "" // "up"/"down" * "direction": "" // "up"/"down"
* } * }
* @param response the specified http servlet response
* @param context the specified http request context
* @param requestJSONObject the specified request json object
* @throws Exception exception * @throws Exception exception
*/ */
@RequestProcessing(value = "/console/page/order/", method = HTTPRequestMethod.PUT) @RequestProcessing(value = "/console/page/order/", method = HTTPRequestMethod.PUT)
......
...@@ -147,14 +147,14 @@ public class PreferenceConsole { ...@@ -147,14 +147,14 @@ public class PreferenceConsole {
/** /**
* Updates reply template. * Updates reply template.
* *
* @param request the specified http servlet request, for example, * @param request the specified http servlet request
* @param response the specified http servlet response
* @param context the specified http request context
* @param requestJSONObject the specified request json object, for example,
* "replyNotificationTemplate": { * "replyNotificationTemplate": {
* "subject": "", * "subject": "",
* "body": "" * "body": ""
* } * }
* @param response the specified http servlet response
* @param context the specified http request context
* @param requestJSONObject the specified request json object
* @throws Exception exception * @throws Exception exception
*/ */
@RequestProcessing(value = "/console/reply/notification/template", method = HTTPRequestMethod.PUT) @RequestProcessing(value = "/console/reply/notification/template", method = HTTPRequestMethod.PUT)
...@@ -340,7 +340,10 @@ public class PreferenceConsole { ...@@ -340,7 +340,10 @@ public class PreferenceConsole {
/** /**
* Updates the preference by the specified request. * Updates the preference by the specified request.
* *
* @param request the specified http servlet request, for example, * @param request the specified http servlet request
* @param response the specified http servlet response
* @param context the specified http request context
* @param requestJSONObject the specified reuqest json object, for example,
* "preference": { * "preference": {
* "mostViewArticleDisplayCount": int, * "mostViewArticleDisplayCount": int,
* "recentCommentDisplayCount": int, * "recentCommentDisplayCount": int,
...@@ -374,9 +377,6 @@ public class PreferenceConsole { ...@@ -374,9 +377,6 @@ public class PreferenceConsole {
* "feedOutputMode: "", * "feedOutputMode: "",
* "feedOutputCnt": int * "feedOutputCnt": int
* } * }
* @param response the specified http servlet response
* @param context the specified http request context
* @param requestJSONObject the specified reuqest json object
* @throws Exception exception * @throws Exception exception
*/ */
@RequestProcessing(value = PREFERENCE_URI_PREFIX, method = HTTPRequestMethod.PUT) @RequestProcessing(value = PREFERENCE_URI_PREFIX, method = HTTPRequestMethod.PUT)
...@@ -472,14 +472,14 @@ public class PreferenceConsole { ...@@ -472,14 +472,14 @@ public class PreferenceConsole {
/** /**
* Updates the Qiniu preference by the specified request. * Updates the Qiniu preference by the specified request.
* *
* @param request the specified http servlet request, for example, * @param request the specified http servlet request
* @param response the specified http servlet response
* @param context the specified http request context
* @param requestJSONObject the specified request json object, for example,
* "qiniuAccessKey": "", * "qiniuAccessKey": "",
* "qiniuSecretKey": "", * "qiniuSecretKey": "",
* "qiniuDomain": "", * "qiniuDomain": "",
* "qiniuBucket": "" * "qiniuBucket": ""
* @param response the specified http servlet response
* @param context the specified http request context
* @param requestJSONObject the specified request json object
* @throws Exception exception * @throws Exception exception
*/ */
@RequestProcessing(value = PREFERENCE_URI_PREFIX + "qiniu", method = HTTPRequestMethod.PUT) @RequestProcessing(value = PREFERENCE_URI_PREFIX + "qiniu", method = HTTPRequestMethod.PUT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment