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

#12401

parent 32cef8b2
......@@ -26,7 +26,6 @@ import org.b3log.latke.servlet.HTTPRequestMethod;
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.solo.model.Article;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Option;
......@@ -37,14 +36,11 @@ import org.b3log.solo.service.UserQueryService;
import org.b3log.solo.util.QueryResults;
import org.json.JSONObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Article receiver (from B3log Symphony).
*
* @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
*/
@RequestProcessor
......@@ -92,7 +88,8 @@ public class ArticleReceiver {
* </pre>
* </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": {
* "oId": "",
* "articleTitle": "",
......@@ -101,19 +98,16 @@ public class ArticleReceiver {
* "userB3Key": "",
* "articleEditorType": ""
* }
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
*/
@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 {
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
final JSONObject ret = new JSONObject();
try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
final JSONObject article = requestJSONObject.optJSONObject(Article.ARTICLE);
final String userB3Key = article.optString("userB3Key");
final JSONObject preference = preferenceQueryService.getPreference();
......@@ -167,7 +161,8 @@ public class ArticleReceiver {
* </pre>
* </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": {
* "oId": "", // Symphony Article#clientArticleId
* "articleTitle": "",
......@@ -176,23 +171,17 @@ public class ArticleReceiver {
* "userB3Key": "",
* "articleEditorType": ""
* }
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
*/
@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 {
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
final JSONObject article = requestJSONObject.optJSONObject(Article.ARTICLE);
final String userB3Key = article.optString("userB3Key");
final JSONObject preference = preferenceQueryService.getPreference();
......
......@@ -31,7 +31,6 @@ import org.b3log.latke.servlet.annotation.RequestProcessor;
import org.b3log.latke.servlet.renderer.JSONRenderer;
import org.b3log.latke.urlfetch.URLFetchService;
import org.b3log.latke.urlfetch.URLFetchServiceFactory;
import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings;
import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article;
......@@ -47,7 +46,6 @@ import org.b3log.solo.util.Comments;
import org.b3log.solo.util.QueryResults;
import org.json.JSONObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.MalformedURLException;
import java.net.URL;
......@@ -57,7 +55,7 @@ import java.util.Date;
* Comment receiver (from B3log Symphony).
*
* @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
*/
@RequestProcessor
......@@ -117,7 +115,7 @@ public class CommentReceiver {
/**
* Adds an article with the specified request.
*
* <p>
* <p>
* Renders the response with a json object, for example,
* <pre>
......@@ -127,7 +125,8 @@ public class CommentReceiver {
* </pre>
* </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": {
* "userB3Key": "",
......@@ -142,26 +141,18 @@ public class CommentReceiver {
* "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
*/
@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 {
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
final Transaction transaction = commentRepository.beginTransaction();
try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
final JSONObject symphonyCmt = requestJSONObject.optJSONObject(Comment.COMMENT);
final JSONObject preference = preferenceQueryService.getPreference();
final String keyOfSolo = preference.optString(Option.ID_C_KEY_OF_SOLO);
......
......@@ -133,7 +133,10 @@ public class LinkConsole {
* </pre>
* </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": {
* "oId": "",
......@@ -142,12 +145,11 @@ public class LinkConsole {
* "linkDescription": ""
* }
* }, 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
*/
@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 {
if (!userQueryService.isAdminLoggedIn(request)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
......@@ -160,8 +162,6 @@ public class LinkConsole {
final JSONObject ret = new JSONObject();
try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
linkMgmtService.updateLink(requestJSONObject);
ret.put(Keys.STATUS_CODE, true);
......
......@@ -91,7 +91,10 @@ public class PageConsole {
* </pre>
* </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": {
* "oId": "",
......@@ -106,9 +109,6 @@ public class PageConsole {
* "pageIcon": ""
* }
* }, 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
*/
@RequestProcessing(value = "/console/page/", method = HTTPRequestMethod.PUT)
......@@ -204,7 +204,9 @@ public class PageConsole {
* </p>
*
* @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": {
* "pageTitle": "",
......@@ -216,8 +218,6 @@ public class PageConsole {
* "pageIcon": ""
* }
* }, 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
*/
@RequestProcessing(value = "/console/page/", method = HTTPRequestMethod.POST)
......@@ -265,14 +265,14 @@ public class PageConsole {
* </pre>
* </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": "",
* "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
*/
@RequestProcessing(value = "/console/page/order/", method = HTTPRequestMethod.PUT)
......
......@@ -147,14 +147,14 @@ public class PreferenceConsole {
/**
* 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": {
* "subject": "",
* "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
*/
@RequestProcessing(value = "/console/reply/notification/template", method = HTTPRequestMethod.PUT)
......@@ -340,7 +340,10 @@ public class PreferenceConsole {
/**
* 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": {
* "mostViewArticleDisplayCount": int,
* "recentCommentDisplayCount": int,
......@@ -374,9 +377,6 @@ public class PreferenceConsole {
* "feedOutputMode: "",
* "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
*/
@RequestProcessing(value = PREFERENCE_URI_PREFIX, method = HTTPRequestMethod.PUT)
......@@ -472,14 +472,14 @@ public class PreferenceConsole {
/**
* 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": "",
* "qiniuSecretKey": "",
* "qiniuDomain": "",
* "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
*/
@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