Commit e8235eef authored by Liang Ding's avatar Liang Ding

#12509 文章时间字段

parent eaea8f98
......@@ -68,7 +68,7 @@ import java.util.List;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.17, Aug 2, 2018
* @version 1.0.0.18, Sep 16, 2018
* @since 0.4.0
*/
@RequestProcessor
......@@ -346,7 +346,7 @@ public class MetaWeblogAPI {
+ "pattern[yyyy-MM-dd'T'HH:mm:ss, yyyyMMdd'T'HH:mm:ss'Z']");
date = DateUtils.parseDate(dateString, new String[]{"yyyyMMdd'T'HH:mm:ss", "yyyyMMdd'T'HH:mm:ss'Z'"});
}
ret.put(Article.ARTICLE_CREATE_DATE, date);
ret.put(Article.ARTICLE_CREATED, date.getTime());
} else if ("title".equals(name)) {
ret.put(Article.ARTICLE_TITLE, member.getJSONObject("value").getString("string"));
} else if ("description".equals(name)) {
......@@ -456,7 +456,7 @@ public class MetaWeblogAPI {
}
final JSONObject article = result.getJSONObject(Article.ARTICLE);
final Date createDate = (Date) article.get(Article.ARTICLE_CREATE_DATE);
final long createDate = article.getLong(Article.ARTICLE_CREATED);
final String articleTitle = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
stringBuilder.append("<struct>");
......@@ -488,7 +488,7 @@ public class MetaWeblogAPI {
final StringBuilder stringBuilder = new StringBuilder();
final List<JSONObject> recentArticles = articleQueryService.getRecentArticles(fetchSize);
for (final JSONObject article : recentArticles) {
final Date createDate = (Date) article.get(Article.ARTICLE_CREATE_DATE);
final long createDate = article.getLong(Article.ARTICLE_CREATED);
final String articleTitle = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
stringBuilder.append("<value><struct>");
......
......@@ -37,12 +37,11 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
/**
* Generates some dummy articles for development testing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.6, Apr 15, 2018
* @version 1.0.0.7, Sep 16, 2018
* @since 0.4.0
*/
@RequestProcessor
......@@ -112,8 +111,8 @@ public class ArticleGenerator {
final int deviationDay = -(Integer.valueOf(String.valueOf(i).substring(0, 1)) % deviationBase);
final Date date = DateUtils.addMonths(new Date(), deviationDay);
article.put(Article.ARTICLE_CREATE_DATE, date);
article.put(Article.ARTICLE_UPDATE_DATE, date);
article.put(Article.ARTICLE_CREATED, date.getTime());
article.put(Article.ARTICLE_UPDATED, date.getTime());
article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random());
article.put(Article.ARTICLE_COMMENTABLE, true);
article.put(Article.ARTICLE_VIEW_PWD, "");
......
......@@ -48,7 +48,7 @@ import java.util.Date;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author ArmstrongCN
* @version 1.0.2.13, Aug 2, 2018
* @version 1.0.2.14, Sep 16, 2018
* @since 0.3.1
*/
public final class ArticleSender extends AbstractEventListener<JSONObject> {
......@@ -104,7 +104,7 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> {
article.put(Article.ARTICLE_TAGS_REF, originalArticle.getString(Article.ARTICLE_TAGS_REF));
article.put(Article.ARTICLE_AUTHOR_EMAIL, originalArticle.getString(Article.ARTICLE_AUTHOR_EMAIL));
article.put(Article.ARTICLE_CONTENT, originalArticle.getString(Article.ARTICLE_CONTENT));
article.put(Article.ARTICLE_CREATE_DATE, ((Date) originalArticle.get(Article.ARTICLE_CREATE_DATE)).getTime());
article.put(Article.ARTICLE_T_CREATE_DATE, originalArticle.getLong(Article.ARTICLE_CREATED));
article.put(Common.POST_TO_COMMUNITY, originalArticle.getBoolean(Common.POST_TO_COMMUNITY));
// Removes this property avoid to persist
......
......@@ -38,8 +38,6 @@ import org.b3log.solo.service.PreferenceQueryService;
import org.b3log.solo.util.Solos;
import org.json.JSONObject;
import java.util.Date;
/**
* This listener is responsible for updating article to B3log Rhythm.
* <p>
......@@ -47,7 +45,7 @@ import java.util.Date;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.3, Aug 2, 2018
* @version 1.0.1.4, Sep 16, 2018
* @since 0.6.0
*/
public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
......@@ -102,7 +100,7 @@ public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
article.put(Article.ARTICLE_TAGS_REF, originalArticle.getString(Article.ARTICLE_TAGS_REF));
article.put(Article.ARTICLE_AUTHOR_EMAIL, originalArticle.getString(Article.ARTICLE_AUTHOR_EMAIL));
article.put(Article.ARTICLE_CONTENT, originalArticle.getString(Article.ARTICLE_CONTENT));
article.put(Article.ARTICLE_CREATE_DATE, ((Date) originalArticle.get(Article.ARTICLE_CREATE_DATE)).getTime());
article.put(Article.ARTICLE_T_CREATE_DATE, originalArticle.getLong(Article.ARTICLE_CREATED));
article.put(Common.POST_TO_COMMUNITY, originalArticle.getBoolean(Common.POST_TO_COMMUNITY));
// Removes this property avoid to persist
......
......@@ -25,7 +25,7 @@ import org.jsoup.safety.Whitelist;
* This class defines all article model relevant keys.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.6, Jun 25, 2017
* @version 1.2.0.0, Sep 16, 2018
* @since 0.3.1
*/
public final class Article {
......@@ -55,20 +55,30 @@ public final class Article {
*/
public static final String ARTICLE_CONTENT = "articleContent";
/**
* Key of created at.
*/
public static final String ARTICLE_CREATED = "articleCreated";
/**
* Key of create date.
*/
public static final String ARTICLE_CREATE_DATE = "articleCreateDate";
public static final String ARTICLE_T_CREATE_DATE = "articleCreateDate";
/**
* Key of create time.
*/
public static final String ARTICLE_CREATE_TIME = "articleCreateTime";
/**
* Key of updated at.
*/
public static final String ARTICLE_UPDATED = "articleUpdated";
/**
* Key of update date.
*/
public static final String ARTICLE_UPDATE_DATE = "articleUpdateDate";
public static final String ARTICLE_T_UPDATE_DATE = "articleUpdateDate";
/**
* Key of update time.
......
......@@ -51,7 +51,7 @@ import java.util.Set;
* Blog processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.1.3, Aug 2, 2018
* @version 1.3.1.4, Sep 16, 2018
* @since 0.4.6
*/
@RequestProcessor
......@@ -223,8 +223,8 @@ public class BlogProcessor {
final JSONArray excludes = new JSONArray();
excludes.put(Article.ARTICLE_CONTENT);
excludes.put(Article.ARTICLE_UPDATE_DATE);
excludes.put(Article.ARTICLE_CREATE_DATE);
excludes.put(Article.ARTICLE_UPDATED);
excludes.put(Article.ARTICLE_CREATED);
excludes.put(Article.ARTICLE_AUTHOR_EMAIL);
excludes.put(Article.ARTICLE_HAD_BEEN_PUBLISHED);
excludes.put(Article.ARTICLE_IS_PUBLISHED);
......
......@@ -64,7 +64,7 @@ import java.util.List;
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://github.com/feroozkhanchintu">feroozkhanchintu</a>
* @author <a href="https://github.com/nanolikeyou">nanolikeyou</a>
* @version 1.1.1.0, May 18, 2018
* @version 1.1.1.1, Sep 16, 2018
* @since 0.3.1
*/
@RequestProcessor
......@@ -142,8 +142,9 @@ public class FeedProcessor {
filters.add(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true));
filters.add(new PropertyFilter(Article.ARTICLE_VIEW_PWD, FilterOperator.EQUAL, ""));
final Query query = new Query().setCurrentPageNum(1).setPageSize(outputCnt).setFilter(new CompositeFilter(CompositeFilterOperator.AND, filters)).addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).setPageCount(
1);
final Query query = new Query().setCurrentPageNum(1).setPageSize(outputCnt).
setFilter(new CompositeFilter(CompositeFilterOperator.AND, filters)).
addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING).setPageCount(1);
final boolean hasMultipleUsers = userQueryService.hasMultipleUsers();
String authorName = "";
......@@ -184,8 +185,8 @@ public class FeedProcessor {
final String summary = isFullContent ? article.getString(Article.ARTICLE_CONTENT)
: article.optString(Article.ARTICLE_ABSTRACT);
ret.setSummary(summary);
final Date updated = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
ret.setUpdated(updated);
final long updated = article.getLong(Article.ARTICLE_UPDATED);
ret.setUpdated(new Date(updated));
final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
ret.setLink(link);
ret.setId(link);
......@@ -311,8 +312,8 @@ public class FeedProcessor {
final String summary = isFullContent ? article.getString(Article.ARTICLE_CONTENT)
: article.optString(Article.ARTICLE_ABSTRACT);
ret.setSummary(summary);
final Date updated = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
ret.setUpdated(updated);
final long updated = article.getLong(Article.ARTICLE_UPDATED);
ret.setUpdated(new Date(updated));
final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
ret.setLink(link);
ret.setId(link);
......@@ -371,8 +372,9 @@ public class FeedProcessor {
filters.add(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true));
filters.add(new PropertyFilter(Article.ARTICLE_VIEW_PWD, FilterOperator.EQUAL, ""));
final Query query = new Query().setCurrentPageNum(1).setPageSize(outputCnt).setFilter(new CompositeFilter(CompositeFilterOperator.AND, filters)).addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).setPageCount(
1);
final Query query = new Query().setPageCount(1).setCurrentPageNum(1).setPageSize(outputCnt).
setFilter(new CompositeFilter(CompositeFilterOperator.AND, filters)).
addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING);
final JSONObject articleResult = articleRepository.get(query);
final JSONArray articles = articleResult.getJSONArray(Keys.RESULTS);
......@@ -416,8 +418,8 @@ public class FeedProcessor {
: article.optString(Article.ARTICLE_ABSTRACT);
description = Emotions.toAliases(description);
ret.setDescription(description);
final Date pubDate = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
ret.setPubDate(pubDate);
final long pubDate = article.getLong(Article.ARTICLE_UPDATED);
ret.setPubDate(new Date(pubDate));
final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
ret.setLink(link);
ret.setGUID(link);
......@@ -549,8 +551,8 @@ public class FeedProcessor {
? article.getString(Article.ARTICLE_CONTENT)
: article.optString(Article.ARTICLE_ABSTRACT);
ret.setDescription(description);
final Date pubDate = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
ret.setPubDate(pubDate);
final long pubDate = article.getLong(Article.ARTICLE_UPDATED);
ret.setPubDate(new Date(pubDate));
final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
ret.setLink(link);
ret.setGUID(link);
......
......@@ -57,7 +57,7 @@ import java.util.Date;
* Site map (sitemap) processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.2.1, Aug 2, 2018
* @version 1.0.2.2, Sep 16, 2018
* @since 0.3.1
*/
@RequestProcessor
......@@ -142,9 +142,9 @@ public class SitemapProcessor {
private void addArticles(final Sitemap sitemap) throws Exception {
final Query query = new Query().setCurrentPageNum(1).
setFilter(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true)).
addSort(Article.ARTICLE_CREATE_DATE, SortDirection.DESCENDING).
addSort(Article.ARTICLE_CREATED, SortDirection.DESCENDING).
addProjection(Article.ARTICLE_PERMALINK, String.class).
addProjection(Article.ARTICLE_UPDATE_DATE, Date.class);
addProjection(Article.ARTICLE_UPDATED, Long.class);
final JSONObject articleResult = articleRepository.get(query);
final JSONArray articles = articleResult.getJSONArray(Keys.RESULTS);
......@@ -154,8 +154,8 @@ public class SitemapProcessor {
final URL url = new URL();
url.setLoc(StringEscapeUtils.escapeXml(Latkes.getServePath() + permalink));
final Date updateDate = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
final String lastMod = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(updateDate);
final long updated = article.getLong(Article.ARTICLE_UPDATED);
final String lastMod = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(updated);
url.setLastMod(lastMod);
sitemap.addURL(url);
......
......@@ -55,7 +55,7 @@ import java.util.stream.Collectors;
* Article console request processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.0, Sep 10, 2018
* @version 1.1.1.1, Sep 16, 2018
* @since 0.4.0
*/
@RequestProcessor
......@@ -306,8 +306,8 @@ public class ArticleConsole {
final JSONArray excludes = new JSONArray();
excludes.put(Article.ARTICLE_CONTENT);
excludes.put(Article.ARTICLE_UPDATE_DATE);
excludes.put(Article.ARTICLE_CREATE_DATE);
excludes.put(Article.ARTICLE_UPDATED);
excludes.put(Article.ARTICLE_CREATED);
excludes.put(Article.ARTICLE_AUTHOR_EMAIL);
excludes.put(Article.ARTICLE_HAD_BEEN_PUBLISHED);
excludes.put(Article.ARTICLE_IS_PUBLISHED);
......
......@@ -66,7 +66,7 @@ import static org.b3log.solo.model.Article.ARTICLE_CONTENT;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.6.16.6, Sep 16, 2018
* @version 1.6.16.7, Sep 16, 2018
* @since 0.3.1
*/
@Service
......@@ -217,15 +217,15 @@ public class Filler {
} else // See https://github.com/b3log/solo/issues/179 for more details
if (Templates.hasExpression(template, "<#list articles1 as article>")) {
isArticles1 = true;
query.addSort(Article.ARTICLE_CREATE_DATE, SortDirection.DESCENDING);
query.addSort(Article.ARTICLE_CREATED, SortDirection.DESCENDING);
LOGGER.trace("Query ${articles1} in index.ftl");
} else { // <#list articles as article>
query.addSort(Article.ARTICLE_PUT_TOP, SortDirection.DESCENDING);
if (preference.getBoolean(Option.ID_C_ENABLE_ARTICLE_UPDATE_HINT)) {
query.addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING);
query.addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING);
} else {
query.addSort(Article.ARTICLE_CREATE_DATE, SortDirection.DESCENDING);
query.addSort(Article.ARTICLE_CREATED, SortDirection.DESCENDING);
}
}
......
......@@ -31,14 +31,13 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* Article repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.3.13, Aug 27, 2018
* @version 1.1.3.14, Sep 16 , 2018
* @since 0.3.1
*/
@Repository
......@@ -106,7 +105,7 @@ public class ArticleRepositoryImpl extends AbstractRepository implements Article
setFilter(CompositeFilterOperator.and(
new PropertyFilter(Article.ARTICLE_AUTHOR_EMAIL, FilterOperator.EQUAL, authorEmail),
new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true))).
addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).addSort(Article.ARTICLE_PUT_TOP, SortDirection.DESCENDING).
addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING).addSort(Article.ARTICLE_PUT_TOP, SortDirection.DESCENDING).
setCurrentPageNum(currentPageNum).setPageSize(pageSize).setPageCount(1);
return get(query);
......@@ -139,7 +138,7 @@ public class ArticleRepositoryImpl extends AbstractRepository implements Article
public List<JSONObject> getRecentArticles(final int fetchSize) throws RepositoryException {
final Query query = new Query().
setFilter(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true)).
addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).
addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING).
setCurrentPageNum(1).setPageSize(fetchSize).setPageCount(1);
return getList(query);
......@@ -149,7 +148,7 @@ public class ArticleRepositoryImpl extends AbstractRepository implements Article
public List<JSONObject> getMostCommentArticles(final int num) throws RepositoryException {
final Query query = new Query().
addSort(Article.ARTICLE_COMMENT_COUNT, SortDirection.DESCENDING).
addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).
addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING).
setFilter(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true)).
setCurrentPageNum(1).setPageSize(num).setPageCount(1);
......@@ -160,7 +159,7 @@ public class ArticleRepositoryImpl extends AbstractRepository implements Article
public List<JSONObject> getMostViewCountArticles(final int num) throws RepositoryException {
final Query query = new Query().
addSort(Article.ARTICLE_VIEW_COUNT, SortDirection.DESCENDING).
addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).
addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING).
setFilter(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true)).
setCurrentPageNum(1).setPageSize(num).setPageCount(1);
......@@ -170,13 +169,13 @@ public class ArticleRepositoryImpl extends AbstractRepository implements Article
@Override
public JSONObject getPreviousArticle(final String articleId) throws RepositoryException {
final JSONObject currentArticle = get(articleId);
final Date currentArticleCreateDate = (Date) currentArticle.opt(Article.ARTICLE_CREATE_DATE);
final long currentArticleCreated = currentArticle.optLong(Article.ARTICLE_CREATED);
final Query query = new Query().
setFilter(CompositeFilterOperator.and(
new PropertyFilter(Article.ARTICLE_CREATE_DATE, FilterOperator.LESS_THAN, currentArticleCreateDate),
new PropertyFilter(Article.ARTICLE_CREATED, FilterOperator.LESS_THAN, currentArticleCreated),
new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true))).
addSort(Article.ARTICLE_CREATE_DATE, SortDirection.DESCENDING).
addSort(Article.ARTICLE_CREATED, SortDirection.DESCENDING).
setCurrentPageNum(1).setPageSize(1).setPageCount(1).
addProjection(Article.ARTICLE_TITLE, String.class).
addProjection(Article.ARTICLE_PERMALINK, String.class).
......@@ -205,13 +204,13 @@ public class ArticleRepositoryImpl extends AbstractRepository implements Article
@Override
public JSONObject getNextArticle(final String articleId) throws RepositoryException {
final JSONObject currentArticle = get(articleId);
final Date currentArticleCreateDate = (Date) currentArticle.opt(Article.ARTICLE_CREATE_DATE);
final long currentArticleCreated = currentArticle.optLong(Article.ARTICLE_CREATED);
final Query query = new Query().
setFilter(CompositeFilterOperator.and(
new PropertyFilter(Article.ARTICLE_CREATE_DATE, FilterOperator.GREATER_THAN, currentArticleCreateDate),
new PropertyFilter(Article.ARTICLE_CREATED, FilterOperator.GREATER_THAN, currentArticleCreated),
new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true))).
addSort(Article.ARTICLE_CREATE_DATE, SortDirection.ASCENDING).
addSort(Article.ARTICLE_CREATED, SortDirection.ASCENDING).
setCurrentPageNum(1).setPageSize(1).setPageCount(1).
addProjection(Article.ARTICLE_TITLE, String.class).
addProjection(Article.ARTICLE_PERMALINK, String.class).
......
......@@ -45,7 +45,6 @@ import org.json.JSONObject;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static org.b3log.solo.model.Article.*;
......@@ -54,7 +53,7 @@ import static org.b3log.solo.model.Article.*;
* Article management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.2.11, Aug 27, 2018
* @version 1.2.2.12, Sep 16, 2018
* @since 0.3.5
*/
@Service
......@@ -297,7 +296,7 @@ public class ArticleMgmtService {
final String articleId = article.getString(Keys.OBJECT_ID);
// Set permalink
final JSONObject oldArticle = articleRepository.get(articleId);
final String permalink = getPermalinkForUpdateArticle(oldArticle, article, (Date) oldArticle.get(ARTICLE_CREATE_DATE));
final String permalink = getPermalinkForUpdateArticle(oldArticle, article, oldArticle.optLong(ARTICLE_CREATED));
article.put(ARTICLE_PERMALINK, permalink);
processTagsForArticleUpdate(oldArticle, article);
......@@ -310,9 +309,9 @@ public class ArticleMgmtService {
// Fill auto properties
fillAutoProperties(oldArticle, article);
// Set date
article.put(ARTICLE_UPDATE_DATE, oldArticle.get(ARTICLE_UPDATE_DATE));
article.put(ARTICLE_UPDATED, oldArticle.getLong(ARTICLE_UPDATED));
final JSONObject preference = preferenceQueryService.getPreference();
final Date date = new Date();
final long now = System.currentTimeMillis();
// The article to update has no sign
if (!article.has(Article.ARTICLE_SIGN_ID)) {
......@@ -322,20 +321,20 @@ public class ArticleMgmtService {
if (article.getBoolean(ARTICLE_IS_PUBLISHED)) { // Publish it
if (articleQueryService.hadBeenPublished(oldArticle)) {
// Edit update date only for published article
article.put(ARTICLE_UPDATE_DATE, date);
article.put(ARTICLE_UPDATED, now);
} else { // This article is a draft and this is the first time to publish it
article.put(ARTICLE_CREATE_DATE, date);
article.put(ARTICLE_UPDATE_DATE, date);
article.put(ARTICLE_CREATED, now);
article.put(ARTICLE_UPDATED, now);
article.put(ARTICLE_HAD_BEEN_PUBLISHED, true);
}
} else { // Save as draft
if (articleQueryService.hadBeenPublished(oldArticle)) {
// Save update date only for published article
article.put(ARTICLE_UPDATE_DATE, date);
article.put(ARTICLE_UPDATED, now);
} else {
// Reset create/update date to indicate this is an new draft
article.put(ARTICLE_CREATE_DATE, date);
article.put(ARTICLE_UPDATE_DATE, date);
article.put(ARTICLE_CREATED, now);
article.put(ARTICLE_UPDATED, now);
}
}
......@@ -487,12 +486,10 @@ public class ArticleMgmtService {
article.put(Article.ARTICLE_VIEW_COUNT, 0);
// Step 3: Set create/updat date
final JSONObject preference = preferenceQueryService.getPreference();
final Date date = new Date();
if (!article.has(Article.ARTICLE_CREATE_DATE)) {
article.put(Article.ARTICLE_CREATE_DATE, date);
if (!article.has(Article.ARTICLE_CREATED)) {
article.put(Article.ARTICLE_CREATED, System.currentTimeMillis());
}
article.put(Article.ARTICLE_UPDATE_DATE, article.opt(Article.ARTICLE_CREATE_DATE));
article.put(Article.ARTICLE_UPDATED, article.optLong(Article.ARTICLE_CREATED));
// Step 4: Set put top to false
article.put(Article.ARTICLE_PUT_TOP, false);
// Step 5: Add tag-article relations
......@@ -1042,8 +1039,8 @@ public class ArticleMgmtService {
* @throws RepositoryException repository exception
*/
private void archiveDate(final JSONObject article) throws RepositoryException {
final Date createDate = (Date) article.opt(Article.ARTICLE_CREATE_DATE);
final String createDateString = DateFormatUtils.format(createDate, "yyyy/MM");
final long created = article.optLong(Article.ARTICLE_CREATED);
final String createDateString = DateFormatUtils.format(created, "yyyy/MM");
JSONObject archiveDate = archiveDateRepository.getByArchiveDate(createDateString);
if (null == archiveDate) {
......@@ -1093,9 +1090,8 @@ public class ArticleMgmtService {
* @throws JSONException json exception
*/
private void fillAutoProperties(final JSONObject oldArticle, final JSONObject article) throws JSONException {
final Date createDate = (Date) oldArticle.get(ARTICLE_CREATE_DATE);
article.put(ARTICLE_CREATE_DATE, createDate);
final long created = oldArticle.getLong(ARTICLE_CREATED);
article.put(ARTICLE_CREATED, created);
article.put(ARTICLE_COMMENT_COUNT, oldArticle.getInt(ARTICLE_COMMENT_COUNT));
article.put(ARTICLE_VIEW_COUNT, oldArticle.getInt(ARTICLE_VIEW_COUNT));
article.put(ARTICLE_PUT_TOP, oldArticle.getBoolean(ARTICLE_PUT_TOP));
......@@ -1112,10 +1108,8 @@ public class ArticleMgmtService {
* @throws ServiceException if invalid permalink occurs
*/
private String getPermalinkForAddArticle(final JSONObject article) throws ServiceException {
final Date date = (Date) article.opt(Article.ARTICLE_CREATE_DATE);
final long date = article.optLong(Article.ARTICLE_CREATED);
String ret = article.optString(Article.ARTICLE_PERMALINK);
if (StringUtils.isBlank(ret)) {
ret = "/articles/" + DateFormatUtils.format(date, "yyyy/MM/dd") + "/" + article.optString(Keys.OBJECT_ID) + ".html";
}
......@@ -1136,16 +1130,16 @@ public class ArticleMgmtService {
}
/**
* Gets article permalink for updating article with the specified old article, article, create date.
* Gets article permalink for updating article with the specified old article, article, created at.
*
* @param oldArticle the specified old article
* @param article the specified article
* @param createDate the specified create date
* @param created the specified created
* @return permalink
* @throws ServiceException if invalid permalink occurs
* @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 long created)
throws ServiceException, JSONException {
final String articleId = article.getString(Keys.OBJECT_ID);
String ret = article.optString(ARTICLE_PERMALINK).trim();
......@@ -1153,7 +1147,7 @@ public class ArticleMgmtService {
if (!oldPermalink.equals(ret)) {
if (StringUtils.isBlank(ret)) {
ret = "/articles/" + DateFormatUtils.format(createDate, "yyyy/MM/dd") + "/" + articleId + ".html";
ret = "/articles/" + DateFormatUtils.format(created, "yyyy/MM/dd") + "/" + articleId + ".html";
}
if (!ret.startsWith("/")) {
......
......@@ -54,7 +54,7 @@ import static org.b3log.solo.model.Article.*;
* @author <a href="http://blog.sweelia.com">ArmstrongCN</a>
* @author <a href="http://zephyr.b3log.org">Zephyr</a>
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.3.2.3, Aug 27, 2018
* @version 1.3.2.4, Sep 16, 2018
* @since 0.3.5
*/
@Service
......@@ -144,12 +144,11 @@ public class ArticleQueryService {
try {
final Query query = new Query().setFilter(
CompositeFilterOperator.and(
new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true),
CompositeFilterOperator.and(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true),
CompositeFilterOperator.or(
new PropertyFilter(Article.ARTICLE_TITLE, FilterOperator.LIKE, "%" + keyword + "%"),
new PropertyFilter(Article.ARTICLE_CONTENT, FilterOperator.LIKE, "%" + keyword + "%"))
)).addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).setCurrentPageNum(currentPageNum).setPageSize(pageSize);
new PropertyFilter(Article.ARTICLE_CONTENT, FilterOperator.LIKE, "%" + keyword + "%")))).
addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING).setCurrentPageNum(currentPageNum).setPageSize(pageSize);
final JSONObject result = articleRepository.get(query);
......@@ -238,7 +237,7 @@ public class ArticleQueryService {
continue;
}
article.put(ARTICLE_CREATE_TIME, ((Date) article.opt(ARTICLE_CREATE_DATE)).getTime());
article.put(ARTICLE_CREATE_TIME, article.optLong(ARTICLE_CREATED));
articles.add(article);
}
......@@ -328,14 +327,13 @@ public class ArticleQueryService {
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();
return recentArticle.getLong(Article.ARTICLE_UPDATED);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
throw new ServiceException("Gets recent article time failed");
......@@ -422,10 +420,10 @@ public class ArticleQueryService {
* @throws JSONException json exception
*/
public boolean hasUpdated(final JSONObject article) throws JSONException {
final Date updateDate = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
final Date createDate = (Date) article.get(Article.ARTICLE_CREATE_DATE);
final long updateDate = article.getLong(Article.ARTICLE_UPDATED);
final long createDate = article.getLong(Article.ARTICLE_CREATED);
return !createDate.equals(updateDate);
return createDate != updateDate;
}
/**
......@@ -447,8 +445,7 @@ public class ArticleQueryService {
*/
public List<JSONObject> getUnpublishedArticles() throws RepositoryException {
final Map<String, SortDirection> sorts = new HashMap<>();
sorts.put(Article.ARTICLE_CREATE_DATE, SortDirection.DESCENDING);
sorts.put(Article.ARTICLE_CREATED, SortDirection.DESCENDING);
sorts.put(Article.ARTICLE_PUT_TOP, SortDirection.DESCENDING);
final Query query = new Query().setFilter(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true));
......@@ -539,7 +536,7 @@ public class ArticleQueryService {
article.remove(ARTICLE_COMMENT_COUNT);
article.remove(ARTICLE_IS_PUBLISHED);
article.remove(ARTICLE_PUT_TOP);
article.remove(ARTICLE_UPDATE_DATE);
article.remove(ARTICLE_UPDATED);
article.remove(ARTICLE_VIEW_COUNT);
article.remove(ARTICLE_RANDOM_DOUBLE);
......@@ -607,9 +604,9 @@ public class ArticleQueryService {
final Query query = new Query().setCurrentPageNum(currentPageNum).setPageSize(pageSize).
addSort(ARTICLE_PUT_TOP, SortDirection.DESCENDING);
if (requestJSONObject.optBoolean(Option.ID_C_ENABLE_ARTICLE_UPDATE_HINT)) {
query.addSort(ARTICLE_UPDATE_DATE, SortDirection.DESCENDING);
query.addSort(ARTICLE_UPDATED, SortDirection.DESCENDING);
} else {
query.addSort(ARTICLE_CREATE_DATE, SortDirection.DESCENDING);
query.addSort(ARTICLE_CREATED, SortDirection.DESCENDING);
}
final String keyword = requestJSONObject.optString(Common.KEYWORD);
......@@ -643,8 +640,8 @@ public class ArticleQueryService {
final JSONObject author = getAuthor(article);
final String authorName = author.getString(User.USER_NAME);
article.put(Common.AUTHOR_NAME, authorName);
article.put(ARTICLE_CREATE_TIME, ((Date) article.get(ARTICLE_CREATE_DATE)).getTime());
article.put(ARTICLE_UPDATE_TIME, ((Date) article.get(ARTICLE_UPDATE_DATE)).getTime());
article.put(ARTICLE_CREATE_TIME, article.getLong(ARTICLE_CREATED));
article.put(ARTICLE_UPDATE_TIME, article.getLong(ARTICLE_UPDATED));
// Remove unused properties
for (int j = 0; j < excludes.length(); j++) {
......@@ -706,7 +703,7 @@ public class ArticleQueryService {
continue;
}
article.put(ARTICLE_CREATE_TIME, ((Date) article.get(ARTICLE_CREATE_DATE)).getTime());
article.put(ARTICLE_CREATE_TIME, article.getLong(ARTICLE_CREATED));
ret.add(article);
}
......@@ -731,15 +728,12 @@ public class ArticleQueryService {
throws ServiceException {
try {
JSONObject result = archiveDateArticleRepository.getByArchiveDateId(archiveDateId, currentPageNum, pageSize);
final JSONArray relations = result.getJSONArray(Keys.RESULTS);
if (0 == relations.length()) {
return Collections.emptyList();
}
final Set<String> articleIds = new HashSet<String>();
final Set<String> articleIds = new HashSet<>();
for (int i = 0; i < relations.length(); i++) {
final JSONObject relation = relations.getJSONObject(i);
final String articleId = relation.getString(Article.ARTICLE + "_" + Keys.OBJECT_ID);
......@@ -747,14 +741,12 @@ public class ArticleQueryService {
articleIds.add(articleId);
}
final List<JSONObject> ret = new ArrayList<JSONObject>();
final List<JSONObject> ret = new ArrayList<>();
final Query query = new Query().setFilter(new PropertyFilter(Keys.OBJECT_ID, FilterOperator.IN, articleIds)).setPageCount(1).index(
Article.ARTICLE_PERMALINK);
result = articleRepository.get(query);
final JSONArray articles = result.getJSONArray(Keys.RESULTS);
for (int i = 0; i < articles.length(); i++) {
final JSONObject article = articles.getJSONObject(i);
......@@ -763,7 +755,7 @@ public class ArticleQueryService {
continue;
}
article.put(ARTICLE_CREATE_TIME, ((Date) article.get(ARTICLE_CREATE_DATE)).getTime());
article.put(ARTICLE_CREATE_TIME, article.getLong(ARTICLE_CREATED));
ret.add(article);
}
......@@ -996,12 +988,12 @@ public class ArticleQueryService {
try {
final JSONObject result = articleRepository.getByAuthorEmail(authorEmail, currentPageNum, pageSize);
final JSONArray articles = result.getJSONArray(Keys.RESULTS);
final List<JSONObject> ret = new ArrayList<JSONObject>();
final List<JSONObject> ret = new ArrayList<>();
for (int i = 0; i < articles.length(); i++) {
final JSONObject article = articles.getJSONObject(i);
article.put(ARTICLE_CREATE_TIME, ((Date) article.get(ARTICLE_CREATE_DATE)).getTime());
article.put(ARTICLE_CREATE_TIME, article.getLong(ARTICLE_CREATED));
ret.add(article);
}
......@@ -1146,9 +1138,9 @@ public class ArticleQueryService {
article.remove(Article.ARTICLE_ABSTRACT);
article.remove(Article.ARTICLE_COMMENT_COUNT);
article.remove(Article.ARTICLE_CONTENT);
article.remove(Article.ARTICLE_CREATE_DATE);
article.remove(Article.ARTICLE_CREATED);
article.remove(Article.ARTICLE_TAGS_REF);
article.remove(Article.ARTICLE_UPDATE_DATE);
article.remove(Article.ARTICLE_UPDATED);
article.remove(Article.ARTICLE_VIEW_COUNT);
article.remove(Article.ARTICLE_RANDOM_DOUBLE);
article.remove(Article.ARTICLE_IS_PUBLISHED);
......
......@@ -41,7 +41,7 @@ import java.util.stream.Collectors;
* Export service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.0, Nov 11, 2017
* @version 1.1.0.1, Sep 16, 2018
* @since 2.5.0
*/
@Service
......@@ -162,9 +162,9 @@ public class ExportService {
final Map<String, Object> front = new LinkedHashMap<>();
final String title = article.optString(Article.ARTICLE_TITLE);
front.put("title", title);
final String date = DateFormatUtils.format((Date) article.opt(Article.ARTICLE_CREATE_DATE), "yyyy-MM-dd HH:mm:ss");
final String date = DateFormatUtils.format(article.optLong(Article.ARTICLE_CREATED), "yyyy-MM-dd HH:mm:ss");
front.put("date", date);
front.put("updated", DateFormatUtils.format((Date) article.opt(Article.ARTICLE_UPDATE_DATE), "yyyy-MM-dd HH:mm:ss"));
front.put("updated", DateFormatUtils.format(article.optLong(Article.ARTICLE_UPDATED), "yyyy-MM-dd HH:mm:ss"));
final List<String> tags = Arrays.stream(article.optString(Article.ARTICLE_TAGS_REF).split(",")).filter(StringUtils::isNotBlank).map(String::trim).collect(Collectors.toList());
if (tags.isEmpty()) {
tags.add("Solo");
......
......@@ -40,7 +40,7 @@ import java.util.*;
* Import service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.1, Nov 11, 2017
* @version 1.0.1.2, Sep 16, 2018
* @since 2.2.0
*/
@Service
......@@ -191,7 +191,7 @@ public class ImportService {
ret.put(Article.ARTICLE_ABSTRACT, abs);
final Date date = parseDate(elems);
ret.put(Article.ARTICLE_CREATE_DATE, date);
ret.put(Article.ARTICLE_CREATED, date.getTime());
final String permalink = (String) elems.get("permalink");
if (StringUtils.isNotBlank(permalink)) {
......
......@@ -49,7 +49,6 @@ import org.json.JSONObject;
import javax.servlet.ServletContext;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Set;
......@@ -57,7 +56,7 @@ import java.util.Set;
* Solo initialization service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.22, Sep 16, 2018
* @version 1.5.2.23, Sep 16, 2018
* @since 0.4.0
*/
@Service
......@@ -288,13 +287,11 @@ public class InitService {
article.put(Article.ARTICLE_SIGN_ID, "1");
article.put(Article.ARTICLE_COMMENT_COUNT, 1);
article.put(Article.ARTICLE_VIEW_COUNT, 0);
final Date date = new Date();
final JSONObject admin = userRepository.getAdmin();
final String authorEmail = admin.optString(User.USER_EMAIL);
article.put(Article.ARTICLE_CREATE_DATE, date);
article.put(Article.ARTICLE_UPDATE_DATE, date);
final long now = System.currentTimeMillis();
article.put(Article.ARTICLE_CREATED, now);
article.put(Article.ARTICLE_UPDATED, now);
article.put(Article.ARTICLE_PUT_TOP, false);
article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random());
article.put(Article.ARTICLE_AUTHOR_EMAIL, authorEmail);
......@@ -313,7 +310,7 @@ public class InitService {
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
comment.put(Comment.COMMENT_THUMBNAIL_URL, Solos.GRAVATAR + "59a5e8209c780307dbe9c9ba728073f5??s=60&r=G");
comment.put(Comment.COMMENT_CREATED, date.getTime());
comment.put(Comment.COMMENT_CREATED, now);
comment.put(Comment.COMMENT_ON_ID, articleId);
comment.put(Comment.COMMENT_ON_TYPE, Article.ARTICLE);
final String commentId = Ids.genTimeMillisId();
......@@ -386,8 +383,8 @@ public class InitService {
* @throws RepositoryException repository exception
*/
public void archiveDate(final JSONObject article) throws RepositoryException {
final Date createDate = (Date) article.opt(Article.ARTICLE_CREATE_DATE);
final String createDateString = DateFormatUtils.format(createDate, "yyyy/MM");
final long created = article.optLong(Article.ARTICLE_CREATED);
final String createDateString = DateFormatUtils.format(created, "yyyy/MM");
final JSONObject archiveDate = new JSONObject();
try {
......
......@@ -21,13 +21,12 @@ import org.b3log.solo.model.Article;
import org.json.JSONObject;
import java.util.Comparator;
import java.util.Date;
/**
* Article comparator by create date.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1, Dec 30, 2010
* @version 1.0.0.2, Sep 16, 2018
*/
public final class ArticleCreateDateComparator implements Comparator<JSONObject> {
......@@ -40,10 +39,10 @@ public final class ArticleCreateDateComparator implements Comparator<JSONObject>
@Override
public int compare(final JSONObject article1, final JSONObject article2) {
try {
final Date date1 = (Date) article1.get(Article.ARTICLE_CREATE_DATE);
final Date date2 = (Date) article2.get(Article.ARTICLE_CREATE_DATE);
final long date1 = article1.getLong(Article.ARTICLE_CREATED);
final long date2 = article2.getLong(Article.ARTICLE_CREATED);
return date2.compareTo(date1);
return (int) (date2 - date1);
} catch (final Exception e) {
throw new IllegalStateException(e);
}
......
......@@ -27,7 +27,7 @@ import java.util.Date;
* Article comparator by update date.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1, Dec 30, 2010
* @version 1.0.0.2, Sep 16, 2018
*/
public final class ArticleUpdateDateComparator implements Comparator<JSONObject> {
......@@ -40,8 +40,8 @@ public final class ArticleUpdateDateComparator implements Comparator<JSONObject>
@Override
public int compare(final JSONObject article1, final JSONObject article2) {
try {
final Date date1 = (Date) article1.get(Article.ARTICLE_UPDATE_DATE);
final Date date2 = (Date) article2.get(Article.ARTICLE_UPDATE_DATE);
final Date date1 = (Date) article1.get(Article.ARTICLE_UPDATED);
final Date date2 = (Date) article2.get(Article.ARTICLE_UPDATED);
return date2.compareTo(date1);
} catch (final Exception e) {
......
......@@ -530,13 +530,13 @@
"type": "boolean"
},
{
"name": "articleCreateDate",
"description": "文章创建时间",
"name": "articleCreated",
"description": "文章创建时间",
"type": "Date"
},
{
"name": "articleUpdateDate",
"description": "文章更新时间",
"name": "articleUpdated",
"description": "文章更新时间",
"type": "Date"
},
{
......
......@@ -17,8 +17,6 @@
*/
package org.b3log.solo.repository.impl;
import java.util.Date;
import java.util.List;
import org.b3log.latke.Keys;
import org.b3log.latke.repository.Query;
import org.b3log.latke.repository.Transaction;
......@@ -30,6 +28,9 @@ import org.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Date;
import java.util.List;
/**
* {@link ArticleRepositoryImpl} test case.
*
......@@ -41,7 +42,7 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
/**
* Adds successfully.
*
*
* @throws Exception exception
*/
@Test
......@@ -61,8 +62,8 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
article.put(Article.ARTICLE_HAD_BEEN_PUBLISHED, true);
article.put(Article.ARTICLE_IS_PUBLISHED, true);
article.put(Article.ARTICLE_PUT_TOP, false);
article.put(Article.ARTICLE_CREATE_DATE, new Date());
article.put(Article.ARTICLE_UPDATE_DATE, new Date());
article.put(Article.ARTICLE_CREATED, new Date().getTime());
article.put(Article.ARTICLE_UPDATED, new Date().getTime());
article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random());
article.put(Article.ARTICLE_SIGN_ID, "1");
article.put(Article.ARTICLE_COMMENTABLE, true);
......@@ -80,7 +81,7 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
/**
* Get by permalink.
*
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "add")
......@@ -96,7 +97,7 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
/**
* Get by permalink.
*
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add"})
......@@ -116,8 +117,8 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
article.put(Article.ARTICLE_HAD_BEEN_PUBLISHED, true);
article.put(Article.ARTICLE_IS_PUBLISHED, true);
article.put(Article.ARTICLE_PUT_TOP, false);
article.put(Article.ARTICLE_CREATE_DATE, new Date());
article.put(Article.ARTICLE_UPDATE_DATE, new Date());
article.put(Article.ARTICLE_CREATED, new Date().getTime());
article.put(Article.ARTICLE_UPDATED, new Date().getTime());
article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random());
article.put(Article.ARTICLE_SIGN_ID, "1");
article.put(Article.ARTICLE_COMMENTABLE, true);
......@@ -146,7 +147,7 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
/**
* Get Most Comment Articles.
*
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add", "previousAndNext"})
......@@ -166,8 +167,8 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
article.put(Article.ARTICLE_HAD_BEEN_PUBLISHED, true);
article.put(Article.ARTICLE_IS_PUBLISHED, true);
article.put(Article.ARTICLE_PUT_TOP, false);
article.put(Article.ARTICLE_CREATE_DATE, new Date());
article.put(Article.ARTICLE_UPDATE_DATE, new Date());
article.put(Article.ARTICLE_CREATED, new Date().getTime());
article.put(Article.ARTICLE_UPDATED, new Date().getTime());
article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random());
article.put(Article.ARTICLE_SIGN_ID, "1");
article.put(Article.ARTICLE_COMMENTABLE, true);
......@@ -191,13 +192,13 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
}
/**
* Get Most View Count Articles
*
* Get Most View Count Articles
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add",
"previousAndNext",
"getMostCommentArticles"})
"previousAndNext",
"getMostCommentArticles"})
public void getMostViewCountArticles() throws Exception {
final ArticleRepository articleRepository = getArticleRepository();
......@@ -214,8 +215,8 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
article.put(Article.ARTICLE_HAD_BEEN_PUBLISHED, false);
article.put(Article.ARTICLE_IS_PUBLISHED, false); // Unpublished
article.put(Article.ARTICLE_PUT_TOP, false);
article.put(Article.ARTICLE_CREATE_DATE, new Date());
article.put(Article.ARTICLE_UPDATE_DATE, new Date());
article.put(Article.ARTICLE_CREATED, new Date().getTime());
article.put(Article.ARTICLE_UPDATED, new Date().getTime());
article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random());
article.put(Article.ARTICLE_SIGN_ID, "1");
article.put(Article.ARTICLE_COMMENTABLE, true);
......@@ -241,13 +242,13 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
/**
* Get Randomly.
*
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add",
"previousAndNext",
"getMostCommentArticles",
"getMostViewCountArticles"})
"previousAndNext",
"getMostCommentArticles",
"getMostViewCountArticles"})
public void getRandomly() throws Exception {
final ArticleRepository articleRepository = getArticleRepository();
......@@ -257,13 +258,13 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
/**
* Get Recent Articles.
*
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add",
"previousAndNext",
"getMostCommentArticles",
"getMostViewCountArticles"})
"previousAndNext",
"getMostCommentArticles",
"getMostViewCountArticles"})
public void getRecentArticles() throws Exception {
final ArticleRepository articleRepository = getArticleRepository();
......@@ -280,7 +281,7 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
/**
* Is Published.
*
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add", "getMostViewCountArticles"})
......
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