Commit 33aa1635 authored by Liang Ding's avatar Liang Ding

c

parent 3fab14b0
...@@ -33,7 +33,7 @@ import org.json.JSONObject; ...@@ -33,7 +33,7 @@ import org.json.JSONObject;
* Tag query service. * Tag query service.
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.2, Nov 11, 2011 * @version 1.0.0.3, Jun 28, 2012
* @since 0.4.0 * @since 0.4.0
*/ */
public final class TagQueryService { public final class TagQueryService {
...@@ -41,8 +41,7 @@ public final class TagQueryService { ...@@ -41,8 +41,7 @@ public final class TagQueryService {
/** /**
* Logger. * Logger.
*/ */
private static final Logger LOGGER = private static final Logger LOGGER = Logger.getLogger(TagQueryService.class.getName());
Logger.getLogger(TagQueryService.class.getName());
/** /**
* Tag repository. * Tag repository.
*/ */
...@@ -65,8 +64,7 @@ public final class TagQueryService { ...@@ -65,8 +64,7 @@ public final class TagQueryService {
* </pre>, returns {@code null} if not found * </pre>, returns {@code null} if not found
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public JSONObject getTagByTitle(final String tagTitle) public JSONObject getTagByTitle(final String tagTitle) throws ServiceException {
throws ServiceException {
try { try {
final JSONObject ret = new JSONObject(); final JSONObject ret = new JSONObject();
...@@ -87,6 +85,22 @@ public final class TagQueryService { ...@@ -87,6 +85,22 @@ public final class TagQueryService {
} }
} }
/**
* Gets the count of tags.
*
* @return count of tags
* @throws ServiceException service exception
*/
public long getTagCount() throws ServiceException {
try {
return tagRepository.count();
} catch (final RepositoryException e) {
LOGGER.log(Level.SEVERE, "Gets tags failed", e);
throw new ServiceException(e);
}
}
/** /**
* Gets all tags. * Gets all tags.
* *
......
...@@ -131,6 +131,27 @@ public final class Articles { ...@@ -131,6 +131,27 @@ public final class Articles {
return true; return true;
} }
/**
* Gets time of the recent updated article.
*
* @return time of the recent updated article, returns {@code 0} if not found
* @throws ServiceException service exception
*/
public long getRecentArticleTime() throws ServiceException {
try {
final List<JSONObject> recentArticles = articleRepository.getRecentArticles(1);
if (recentArticles.isEmpty()) {
return 0;
}
final JSONObject recentArticle = recentArticles.get(0);
return ((Date) recentArticle.get(Article.ARTICLE_UPDATE_DATE)).getTime();
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
throw new ServiceException("Gets recent article time failed");
}
}
/** /**
* Gets the specified article's author. * Gets the specified article's author.
* *
......
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