Commit 8ccb036c authored by Liang Ding's avatar Liang Ding

🎨 Cleanup code

parent f46cdb6f
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package org.b3log.solo.filter; package org.b3log.solo.filter;
import org.b3log.latke.ioc.LatkeBeanManager; import org.b3log.latke.ioc.LatkeBeanManager;
import org.b3log.latke.ioc.Lifecycle; import org.b3log.latke.ioc.Lifecycle;
import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Level;
...@@ -31,7 +30,6 @@ import javax.servlet.http.HttpServletRequest; ...@@ -31,7 +30,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
/** /**
* Authentication filter. * Authentication filter.
* *
......
...@@ -59,10 +59,10 @@ public final class InitCheckFilter implements Filter { ...@@ -59,10 +59,10 @@ public final class InitCheckFilter implements Filter {
/** /**
* If Solo has not been initialized, so redirects to /init. * If Solo has not been initialized, so redirects to /init.
* *
* @param request the specified request * @param request the specified request
* @param response the specified response * @param response the specified response
* @param chain filter chain * @param chain filter chain
* @throws IOException io exception * @throws IOException io exception
* @throws ServletException servlet exception * @throws ServletException servlet exception
*/ */
@Override @Override
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package org.b3log.solo.filter; package org.b3log.solo.filter;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes; import org.b3log.latke.Latkes;
...@@ -44,16 +43,15 @@ import javax.servlet.http.HttpServletRequest; ...@@ -44,16 +43,15 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
/** /**
* Article/Page permalink filter. * Article/Page permalink filter.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.7, Jan 8, 2013 * @version 1.0.1.7, Jan 8, 2013
* @see org.b3log.solo.processor.ArticleProcessor#showArticle(org.b3log.latke.servlet.HTTPRequestContext,
* javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
* @see org.b3log.solo.processor.PageProcessor#showPage(org.b3log.latke.servlet.HTTPRequestContext)
* @since 0.3.1 * @since 0.3.1
* @see org.b3log.solo.processor.ArticleProcessor#showArticle(org.b3log.latke.servlet.HTTPRequestContext,
* javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
* @see org.b3log.solo.processor.PageProcessor#showPage(org.b3log.latke.servlet.HTTPRequestContext)
*/ */
public final class PermalinkFilter implements Filter { public final class PermalinkFilter implements Filter {
...@@ -63,20 +61,21 @@ public final class PermalinkFilter implements Filter { ...@@ -63,20 +61,21 @@ public final class PermalinkFilter implements Filter {
private static final Logger LOGGER = Logger.getLogger(PermalinkFilter.class); private static final Logger LOGGER = Logger.getLogger(PermalinkFilter.class);
@Override @Override
public void init(final FilterConfig filterConfig) throws ServletException {} public void init(final FilterConfig filterConfig) throws ServletException {
}
/** /**
* Tries to dispatch request to article processor. * Tries to dispatch request to article processor.
* *
* @param request the specified request * @param request the specified request
* @param response the specified response * @param response the specified response
* @param chain filter chain * @param chain filter chain
* @throws IOException io exception * @throws IOException io exception
* @throws ServletException servlet exception * @throws ServletException servlet exception
*/ */
@Override @Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
throws IOException, ServletException { throws IOException, ServletException {
final HttpServletRequest httpServletRequest = (HttpServletRequest) request; final HttpServletRequest httpServletRequest = (HttpServletRequest) request;
final HttpServletResponse httpServletResponse = (HttpServletResponse) response; final HttpServletResponse httpServletResponse = (HttpServletResponse) response;
...@@ -103,10 +102,9 @@ public final class PermalinkFilter implements Filter { ...@@ -103,10 +102,9 @@ public final class PermalinkFilter implements Filter {
final ArticleRepository articleRepository = beanManager.getReference(ArticleRepositoryImpl.class); final ArticleRepository articleRepository = beanManager.getReference(ArticleRepositoryImpl.class);
article = articleRepository.getByPermalink(permalink); article = articleRepository.getByPermalink(permalink);
if (null == article) { if (null == article) {
final PageRepository pageRepository = beanManager.getReference(PageRepositoryImpl.class); final PageRepository pageRepository = beanManager.getReference(PageRepositoryImpl.class);
page = pageRepository.getByPermalink(permalink); page = pageRepository.getByPermalink(permalink);
} }
...@@ -129,7 +127,7 @@ public final class PermalinkFilter implements Filter { ...@@ -129,7 +127,7 @@ public final class PermalinkFilter implements Filter {
if (null != article && articleQueryService.needViewPwd(httpServletRequest, article)) { if (null != article && articleQueryService.needViewPwd(httpServletRequest, article)) {
try { try {
httpServletResponse.sendRedirect( httpServletResponse.sendRedirect(
Latkes.getServePath() + "/console/article-pwd?articleId=" + article.optString(Keys.OBJECT_ID)); Latkes.getServePath() + "/console/article-pwd?articleId=" + article.optString(Keys.OBJECT_ID));
return; return;
} catch (final Exception e) { } catch (final Exception e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND); httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
...@@ -141,20 +139,20 @@ public final class PermalinkFilter implements Filter { ...@@ -141,20 +139,20 @@ public final class PermalinkFilter implements Filter {
} }
/** /**
* Dispatches the specified request to the specified article or page * Dispatches the specified request to the specified article or page
* processor with the specified response. * processor with the specified response.
* *
* @param request the specified request * @param request the specified request
* @param response the specified response * @param response the specified response
* @param article the specified article * @param article the specified article
* @param page the specified page * @param page the specified page
* @throws ServletException servlet exception * @throws ServletException servlet exception
* @throws IOException io exception * @throws IOException io exception
* @see HTTPRequestDispatcher#dispatch(org.b3log.latke.servlet.HTTPRequestContext) * @see DispatcherServlet#result(HTTPRequestContext)
*/ */
private void dispatchToArticleOrPageProcessor(final ServletRequest request, final ServletResponse response, private void dispatchToArticleOrPageProcessor(final ServletRequest request, final ServletResponse response,
final JSONObject article, final JSONObject page) final JSONObject article, final JSONObject page)
throws ServletException, IOException { throws ServletException, IOException {
final HTTPRequestContext context = new HTTPRequestContext(); final HTTPRequestContext context = new HTTPRequestContext();
context.setRequest((HttpServletRequest) request); context.setRequest((HttpServletRequest) request);
...@@ -171,7 +169,6 @@ public final class PermalinkFilter implements Filter { ...@@ -171,7 +169,6 @@ public final class PermalinkFilter implements Filter {
request.setAttribute(Keys.HttpRequest.REQUEST_METHOD, HTTPRequestMethod.GET.name()); request.setAttribute(Keys.HttpRequest.REQUEST_METHOD, HTTPRequestMethod.GET.name());
final HttpControl httpControl = new HttpControl(DispatcherServlet.SYS_HANDLER.iterator(), context); final HttpControl httpControl = new HttpControl(DispatcherServlet.SYS_HANDLER.iterator(), context);
try { try {
httpControl.nextHandler(); httpControl.nextHandler();
} catch (final Exception e) { } catch (final Exception e) {
...@@ -182,5 +179,6 @@ public final class PermalinkFilter implements Filter { ...@@ -182,5 +179,6 @@ public final class PermalinkFilter implements Filter {
} }
@Override @Override
public void destroy() {} public void destroy() {
}
} }
...@@ -78,8 +78,8 @@ public class ListHandler extends AbstractEventListener<JSONObject> { ...@@ -78,8 +78,8 @@ public class ListHandler extends AbstractEventListener<JSONObject> {
element.before("<span id='" + id + "'></span>"); element.before("<span id='" + id + "'></span>");
listBuilder.append("<li class='b3-solo-list-").append(tagName).append("'><a href='#").append(id).append("'>").append(text). listBuilder.append("<li class='b3-solo-list-").append(tagName).append("'><a href='#").append(id).append("'>").
append("</a></li>"); append(text).append("</a></li>");
} }
listBuilder.append("</ul>"); listBuilder.append("</ul>");
......
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