Commit 55a73129 authored by Liang Ding's avatar Liang Ding

🎨 Cleanup code

parent b22004e3
......@@ -198,7 +198,6 @@ public class ArticleProcessor {
public void onArticlePwdForm(final RequestContext context) {
try {
final HttpServletRequest request = context.getRequest();
final HttpServletResponse response = context.getResponse();
final String articleId = request.getParameter("articleId");
final String pwdTyped = request.getParameter("pwdTyped");
......@@ -216,12 +215,12 @@ public class ArticleProcessor {
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;
}
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) {
LOGGER.log(Level.ERROR, "Processes article view password form submits failed", e);
......@@ -509,7 +508,7 @@ public class ArticleProcessor {
final JSONObject authorRet = userQueryService.getUser(authorId);
if (null == authorRet) {
context.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND);
context.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
......
......@@ -168,7 +168,6 @@ public class FeedProcessor {
*/
@RequestProcessing(value = "/rss.xml", method = {HttpMethod.GET, HttpMethod.HEAD})
public void blogArticlesRSS(final RequestContext context) {
final HttpServletResponse response = context.getResponse();
final RssRenderer renderer = new RssRenderer();
context.setRenderer(renderer);
......@@ -177,7 +176,8 @@ public class FeedProcessor {
try {
final JSONObject preference = preferenceQueryService.getPreference();
if (null == preference) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
context.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
......
......@@ -108,7 +108,8 @@ public class PageProcessor {
try {
final JSONObject preference = preferenceQueryService.getPreference();
if (null == preference) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
context.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
......@@ -117,7 +118,8 @@ public class PageProcessor {
// See PermalinkFilter#dispatchToArticleOrPageProcessor()
final JSONObject page = (JSONObject) request.getAttribute(Page.PAGE);
if (null == page) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
context.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
......
......@@ -120,7 +120,7 @@ public class TagProcessor {
LOGGER.log(Level.DEBUG, "Tag [title={0}, currentPageNum={1}]", tagTitle, currentPageNum);
final JSONObject result = tagQueryService.getTagByTitle(tagTitle);
if (null == result) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
context.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
......@@ -135,7 +135,7 @@ public class TagProcessor {
final int windowSize = preference.getInt(Option.ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE);
final List<JSONObject> articles = articleQueryService.getArticlesByTag(tagId, currentPageNum, pageSize);
if (articles.isEmpty()) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
context.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
......
......@@ -252,11 +252,7 @@ public class AdminConsole {
final HttpServletResponse response = context.getResponse();
if (!Solos.isAdminLoggedIn(request, response)) {
try {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} catch (final Exception e) {
// ignored
}
context.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
......@@ -369,11 +365,7 @@ public class AdminConsole {
final HttpServletRequest request = context.getRequest();
final HttpServletResponse response = context.getResponse();
if (!Solos.isAdminLoggedIn(request, response)) {
try {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} catch (final Exception e) {
// ignored
}
context.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
......@@ -424,11 +416,7 @@ public class AdminConsole {
final HttpServletRequest request = context.getRequest();
final HttpServletResponse response = context.getResponse();
if (!Solos.isAdminLoggedIn(request, response)) {
try {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} catch (final Exception e) {
// ignored
}
context.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
......
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