Commit 2cde50ff authored by Liang Ding's avatar Liang Ding

🎨 clean code

parent 8579f4ef
...@@ -54,7 +54,7 @@ import static org.b3log.solo.model.Article.*; ...@@ -54,7 +54,7 @@ import static org.b3log.solo.model.Article.*;
* Article management service. * Article management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.2.7, Nov 20, 2015 * @version 1.2.2.8, Jun 25, 2017
* @since 0.3.5 * @since 0.3.5
*/ */
@Service @Service
...@@ -63,7 +63,7 @@ public class ArticleMgmtService { ...@@ -63,7 +63,7 @@ public class ArticleMgmtService {
/** /**
* Logger. * Logger.
*/ */
private static final Logger LOGGER = Logger.getLogger(ArticleMgmtService.class.getName()); private static final Logger LOGGER = Logger.getLogger(ArticleMgmtService.class);
/** /**
* Article query service. * Article query service.
...@@ -155,11 +155,29 @@ public class ArticleMgmtService { ...@@ -155,11 +155,29 @@ public class ArticleMgmtService {
@Inject @Inject
private TagMgmtService tagMgmtService; private TagMgmtService tagMgmtService;
/**
* Determines whether the specified tag title exists in the specified tags.
*
* @param tagTitle the specified tag title
* @param tags the specified tags
* @return {@code true} if it exists, {@code false} otherwise
* @throws JSONException json exception
*/
private static boolean tagExists(final String tagTitle, final List<JSONObject> tags) throws JSONException {
for (final JSONObject tag : tags) {
if (tag.getString(Tag.TAG_TITLE).equals(tagTitle)) {
return true;
}
}
return false;
}
/** /**
* Article comment count +1 for an article specified by the given article id. * Article comment count +1 for an article specified by the given article id.
* *
* @param articleId the given article id * @param articleId the given article id
* @throws JSONException json exception * @throws JSONException json exception
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
public void incArticleCommentCount(final String articleId) throws JSONException, RepositoryException { public void incArticleCommentCount(final String articleId) throws JSONException, RepositoryException {
...@@ -216,8 +234,8 @@ public class ArticleMgmtService { ...@@ -216,8 +234,8 @@ public class ArticleMgmtService {
* Puts an article specified by the given article id to top or cancel top. * Puts an article specified by the given article id to top or cancel top.
* *
* @param articleId the given article id * @param articleId the given article id
* @param top the specified flag, {@code true} to top, {@code false} to * @param top the specified flag, {@code true} to top, {@code false} to
* cancel top * cancel top
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public void topArticle(final String articleId, final boolean top) throws ServiceException { public void topArticle(final String articleId, final boolean top) throws ServiceException {
...@@ -245,23 +263,21 @@ public class ArticleMgmtService { ...@@ -245,23 +263,21 @@ public class ArticleMgmtService {
* Updates an article by the specified request json object. * Updates an article by the specified request json object.
* *
* @param requestJSONObject the specified request json object, for example, * @param requestJSONObject the specified request json object, for example,
* <pre> * {
* { * "article": {
* "article": { * "oId": "",
* "oId": "", * "articleTitle": "",
* "articleTitle": "", * "articleAbstract": "",
* "articleAbstract": "", * "articleContent": "",
* "articleContent": "", * "articleTags": "tag1,tag2,tag3",
* "articleTags": "tag1,tag2,tag3", * "articlePermalink": "", // optional
* "articlePermalink": "", // optional * "articleIsPublished": boolean,
* "articleIsPublished": boolean, * "articleSignId": "", // optional
* "articleSignId": "", // optional * "articleCommentable": boolean,
* "articleCommentable": boolean, * "articleViewPwd": "",
* "articleViewPwd": "", * "articleEditorType": "" // optional, preference specified if not exists this key
* "articleEditorType": "" // optional, preference specified if not exists this key * }
* } * }
* }
* </pre>
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public void updateArticle(final JSONObject requestJSONObject) throws ServiceException { public void updateArticle(final JSONObject requestJSONObject) throws ServiceException {
...@@ -273,7 +289,7 @@ public class ArticleMgmtService { ...@@ -273,7 +289,7 @@ public class ArticleMgmtService {
final JSONObject article = requestJSONObject.getJSONObject(ARTICLE); final JSONObject article = requestJSONObject.getJSONObject(ARTICLE);
final String tagsString = article.optString(Article.ARTICLE_TAGS_REF); final String tagsString = article.optString(Article.ARTICLE_TAGS_REF);
article.put(Article.ARTICLE_TAGS_REF, tagsString.replaceAll(",", ",").replaceAll("、", ",")); article.put(Article.ARTICLE_TAGS_REF, tagsString.replaceAll(",", ",").replaceAll("、", ","));
final String articleId = article.getString(Keys.OBJECT_ID); final String articleId = article.getString(Keys.OBJECT_ID);
// Set permalink // Set permalink
final JSONObject oldArticle = articleRepository.get(articleId); final JSONObject oldArticle = articleRepository.get(articleId);
...@@ -361,7 +377,7 @@ public class ArticleMgmtService { ...@@ -361,7 +377,7 @@ public class ArticleMgmtService {
eventData.put(ARTICLE, article); eventData.put(ARTICLE, article);
eventData.put(Keys.RESULTS, ret); eventData.put(Keys.RESULTS, ret);
try { try {
eventManager.fireEventSynchronously(new Event<JSONObject>(EventTypes.ADD_ARTICLE, eventData)); eventManager.fireEventSynchronously(new Event<>(EventTypes.ADD_ARTICLE, eventData));
} catch (final EventException e) { } catch (final EventException e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); LOGGER.log(Level.ERROR, e.getMessage(), e);
} }
...@@ -372,7 +388,7 @@ public class ArticleMgmtService { ...@@ -372,7 +388,7 @@ public class ArticleMgmtService {
eventData.put(ARTICLE, article); eventData.put(ARTICLE, article);
eventData.put(Keys.RESULTS, ret); eventData.put(Keys.RESULTS, ret);
try { try {
eventManager.fireEventSynchronously(new Event<JSONObject>(EventTypes.UPDATE_ARTICLE, eventData)); eventManager.fireEventSynchronously(new Event<>(EventTypes.UPDATE_ARTICLE, eventData));
} catch (final EventException e) { } catch (final EventException e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); LOGGER.log(Level.ERROR, e.getMessage(), e);
} }
...@@ -402,25 +418,23 @@ public class ArticleMgmtService { ...@@ -402,25 +418,23 @@ public class ArticleMgmtService {
* Adds an article from the specified request json object. * Adds an article from the specified request json object.
* *
* @param requestJSONObject the specified request json object, for example, * @param requestJSONObject the specified request json object, for example,
* <pre> * {
* { * "article": {
* "article": { * "articleAuthorEmail": "",
* "articleAuthorEmail": "", * "articleTitle": "",
* "articleTitle": "", * "articleAbstract": "",
* "articleAbstract": "", * "articleContent": "",
* "articleContent": "", * "articleTags": "tag1,tag2,tag3",
* "articleTags": "tag1,tag2,tag3", * "articleIsPublished": boolean,
* "articleIsPublished": boolean, * "articlePermalink": "", // optional
* "articlePermalink": "", // optional * "postToCommunity": boolean, // optional, default is true
* "postToCommunity": boolean, // optional, default is true * "articleSignId": "" // optional, default is "0",
* "articleSignId": "" // optional, default is "0", * "articleCommentable": boolean,
* "articleCommentable": boolean, * "articleViewPwd": "",
* "articleViewPwd": "", * "articleEditorType": "", // optional, preference specified if not exists this key
* "articleEditorType": "", // optional, preference specified if not exists this key * "oId": "" // optional, generate it if not exists this key
* "oId": "" // optional, generate it if not exists this key * }
* } * }
* }
* </pre>
* @return generated article id * @return generated article id
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
...@@ -534,7 +548,7 @@ public class ArticleMgmtService { ...@@ -534,7 +548,7 @@ public class ArticleMgmtService {
final JSONObject eventData = new JSONObject(); final JSONObject eventData = new JSONObject();
eventData.put(Article.ARTICLE, article); eventData.put(Article.ARTICLE, article);
eventManager.fireEventSynchronously(new Event<JSONObject>(EventTypes.ADD_ARTICLE, eventData)); eventManager.fireEventSynchronously(new Event<>(EventTypes.ADD_ARTICLE, eventData));
} }
article.remove(Common.POST_TO_COMMUNITY); article.remove(Common.POST_TO_COMMUNITY);
...@@ -602,7 +616,7 @@ public class ArticleMgmtService { ...@@ -602,7 +616,7 @@ public class ArticleMgmtService {
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public void updateArticlesRandomValue(final int updateCnt) public void updateArticlesRandomValue(final int updateCnt)
throws ServiceException { throws ServiceException {
final Transaction transaction = articleRepository.beginTransaction(); final Transaction transaction = articleRepository.beginTransaction();
try { try {
...@@ -628,7 +642,7 @@ public class ArticleMgmtService { ...@@ -628,7 +642,7 @@ public class ArticleMgmtService {
/** /**
* Increments the view count of the article specified by the given article id. * Increments the view count of the article specified by the given article id.
* *
* @param articleId the given article id * @param articleId the given article id
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
...@@ -728,7 +742,7 @@ public class ArticleMgmtService { ...@@ -728,7 +742,7 @@ public class ArticleMgmtService {
archiveDateRepository.remove(archiveDateId); archiveDateRepository.remove(archiveDateId);
} else { } else {
final JSONObject newArchiveDate = new JSONObject(archiveDate, final JSONObject newArchiveDate = new JSONObject(archiveDate,
CollectionUtils.jsonArrayToArray(archiveDate.names(), String[].class)); CollectionUtils.jsonArrayToArray(archiveDate.names(), String[].class));
newArchiveDate.put(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT, archiveDateArticleCnt); newArchiveDate.put(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT, archiveDateArticleCnt);
newArchiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, archiveDatePublishedArticleCnt); newArchiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, archiveDatePublishedArticleCnt);
...@@ -773,11 +787,11 @@ public class ArticleMgmtService { ...@@ -773,11 +787,11 @@ public class ArticleMgmtService {
/** /**
* Processes tags for article update. * Processes tags for article update.
* * <p>
* <ul> * <ul>
* <li>Un-tags old article, decrements tag reference count</li> * <li>Un-tags old article, decrements tag reference count</li>
* <li>Removes old article-tag relations</li> * <li>Removes old article-tag relations</li>
* <li>Saves new article-tag relations with tag reference count</li> * <li>Saves new article-tag relations with tag reference count</li>
* </ul> * </ul>
* *
* @param oldArticle the specified old article * @param oldArticle the specified old article
...@@ -789,7 +803,7 @@ public class ArticleMgmtService { ...@@ -789,7 +803,7 @@ public class ArticleMgmtService {
final List<JSONObject> oldTags = tagRepository.getByArticleId(oldArticleId); final List<JSONObject> oldTags = tagRepository.getByArticleId(oldArticleId);
final String tagsString = newArticle.getString(Article.ARTICLE_TAGS_REF); final String tagsString = newArticle.getString(Article.ARTICLE_TAGS_REF);
String[] tagStrings = tagsString.split(","); String[] tagStrings = tagsString.split(",");
final List<JSONObject> newTags = new ArrayList<JSONObject>(); final List<JSONObject> newTags = new ArrayList<>();
for (int i = 0; i < tagStrings.length; i++) { for (int i = 0; i < tagStrings.length; i++) {
final String tagTitle = tagStrings[i].trim(); final String tagTitle = tagStrings[i].trim();
...@@ -802,9 +816,9 @@ public class ArticleMgmtService { ...@@ -802,9 +816,9 @@ public class ArticleMgmtService {
newTags.add(newTag); newTags.add(newTag);
} }
final List<JSONObject> tagsDropped = new ArrayList<JSONObject>(); final List<JSONObject> tagsDropped = new ArrayList<>();
final List<JSONObject> tagsNeedToAdd = new ArrayList<JSONObject>(); final List<JSONObject> tagsNeedToAdd = new ArrayList<>();
final List<JSONObject> tagsUnchanged = new ArrayList<JSONObject>(); final List<JSONObject> tagsUnchanged = new ArrayList<>();
for (final JSONObject newTag : newTags) { for (final JSONObject newTag : newTags) {
final String newTagTitle = newTag.getString(Tag.TAG_TITLE); final String newTagTitle = newTag.getString(Tag.TAG_TITLE);
...@@ -872,7 +886,7 @@ public class ArticleMgmtService { ...@@ -872,7 +886,7 @@ public class ArticleMgmtService {
tagIdsDropped[i] = id; tagIdsDropped[i] = id;
} }
removeTagArticleRelations(oldArticleId, 0 == tagIdsDropped.length ? new String[] {"l0y0l"} : tagIdsDropped); removeTagArticleRelations(oldArticleId, 0 == tagIdsDropped.length ? new String[]{"l0y0l"} : tagIdsDropped);
tagStrings = new String[tagsNeedToAdd.size()]; tagStrings = new String[tagsNeedToAdd.size()];
for (int i = 0; i < tagStrings.length; i++) { for (int i = 0; i < tagStrings.length; i++) {
...@@ -888,18 +902,18 @@ public class ArticleMgmtService { ...@@ -888,18 +902,18 @@ public class ArticleMgmtService {
/** /**
* Removes tag-article relations by the specified article id and tag ids of the relations to be removed. * Removes tag-article relations by the specified article id and tag ids of the relations to be removed.
* * <p>
* <p> * <p>
* Removes all relations if not specified the tag ids. * Removes all relations if not specified the tag ids.
* </p> * </p>
* *
* @param articleId the specified article id * @param articleId the specified article id
* @param tagIds the specified tag ids of the relations to be removed * @param tagIds the specified tag ids of the relations to be removed
* @throws JSONException json exception * @throws JSONException json exception
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
private void removeTagArticleRelations(final String articleId, final String... tagIds) private void removeTagArticleRelations(final String articleId, final String... tagIds)
throws JSONException, RepositoryException { throws JSONException, RepositoryException {
final List<String> tagIdList = Arrays.asList(tagIds); final List<String> tagIdList = Arrays.asList(tagIds);
final List<JSONObject> tagArticleRelations = tagArticleRepository.getByArticleId(articleId); final List<JSONObject> tagArticleRelations = tagArticleRepository.getByArticleId(articleId);
...@@ -922,7 +936,7 @@ public class ArticleMgmtService { ...@@ -922,7 +936,7 @@ public class ArticleMgmtService {
/** /**
* Adds relation of the specified tags and article. * Adds relation of the specified tags and article.
* *
* @param tags the specified tags * @param tags the specified tags
* @param article the specified article * @param article the specified article
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
...@@ -942,7 +956,7 @@ public class ArticleMgmtService { ...@@ -942,7 +956,7 @@ public class ArticleMgmtService {
* Tags the specified article with the specified tag titles. * Tags the specified article with the specified tag titles.
* *
* @param tagTitles the specified tag titles * @param tagTitles the specified tag titles
* @param article the specified article * @param article the specified article
* @return an array of tags * @return an array of tags
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
...@@ -996,12 +1010,12 @@ public class ArticleMgmtService { ...@@ -996,12 +1010,12 @@ public class ArticleMgmtService {
/** /**
* Removes article comments by the specified article id. * Removes article comments by the specified article id.
* * <p>
* <p> Removes related comments, sets article/blog comment statistic count. * <p> Removes related comments, sets article/blog comment statistic count.
* </p> * </p>
* *
* @param articleId the specified article id * @param articleId the specified article id
* @throws JSONException json exception * @throws JSONException json exception
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
private void removeArticleComments(final String articleId) throws JSONException, RepositoryException { private void removeArticleComments(final String articleId) throws JSONException, RepositoryException {
...@@ -1021,36 +1035,16 @@ public class ArticleMgmtService { ...@@ -1021,36 +1035,16 @@ public class ArticleMgmtService {
} }
} }
/**
* Determines whether the specified tag title exists in the specified tags.
*
* @param tagTitle the specified tag title
* @param tags the specified tags
* @return {@code true} if it exists, {@code false} otherwise
* @throws JSONException json exception
*/
private static boolean tagExists(final String tagTitle, final List<JSONObject> tags) throws JSONException {
for (final JSONObject tag : tags) {
if (tag.getString(Tag.TAG_TITLE).equals(tagTitle)) {
return true;
}
}
return false;
}
/** /**
* Archive the create date with the specified article. * Archive the create date with the specified article.
* *
* @param article the specified article, for example, * @param article the specified article, for example,
* <pre> * {
* { * ....,
* ...., * "oId": "",
* "oId": "", * "articleCreateDate": java.util.Date,
* "articleCreateDate": java.util.Date, * ....
* .... * }
* }
* </pre>
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
private void archiveDate(final JSONObject article) throws RepositoryException { private void archiveDate(final JSONObject article) throws RepositoryException {
...@@ -1061,7 +1055,7 @@ public class ArticleMgmtService { ...@@ -1061,7 +1055,7 @@ public class ArticleMgmtService {
if (null == archiveDate) { if (null == archiveDate) {
archiveDate = new JSONObject(); archiveDate = new JSONObject();
try { try {
archiveDate.put(ArchiveDate.ARCHIVE_TIME, DateUtils.parseDate(createDateString, new String[] {"yyyy/MM"}).getTime()); archiveDate.put(ArchiveDate.ARCHIVE_TIME, DateUtils.parseDate(createDateString, new String[]{"yyyy/MM"}).getTime());
archiveDate.put(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT, 0); archiveDate.put(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT, 0);
archiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, 0); archiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, 0);
...@@ -1077,7 +1071,7 @@ public class ArticleMgmtService { ...@@ -1077,7 +1071,7 @@ public class ArticleMgmtService {
newArchiveDate.put(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT, archiveDate.optInt(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT) + 1); newArchiveDate.put(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT, archiveDate.optInt(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT) + 1);
if (article.optBoolean(Article.ARTICLE_IS_PUBLISHED)) { if (article.optBoolean(Article.ARTICLE_IS_PUBLISHED)) {
newArchiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, newArchiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT,
archiveDate.optInt(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT) + 1); archiveDate.optInt(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT) + 1);
} }
archiveDateRepository.update(archiveDate.optString(Keys.OBJECT_ID), newArchiveDate); archiveDateRepository.update(archiveDate.optString(Keys.OBJECT_ID), newArchiveDate);
...@@ -1091,16 +1085,17 @@ public class ArticleMgmtService { ...@@ -1091,16 +1085,17 @@ public class ArticleMgmtService {
/** /**
* Fills 'auto' properties for the specified article and old article. * Fills 'auto' properties for the specified article and old article.
* * <p>
* <p> Some properties of an article are not been changed while article * Some properties of an article are not been changed while article
* updating, these properties are called 'auto' properties. </p> * updating, these properties are called 'auto' properties.
* * </p>
* <p> The property(named {@value * <p>
* org.b3log.solo.model.Article#ARTICLE_RANDOM_DOUBLE}) of the specified * The property(named {@value org.b3log.solo.model.Article#ARTICLE_RANDOM_DOUBLE}) of the specified
* article will be regenerated. </p> * article will be regenerated.
* </p>
* *
* @param oldArticle the specified old article * @param oldArticle the specified old article
* @param article the specified article * @param article the specified article
* @throws JSONException json exception * @throws JSONException json exception
*/ */
private void fillAutoProperties(final JSONObject oldArticle, final JSONObject article) throws JSONException { private void fillAutoProperties(final JSONObject oldArticle, final JSONObject article) throws JSONException {
...@@ -1116,8 +1111,7 @@ public class ArticleMgmtService { ...@@ -1116,8 +1111,7 @@ public class ArticleMgmtService {
} }
/** /**
* Gets article permalink for adding article with the specified * Gets article permalink for adding article with the specified article.
* article.
* *
* @param article the specified article * @param article the specified article
* @return permalink * @return permalink
...@@ -1148,18 +1142,17 @@ public class ArticleMgmtService { ...@@ -1148,18 +1142,17 @@ public class ArticleMgmtService {
} }
/** /**
* Gets article permalink for updating article with the specified * Gets article permalink for updating article with the specified old article, article, create date.
* old article, article, create date.
* *
* @param oldArticle the specified old article * @param oldArticle the specified old article
* @param article the specified article * @param article the specified article
* @param createDate the specified create date * @param createDate the specified create date
* @return permalink * @return permalink
* @throws ServiceException if invalid permalink occurs * @throws ServiceException if invalid permalink occurs
* @throws JSONException json exception * @throws JSONException json exception
*/ */
private String getPermalinkForUpdateArticle(final JSONObject oldArticle, final JSONObject article, final Date createDate) private String getPermalinkForUpdateArticle(final JSONObject oldArticle, final JSONObject article, final Date createDate)
throws ServiceException, JSONException { throws ServiceException, JSONException {
final String articleId = article.getString(Keys.OBJECT_ID); final String articleId = article.getString(Keys.OBJECT_ID);
String ret = article.optString(ARTICLE_PERMALINK).trim(); String ret = article.optString(ARTICLE_PERMALINK).trim();
final String oldPermalink = oldArticle.getString(ARTICLE_PERMALINK); final String oldPermalink = oldArticle.getString(ARTICLE_PERMALINK);
...@@ -1186,46 +1179,44 @@ public class ArticleMgmtService { ...@@ -1186,46 +1179,44 @@ public class ArticleMgmtService {
} }
/** /**
* Decrements reference count of archive date of an published article * Decrements reference count of archive date of an published article specified by the given article id.
* specified by the given article id.
* *
* @param articleId the given article id * @param articleId the given article id
* @throws JSONException json exception * @throws JSONException json exception
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
private void decArchiveDatePublishedRefCount(final String articleId) private void decArchiveDatePublishedRefCount(final String articleId)
throws JSONException, RepositoryException { throws JSONException, RepositoryException {
final JSONObject archiveDateArticleRelation = archiveDateArticleRepository.getByArticleId(articleId); final JSONObject archiveDateArticleRelation = archiveDateArticleRepository.getByArticleId(articleId);
final String archiveDateId = archiveDateArticleRelation.getString(ArchiveDate.ARCHIVE_DATE + "_" + Keys.OBJECT_ID); final String archiveDateId = archiveDateArticleRelation.getString(ArchiveDate.ARCHIVE_DATE + "_" + Keys.OBJECT_ID);
final JSONObject archiveDate = archiveDateRepository.get(archiveDateId); final JSONObject archiveDate = archiveDateRepository.get(archiveDateId);
archiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, archiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT,
archiveDate.getInt(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT) - 1); archiveDate.getInt(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT) - 1);
archiveDateRepository.update(archiveDateId, archiveDate); archiveDateRepository.update(archiveDateId, archiveDate);
} }
/** /**
* Increments reference count of archive date of an published article * Increments reference count of archive date of an published article specified by the given article id.
* specified by the given article id.
* *
* @param articleId the given article id * @param articleId the given article id
* @throws JSONException json exception * @throws JSONException json exception
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
private void incArchiveDatePublishedRefCount(final String articleId) private void incArchiveDatePublishedRefCount(final String articleId)
throws JSONException, RepositoryException { throws JSONException, RepositoryException {
final JSONObject archiveDateArticleRelation = archiveDateArticleRepository.getByArticleId(articleId); final JSONObject archiveDateArticleRelation = archiveDateArticleRepository.getByArticleId(articleId);
final String archiveDateId = archiveDateArticleRelation.getString(ArchiveDate.ARCHIVE_DATE + "_" + Keys.OBJECT_ID); final String archiveDateId = archiveDateArticleRelation.getString(ArchiveDate.ARCHIVE_DATE + "_" + Keys.OBJECT_ID);
final JSONObject archiveDate = archiveDateRepository.get(archiveDateId); final JSONObject archiveDate = archiveDateRepository.get(archiveDateId);
archiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, archiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT,
archiveDate.getInt(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT) + 1); archiveDate.getInt(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT) + 1);
archiveDateRepository.update(archiveDateId, archiveDate); archiveDateRepository.update(archiveDateId, archiveDate);
} }
/** /**
* Sets archive date article repository with the specified archive date article repository. * Sets archive date article repository with the specified archive date article repository.
* *
* @param archiveDateArticleRepository the specified archive date article repository * @param archiveDateArticleRepository the specified archive date article repository
*/ */
public void setArchiveDateArticleRepository(final ArchiveDateArticleRepository archiveDateArticleRepository) { public void setArchiveDateArticleRepository(final ArchiveDateArticleRepository archiveDateArticleRepository) {
...@@ -1234,7 +1225,7 @@ public class ArticleMgmtService { ...@@ -1234,7 +1225,7 @@ public class ArticleMgmtService {
/** /**
* Sets archive date repository with the specified archive date repository. * Sets archive date repository with the specified archive date repository.
* *
* @param archiveDateRepository the specified archive date repository * @param archiveDateRepository the specified archive date repository
*/ */
public void setArchiveDateRepository(final ArchiveDateRepository archiveDateRepository) { public void setArchiveDateRepository(final ArchiveDateRepository archiveDateRepository) {
...@@ -1243,7 +1234,7 @@ public class ArticleMgmtService { ...@@ -1243,7 +1234,7 @@ public class ArticleMgmtService {
/** /**
* Sets the article repository with the specified article repository. * Sets the article repository with the specified article repository.
* *
* @param articleRepository the specified article repository * @param articleRepository the specified article repository
*/ */
public void setArticleRepository(final ArticleRepository articleRepository) { public void setArticleRepository(final ArticleRepository articleRepository) {
...@@ -1252,7 +1243,7 @@ public class ArticleMgmtService { ...@@ -1252,7 +1243,7 @@ public class ArticleMgmtService {
/** /**
* Sets the article query service with the specified article query service. * Sets the article query service with the specified article query service.
* *
* @param articleQueryService the specified article query service * @param articleQueryService the specified article query service
*/ */
public void setArticleQueryService(final ArticleQueryService articleQueryService) { public void setArticleQueryService(final ArticleQueryService articleQueryService) {
...@@ -1261,7 +1252,7 @@ public class ArticleMgmtService { ...@@ -1261,7 +1252,7 @@ public class ArticleMgmtService {
/** /**
* Sets the permalink query service with the specified permalink query service. * Sets the permalink query service with the specified permalink query service.
* *
* @param permalinkQueryService the specified permalink query service * @param permalinkQueryService the specified permalink query service
*/ */
public void setPermalinkQueryService(final PermalinkQueryService permalinkQueryService) { public void setPermalinkQueryService(final PermalinkQueryService permalinkQueryService) {
...@@ -1270,7 +1261,7 @@ public class ArticleMgmtService { ...@@ -1270,7 +1261,7 @@ public class ArticleMgmtService {
/** /**
* Sets the user repository with the specified user repository. * Sets the user repository with the specified user repository.
* *
* @param userRepository the specified user repository * @param userRepository the specified user repository
*/ */
public void setUserRepository(final UserRepository userRepository) { public void setUserRepository(final UserRepository userRepository) {
...@@ -1279,7 +1270,7 @@ public class ArticleMgmtService { ...@@ -1279,7 +1270,7 @@ public class ArticleMgmtService {
/** /**
* Sets the preference query service with the specified preference query service. * Sets the preference query service with the specified preference query service.
* *
* @param preferenceQueryService the specified preference query service * @param preferenceQueryService the specified preference query service
*/ */
public void setPreferenceQueryService(final PreferenceQueryService preferenceQueryService) { public void setPreferenceQueryService(final PreferenceQueryService preferenceQueryService) {
...@@ -1288,7 +1279,7 @@ public class ArticleMgmtService { ...@@ -1288,7 +1279,7 @@ public class ArticleMgmtService {
/** /**
* Sets the statistic management service with the specified statistic management service. * Sets the statistic management service with the specified statistic management service.
* *
* @param statisticMgmtService the specified statistic management service * @param statisticMgmtService the specified statistic management service
*/ */
public void setStatisticMgmtService(final StatisticMgmtService statisticMgmtService) { public void setStatisticMgmtService(final StatisticMgmtService statisticMgmtService) {
...@@ -1297,7 +1288,7 @@ public class ArticleMgmtService { ...@@ -1297,7 +1288,7 @@ public class ArticleMgmtService {
/** /**
* Sets the statistic query service with the specified statistic query service. * Sets the statistic query service with the specified statistic query service.
* *
* @param statisticQueryService the specified statistic query service * @param statisticQueryService the specified statistic query service
*/ */
public void setStatisticQueryService(final StatisticQueryService statisticQueryService) { public void setStatisticQueryService(final StatisticQueryService statisticQueryService) {
...@@ -1306,7 +1297,7 @@ public class ArticleMgmtService { ...@@ -1306,7 +1297,7 @@ public class ArticleMgmtService {
/** /**
* Sets the tag repository with the specified tag repository. * Sets the tag repository with the specified tag repository.
* *
* @param tagRepository the specified tag repository * @param tagRepository the specified tag repository
*/ */
public void setTagRepository(final TagRepository tagRepository) { public void setTagRepository(final TagRepository tagRepository) {
...@@ -1315,7 +1306,7 @@ public class ArticleMgmtService { ...@@ -1315,7 +1306,7 @@ public class ArticleMgmtService {
/** /**
* Sets the tag article repository with the specified tag article repository. * Sets the tag article repository with the specified tag article repository.
* *
* @param tagArticleRepository the specified tag article repository * @param tagArticleRepository the specified tag article repository
*/ */
public void setTagArticleRepository(final TagArticleRepository tagArticleRepository) { public void setTagArticleRepository(final TagArticleRepository tagArticleRepository) {
...@@ -1324,7 +1315,7 @@ public class ArticleMgmtService { ...@@ -1324,7 +1315,7 @@ public class ArticleMgmtService {
/** /**
* Sets tag management service with the specified tag management service. * Sets tag management service with the specified tag management service.
* *
* @param tagMgmtService the specified tag management service * @param tagMgmtService the specified tag management service
*/ */
public void setTagMgmtService(final TagMgmtService tagMgmtService) { public void setTagMgmtService(final TagMgmtService tagMgmtService) {
...@@ -1333,7 +1324,7 @@ public class ArticleMgmtService { ...@@ -1333,7 +1324,7 @@ public class ArticleMgmtService {
/** /**
* Sets the comment repository with the specified comment repository. * Sets the comment repository with the specified comment repository.
* *
* @param commentRepository the specified comment repository * @param commentRepository the specified comment repository
*/ */
public void setCommentRepository(final CommentRepository commentRepository) { public void setCommentRepository(final CommentRepository commentRepository) {
...@@ -1342,7 +1333,7 @@ public class ArticleMgmtService { ...@@ -1342,7 +1333,7 @@ public class ArticleMgmtService {
/** /**
* Sets the language service with the specified language service. * Sets the language service with the specified language service.
* *
* @param langPropsService the specified language service * @param langPropsService the specified language service
*/ */
public void setLangPropsService(final LangPropsService langPropsService) { public void setLangPropsService(final LangPropsService langPropsService) {
......
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