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

🎨 clean code

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