This commit is contained in:
Athou
2013-04-09 11:10:26 +02:00
parent 1f8aa26571
commit 384bafa38e
8 changed files with 130 additions and 21 deletions

View File

@@ -42,8 +42,9 @@ import com.commafeed.frontend.pages.FaviconPage;
import com.commafeed.frontend.pages.GoogleImportCallbackPage;
import com.commafeed.frontend.pages.GoogleImportRedirectPage;
import com.commafeed.frontend.pages.HomePage;
import com.commafeed.frontend.pages.WelcomePage;
import com.commafeed.frontend.pages.LogoutPage;
import com.commafeed.frontend.pages.TestRssPage;
import com.commafeed.frontend.pages.WelcomePage;
import com.commafeed.frontend.utils.exception.DisplayExceptionPage;
import de.agilecoders.wicket.Bootstrap;
@@ -64,6 +65,8 @@ public class CommaFeedApplication extends AuthenticatedWebApplication {
mountPage("google/import/redirect", GoogleImportRedirectPage.class);
mountPage("google/import/callback", GoogleImportCallbackPage.class);
mountPage("testfeed", TestRssPage.class);
setupInjection();
getMarkupSettings().setStripWicketTags(true);

View File

@@ -10,6 +10,7 @@ public class Entries implements Serializable {
private String name;
private String message;
private int errorCount;
private long timestamp;
private List<Entry> entries = Lists.newArrayList();
public String getName() {
@@ -44,4 +45,12 @@ public class Entries implements Serializable {
this.errorCount = errorCount;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
}

View File

@@ -0,0 +1,53 @@
package com.commafeed.frontend.pages;
import java.io.StringWriter;
import java.util.Calendar;
import java.util.List;
import java.util.UUID;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.handler.TextRequestHandler;
import com.google.common.collect.Lists;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndEntryImpl;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.feed.synd.SyndFeedImpl;
import com.sun.syndication.io.SyndFeedOutput;
@SuppressWarnings("serial")
public class TestRssPage extends WebPage {
public TestRssPage() {
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("rss_2.0");
feed.setTitle("Test RSS");
feed.setLink("");
feed.setDescription("New entries everytime it is accessed");
List<SyndEntry> entries = Lists.newArrayList();
for (int i = 0; i < 5; i++) {
SyndEntry entry = new SyndEntryImpl();
String uuid = UUID.randomUUID().toString();
entry.setUri(uuid);
entry.setTitle(uuid);
entry.setLink("http://www.example.com/" + uuid);
entry.setPublishedDate(Calendar.getInstance().getTime());
entries.add(entry);
}
feed.setEntries(entries);
SyndFeedOutput output = new SyndFeedOutput();
StringWriter writer = new StringWriter();
try {
output.output(feed, writer);
} catch (Exception e) {
writer.write("Could not get feed information");
}
getRequestCycle().scheduleRequestHandlerAfterCurrent(
new TextRequestHandler("text/xml", "UTF-8", writer.toString()));
}
}

View File

@@ -1,5 +1,7 @@
package com.commafeed.frontend.rest.resources;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.ws.rs.DefaultValue;
@@ -92,7 +94,7 @@ public class EntriesREST extends AbstractREST {
}
}
entries.setTimestamp(Calendar.getInstance().getTimeInMillis());
return entries;
}
@@ -117,11 +119,15 @@ public class EntriesREST extends AbstractREST {
@Path("mark")
@GET
public Response mark(@QueryParam("type") Type type,
@QueryParam("id") String id, @QueryParam("read") boolean read) {
@QueryParam("id") String id, @QueryParam("read") boolean read,
@QueryParam("olderThan") Long olderThanTimestamp) {
Preconditions.checkNotNull(type);
Preconditions.checkNotNull(id);
Preconditions.checkNotNull(read);
Date olderThan = olderThanTimestamp == null ? null : new Date(
olderThanTimestamp);
if (type == Type.entry) {
FeedEntryStatus status = feedEntryStatusService.findById(getUser(),
Long.valueOf(id));
@@ -132,7 +138,7 @@ public class EntriesREST extends AbstractREST {
FeedSubscription subscription = feedSubscriptionService
.findById(getUser(), Long.valueOf(id));
feedEntryStatusService.markFeedEntries(getUser(),
subscription.getFeed());
subscription.getFeed(), olderThan);
} else {
throw new WebApplicationException(Response.status(
Status.INTERNAL_SERVER_ERROR).build());
@@ -140,14 +146,14 @@ public class EntriesREST extends AbstractREST {
} else if (type == Type.category) {
if (read) {
if (ALL.equals(id)) {
feedEntryStatusService.markAllEntries(getUser());
feedEntryStatusService.markAllEntries(getUser(), olderThan);
} else {
List<FeedCategory> categories = feedCategoryService
.findAllChildrenCategories(getUser(),
feedCategoryService.findById(getUser(),
Long.valueOf(id)));
feedEntryStatusService.markCategoryEntries(getUser(),
categories);
categories, olderThan);
}
} else {
throw new WebApplicationException(Response.status(