2013-03-23 16:17:19 +01:00
|
|
|
package com.commafeed.frontend.model;
|
2013-03-22 09:29:30 +01:00
|
|
|
|
2013-03-23 15:52:26 +01:00
|
|
|
import java.io.Serializable;
|
2013-04-30 07:12:45 +02:00
|
|
|
import java.util.Arrays;
|
2013-03-22 22:11:40 +01:00
|
|
|
import java.util.Date;
|
|
|
|
|
|
2013-04-15 14:47:37 +02:00
|
|
|
import javax.xml.bind.annotation.XmlAccessType;
|
|
|
|
|
import javax.xml.bind.annotation.XmlAccessorType;
|
|
|
|
|
import javax.xml.bind.annotation.XmlRootElement;
|
|
|
|
|
|
2013-05-26 15:36:55 +02:00
|
|
|
import com.commafeed.backend.feeds.FeedUtils;
|
2013-04-18 12:50:44 +02:00
|
|
|
import com.commafeed.backend.model.FeedEntry;
|
|
|
|
|
import com.commafeed.backend.model.FeedEntryStatus;
|
2013-06-20 18:45:58 +02:00
|
|
|
import com.commafeed.backend.model.FeedSubscription;
|
2013-04-30 07:12:45 +02:00
|
|
|
import com.sun.syndication.feed.synd.SyndContentImpl;
|
|
|
|
|
import com.sun.syndication.feed.synd.SyndEntry;
|
|
|
|
|
import com.sun.syndication.feed.synd.SyndEntryImpl;
|
2013-04-16 12:36:18 +02:00
|
|
|
import com.wordnik.swagger.annotations.ApiClass;
|
|
|
|
|
import com.wordnik.swagger.annotations.ApiProperty;
|
|
|
|
|
|
2013-03-25 12:24:00 +01:00
|
|
|
@SuppressWarnings("serial")
|
2013-04-15 14:47:37 +02:00
|
|
|
@XmlRootElement
|
|
|
|
|
@XmlAccessorType(XmlAccessType.FIELD)
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiClass("Entry details")
|
2013-03-23 15:52:26 +01:00
|
|
|
public class Entry implements Serializable {
|
|
|
|
|
|
2013-06-22 21:36:55 +02:00
|
|
|
public static Entry build(FeedEntryStatus status, String publicUrl,
|
|
|
|
|
boolean proxyImages) {
|
2013-04-18 12:50:44 +02:00
|
|
|
Entry entry = new Entry();
|
|
|
|
|
|
|
|
|
|
FeedEntry feedEntry = status.getEntry();
|
2013-06-20 18:45:58 +02:00
|
|
|
FeedSubscription sub = status.getSubscription();
|
|
|
|
|
|
|
|
|
|
entry.setRead(status.isRead());
|
|
|
|
|
entry.setStarred(status.isStarred());
|
|
|
|
|
|
|
|
|
|
entry.setId(String.valueOf(feedEntry.getId()));
|
2013-04-30 07:12:45 +02:00
|
|
|
entry.setGuid(feedEntry.getGuid());
|
2013-04-18 12:50:44 +02:00
|
|
|
entry.setTitle(feedEntry.getContent().getTitle());
|
2013-06-22 21:36:55 +02:00
|
|
|
entry.setContent(FeedUtils.proxyImages(feedEntry.getContent()
|
|
|
|
|
.getContent(), publicUrl, proxyImages));
|
2013-05-31 08:17:58 +02:00
|
|
|
entry.setRtl(FeedUtils.isRTL(feedEntry));
|
2013-05-19 06:47:37 +02:00
|
|
|
entry.setAuthor(feedEntry.getAuthor());
|
2013-06-20 18:45:58 +02:00
|
|
|
entry.setEnclosureUrl(feedEntry.getContent().getEnclosureUrl());
|
|
|
|
|
entry.setEnclosureType(feedEntry.getContent().getEnclosureType());
|
2013-04-18 12:50:44 +02:00
|
|
|
entry.setDate(feedEntry.getUpdated());
|
2013-06-08 14:09:46 +02:00
|
|
|
entry.setInsertedDate(feedEntry.getInserted());
|
2013-04-18 12:50:44 +02:00
|
|
|
entry.setUrl(feedEntry.getUrl());
|
|
|
|
|
|
2013-06-20 18:45:58 +02:00
|
|
|
entry.setFeedName(sub.getTitle());
|
|
|
|
|
entry.setFeedId(String.valueOf(sub.getId()));
|
|
|
|
|
entry.setFeedUrl(sub.getFeed().getUrl());
|
|
|
|
|
entry.setFeedLink(sub.getFeed().getLink());
|
|
|
|
|
entry.setIconUrl(FeedUtils.getFaviconUrl(sub, publicUrl));
|
2013-04-18 12:50:44 +02:00
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-30 07:12:45 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("entry id")
|
2013-03-22 09:29:30 +01:00
|
|
|
private String id;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-04-30 07:12:45 +02:00
|
|
|
@ApiProperty("entry guid")
|
|
|
|
|
private String guid;
|
|
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("entry title")
|
2013-03-22 09:29:30 +01:00
|
|
|
private String title;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("entry content")
|
2013-03-22 09:29:30 +01:00
|
|
|
private String content;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-05-31 08:17:58 +02:00
|
|
|
@ApiProperty("wether entry content and title are rtl")
|
|
|
|
|
private boolean rtl;
|
|
|
|
|
|
2013-05-19 06:47:37 +02:00
|
|
|
@ApiProperty("entry author")
|
|
|
|
|
private String author;
|
|
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("entry enclosure url, if any")
|
2013-04-09 13:37:00 +02:00
|
|
|
private String enclosureUrl;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("entry enclosure mime type, if any")
|
2013-04-09 13:37:00 +02:00
|
|
|
private String enclosureType;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("entry publication date")
|
2013-03-22 22:11:40 +01:00
|
|
|
private Date date;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-06-08 14:09:46 +02:00
|
|
|
@ApiProperty("entry insertion date in the database")
|
|
|
|
|
private Date insertedDate;
|
|
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("feed id")
|
2013-03-22 09:29:30 +01:00
|
|
|
private String feedId;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("feed name")
|
2013-03-22 09:29:30 +01:00
|
|
|
private String feedName;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-04-30 16:17:34 +02:00
|
|
|
@ApiProperty("this entry's feed url")
|
2013-04-09 12:03:03 +02:00
|
|
|
private String feedUrl;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-04-30 16:17:34 +02:00
|
|
|
@ApiProperty("this entry's website url")
|
|
|
|
|
private String feedLink;
|
|
|
|
|
|
2013-05-26 15:36:55 +02:00
|
|
|
@ApiProperty(value = "The favicon url to use for this feed")
|
|
|
|
|
private String iconUrl;
|
|
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("entry url")
|
2013-03-22 09:29:30 +01:00
|
|
|
private String url;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("read sttaus")
|
2013-03-22 09:29:30 +01:00
|
|
|
private boolean read;
|
2013-04-18 12:50:44 +02:00
|
|
|
|
2013-04-16 12:36:18 +02:00
|
|
|
@ApiProperty("starred status")
|
2013-03-22 09:29:30 +01:00
|
|
|
private boolean starred;
|
|
|
|
|
|
|
|
|
|
public String getId() {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setId(String id) {
|
|
|
|
|
this.id = id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getTitle() {
|
|
|
|
|
return title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTitle(String title) {
|
|
|
|
|
this.title = title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getContent() {
|
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setContent(String content) {
|
|
|
|
|
this.content = content;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 22:11:40 +01:00
|
|
|
public Date getDate() {
|
2013-03-22 09:29:30 +01:00
|
|
|
return date;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 22:11:40 +01:00
|
|
|
public void setDate(Date date) {
|
2013-03-22 09:29:30 +01:00
|
|
|
this.date = date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getFeedId() {
|
|
|
|
|
return feedId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFeedId(String feedId) {
|
|
|
|
|
this.feedId = feedId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getFeedName() {
|
|
|
|
|
return feedName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFeedName(String feedName) {
|
|
|
|
|
this.feedName = feedName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getUrl() {
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setUrl(String url) {
|
|
|
|
|
this.url = url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isRead() {
|
|
|
|
|
return read;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRead(boolean read) {
|
|
|
|
|
this.read = read;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isStarred() {
|
|
|
|
|
return starred;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setStarred(boolean starred) {
|
|
|
|
|
this.starred = starred;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-09 12:03:03 +02:00
|
|
|
public String getFeedUrl() {
|
|
|
|
|
return feedUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFeedUrl(String feedUrl) {
|
|
|
|
|
this.feedUrl = feedUrl;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-09 13:37:00 +02:00
|
|
|
public String getEnclosureUrl() {
|
|
|
|
|
return enclosureUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setEnclosureUrl(String enclosureUrl) {
|
|
|
|
|
this.enclosureUrl = enclosureUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getEnclosureType() {
|
|
|
|
|
return enclosureType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setEnclosureType(String enclosureType) {
|
|
|
|
|
this.enclosureType = enclosureType;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-30 07:12:45 +02:00
|
|
|
public String getGuid() {
|
|
|
|
|
return guid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setGuid(String guid) {
|
|
|
|
|
this.guid = guid;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-30 16:17:34 +02:00
|
|
|
public String getFeedLink() {
|
|
|
|
|
return feedLink;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFeedLink(String feedLink) {
|
|
|
|
|
this.feedLink = feedLink;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-19 06:47:37 +02:00
|
|
|
public String getAuthor() {
|
|
|
|
|
return author;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAuthor(String author) {
|
|
|
|
|
this.author = author;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-26 15:36:55 +02:00
|
|
|
public String getIconUrl() {
|
|
|
|
|
return iconUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setIconUrl(String iconUrl) {
|
|
|
|
|
this.iconUrl = iconUrl;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-31 08:17:58 +02:00
|
|
|
public boolean isRtl() {
|
|
|
|
|
return rtl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRtl(boolean rtl) {
|
|
|
|
|
this.rtl = rtl;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-08 14:09:46 +02:00
|
|
|
public Date getInsertedDate() {
|
|
|
|
|
return insertedDate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setInsertedDate(Date insertedDate) {
|
|
|
|
|
this.insertedDate = insertedDate;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 09:29:30 +01:00
|
|
|
}
|