From 5998fa9126f975b21c2b82144c75eb529d293430 Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Sun, 20 Sep 2020 18:17:43 +0200 Subject: [PATCH] Delete unused code --- .../java/com/readrops/api/localfeed/AFeed.kt | 9 - .../com/readrops/api/localfeed/RSSQuery.java | 198 ------------------ .../api/localfeed/RSSQueryResult.java | 42 ---- .../api/localfeed/atom/ATOMAuthor.java | 22 -- .../api/localfeed/atom/ATOMEntry.java | 98 --------- .../readrops/api/localfeed/atom/ATOMFeed.java | 128 ----------- .../readrops/api/localfeed/atom/ATOMLink.java | 30 --- .../readrops/api/localfeed/json/JSONAuthor.kt | 9 - .../readrops/api/localfeed/json/JSONFeed.kt | 15 -- .../readrops/api/localfeed/json/JSONItem.kt | 21 -- .../api/localfeed/rss/RSSChannel.java | 87 -------- .../api/localfeed/rss/RSSEnclosure.java | 30 --- .../readrops/api/localfeed/rss/RSSFeed.java | 21 -- .../readrops/api/localfeed/rss/RSSItem.java | 154 -------------- .../readrops/api/localfeed/rss/RSSLink.java | 40 ---- .../api/localfeed/rss/RSSMediaContent.java | 30 --- .../app/utils/matchers/FeedMatcher.java | 65 ------ .../app/utils/matchers/ItemMatcher.java | 123 ----------- 18 files changed, 1122 deletions(-) delete mode 100644 api/src/main/java/com/readrops/api/localfeed/AFeed.kt delete mode 100644 api/src/main/java/com/readrops/api/localfeed/RSSQuery.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/RSSQueryResult.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/atom/ATOMAuthor.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/atom/ATOMEntry.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/atom/ATOMFeed.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/atom/ATOMLink.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/json/JSONAuthor.kt delete mode 100644 api/src/main/java/com/readrops/api/localfeed/json/JSONFeed.kt delete mode 100644 api/src/main/java/com/readrops/api/localfeed/json/JSONItem.kt delete mode 100644 api/src/main/java/com/readrops/api/localfeed/rss/RSSChannel.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/rss/RSSEnclosure.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/rss/RSSFeed.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/rss/RSSItem.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/rss/RSSLink.java delete mode 100644 api/src/main/java/com/readrops/api/localfeed/rss/RSSMediaContent.java delete mode 100644 app/src/main/java/com/readrops/app/utils/matchers/FeedMatcher.java delete mode 100644 app/src/main/java/com/readrops/app/utils/matchers/ItemMatcher.java diff --git a/api/src/main/java/com/readrops/api/localfeed/AFeed.kt b/api/src/main/java/com/readrops/api/localfeed/AFeed.kt deleted file mode 100644 index 3cbd7653..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/AFeed.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.readrops.api.localfeed - -/* - A simple class to give an abstract level to rss/atom/json feed classes - */ -abstract class AFeed { - var etag: String? = null - var lastModified: String? = null -} \ No newline at end of file diff --git a/api/src/main/java/com/readrops/api/localfeed/RSSQuery.java b/api/src/main/java/com/readrops/api/localfeed/RSSQuery.java deleted file mode 100644 index 75b8c8fc..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/RSSQuery.java +++ /dev/null @@ -1,198 +0,0 @@ -package com.readrops.api.localfeed; - -import android.accounts.NetworkErrorException; -import android.util.Log; - -import com.readrops.api.localfeed.atom.ATOMFeed; -import com.readrops.api.localfeed.json.JSONFeed; -import com.readrops.api.localfeed.rss.RSSFeed; -import com.readrops.api.localfeed.rss.RSSLink; -import com.readrops.api.utils.HttpManager; -import com.readrops.api.utils.LibUtils; -import com.readrops.api.utils.UnknownFormatException; -import com.squareup.moshi.JsonAdapter; -import com.squareup.moshi.Moshi; - -import org.simpleframework.xml.Serializer; -import org.simpleframework.xml.core.Persister; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; - -public class RSSQuery { - - private static final String TAG = RSSQuery.class.getSimpleName(); - - private static final String RSS_CONTENT_TYPE_REGEX = "([^;]+)"; - - private static final String RSS_2_REGEX = "rss.*version=\"2.0\""; - - private static final String ATOM_REGEX = "has to be called from another thread than the main one. - * - * @param url url to request - * @throws Exception - */ - public RSSQueryResult queryUrl(String url, Map headers) throws Exception { - Response response = query(url, headers); - - if (response.isSuccessful()) { - String header = response.header(LibUtils.CONTENT_TYPE_HEADER); - RSSType type = getRSSType(header); - - if (type == null) - return new RSSQueryResult(new UnknownFormatException("bad content type : " + header + "for " + url)); - - return parseFeed(response.body().byteStream(), type, response); - } else if (response.code() == 304) - return null; - else - return new RSSQueryResult(new NetworkErrorException("Error " + response.code() + " when requesting url " + url)); - } - - public boolean isUrlFeedLink(String url) throws IOException { - Response response = query(url, new HashMap<>()); - - if (response.isSuccessful()) { - String header = response.header(LibUtils.CONTENT_TYPE_HEADER); - RSSType type = getRSSType(header); - - if (type == RSSType.RSS_UNKNOWN) { - RSSType contentType = getContentRSSType(response.body().string()); - return contentType != RSSType.RSS_UNKNOWN; - } else return type != null; - } else - return false; - } - - private Response query(String url, Map headers) throws IOException { - OkHttpClient okHttpClient = HttpManager.getInstance().getOkHttpClient(); - HttpManager.getInstance().setCredentials(null); - - Request.Builder builder = new Request.Builder().url(url); - for (String header : headers.keySet()) { - String value = headers.get(header); - builder.addHeader(header, value); - } - - Request request = builder.build(); - return okHttpClient.newCall(request).execute(); - } - - private RSSType getRSSType(String contentType) { - Pattern pattern = Pattern.compile(RSS_CONTENT_TYPE_REGEX); - Matcher matcher = pattern.matcher(contentType); - - String header; - if (matcher.find()) - header = matcher.group(0); - else - header = contentType; - - switch (header) { - case LibUtils.RSS_DEFAULT_CONTENT_TYPE: - return RSSType.RSS_2; - case LibUtils.RSS_TEXT_CONTENT_TYPE: - case LibUtils.HTML_CONTENT_TYPE: - case LibUtils.RSS_APPLICATION_CONTENT_TYPE: - return RSSType.RSS_UNKNOWN; - case LibUtils.ATOM_CONTENT_TYPE: - return RSSType.RSS_ATOM; - case LibUtils.JSON_CONTENT_TYPE: - return RSSType.RSS_JSON; - default: - Log.d(TAG, "bad content type : " + contentType); - return null; - } - } - - /** - * Parse input feed - * - * @param stream source to parse - * @param type rss type, important to know the feed format - * @param response query response - * @throws Exception - */ - private RSSQueryResult parseFeed(InputStream stream, RSSType type, Response response) throws Exception { - String xml = LibUtils.inputStreamToString(stream); - Serializer serializer = new Persister(); - - if (type == RSSType.RSS_UNKNOWN) { - RSSType contentType = getContentRSSType(xml); - if (contentType == RSSType.RSS_UNKNOWN) { - return new RSSQueryResult(new UnknownFormatException("Unknown content format")); - } else - type = contentType; - } - - String etag = response.header(LibUtils.ETAG_HEADER); - String lastModified = response.header(LibUtils.LAST_MODIFIED_HEADER); - AFeed feed = null; - RSSQueryResult queryResult = new RSSQueryResult(); - - switch (type) { - case RSS_2: - feed = serializer.read(RSSFeed.class, xml); - - // workaround if the channel does not have any atom:link tag - if (((RSSFeed) feed).getChannel().getFeedUrl() == null) { - ((RSSFeed) feed).getChannel().getLinks().add(new RSSLink(null, response.request().url().toString())); - } - break; - case RSS_ATOM: - feed = serializer.read(ATOMFeed.class, xml); - ((ATOMFeed) feed).setWebsiteUrl(response.request().url().scheme() + "://" + response.request().url().host()); - ((ATOMFeed) feed).setUrl(response.request().url().toString()); - break; - case RSS_JSON: - Moshi moshi = new Moshi.Builder() - .build(); - - JsonAdapter jsonFeedAdapter = moshi.adapter(JSONFeed.class); - feed = jsonFeedAdapter.fromJson(xml); - break; - } - - queryResult.setFeed(feed); - queryResult.setRssType(type); - - feed.setEtag(etag); - feed.setLastModified(lastModified); - - return queryResult; - } - - private RSSType getContentRSSType(String content) { - RSSType type; - - if (Pattern.compile(RSS_2_REGEX).matcher(content).find()) - type = RSSType.RSS_2; - else if (Pattern.compile(ATOM_REGEX).matcher(content).find()) - type = RSSType.RSS_ATOM; - else - type = RSSType.RSS_UNKNOWN; - - return type; - } - - public enum RSSType { - RSS_2, - RSS_ATOM, - RSS_JSON, - RSS_UNKNOWN - } - - -} diff --git a/api/src/main/java/com/readrops/api/localfeed/RSSQueryResult.java b/api/src/main/java/com/readrops/api/localfeed/RSSQueryResult.java deleted file mode 100644 index 449e162a..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/RSSQueryResult.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.readrops.api.localfeed; - -public class RSSQueryResult { - - private AFeed feed; - - private RSSQuery.RSSType rssType; - - private Exception exception; - - public RSSQueryResult(Exception exception) { - this.exception = exception; - } - - public RSSQueryResult() { - - } - - public AFeed getFeed() { - return feed; - } - - public void setFeed(AFeed feed) { - this.feed = feed; - } - - public RSSQuery.RSSType getRssType() { - return rssType; - } - - public void setRssType(RSSQuery.RSSType rssType) { - this.rssType = rssType; - } - - public void setException(Exception exception) { - this.exception = exception; - } - - public Exception getException() { - return exception; - } -} diff --git a/api/src/main/java/com/readrops/api/localfeed/atom/ATOMAuthor.java b/api/src/main/java/com/readrops/api/localfeed/atom/ATOMAuthor.java deleted file mode 100644 index 302d06c3..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/atom/ATOMAuthor.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.readrops.api.localfeed.atom; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.Root; - -@Root(name = "author", strict = false) -public class ATOMAuthor { - - @Element(required = false) - private String name; - - @Element(required = false) - private String email; - - public String getName() { - return name; - } - - public String getEmail() { - return email; - } -} diff --git a/api/src/main/java/com/readrops/api/localfeed/atom/ATOMEntry.java b/api/src/main/java/com/readrops/api/localfeed/atom/ATOMEntry.java deleted file mode 100644 index 08671f1e..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/atom/ATOMEntry.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.readrops.api.localfeed.atom; - -import org.simpleframework.xml.Attribute; -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.List; - -@Root(name = "entry", strict = false) -public class ATOMEntry { - - @Element(required = false) - private String title; - - @ElementList(name = "link", inline = true, required = false) - private List links; - - @Element(required = false) - private String updated; - - @Element(required = false) - private String summary; - - @Element(required = false) - private String id; - - @Element(required = false) - private String content; - - @Attribute(name = "type", required = false) - private String contentType; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public List getLinks() { - return links; - } - - public void setLinks(List links) { - this.links = links; - } - - public String getUpdated() { - return updated; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getSummary() { - return summary; - } - - public void setSummary(String summary) { - this.summary = summary; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - public String getUrl() { - for (ATOMLink link : links) { - if (link.getRel() == null || link.getRel().equals("self") || link.getRel().equals("alternate")) - return link.getHref(); - } - - return null; - } -} diff --git a/api/src/main/java/com/readrops/api/localfeed/atom/ATOMFeed.java b/api/src/main/java/com/readrops/api/localfeed/atom/ATOMFeed.java deleted file mode 100644 index e83e3c1f..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/atom/ATOMFeed.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.readrops.api.localfeed.atom; - -import com.readrops.api.localfeed.AFeed; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.List; - -@Root(name = "feed", strict = false) -public class ATOMFeed extends AFeed { - - @Element(required = false) - private String title; - - @ElementList(name = "link", inline = true, required = false) - private List links; - - private String url; - - private String websiteUrl; - - @Element(required = false) - private String id; - - @Element(required = false) - private String subtitle; - - @Element(required = false) - private String updated; - - @Element(required = false) - private ATOMAuthor author; - - @ElementList(inline = true, required = false) - private List entries; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public List getLinks() { - return links; - } - - public void setLinks(List links) { - this.links = links; - } - - public String getSubtitle() { - return subtitle; - } - - public void setSubtitle(String subtitle) { - this.subtitle = subtitle; - } - - public String getUpdated() { - return updated; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public ATOMAuthor getAuthor() { - return author; - } - - public void setAuthor(ATOMAuthor author) { - this.author = author; - } - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getWebsiteUrl() { - return websiteUrl; - } - - public void setWebsiteUrl(String websiteUrl) { - this.websiteUrl = websiteUrl; - } - - /*public String getWebSiteUrl() { - return id; - } - - public String getUrl() { - if (links.size() > 0) { - if (links.get(0).getRel() != null) - return links.get(0).getHref(); - else { - if (links.size() > 1) - return links.get(1).getHref(); - else - return null; - } - } else - return null; - }*/ -} diff --git a/api/src/main/java/com/readrops/api/localfeed/atom/ATOMLink.java b/api/src/main/java/com/readrops/api/localfeed/atom/ATOMLink.java deleted file mode 100644 index 024a137f..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/atom/ATOMLink.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.readrops.api.localfeed.atom; - -import org.simpleframework.xml.Attribute; -import org.simpleframework.xml.Root; - -@Root(name = "link", strict = false) -public class ATOMLink { - - @Attribute(name = "href", required = false) - private String href; - - @Attribute(name = "rel", required = false) - private String rel; - - public String getHref() { - return href; - } - - public void setHref(String href) { - this.href = href; - } - - public String getRel() { - return rel; - } - - public void setRel(String rel) { - this.rel = rel; - } -} diff --git a/api/src/main/java/com/readrops/api/localfeed/json/JSONAuthor.kt b/api/src/main/java/com/readrops/api/localfeed/json/JSONAuthor.kt deleted file mode 100644 index 125e69a1..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/json/JSONAuthor.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.readrops.api.localfeed.json - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class JSONAuthor(val name: String, - val url: String, - @Json(name = "avatar") val avatarUrl: String?) \ No newline at end of file diff --git a/api/src/main/java/com/readrops/api/localfeed/json/JSONFeed.kt b/api/src/main/java/com/readrops/api/localfeed/json/JSONFeed.kt deleted file mode 100644 index 7d83d834..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/json/JSONFeed.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.readrops.api.localfeed.json - -import com.readrops.api.localfeed.AFeed -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class JSONFeed(val version: String, - val title: String, - @Json(name = "home_page_url") val homePageUrl: String?, - @Json(name = "feed_url") val feedUrl: String?, - val description: String?, - @Json(name = "icon") val iconUrl: String?, - @Json(name = "favicon") val faviconUrl: String?, - val items: List) : AFeed() \ No newline at end of file diff --git a/api/src/main/java/com/readrops/api/localfeed/json/JSONItem.kt b/api/src/main/java/com/readrops/api/localfeed/json/JSONItem.kt deleted file mode 100644 index 94e50b51..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/json/JSONItem.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.readrops.api.localfeed.json - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class JSONItem(val id: String, - val title: String?, - val summary: String?, - @Json(name = "content_text") val contentText: String?, - @Json(name = "content_html") val contentHtml: String?, - val url: String?, - @Json(name = "image") val imageUrl: String?, - @Json(name = "date_published") val pubDate: String, - @Json(name = "date_modified") val modDate: String?, - val author: JSONAuthor?) { - - fun getContent(): String? { - return contentHtml ?: contentText - } -} \ No newline at end of file diff --git a/api/src/main/java/com/readrops/api/localfeed/rss/RSSChannel.java b/api/src/main/java/com/readrops/api/localfeed/rss/RSSChannel.java deleted file mode 100644 index 32c88be3..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/rss/RSSChannel.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.readrops.api.localfeed.rss; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.List; - -@Root(name = "channel", strict = false) -public class RSSChannel { - - @Element(name = "title", required = false) - private String title; - - @Element(name = "description", required = false) - private String description; - - // workaround to get the two links (feed and regular) - @ElementList(name = "link", inline = true, required = false) - private List links; - - @Element(name = "lastBuildDate", required = false) - private String lastUpdated; - - @ElementList(inline = true, required = false) - private List items; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public List getLinks() { - return links; - } - - public void setLinks(List links) { - this.links = links; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - - public String getLastUpdated() { - return lastUpdated; - } - - public void setLastUpdated(String lastUpdated) { - this.lastUpdated = lastUpdated; - } - - public String getFeedUrl() { - if (links.size() > 1) { - if (links.get(0).getHref() != null) - return links.get(0).getHref(); - else - return links.get(1).getHref(); - } else - return null; - } - - public String getUrl() { - if (links.size() > 1) { - if (links.get(1).getText() != null) - return links.get(1).getText(); - else - return links.get(0).getText(); - } else - return null; - } -} diff --git a/api/src/main/java/com/readrops/api/localfeed/rss/RSSEnclosure.java b/api/src/main/java/com/readrops/api/localfeed/rss/RSSEnclosure.java deleted file mode 100644 index 45a25dbd..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/rss/RSSEnclosure.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.readrops.api.localfeed.rss; - -import org.simpleframework.xml.Attribute; -import org.simpleframework.xml.Root; - -@Root(name = "enclosure", strict = false) -public class RSSEnclosure { - - @Attribute(required = false) - private String type; - - @Attribute(required = false) - private String url; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } -} diff --git a/api/src/main/java/com/readrops/api/localfeed/rss/RSSFeed.java b/api/src/main/java/com/readrops/api/localfeed/rss/RSSFeed.java deleted file mode 100644 index e52ab253..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/rss/RSSFeed.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.readrops.api.localfeed.rss; - -import com.readrops.api.localfeed.AFeed; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.Root; - -@Root(name = "rss", strict = false) -public class RSSFeed extends AFeed { - - @Element(name = "channel", required = false) - private RSSChannel channel; - - public RSSChannel getChannel() { - return channel; - } - - public void setChannel(RSSChannel channel) { - this.channel = channel; - } -} diff --git a/api/src/main/java/com/readrops/api/localfeed/rss/RSSItem.java b/api/src/main/java/com/readrops/api/localfeed/rss/RSSItem.java deleted file mode 100644 index 7cd15406..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/rss/RSSItem.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.readrops.api.localfeed.rss; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Namespace; -import org.simpleframework.xml.Root; - -import java.util.List; - -@Root(name = "item", strict = false) -public class RSSItem { - - @Element - private String title; - - @Element(name = "link", required = false) - private String link; - - @Element(name = "imageLink", required = false) - private String imageLink; - - @ElementList(name = "content", inline = true, required = false) - @Namespace(prefix = "media") - private List mediaContents; - - @ElementList(name = "enclosure", inline = true, required = false) - private List enclosures; - - @ElementList(name = "creator", inline = true, required = false) - @Namespace(prefix = "dc", reference = "http://purl.org/dc/elements/1.1/") - private List creator; - - @Element(required = false) - private String author; - - @Element(name = "pubDate", required = false) - private String pubDate; - - @Element(name = "date", required = false) - @Namespace(prefix = "dc") - private String date; - - @Element(name = "description", required = false) - private String description; - - @Element(name = "encoded", required = false) - @Namespace(prefix = "content") - private String content; - - @Element(required = false) - private String guid; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - public String getImageLink() { - return imageLink; - } - - public void setImageLink(String imageLink) { - this.imageLink = imageLink; - } - - public List getCreator() { - return creator; - } - - public void setCreator(List creator) { - this.creator = creator; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getGuid() { - return guid; - } - - public void setGuid(String guid) { - this.guid = guid; - } - - public List getMediaContents() { - return mediaContents; - } - - public void setMediaContents(List mediaContents) { - this.mediaContents = mediaContents; - } - - public List getEnclosures() { - return enclosures; - } - - public void setEnclosures(List enclosures) { - this.enclosures = enclosures; - } - - public String getDate() { - if (pubDate != null) - return pubDate; - else - return date; - } - - public void setDate(String date) { - this.date = date; - } - - public String getAuthor() { - if (creator != null && !creator.isEmpty()) - return creator.get(0); - else - return author; - } - - public void setAuthor(String author) { - this.author = author; - } -} diff --git a/api/src/main/java/com/readrops/api/localfeed/rss/RSSLink.java b/api/src/main/java/com/readrops/api/localfeed/rss/RSSLink.java deleted file mode 100644 index e6511c33..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/rss/RSSLink.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.readrops.api.localfeed.rss; - -import org.simpleframework.xml.Attribute; -import org.simpleframework.xml.Root; -import org.simpleframework.xml.Text; - -@Root(name = "link", strict = false) -public class RSSLink { - - @Text(required = false) - private String text; - - @Attribute(name = "href", required = false) - private String href; - - public RSSLink() { - - } - - public RSSLink(String text, String href) { - this.text = text; - this.href = href; - } - - public String getHref() { - return href; - } - - public void setHref(String href) { - this.href = href; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } -} diff --git a/api/src/main/java/com/readrops/api/localfeed/rss/RSSMediaContent.java b/api/src/main/java/com/readrops/api/localfeed/rss/RSSMediaContent.java deleted file mode 100644 index 4e7c38e1..00000000 --- a/api/src/main/java/com/readrops/api/localfeed/rss/RSSMediaContent.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.readrops.api.localfeed.rss; - -import org.simpleframework.xml.Attribute; -import org.simpleframework.xml.Root; - -@Root(name = "content", strict = false) -public class RSSMediaContent { - - @Attribute(required = false) - private String url; - - @Attribute(required = false) - private String medium; - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getMedium() { - return medium; - } - - public void setMedium(String medium) { - this.medium = medium; - } -} diff --git a/app/src/main/java/com/readrops/app/utils/matchers/FeedMatcher.java b/app/src/main/java/com/readrops/app/utils/matchers/FeedMatcher.java deleted file mode 100644 index bb07ae91..00000000 --- a/app/src/main/java/com/readrops/app/utils/matchers/FeedMatcher.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.readrops.app.utils.matchers; - -import com.readrops.db.entities.Feed; -import com.readrops.api.localfeed.atom.ATOMFeed; -import com.readrops.api.localfeed.json.JSONFeed; -import com.readrops.api.localfeed.rss.RSSChannel; -import com.readrops.api.localfeed.rss.RSSFeed; - -import org.jsoup.Jsoup; - -public final class FeedMatcher { - - public static Feed feedFromRSS(RSSFeed rssFeed) { - Feed feed = new Feed(); - RSSChannel channel = rssFeed.getChannel(); - - feed.setName(Jsoup.parse(channel.getTitle()).text()); - feed.setUrl(channel.getFeedUrl()); - feed.setSiteUrl(channel.getUrl()); - feed.setDescription(channel.getDescription()); - feed.setLastUpdated(channel.getLastUpdated()); - - feed.setEtag(rssFeed.getEtag()); - feed.setLastModified(rssFeed.getLastModified()); - - feed.setFolderId(null); - - return feed; - } - - public static Feed feedFromATOM(ATOMFeed atomFeed) { - Feed feed = new Feed(); - - feed.setName(atomFeed.getTitle()); - feed.setDescription(atomFeed.getSubtitle()); - feed.setUrl(atomFeed.getUrl()); - feed.setSiteUrl(atomFeed.getWebsiteUrl()); - feed.setDescription(atomFeed.getSubtitle()); - feed.setLastUpdated(atomFeed.getUpdated()); - - feed.setEtag(atomFeed.getEtag()); - feed.setLastModified(atomFeed.getLastModified()); - - feed.setFolderId(null); - - return feed; - } - - public static Feed feedFromJSON(JSONFeed jsonFeed) { - Feed feed = new Feed(); - - feed.setName(jsonFeed.getTitle()); - feed.setUrl(jsonFeed.getFeedUrl()); - feed.setSiteUrl(jsonFeed.getHomePageUrl()); - feed.setDescription(jsonFeed.getDescription()); - - feed.setEtag(jsonFeed.getEtag()); - feed.setLastModified(jsonFeed.getLastModified()); - feed.setIconUrl(jsonFeed.getFaviconUrl()); - - feed.setFolderId(null); - - return feed; - } -} diff --git a/app/src/main/java/com/readrops/app/utils/matchers/ItemMatcher.java b/app/src/main/java/com/readrops/app/utils/matchers/ItemMatcher.java deleted file mode 100644 index 58803743..00000000 --- a/app/src/main/java/com/readrops/app/utils/matchers/ItemMatcher.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.readrops.app.utils.matchers; - -import com.readrops.api.localfeed.atom.ATOMEntry; -import com.readrops.api.localfeed.json.JSONItem; -import com.readrops.api.localfeed.rss.RSSEnclosure; -import com.readrops.api.localfeed.rss.RSSItem; -import com.readrops.api.localfeed.rss.RSSMediaContent; -import com.readrops.api.utils.DateUtils; -import com.readrops.api.utils.LibUtils; -import com.readrops.api.utils.ParseException; -import com.readrops.app.utils.Utils; -import com.readrops.db.entities.Feed; -import com.readrops.db.entities.Item; - -import java.util.ArrayList; -import java.util.List; - -public final class ItemMatcher { - - public static List itemsFromRSS(List items, Feed feed) throws ParseException { - List dbItems = new ArrayList<>(); - - for (RSSItem item : items) { - Item newItem = new Item(); - - newItem.setAuthor(item.getAuthor()); - newItem.setContent(item.getContent()); // Jsoup.clean(item.getContent(), Whitelist.relaxed()) - newItem.setDescription(item.getDescription()); - newItem.setGuid(item.getGuid() != null ? item.getGuid() : item.getLink()); - newItem.setTitle(LibUtils.cleanText(item.getTitle())); - - try { - newItem.setPubDate(DateUtils.stringToLocalDateTime(item.getDate())); - } catch (Exception e) { - throw new ParseException(); - } - - newItem.setLink(item.getLink()); - newItem.setFeedId(feed.getId()); - - if (item.getMediaContents() != null && !item.getMediaContents().isEmpty()) { - for (RSSMediaContent mediaContent : item.getMediaContents()) { - if (mediaContent.getMedium() != null && Utils.isTypeImage(mediaContent.getMedium())) { - newItem.setImageLink(mediaContent.getUrl()); - break; - } - } - } else { - if (item.getEnclosures() != null) { - for (RSSEnclosure enclosure : item.getEnclosures()) { - if (enclosure.getType() != null && Utils.isTypeImage(enclosure.getType()) - && enclosure.getUrl() != null) { - newItem.setImageLink(enclosure.getUrl()); - break; - } - } - - } - } - - dbItems.add(newItem); - } - - return dbItems; - } - - public static List itemsFromATOM(List items, Feed feed) throws ParseException { - List dbItems = new ArrayList<>(); - - for (ATOMEntry item : items) { - Item dbItem = new Item(); - - dbItem.setContent(item.getContent()); // Jsoup.clean(item.getContent(), Whitelist.relaxed()) - dbItem.setDescription(item.getSummary()); - dbItem.setGuid(item.getId()); - dbItem.setTitle(LibUtils.cleanText(item.getTitle())); - - try { - dbItem.setPubDate(DateUtils.stringToLocalDateTime(item.getUpdated())); - } catch (Exception e) { - throw new ParseException(); - } - - dbItem.setLink(item.getUrl()); - - dbItem.setFeedId(feed.getId()); - - dbItems.add(dbItem); - } - - return dbItems; - } - - public static List itemsFromJSON(List items, Feed feed) throws ParseException { - List dbItems = new ArrayList<>(); - - for (JSONItem item : items) { - Item dbItem = new Item(); - - if (item.getAuthor() != null) - dbItem.setAuthor(item.getAuthor().getName()); - - dbItem.setContent(item.getContent()); // Jsoup.clean(item.getContent(), Whitelist.relaxed()) - dbItem.setDescription(item.getSummary()); - dbItem.setGuid(item.getId()); - dbItem.setTitle(LibUtils.cleanText(item.getTitle())); - - try { - dbItem.setPubDate(DateUtils.stringToLocalDateTime(item.getPubDate())); - } catch (Exception e) { - throw new ParseException(); - } - - dbItem.setLink(item.getUrl()); - - dbItem.setFeedId(feed.getId()); - - dbItems.add(dbItem); - } - - return dbItems; - } -}