mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
feed fetching now uses POST (fix #418)
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
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("Feed information request")
|
||||||
|
public class FeedInfoRequest implements Serializable {
|
||||||
|
|
||||||
|
@ApiProperty(value = "feed url", required = true)
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -60,6 +60,7 @@ import com.commafeed.frontend.model.Entries;
|
|||||||
import com.commafeed.frontend.model.Entry;
|
import com.commafeed.frontend.model.Entry;
|
||||||
import com.commafeed.frontend.model.FeedInfo;
|
import com.commafeed.frontend.model.FeedInfo;
|
||||||
import com.commafeed.frontend.model.Subscription;
|
import com.commafeed.frontend.model.Subscription;
|
||||||
|
import com.commafeed.frontend.model.request.FeedInfoRequest;
|
||||||
import com.commafeed.frontend.model.request.FeedModificationRequest;
|
import com.commafeed.frontend.model.request.FeedModificationRequest;
|
||||||
import com.commafeed.frontend.model.request.IDRequest;
|
import com.commafeed.frontend.model.request.IDRequest;
|
||||||
import com.commafeed.frontend.model.request.MarkRequest;
|
import com.commafeed.frontend.model.request.MarkRequest;
|
||||||
@@ -239,16 +240,17 @@ public class FeedREST extends AbstractResourceREST {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@POST
|
||||||
@Path("/fetch")
|
@Path("/fetch")
|
||||||
@ApiOperation(value = "Fetch a feed", notes = "Fetch a feed by its url", responseClass = "com.commafeed.frontend.model.FeedInfo")
|
@ApiOperation(value = "Fetch a feed", notes = "Fetch a feed by its url", responseClass = "com.commafeed.frontend.model.FeedInfo")
|
||||||
public Response fetchFeed(
|
public Response fetchFeed(
|
||||||
@ApiParam(value = "the feed's url", required = true) @QueryParam("url") String url) {
|
@ApiParam(value = "feed url", required = true) FeedInfoRequest req) {
|
||||||
Preconditions.checkNotNull(url);
|
Preconditions.checkNotNull(req);
|
||||||
|
Preconditions.checkNotNull(req.getUrl());
|
||||||
|
|
||||||
FeedInfo info = null;
|
FeedInfo info = null;
|
||||||
try {
|
try {
|
||||||
info = fetchFeedInternal(url);
|
info = fetchFeedInternal(req.getUrl());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return Response.status(Status.INTERNAL_SERVER_ERROR)
|
return Response.status(Status.INTERNAL_SERVER_ERROR)
|
||||||
.entity(e.getMessage()).build();
|
.entity(e.getMessage()).build();
|
||||||
@@ -307,7 +309,8 @@ public class FeedREST extends AbstractResourceREST {
|
|||||||
if (sub == null) {
|
if (sub == null) {
|
||||||
return Response.status(Status.NOT_FOUND).build();
|
return Response.status(Status.NOT_FOUND).build();
|
||||||
}
|
}
|
||||||
Long unreadCount = feedSubscriptionService.getUnreadCount(getUser()).get(id);
|
Long unreadCount = feedSubscriptionService.getUnreadCount(getUser())
|
||||||
|
.get(id);
|
||||||
if (unreadCount == null) {
|
if (unreadCount == null) {
|
||||||
unreadCount = new Long(0);
|
unreadCount = new Long(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ function($resource, $http) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fetch : {
|
fetch : {
|
||||||
method : 'GET',
|
method : 'POST',
|
||||||
params : {
|
params : {
|
||||||
_method : 'fetch'
|
_method : 'fetch'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user