rename feeds

This commit is contained in:
Athou
2013-04-01 14:30:40 +02:00
parent c8b587a94b
commit 0ae088b100
5 changed files with 60 additions and 20 deletions

View File

@@ -25,6 +25,7 @@ import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.frontend.model.Category;
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.sun.syndication.io.FeedException;
@@ -78,12 +79,29 @@ public class SubscriptionsREST extends AbstractREST {
return Response.ok(Status.OK).build();
}
@GET
@Path("rename")
public Response rename(@QueryParam("type") Type type,
@QueryParam("id") Long id, @QueryParam("name") String name) {
if (type == Type.feed) {
FeedSubscription subscription = feedSubscriptionService.findById(
getUser(), id);
subscription.setTitle(name);
feedSubscriptionService.update(subscription);
} else if (type == Type.category) {
FeedCategory category = feedCategoryService.findById(getUser(), id);
category.setName(name);
feedCategoryService.update(category);
}
return Response.ok(Status.OK).build();
}
@GET
@Path("collapse")
public Response collapse(@QueryParam("id") String id,
@QueryParam("collapse") boolean collapse) {
Preconditions.checkNotNull(id);
if (!"all".equals(id)) {
if (EntriesREST.ALL.equals(id)) {
FeedCategory category = feedCategoryService.findById(getUser(),
Long.valueOf(id));
category.setCollapsed(collapse);