rest endpoint to retrieve a feed or a category as a feed

This commit is contained in:
Athou
2013-04-30 07:12:45 +02:00
parent aef82fe690
commit 2cbf51c287
3 changed files with 132 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package com.commafeed.frontend.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
@@ -9,6 +10,9 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryStatus;
import com.sun.syndication.feed.synd.SyndContentImpl;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndEntryImpl;
import com.wordnik.swagger.annotations.ApiClass;
import com.wordnik.swagger.annotations.ApiProperty;
@@ -23,6 +27,7 @@ public class Entry implements Serializable {
FeedEntry feedEntry = status.getEntry();
entry.setId(String.valueOf(status.getId()));
entry.setGuid(feedEntry.getGuid());
entry.setTitle(feedEntry.getContent().getTitle());
entry.setContent(feedEntry.getContent().getContent());
entry.setEnclosureUrl(status.getEntry().getContent().getEnclosureUrl());
@@ -40,9 +45,26 @@ public class Entry implements Serializable {
return entry;
}
public SyndEntry asRss() {
SyndEntry entry = new SyndEntryImpl();
entry.setUri(getGuid());
entry.setTitle(getTitle());
SyndContentImpl content = new SyndContentImpl();
content.setValue(getContent());
entry.setContents(Arrays.asList(content));
entry.setLink(getUrl());
entry.setPublishedDate(getDate());
return entry;
}
@ApiProperty("entry id")
private String id;
@ApiProperty("entry guid")
private String guid;
@ApiProperty("entry title")
private String title;
@@ -172,4 +194,12 @@ public class Entry implements Serializable {
this.enclosureType = enclosureType;
}
public String getGuid() {
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
}