Search in sources :

Example 1 with Category

use of org.b3log.solo.model.feed.atom.Category in project solo by b3log.

the class FeedProcessor method getEntryForArticle.

private Entry getEntryForArticle(final List<JSONObject> articles, final boolean hasMultipleUsers, String authorName, final boolean isFullContent, int i) throws org.json.JSONException, org.b3log.latke.service.ServiceException {
    final JSONObject article = articles.get(i);
    final Entry ret = new Entry();
    final String title = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
    ret.setTitle(title);
    final String summary = isFullContent ? StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT)) : StringEscapeUtils.escapeXml(article.optString(Article.ARTICLE_ABSTRACT));
    ret.setSummary(summary);
    final Date updated = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
    ret.setUpdated(updated);
    final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
    ret.setLink(link);
    ret.setId(link);
    if (hasMultipleUsers) {
        authorName = StringEscapeUtils.escapeXml(articleQueryService.getAuthor(article).getString(User.USER_NAME));
    }
    ret.setAuthor(authorName);
    final String tagsString = article.getString(Article.ARTICLE_TAGS_REF);
    final String[] tagStrings = tagsString.split(",");
    for (final String tagString : tagStrings) {
        final Category catetory = new Category();
        ret.addCatetory(catetory);
        catetory.setTerm(tagString);
    }
    return ret;
}
Also used : Entry(org.b3log.solo.model.feed.atom.Entry) Category(org.b3log.solo.model.feed.atom.Category) JSONObject(org.json.JSONObject) Date(java.util.Date)

Example 2 with Category

use of org.b3log.solo.model.feed.atom.Category in project solo by b3log.

the class FeedProcessor method getEntry.

private Entry getEntry(final boolean hasMultipleUsers, String authorName, final JSONArray articles, final boolean isFullContent, int i) throws org.json.JSONException, org.b3log.latke.service.ServiceException {
    final JSONObject article = articles.getJSONObject(i);
    final Entry ret = new Entry();
    final String title = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
    ret.setTitle(title);
    final String summary = isFullContent ? StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT)) : StringEscapeUtils.escapeXml(article.optString(Article.ARTICLE_ABSTRACT));
    ret.setSummary(summary);
    final Date updated = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
    ret.setUpdated(updated);
    final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
    ret.setLink(link);
    ret.setId(link);
    if (hasMultipleUsers) {
        authorName = StringEscapeUtils.escapeXml(articleQueryService.getAuthor(article).getString(User.USER_NAME));
    }
    ret.setAuthor(authorName);
    final String tagsString = article.getString(Article.ARTICLE_TAGS_REF);
    final String[] tagStrings = tagsString.split(",");
    for (final String tagString : tagStrings) {
        final Category catetory = new Category();
        ret.addCatetory(catetory);
        final String tag = tagString;
        catetory.setTerm(tag);
    }
    return ret;
}
Also used : Entry(org.b3log.solo.model.feed.atom.Entry) Category(org.b3log.solo.model.feed.atom.Category) JSONObject(org.json.JSONObject) Date(java.util.Date)

Aggregations

Date (java.util.Date)2 Category (org.b3log.solo.model.feed.atom.Category)2 Entry (org.b3log.solo.model.feed.atom.Entry)2 JSONObject (org.json.JSONObject)2