Commit d36ce8a4 authored by Liang Ding's avatar Liang Ding

#12633

parent 1d9e6775
...@@ -262,6 +262,10 @@ public class ArticleRepository extends AbstractRepository { ...@@ -262,6 +262,10 @@ public class ArticleRepository extends AbstractRepository {
*/ */
public JSONObject getPreviousArticle(final String articleId) throws RepositoryException { public JSONObject getPreviousArticle(final String articleId) throws RepositoryException {
final JSONObject currentArticle = get(articleId); final JSONObject currentArticle = get(articleId);
if (null == currentArticle) {
return null;
}
final long currentArticleCreated = currentArticle.optLong(Article.ARTICLE_CREATED); final long currentArticleCreated = currentArticle.optLong(Article.ARTICLE_CREATED);
final Query query = new Query(). final Query query = new Query().
...@@ -309,6 +313,10 @@ public class ArticleRepository extends AbstractRepository { ...@@ -309,6 +313,10 @@ public class ArticleRepository extends AbstractRepository {
*/ */
public JSONObject getNextArticle(final String articleId) throws RepositoryException { public JSONObject getNextArticle(final String articleId) throws RepositoryException {
final JSONObject currentArticle = get(articleId); final JSONObject currentArticle = get(articleId);
if (null == currentArticle) {
return null;
}
final long currentArticleCreated = currentArticle.optLong(Article.ARTICLE_CREATED); final long currentArticleCreated = currentArticle.optLong(Article.ARTICLE_CREATED);
final Query query = new Query(). final Query query = new Query().
......
...@@ -727,12 +727,19 @@ public class ArticleMgmtService { ...@@ -727,12 +727,19 @@ public class ArticleMgmtService {
if (tagIdList.isEmpty()) { // Removes all if un-specified if (tagIdList.isEmpty()) { // Removes all if un-specified
relationId = tagArticleRelation.getString(Keys.OBJECT_ID); relationId = tagArticleRelation.getString(Keys.OBJECT_ID);
tagArticleRepository.remove(relationId); tagArticleRepository.remove(relationId);
} else { } else {
if (tagIdList.contains(tagArticleRelation.getString(Tag.TAG + "_" + Keys.OBJECT_ID))) { if (tagIdList.contains(tagArticleRelation.getString(Tag.TAG + "_" + Keys.OBJECT_ID))) {
relationId = tagArticleRelation.getString(Keys.OBJECT_ID); relationId = tagArticleRelation.getString(Keys.OBJECT_ID);
tagArticleRepository.remove(relationId); tagArticleRepository.remove(relationId);
} }
} }
final String tagId = tagArticleRelation.optString(Tag.TAG + "_" + Keys.OBJECT_ID);
final int articleCount = tagArticleRepository.getArticleCount(tagId);
if (1 > articleCount) {
tagRepository.remove(tagId);
}
} }
} }
......
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