Commit 1647e743 authored by Van's avatar Van

Merge remote-tracking branch 'origin/2.9.7-dev' into 2.9.7-dev

parents d70799d7 4c16e7b5
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
</scm> </scm>
<properties> <properties>
<org.b3log.latke.version>2.4.34</org.b3log.latke.version> <org.b3log.latke.version>2.4.35</org.b3log.latke.version>
<slf4j.version>1.7.5</slf4j.version> <slf4j.version>1.7.5</slf4j.version>
<jsoup.version>1.9.1</jsoup.version> <jsoup.version>1.9.1</jsoup.version>
......
...@@ -198,7 +198,6 @@ public class ArticleProcessor { ...@@ -198,7 +198,6 @@ public class ArticleProcessor {
public void onArticlePwdForm(final RequestContext context) { public void onArticlePwdForm(final RequestContext context) {
try { try {
final HttpServletRequest request = context.getRequest(); final HttpServletRequest request = context.getRequest();
final HttpServletResponse response = context.getResponse();
final String articleId = request.getParameter("articleId"); final String articleId = request.getParameter("articleId");
final String pwdTyped = request.getParameter("pwdTyped"); final String pwdTyped = request.getParameter("pwdTyped");
...@@ -216,12 +215,12 @@ public class ArticleProcessor { ...@@ -216,12 +215,12 @@ public class ArticleProcessor {
session.setAttribute(Common.ARTICLES_VIEW_PWD, viewPwds); session.setAttribute(Common.ARTICLES_VIEW_PWD, viewPwds);
} }
response.sendRedirect(Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK)); context.sendRedirect(Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK));
return; return;
} }
response.sendRedirect(Latkes.getServePath() + "/console/article-pwd?articleId=" + article.optString(Keys.OBJECT_ID) + "&msg=1"); context.sendRedirect(Latkes.getServePath() + "/console/article-pwd?articleId=" + article.optString(Keys.OBJECT_ID) + "&msg=1");
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Processes article view password form submits failed", e); LOGGER.log(Level.ERROR, "Processes article view password form submits failed", e);
...@@ -509,7 +508,7 @@ public class ArticleProcessor { ...@@ -509,7 +508,7 @@ public class ArticleProcessor {
final JSONObject authorRet = userQueryService.getUser(authorId); final JSONObject authorRet = userQueryService.getUser(authorId);
if (null == authorRet) { if (null == authorRet) {
context.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND); context.sendError(HttpServletResponse.SC_NOT_FOUND);
return; return;
} }
......
...@@ -168,7 +168,6 @@ public class FeedProcessor { ...@@ -168,7 +168,6 @@ public class FeedProcessor {
*/ */
@RequestProcessing(value = "/rss.xml", method = {HttpMethod.GET, HttpMethod.HEAD}) @RequestProcessing(value = "/rss.xml", method = {HttpMethod.GET, HttpMethod.HEAD})
public void blogArticlesRSS(final RequestContext context) { public void blogArticlesRSS(final RequestContext context) {
final HttpServletResponse response = context.getResponse();
final RssRenderer renderer = new RssRenderer(); final RssRenderer renderer = new RssRenderer();
context.setRenderer(renderer); context.setRenderer(renderer);
...@@ -177,7 +176,8 @@ public class FeedProcessor { ...@@ -177,7 +176,8 @@ public class FeedProcessor {
try { try {
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
if (null == preference) { if (null == preference) {
response.sendError(HttpServletResponse.SC_NOT_FOUND); context.sendError(HttpServletResponse.SC_NOT_FOUND);
return; return;
} }
......
...@@ -108,7 +108,8 @@ public class PageProcessor { ...@@ -108,7 +108,8 @@ public class PageProcessor {
try { try {
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
if (null == preference) { if (null == preference) {
response.sendError(HttpServletResponse.SC_NOT_FOUND); context.sendError(HttpServletResponse.SC_NOT_FOUND);
return; return;
} }
...@@ -117,7 +118,8 @@ public class PageProcessor { ...@@ -117,7 +118,8 @@ public class PageProcessor {
// See PermalinkFilter#dispatchToArticleOrPageProcessor() // See PermalinkFilter#dispatchToArticleOrPageProcessor()
final JSONObject page = (JSONObject) request.getAttribute(Page.PAGE); final JSONObject page = (JSONObject) request.getAttribute(Page.PAGE);
if (null == page) { if (null == page) {
response.sendError(HttpServletResponse.SC_NOT_FOUND); context.sendError(HttpServletResponse.SC_NOT_FOUND);
return; return;
} }
......
...@@ -120,7 +120,7 @@ public class TagProcessor { ...@@ -120,7 +120,7 @@ public class TagProcessor {
LOGGER.log(Level.DEBUG, "Tag [title={0}, currentPageNum={1}]", tagTitle, currentPageNum); LOGGER.log(Level.DEBUG, "Tag [title={0}, currentPageNum={1}]", tagTitle, currentPageNum);
final JSONObject result = tagQueryService.getTagByTitle(tagTitle); final JSONObject result = tagQueryService.getTagByTitle(tagTitle);
if (null == result) { if (null == result) {
response.sendError(HttpServletResponse.SC_NOT_FOUND); context.sendError(HttpServletResponse.SC_NOT_FOUND);
return; return;
} }
...@@ -135,7 +135,7 @@ public class TagProcessor { ...@@ -135,7 +135,7 @@ public class TagProcessor {
final int windowSize = preference.getInt(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE); final int windowSize = preference.getInt(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
final List<JSONObject> articles = articleQueryService.getArticlesByTag(tagId, currentPageNum, pageSize); final List<JSONObject> articles = articleQueryService.getArticlesByTag(tagId, currentPageNum, pageSize);
if (articles.isEmpty()) { if (articles.isEmpty()) {
response.sendError(HttpServletResponse.SC_NOT_FOUND); context.sendError(HttpServletResponse.SC_NOT_FOUND);
return; return;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package org.b3log.solo.api; package org.b3log.solo.processor.api;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.ioc.Inject; import org.b3log.latke.ioc.Inject;
...@@ -37,7 +37,7 @@ import org.b3log.solo.service.UserQueryService; ...@@ -37,7 +37,7 @@ import org.b3log.solo.service.UserQueryService;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* Article receiver from B3log Symphony. * Receiving articles from B3log community. Visits <a href="https://hacpai.com/b3log">B3log 构思</a> for more details.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.4.3, Sep 25, 2018 * @version 1.0.4.3, Sep 25, 2018
...@@ -78,6 +78,21 @@ public class B3ArticleReceiver { ...@@ -78,6 +78,21 @@ public class B3ArticleReceiver {
/** /**
* Adds an article with the specified request. * Adds an article with the specified request.
* <p> * <p>
* Request json:
* <pre>
* {
* "article": {
* "oId": "",
* "articleTitle": "",
* "articleContent": "",
* "articleTags": "tag1,tag2,tag3",
* "userB3Key": "",
* "articleEditorType": ""
* }
* }
* </pre>
* </p>
* <p>
* Renders the response with a json object, for example, * Renders the response with a json object, for example,
* <pre> * <pre>
* { * {
...@@ -88,24 +103,14 @@ public class B3ArticleReceiver { ...@@ -88,24 +103,14 @@ public class B3ArticleReceiver {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified http request context
* @param requestJSONObject the specified http servlet request, for example,
* "article": {
* "oId": "",
* "articleTitle": "",
* "articleContent": "",
* "articleTags": "tag1,tag2,tag3",
* "userB3Key": "",
* "articleEditorType": ""
* }
* @throws Exception exception
*/ */
@RequestProcessing(value = "/apis/symphony/article", method = HttpMethod.POST) @RequestProcessing(value = "/apis/symphony/article", method = HttpMethod.POST)
public void addArticle(final RequestContext context, final JSONObject requestJSONObject) public void addArticle(final RequestContext context) {
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();
final JSONObject requestJSONObject = context.requestJSON();
try { try {
final JSONObject article = requestJSONObject.optJSONObject(Article.ARTICLE); final JSONObject article = requestJSONObject.optJSONObject(Article.ARTICLE);
...@@ -151,6 +156,21 @@ public class B3ArticleReceiver { ...@@ -151,6 +156,21 @@ public class B3ArticleReceiver {
/** /**
* Updates an article with the specified request. * Updates an article with the specified request.
* <p> * <p>
* Request json:
* <pre>
* {
* "article": {
* "oId": "", // Symphony Article#clientArticleId
* "articleTitle": "",
* "articleContent": "",
* "articleTags": "tag1,tag2,tag3",
* "userB3Key": "",
* "articleEditorType": ""
* }
* }
* </pre>
* </p>
* <p>
* Renders the response with a json object, for example, * Renders the response with a json object, for example,
* <pre> * <pre>
* { * {
...@@ -160,25 +180,15 @@ public class B3ArticleReceiver { ...@@ -160,25 +180,15 @@ public class B3ArticleReceiver {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified http request context
* @param requestJSONObject the specified http servlet request, for example,
* "article": {
* "oId": "", // Symphony Article#clientArticleId
* "articleTitle": "",
* "articleContent": "",
* "articleTags": "tag1,tag2,tag3",
* "userB3Key": "",
* "articleEditorType": ""
* }
* @throws Exception exception
*/ */
@RequestProcessing(value = "/apis/symphony/article", method = HttpMethod.PUT) @RequestProcessing(value = "/apis/symphony/article", method = HttpMethod.PUT)
public void updateArticle(final RequestContext context, final JSONObject requestJSONObject) public void updateArticle(final RequestContext context) {
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 JSONObject requestJSONObject = context.requestJSON();
try { try {
final JSONObject article = requestJSONObject.optJSONObject(Article.ARTICLE); final JSONObject article = requestJSONObject.optJSONObject(Article.ARTICLE);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package org.b3log.solo.api; package org.b3log.solo.processor.api;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.lang.time.DateFormatUtils;
...@@ -49,7 +49,7 @@ import java.net.URL; ...@@ -49,7 +49,7 @@ import java.net.URL;
import java.util.Date; import java.util.Date;
/** /**
* Comment receiver from B3log Symphony. * Receiving comments from B3log community. Visits <a href="https://hacpai.com/b3log">B3log 构思</a> for more details.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.19, Nov 6, 2018 * @version 1.1.1.19, Nov 6, 2018
...@@ -108,6 +108,25 @@ public class B3CommentReceiver { ...@@ -108,6 +108,25 @@ public class B3CommentReceiver {
/** /**
* Adds a comment with the specified request. * Adds a comment with the specified request.
* <p> * <p>
* Request json:
* <pre>
* {
* "comment": {
* "userB3Key": "",
* "oId": "",
* "commentSymphonyArticleId": "",
* "commentOnArticleId": "",
* "commentAuthorName": "",
* "commentAuthorEmail": "",
* "commentAuthorURL": "",
* "commentAuthorThumbnailURL": "",
* "commentContent": "",
* "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply
* }
* }
* </pre>
* </p>
* <p>
* Renders the response with a json object, for example, * Renders the response with a json object, for example,
* <pre> * <pre>
* { * {
...@@ -116,32 +135,16 @@ public class B3CommentReceiver { ...@@ -116,32 +135,16 @@ public class B3CommentReceiver {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified http request context
* @param requestJSONObject the specified http servlet request, for example,
* {
* "comment": {
* "userB3Key": "",
* "oId": "",
* "commentSymphonyArticleId": "",
* "commentOnArticleId": "",
* "commentAuthorName": "",
* "commentAuthorEmail": "",
* "commentAuthorURL": "",
* "commentAuthorThumbnailURL": "",
* "commentContent": "",
* "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply
* }
* }
* @throws Exception exception
*/ */
@RequestProcessing(value = "/apis/symphony/comment", method = HttpMethod.PUT) @RequestProcessing(value = "/apis/symphony/comment", method = HttpMethod.PUT)
public void addComment(final RequestContext context, final JSONObject requestJSONObject) public void addComment(final RequestContext context) {
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 JSONObject requestJSONObject = context.requestJSON();
final Transaction transaction = commentRepository.beginTransaction(); final Transaction transaction = commentRepository.beginTransaction();
try { try {
final JSONObject symphonyCmt = requestJSONObject.optJSONObject(Comment.COMMENT); final JSONObject symphonyCmt = requestJSONObject.optJSONObject(Comment.COMMENT);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package org.b3log.solo.api; package org.b3log.solo.processor.api;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
......
...@@ -252,11 +252,7 @@ public class AdminConsole { ...@@ -252,11 +252,7 @@ public class AdminConsole {
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
if (!Solos.isAdminLoggedIn(request, response)) { if (!Solos.isAdminLoggedIn(request, response)) {
try { context.sendError(HttpServletResponse.SC_UNAUTHORIZED);
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} catch (final Exception e) {
// ignored
}
return; return;
} }
...@@ -369,11 +365,7 @@ public class AdminConsole { ...@@ -369,11 +365,7 @@ public class AdminConsole {
final HttpServletRequest request = context.getRequest(); final HttpServletRequest request = context.getRequest();
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
if (!Solos.isAdminLoggedIn(request, response)) { if (!Solos.isAdminLoggedIn(request, response)) {
try { context.sendError(HttpServletResponse.SC_UNAUTHORIZED);
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} catch (final Exception e) {
// ignored
}
return; return;
} }
...@@ -424,11 +416,7 @@ public class AdminConsole { ...@@ -424,11 +416,7 @@ public class AdminConsole {
final HttpServletRequest request = context.getRequest(); final HttpServletRequest request = context.getRequest();
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
if (!Solos.isAdminLoggedIn(request, response)) { if (!Solos.isAdminLoggedIn(request, response)) {
try { context.sendError(HttpServletResponse.SC_UNAUTHORIZED);
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} catch (final Exception e) {
// ignored
}
return; return;
} }
......
...@@ -27,7 +27,7 @@ import org.b3log.latke.repository.jdbc.util.Connections; ...@@ -27,7 +27,7 @@ import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.latke.repository.jdbc.util.JdbcRepositories; import org.b3log.latke.repository.jdbc.util.JdbcRepositories;
import org.b3log.latke.service.ServiceException; import org.b3log.latke.service.ServiceException;
import org.b3log.latke.util.Crypts; import org.b3log.latke.util.Crypts;
import org.b3log.solo.api.MetaWeblogAPI; import org.b3log.solo.processor.api.MetaWeblogAPI;
import org.b3log.solo.cache.*; import org.b3log.solo.cache.*;
import org.b3log.solo.processor.MockDispatcherServlet; import org.b3log.solo.processor.MockDispatcherServlet;
import org.b3log.solo.repository.*; import org.b3log.solo.repository.*;
......
...@@ -21,7 +21,7 @@ import org.apache.commons.lang.StringUtils; ...@@ -21,7 +21,7 @@ import org.apache.commons.lang.StringUtils;
import org.b3log.solo.AbstractTestCase; import org.b3log.solo.AbstractTestCase;
import org.b3log.solo.MockHttpServletRequest; import org.b3log.solo.MockHttpServletRequest;
import org.b3log.solo.MockHttpServletResponse; import org.b3log.solo.MockHttpServletResponse;
import org.b3log.solo.api.MetaWeblogAPI; import org.b3log.solo.processor.api.MetaWeblogAPI;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.Test; import org.testng.annotations.Test;
......
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