Java Code Examples for com.rometools.rome.feed.rss.Guid#isPermaLink()

The following examples show how to use com.rometools.rome.feed.rss.Guid#isPermaLink() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RSS20Generator.java    From rome with Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(final Item item, final Element eItem, final int index) {

    super.populateItem(item, eItem, index);

    final Element description = eItem.getChild("description", getFeedNamespace());
    if (description != null) {
        description.removeAttribute("type");
    }

    final String author = item.getAuthor();
    if (author != null) {
        eItem.addContent(generateSimpleElement("author", author));
    }

    final String comments = item.getComments();
    if (comments != null) {
        eItem.addContent(generateSimpleElement("comments", comments));
    }

    final Guid guid = item.getGuid();
    if (guid != null) {
        final Element eGuid = generateSimpleElement("guid", guid.getValue());
        if (!guid.isPermaLink()) {
            eGuid.setAttribute("isPermaLink", "false");
        }
        eItem.addContent(eGuid);
    }
}
 
Example 2
Source File: ConverterForRSS094.java    From rome with Apache License 2.0 4 votes vote down vote up
@Override
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {

    final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);

    // adding native feed author to DC creators list
    final String author = item.getAuthor();
    if (author != null) {
        final List<String> creators = ((DCModule) syndEntry.getModule(DCModule.URI)).getCreators();
        if (!creators.contains(author)) {

            // using a set to remove duplicates
            final Set<String> s = new LinkedHashSet<String>();

            // DC creators
            s.addAll(creators);

            // feed native author
            s.add(author);

            creators.clear();
            creators.addAll(s);
        }
    }

    final Guid guid = item.getGuid();
    final String itemLink = item.getLink();
    if (guid != null) {
        final String guidValue = guid.getValue();
        syndEntry.setUri(guidValue);
        if (itemLink == null && guid.isPermaLink()) {
            syndEntry.setLink(guidValue);
        }
    } else {
        syndEntry.setUri(itemLink);
    }

    if (item.getComments() != null) {
        final SyndLinkImpl comments = new SyndLinkImpl();
        comments.setRel("comments");
        comments.setHref(item.getComments());
        comments.setType("text/html");
    }

    return syndEntry;

}