subscribe by url callback and subtome support

This commit is contained in:
Athou
2013-05-19 10:03:26 +02:00
parent f59198e018
commit d8277800bd
6 changed files with 48 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
package com.commafeed.frontend.rest.resources;
import java.io.StringWriter;
import java.net.URI;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@@ -229,6 +230,29 @@ public class FeedREST extends AbstractResourceREST {
return Response.ok(Status.OK).build();
}
@GET
@Path("/subscribe")
@ApiOperation(value = "Subscribe to a feed", notes = "Subscribe to a feed")
public Response subscribe(
@ApiParam(value = "feed url", required = true) @QueryParam("url") String url) {
try {
Preconditions.checkNotNull(url);
url = prependHttp(url);
url = ((FeedInfo) fetchFeed(url).getEntity()).getUrl();
FeedInfo info = (FeedInfo) fetchFeed(url).getEntity();
feedSubscriptionService.subscribe(getUser(), info.getUrl(),
info.getTitle(), null);
} catch (Exception e) {
log.info("Could not subscribe to url {} : {}", url, e.getMessage());
}
return Response.temporaryRedirect(
URI.create(applicationSettingsService.get().getPublicUrl()))
.build();
}
private String prependHttp(String url) {
if (!url.startsWith("http")) {
url = "http://" + url;