Commit 21772b2f authored by Liang Ding's avatar Liang Ding

Fixed #159

parent 0d7ef19f
......@@ -15,10 +15,10 @@
*/
package org.b3log.solo.filter;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
......@@ -51,7 +51,7 @@ import org.json.JSONObject;
* Page cache filter.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.1.0, Jul 16, 2012
* @version 1.0.1.1, Jan 8, 2013
* @since 0.3.1
*/
public final class PageCacheFilter implements Filter {
......@@ -145,7 +145,7 @@ public final class PageCacheFilter implements Filter {
try {
// If cached an article that has view password, dispatches the password form
if (langPropsService.get(PageTypes.ARTICLE.getLangeLabel()).equals(cachedType)
&& cachedPageContentObject.has(PageCaches.CACHED_PWD)) {
&& cachedPageContentObject.has(PageCaches.CACHED_PWD)) {
JSONObject article = new JSONObject();
final String articleId = cachedPageContentObject.optString(PageCaches.CACHED_OID);
......@@ -159,7 +159,7 @@ public final class PageCacheFilter implements Filter {
final HttpServletResponse httpServletResponse = (HttpServletResponse) response;
try {
httpServletResponse.sendRedirect(Latkes.getServePath()
+ "/console/article-pwd" + articles.buildArticleViewPwdFormParameters(article));
+ "/console/article-pwd?articleId=" + article.optString(Keys.OBJECT_ID));
return;
} catch (final Exception e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
......@@ -184,7 +184,7 @@ public final class PageCacheFilter implements Filter {
final String cachedTitle = cachedPageContentObject.getString(PageCaches.CACHED_TITLE);
LOGGER.log(Level.FINEST, "Cached value[key={0}, type={1}, title={2}]",
new Object[]{pageCacheKey, cachedType, cachedTitle});
new Object[]{pageCacheKey, cachedType, cachedTitle});
statistics.incBlogViewCount((HttpServletRequest) request, (HttpServletResponse) response);
......
......@@ -15,9 +15,9 @@
*/
package org.b3log.solo.filter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
......@@ -47,7 +47,7 @@ import org.json.JSONObject;
* Article/Page permalink filter.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.1.6, May 17, 2012
* @version 1.0.1.7, Jan 8, 2013
* @since 0.3.1
* @see org.b3log.solo.processor.ArticleProcessor#showArticle(org.b3log.latke.servlet.HTTPRequestContext,
* javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
......@@ -129,7 +129,7 @@ public final class PermalinkFilter implements Filter {
if (null != article && articles.needViewPwd(httpServletRequest, article)) {
try {
httpServletResponse.sendRedirect(Latkes.getServePath()
+ "/console/article-pwd" + articles.buildArticleViewPwdFormParameters(article));
+ "/console/article-pwd?articleId=" + article.optString(Keys.OBJECT_ID));
return;
} catch (final Exception e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
......@@ -153,7 +153,7 @@ public final class PermalinkFilter implements Filter {
* @see HTTPRequestDispatcher#dispatch(org.b3log.latke.servlet.HTTPRequestContext)
*/
private void dispatchToArticleOrPageProcessor(final ServletRequest request, final ServletResponse response,
final JSONObject article, final JSONObject page)
final JSONObject article, final JSONObject page)
throws ServletException, IOException {
final HTTPRequestContext context = new HTTPRequestContext();
context.setRequest((HttpServletRequest) request);
......
......@@ -19,7 +19,7 @@ package org.b3log.solo.model;
* This class defines all article model relevant keys.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.1.5, Apr 29, 2012
* @version 1.0.1.6, Jan 8, 2013
* @since 0.3.1
*/
public final class Article {
......@@ -56,6 +56,10 @@ public final class Article {
* Key of update date.
*/
public static final String ARTICLE_UPDATE_DATE = "articleUpdateDate";
/**
* Key of update time.
*/
public static final String ARTICLE_UPDATE_TIME = "articleUpdateTime";
/**
* Key of tags.
*/
......
......@@ -15,8 +15,6 @@
*/
package org.b3log.solo.util;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -25,7 +23,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.b3log.solo.model.Article;
import org.b3log.latke.Keys;
import org.b3log.latke.repository.*;
import org.b3log.latke.service.ServiceException;
......@@ -33,6 +30,7 @@ import org.b3log.latke.user.UserService;
import org.b3log.latke.user.UserServiceFactory;
import org.b3log.latke.util.CollectionUtils;
import org.b3log.latke.util.Strings;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Preference;
import org.b3log.solo.repository.ArticleRepository;
......@@ -47,7 +45,7 @@ import org.json.JSONObject;
* Article utilities.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.2.8, May 6, 2012
* @version 1.0.2.9, Jan 8, 2013
* @since 0.3.1
*/
public final class Articles {
......@@ -69,26 +67,6 @@ public final class Articles {
*/
private UserService userService = UserServiceFactory.getUserService();
/**
* Builds article view password form parameters with the specified article.
*
* @param article the specified article
* @return parameters string, for example,
* <pre>
* "?articleId=xxx&articleTitle=xxx&articlePermalink=xxx&articleAbstract=xxx"
* </pre>
* @throws UnsupportedEncodingException if can not encode the arguments
*/
public String buildArticleViewPwdFormParameters(final JSONObject article) throws UnsupportedEncodingException {
final StringBuilder parametersBuilder =
new StringBuilder("?articleId=").append(article.optString(Keys.OBJECT_ID)).
append("&articleTitle=").append(URLEncoder.encode(article.optString(Article.ARTICLE_TITLE), "UTF-8")).
append("&articlePermalink=").append(URLEncoder.encode(article.optString(Article.ARTICLE_PERMALINK), "UTF-8")).
append("&articleAbstract=").append(URLEncoder.encode(article.optString(Article.ARTICLE_ABSTRACT, " "), "UTF-8"));
return parametersBuilder.toString();
}
/**
* Checks whether need password to view the specified article with the specified request.
*
......@@ -178,8 +156,8 @@ public final class Articles {
if (null == ret) {
LOGGER.log(Level.WARNING,
"Gets author of article failed, assumes the administrator is the author of this article[id={0}]",
article.getString(Keys.OBJECT_ID));
"Gets author of article failed, assumes the administrator is the author of this article[id={0}]",
article.getString(Keys.OBJECT_ID));
// This author may be deleted by admin, use admin as the author
// of this article
ret = userRepository.getAdmin();
......
......@@ -34,7 +34,7 @@
<#if msg??>
<div>${msg}</div>
</#if>
<form method="POST" action="${staticServePath}/console/article-pwd">
<form method="POST" action="${servePath}/console/article-pwd">
<label for="pwdTyped">访问密码:</label>
<input type="password" id="pwdTyped" name="pwdTyped" />
<input type="hidden" name="articleId" value="${articleId}" />
......
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