final String userPwd =
requestJSONObject.getString(
BLOG_SYNC_EXTERNAL_BLOGGING_SYS_USER_PASSWORD);
final String archiveDate = requestJSONObject.getString(
BLOG_SYNC_EXTERNAL_ARCHIVE_DATE);
final MetaWeblog metaWeblog = BlogFactory.getMetaWeblog(externalSys);
metaWeblog.setUserName(userName);
metaWeblog.setUserPassword(userPwd);
final List<String> externalArticleIds =
metaWeblog.getArticleIdsByArchiveDate(archiveDate);
LOGGER.log(Level.FINER,
"There are [{0}] articles of [{1}] user[userName={2}] in [{3}]",
new Object[]{externalArticleIds.size(),
externalSys,
userName,
archiveDate});
final JSONArray articles = new JSONArray();
ret.put(BLOG_SYNC_EXTERNAL_ARTICLES, articles);
int retrievalCnt = 0;
for (final String externalArticleId : externalArticleIds) {
final JSONObject soloArticle =
externalArticleSoloArticleRepository.getSoloArticle(
externalArticleId, externalSys);
JSONObject article = null;
boolean imported = false;
if (null != soloArticle) {
article = soloArticle;
imported = soloArticle.getBoolean(
BLOG_SYNC_EXTERNAL_ARTICLE_IMPORTED);
} else { // Not retrieved yet, get the article from External blogging system
final Post externalPost =
metaWeblog.getPost(externalArticleId);
if (null == externalPost) {
LOGGER.log(Level.WARNING,
"Retrieve article[postId={0}] from external blogging system[{1}] is null",
new String[]{externalArticleId, externalSys});
continue;