Commit 204f9cee authored by Liang Ding's avatar Liang Ding

🎨 clean code

parent ec8df866
......@@ -230,7 +230,7 @@ public class CommentReceiver {
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
LOGGER.log(Level.WARN, "Not found orginal comment[id={0}] of reply[name={1}, content={2}]",
new String[]{originalCommentId, commentName, commentContent});
originalCommentId, commentName, commentContent);
}
} else {
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
......
......@@ -16,17 +16,16 @@
package org.b3log.solo.processor.util;
import freemarker.template.TemplateMethodModel;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import org.b3log.latke.Keys;
import org.b3log.latke.ioc.inject.Inject;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service;
import org.b3log.solo.model.Tag;
import org.b3log.solo.service.ArticleQueryService;
import org.b3log.solo.service.TagQueryService;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
......@@ -37,39 +36,37 @@ import java.util.List;
* Fill tag articles.
*
* @author <a href="mailto:385321165@qq.com">DASHU</a>
* @version 0.0.0.1, Jul 1, 2013
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.2, Apr 12, 2017
* @since 0.6.1
*/
@Service
public class FillTagArticles implements TemplateMethodModel {
public class FillTagArticles implements TemplateMethodModelEx {
/**
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(FillTagArticles.class.getName());
private static final Logger LOGGER = Logger.getLogger(FillTagArticles.class);
/**
* Arg size.
*/
private static final int ARG_SIZE = 3;
/**
* Tag query service.
*/
@Inject
private TagQueryService tagQueryService;
/**
* Article query service.
*/
@Inject
private ArticleQueryService articleQueryService;
/**
* Arg size.
*/
private static final int ARG_SIZE = 3;
@Override
public Object exec(final List arguments) throws TemplateModelException {
if (arguments.size() != ARG_SIZE) {
LOGGER.debug("FillTagArticles with wrong arguments!");
throw new TemplateModelException("Wrong arguments!");
}
......@@ -78,9 +75,7 @@ public class FillTagArticles implements TemplateMethodModel {
final int pageSize = Integer.parseInt((String) arguments.get(2));
try {
final JSONObject result = tagQueryService.getTagByTitle(tagTitle);
if (null == result) {
return new ArrayList<JSONObject>();
}
......@@ -88,14 +83,11 @@ public class FillTagArticles implements TemplateMethodModel {
final JSONObject tag = result.getJSONObject(Tag.TAG);
final String tagId = tag.getString(Keys.OBJECT_ID);
final List<JSONObject> list = articleQueryService.getArticlesByTag(tagId, currentPageNum, pageSize);
return list;
final List<JSONObject> ret = articleQueryService.getArticlesByTag(tagId, currentPageNum, pageSize);
} catch (final ServiceException e) {
e.printStackTrace();
} catch (final JSONException e) {
e.printStackTrace();
return ret;
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Fill tag articles failed", e);
}
return null;
......
......@@ -609,7 +609,7 @@ public class CommentMgmtService {
ret.put(Common.IS_REPLY, true);
} else {
LOGGER.log(Level.WARN, "Not found orginal comment[id={0}] of reply[name={1}, content={2}]",
new String[]{originalCommentId, commentName, commentContent});
originalCommentId, commentName, commentContent);
}
}
setCommentThumbnailURL(comment);
......
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