final String requestURI = request.getRequestURI();
final int num = Integer.valueOf(requestURI.substring((Latkes.getContextPath() + "/dev/articles/gen/").length()));
try {
final ArticleMgmtService articleMgmtService = ArticleMgmtService.getInstance();
final UserQueryService userQueryService = UserQueryService.getInstance();
final JSONObject admin = userQueryService.getAdmin();
final String authorEmail = admin.optString(User.USER_EMAIL);
for (int i = 0; i < num; i++) {
final JSONObject article = new JSONObject();
// XXX: http://en.wikipedia.org/wiki/Markov_chain
article.put(Article.ARTICLE_TITLE, "article title" + i);
article.put(Article.ARTICLE_ABSTRACT, "article" + i + " abstract");
article.put(Article.ARTICLE_TAGS_REF, "tag1,tag2");
article.put(Article.ARTICLE_AUTHOR_EMAIL, authorEmail);
article.put(Article.ARTICLE_COMMENT_COUNT, 0);
article.put(Article.ARTICLE_VIEW_COUNT, 0);
article.put(Article.ARTICLE_CONTENT, "article content");
article.put(Article.ARTICLE_PERMALINK, "article" + i + " permalink");
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_RANDOM_DOUBLE, Math.random());
article.put(Article.ARTICLE_COMMENTABLE, true);
article.put(Article.ARTICLE_VIEW_PWD, "");
article.put(Article.ARTICLE_SIGN_ID, "1");
articleMgmtService.addArticle(new JSONObject().put(Article.ARTICLE, article));
}
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}