initial starring support

This commit is contained in:
Athou
2013-04-29 22:37:26 +02:00
parent 7c061d333a
commit d5218b8773
5 changed files with 92 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
package com.commafeed.frontend.model.request;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.wordnik.swagger.annotations.ApiClass;
import com.wordnik.swagger.annotations.ApiProperty;
@SuppressWarnings("serial")
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@ApiClass("Star Request")
public class StarRequest implements Serializable {
@ApiProperty(value = "id", required = true)
private String id;
@ApiProperty(value = "starred or not")
private boolean starred;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public boolean isStarred() {
return starred;
}
public void setStarred(boolean starred) {
this.starred = starred;
}
}

View File

@@ -42,12 +42,13 @@ import com.wordnik.swagger.annotations.ApiParam;
public class CategoryREST extends AbstractResourceREST {
public static final String ALL = "all";
public static final String STARRED = "starred";
@Path("/entries")
@GET
@ApiOperation(value = "Get category entries", notes = "Get a list of category entries", responseClass = "com.commafeed.frontend.model.Entries")
public Entries getCategoryEntries(
@ApiParam(value = "id of the category, or 'all'", required = true) @QueryParam("id") String id,
@ApiParam(value = "id of the category, 'all' or 'starred'", required = true) @QueryParam("id") String id,
@ApiParam(value = "all entries or only unread ones", allowableValues = "all,unread", required = true) @QueryParam("readType") ReadType readType,
@ApiParam(value = "offset for paging") @DefaultValue("0") @QueryParam("offset") int offset,
@ApiParam(value = "limit for paging") @DefaultValue("-1") @QueryParam("limit") int limit,
@@ -67,6 +68,13 @@ public class CategoryREST extends AbstractResourceREST {
entries.getEntries().add(Entry.build(status));
}
} else if (STARRED.equals(id)) {
entries.setName("Starred");
List<FeedEntryStatus> starred = feedEntryStatusDAO.findStarred(
getUser(), offset, limit, order, true);
for (FeedEntryStatus status : starred) {
entries.getEntries().add(Entry.build(status));
}
} else {
FeedCategory feedCategory = feedCategoryDAO.findById(getUser(),
Long.valueOf(id));

View File

@@ -16,6 +16,7 @@ import com.commafeed.backend.model.FeedEntryStatus;
import com.commafeed.frontend.model.Entries;
import com.commafeed.frontend.model.Entry;
import com.commafeed.frontend.model.request.MarkRequest;
import com.commafeed.frontend.model.request.StarRequest;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.wordnik.swagger.annotations.Api;
@@ -40,6 +41,20 @@ public class EntryREST extends AbstractResourceREST {
return Response.ok(Status.OK).build();
}
@Path("/star")
@POST
@ApiOperation(value = "Mark a feed entry", notes = "Mark a feed entry as read/unread")
public Response starFeedEntry(
@ApiParam(value = "Star Request", required = true) StarRequest req) {
Preconditions.checkNotNull(req);
Preconditions.checkNotNull(req.getId());
feedEntryService.starEntry(getUser(), Long.valueOf(req.getId()),
req.isStarred());
return Response.ok(Status.OK).build();
}
@Path("/search")
@GET
@ApiOperation(value = "Search for entries", notes = "Look through title and content of entries by keywords", responseClass = "com.commafeed.frontend.model.Entries")