api tweak

This commit is contained in:
Athou
2013-04-16 10:42:34 +02:00
parent 43eafd51c7
commit 852f834377
3 changed files with 19 additions and 30 deletions

View File

@@ -69,15 +69,6 @@ public class FeedRefreshWorker {
return new AsyncResult<Void>(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,

View File

@@ -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,

View File

@@ -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 {