forked from Archives/Athou_commafeed
fix build warning
This commit is contained in:
@@ -10,7 +10,6 @@ import com.codahale.metrics.Timer;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection(
|
||||
registerFullHierarchy = true,
|
||||
targets = {
|
||||
// metrics
|
||||
MetricRegistry.class, Meter.class, Gauge.class, Counter.class, Timer.class, Histogram.class,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.commafeed.backend.feed;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
@@ -8,6 +11,11 @@ import org.jsoup.select.Elements;
|
||||
|
||||
import com.commafeed.backend.feed.parser.TextDirectionDetector;
|
||||
import com.commafeed.backend.model.FeedSubscription;
|
||||
import com.commafeed.frontend.model.Entry;
|
||||
import com.rometools.rome.feed.synd.SyndContentImpl;
|
||||
import com.rometools.rome.feed.synd.SyndEnclosureImpl;
|
||||
import com.rometools.rome.feed.synd.SyndEntry;
|
||||
import com.rometools.rome.feed.synd.SyndEntryImpl;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -68,4 +76,27 @@ public class FeedUtils {
|
||||
return "rest/server/proxy?u=" + ImageProxyUrl.encode(url);
|
||||
}
|
||||
|
||||
public static SyndEntry asRss(Entry entry) {
|
||||
SyndEntry e = new SyndEntryImpl();
|
||||
|
||||
e.setUri(entry.getGuid());
|
||||
e.setTitle(entry.getTitle());
|
||||
e.setAuthor(entry.getAuthor());
|
||||
|
||||
SyndContentImpl c = new SyndContentImpl();
|
||||
c.setValue(entry.getContent());
|
||||
e.setContents(Collections.singletonList(c));
|
||||
|
||||
if (entry.getEnclosureUrl() != null) {
|
||||
SyndEnclosureImpl enclosure = new SyndEnclosureImpl();
|
||||
enclosure.setType(entry.getEnclosureType());
|
||||
enclosure.setUrl(entry.getEnclosureUrl());
|
||||
e.setEnclosures(Collections.singletonList(enclosure));
|
||||
}
|
||||
|
||||
e.setLink(entry.getUrl());
|
||||
e.setPublishedDate(entry.getDate() == null ? null : Date.from(entry.getDate()));
|
||||
return e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.commafeed.frontend.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -16,10 +14,6 @@ import com.commafeed.backend.model.FeedEntryContent;
|
||||
import com.commafeed.backend.model.FeedEntryStatus;
|
||||
import com.commafeed.backend.model.FeedEntryTag;
|
||||
import com.commafeed.backend.model.FeedSubscription;
|
||||
import com.rometools.rome.feed.synd.SyndContentImpl;
|
||||
import com.rometools.rome.feed.synd.SyndEnclosureImpl;
|
||||
import com.rometools.rome.feed.synd.SyndEntry;
|
||||
import com.rometools.rome.feed.synd.SyndEntryImpl;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.Data;
|
||||
@@ -149,26 +143,4 @@ public class Entry implements Serializable {
|
||||
return entry;
|
||||
}
|
||||
|
||||
public SyndEntry asRss() {
|
||||
SyndEntry entry = new SyndEntryImpl();
|
||||
|
||||
entry.setUri(getGuid());
|
||||
entry.setTitle(getTitle());
|
||||
entry.setAuthor(getAuthor());
|
||||
|
||||
SyndContentImpl content = new SyndContentImpl();
|
||||
content.setValue(getContent());
|
||||
entry.setContents(Collections.singletonList(content));
|
||||
|
||||
if (getEnclosureUrl() != null) {
|
||||
SyndEnclosureImpl enclosure = new SyndEnclosureImpl();
|
||||
enclosure.setType(getEnclosureType());
|
||||
enclosure.setUrl(getEnclosureUrl());
|
||||
entry.setEnclosures(Collections.singletonList(enclosure));
|
||||
}
|
||||
|
||||
entry.setLink(getUrl());
|
||||
entry.setPublishedDate(getDate() == null ? null : Date.from(getDate()));
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.commafeed.backend.dao.FeedCategoryDAO;
|
||||
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
||||
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
||||
import com.commafeed.backend.feed.FeedEntryKeyword;
|
||||
import com.commafeed.backend.feed.FeedUtils;
|
||||
import com.commafeed.backend.model.FeedCategory;
|
||||
import com.commafeed.backend.model.FeedEntryStatus;
|
||||
import com.commafeed.backend.model.FeedSubscription;
|
||||
@@ -217,7 +218,7 @@ public class CategoryREST {
|
||||
feed.setTitle("CommaFeed - " + entries.getName());
|
||||
feed.setDescription("CommaFeed - " + entries.getName());
|
||||
feed.setLink(uri.getBaseUri().toString());
|
||||
feed.setEntries(entries.getEntries().stream().map(Entry::asRss).toList());
|
||||
feed.setEntries(entries.getEntries().stream().map(FeedUtils::asRss).toList());
|
||||
|
||||
SyndFeedOutput output = new SyndFeedOutput();
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.commafeed.backend.feed.FeedEntryKeyword;
|
||||
import com.commafeed.backend.feed.FeedFetcher;
|
||||
import com.commafeed.backend.feed.FeedFetcher.FeedFetcherResult;
|
||||
import com.commafeed.backend.feed.FeedRefreshEngine;
|
||||
import com.commafeed.backend.feed.FeedUtils;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
import com.commafeed.backend.model.FeedCategory;
|
||||
import com.commafeed.backend.model.FeedEntry;
|
||||
@@ -219,7 +220,7 @@ public class FeedREST {
|
||||
feed.setTitle("CommaFeed - " + entries.getName());
|
||||
feed.setDescription("CommaFeed - " + entries.getName());
|
||||
feed.setLink(uri.getBaseUri().toString());
|
||||
feed.setEntries(entries.getEntries().stream().map(Entry::asRss).toList());
|
||||
feed.setEntries(entries.getEntries().stream().map(FeedUtils::asRss).toList());
|
||||
|
||||
SyndFeedOutput output = new SyndFeedOutput();
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.commafeed.frontend.model;
|
||||
package com.commafeed.backend.feed;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
@@ -6,9 +6,10 @@ import java.util.Date;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.commafeed.frontend.model.Entry;
|
||||
import com.rometools.rome.feed.synd.SyndEntry;
|
||||
|
||||
class EntryTest {
|
||||
class FeedUtilsTest {
|
||||
|
||||
@Test
|
||||
void asRss() {
|
||||
@@ -25,7 +26,7 @@ class EntryTest {
|
||||
entry.setDate(Instant.ofEpochSecond(1));
|
||||
entry.setUrl("http://example.com/test-entry");
|
||||
|
||||
SyndEntry syndEntry = entry.asRss();
|
||||
SyndEntry syndEntry = FeedUtils.asRss(entry);
|
||||
Assertions.assertEquals("guid-1", syndEntry.getUri());
|
||||
Assertions.assertEquals("Test Entry", syndEntry.getTitle());
|
||||
Assertions.assertEquals("Author Name", syndEntry.getAuthor());
|
||||
@@ -37,5 +38,4 @@ class EntryTest {
|
||||
Assertions.assertEquals("http://example.com/test-entry", syndEntry.getLink());
|
||||
Assertions.assertEquals(Date.from(Instant.ofEpochSecond(1)), syndEntry.getPublishedDate());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user