Search code examples
springfeednetbeans-7atom-feed

How to add link in atom feed using spring 3, netbeans


Using spring3.2 and netbeans 7.2

Warning code :

@Override
    protected List<Entry> buildFeedEntries(Map<String, Object> model,
            HttpServletRequest request, HttpServletResponse response) throws Exception {

        @SuppressWarnings("unchecked")
        List<Feed_vo> contentList = (List<Feed_vo>) model.get("feedContent");
        List<Entry> entries = new ArrayList<Entry>(contentList.size());

        for (Feed_vo content : contentList) {
            Entry entry = new Entry();
            String date = String.format("%1$tY-%1$tm-%1$td", content.getCreatedDate());
            entry.setId(String.format("tag:featuriz.com,%s:%d", date, content.getId()));
            entry.setTitle(String.format("%s | on %s by %s",content.getTitle(), date, content.getAuthor()));
            entry = setLink(content, entry);
            entry.setUpdated(content.getCreatedDate());

            Content summary = new Content();
            summary.setValue(content.getSummary());
            entry.setSummary(summary);

            entries.add(entry);
        }

        return entries;

    }

    private Entry setLink(Feed_vo vo, Entry entry) {
        ArrayList l = new ArrayList();
        Link link = new Link();
        link.setType("text/html");
        link.setHref(vo.getUrl());
        l.add(link);
        entry.setAlternateLinks(l);
        return entry;
    }

This code works but Netbeans warning :

/home/sudhakar/**/CustomAtomViewer.java:72: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
        l.add(link);
1 warning

How to solve this warning.

Also inform me the correct format for atom and rss feed.

(How the output should look like. ie. output source).


Solution

  • Warnings solved by this code:

    List<Link> v = new ArrayList<Link>();
            Link link = new Link();
            link.setType("text/html");
            link.setHref(vo.getUrl());
            v.add(link);
            entry.setAlternateLinks(v);