From 852f83437727d430af572af61f3ac6256352bccc Mon Sep 17 00:00:00 2001 From: Athou Date: Tue, 16 Apr 2013 10:42:34 +0200 Subject: [PATCH] api tweak --- .../backend/feeds/FeedRefreshWorker.java | 9 ------ .../frontend/rest/resources/EntriesREST.java | 8 ++--- .../rest/resources/SubscriptionsREST.java | 32 +++++++++---------- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/commafeed/backend/feeds/FeedRefreshWorker.java b/src/main/java/com/commafeed/backend/feeds/FeedRefreshWorker.java index 796772c5..98131442 100644 --- a/src/main/java/com/commafeed/backend/feeds/FeedRefreshWorker.java +++ b/src/main/java/com/commafeed/backend/feeds/FeedRefreshWorker.java @@ -69,15 +69,6 @@ public class FeedRefreshWorker { return new AsyncResult(null); } - @Asynchronous - public void updateAsync(Feed feed) { - try { - update(feed); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - } - private void update(Feed feed) throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, diff --git a/src/main/java/com/commafeed/frontend/rest/resources/EntriesREST.java b/src/main/java/com/commafeed/frontend/rest/resources/EntriesREST.java index e3ad9900..2f7c4d78 100644 --- a/src/main/java/com/commafeed/frontend/rest/resources/EntriesREST.java +++ b/src/main/java/com/commafeed/frontend/rest/resources/EntriesREST.java @@ -48,7 +48,7 @@ public class EntriesREST extends AbstractREST { @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, - @ApiParam(value = "entry date ordering", allowableValues = "asc,desc") @QueryParam("order") @DefaultValue("desc") ReadingOrder order) { + @ApiParam(value = "date ordering", allowableValues = "asc,desc") @QueryParam("order") @DefaultValue("desc") ReadingOrder order) { Preconditions.checkNotNull(id); Preconditions.checkNotNull(readType); @@ -83,7 +83,7 @@ public class EntriesREST extends AbstractREST { @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, - @ApiParam(value = "entry date ordering", allowableValues = "asc,desc") @QueryParam("order") @DefaultValue("desc") ReadingOrder order) { + @ApiParam(value = "date ordering", allowableValues = "asc,desc") @QueryParam("order") @DefaultValue("desc") ReadingOrder order) { Preconditions.checkNotNull(id); Preconditions.checkNotNull(readType); @@ -179,7 +179,7 @@ public class EntriesREST extends AbstractREST { @Path("/category/mark") @GET - @ApiOperation(value = "Mark feed entries", notes = "Mark feed entries as read/unread") + @ApiOperation(value = "Mark category entries", notes = "Mark feed entries as read/unread") public Response markCategoryEntries( @ApiParam(value = "category id, or 'all'", required = true) @QueryParam("id") String id, @ApiParam(value = "only entries older than this, prevent marking an entry that was not retrieved") @QueryParam("olderThan") Long olderThanTimestamp) { @@ -205,7 +205,7 @@ public class EntriesREST extends AbstractREST { @Path("/search") @GET - @ApiOperation(value = "Search for entries", notes = "Look through title and content of entries by keywords") + @ApiOperation(value = "Search for entries", notes = "Look through title and content of entries by keywords", responseClass = "com.commafeed.frontend.model.Entries") public Entries searchEntries( @ApiParam(value = "keywords separated by spaces, 3 characters minimum", required = true) @QueryParam("keywords") String keywords, @ApiParam(value = "offset for paging") @DefaultValue("0") @QueryParam("offset") int offset, diff --git a/src/main/java/com/commafeed/frontend/rest/resources/SubscriptionsREST.java b/src/main/java/com/commafeed/frontend/rest/resources/SubscriptionsREST.java index a086fdf4..91073bb9 100644 --- a/src/main/java/com/commafeed/frontend/rest/resources/SubscriptionsREST.java +++ b/src/main/java/com/commafeed/frontend/rest/resources/SubscriptionsREST.java @@ -5,7 +5,6 @@ import java.util.Comparator; import java.util.List; import java.util.Map; -import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -23,7 +22,6 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ObjectUtils; -import com.commafeed.backend.feeds.FeedRefreshWorker; import com.commafeed.backend.model.Feed; import com.commafeed.backend.model.FeedCategory; import com.commafeed.backend.model.FeedSubscription; @@ -32,15 +30,16 @@ import com.commafeed.frontend.model.Subscription; import com.commafeed.frontend.model.SubscriptionRequest; import com.commafeed.frontend.rest.resources.EntriesREST.Type; import com.google.common.base.Preconditions; +import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiOperation; -@Path("subscriptions") +@Path("/subscriptions") +@Api(value = "/subscriptions", description = "Operations about user feed subscriptions") public class SubscriptionsREST extends AbstractREST { - @Inject - FeedRefreshWorker worker; - @GET - @Path("fetch") + @Path("/fetch") + @ApiOperation(value = "Search for entries", notes = "Look through title and content of entries by keywords", responseClass = "com.commafeed.frontend.model.Entries") public Feed fetchFeed(@QueryParam("url") String url) { Preconditions.checkNotNull(url); @@ -57,7 +56,7 @@ public class SubscriptionsREST extends AbstractREST { } @POST - @Path("subscribe") + @Path("/subscribe") public Response subscribe(SubscriptionRequest req) { Preconditions.checkNotNull(req); Preconditions.checkNotNull(req.getTitle()); @@ -69,9 +68,8 @@ public class SubscriptionsREST extends AbstractREST { FeedCategory category = EntriesREST.ALL.equals(req.getCategoryId()) ? null : feedCategoryDAO.findById(Long.valueOf(req.getCategoryId())); Feed fetchedFeed = fetchFeed(url); - Feed feed = feedSubscriptionService.subscribe(getUser(), - fetchedFeed.getUrl(), req.getTitle(), category); - worker.updateAsync(feed); + feedSubscriptionService.subscribe(getUser(), fetchedFeed.getUrl(), + req.getTitle(), category); return Response.ok(Status.OK).build(); } @@ -84,7 +82,7 @@ public class SubscriptionsREST extends AbstractREST { } @GET - @Path("unsubscribe") + @Path("/unsubscribe") public Response unsubscribe(@QueryParam("id") Long subscriptionId) { FeedSubscription sub = feedSubscriptionDAO.findById(getUser(), subscriptionId); @@ -97,7 +95,7 @@ public class SubscriptionsREST extends AbstractREST { } @GET - @Path("rename") + @Path("/rename") public Response rename(@QueryParam("type") Type type, @QueryParam("id") Long id, @QueryParam("name") String name) { if (type == Type.feed) { @@ -114,7 +112,7 @@ public class SubscriptionsREST extends AbstractREST { } @GET - @Path("collapse") + @Path("/collapse") public Response collapse(@QueryParam("id") String id, @QueryParam("collapse") boolean collapse) { Preconditions.checkNotNull(id); @@ -127,7 +125,7 @@ public class SubscriptionsREST extends AbstractREST { return Response.ok(Status.OK).build(); } - @Path("addCategory") + @Path("/addCategory") @GET public Response addCategory(@QueryParam("name") String name, @QueryParam("parentId") String parentId) { @@ -146,7 +144,7 @@ public class SubscriptionsREST extends AbstractREST { } @GET - @Path("deleteCategory") + @Path("/deleteCategory") public Response deleteCategory(@QueryParam("id") Long id) { FeedCategory cat = feedCategoryDAO.findById(getUser(), id); if (cat != null) { @@ -164,7 +162,7 @@ public class SubscriptionsREST extends AbstractREST { } @POST - @Path("import") + @Path("/import") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response importOpml() { try {