mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
rest method for merging feeds
This commit is contained in:
@@ -39,7 +39,7 @@ public class FeedService {
|
|||||||
return feed;
|
return feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mergeFeeds(Feed into, Feed... feeds) {
|
public void mergeFeeds(Feed into, List<Feed> feeds) {
|
||||||
for (Feed feed : feeds) {
|
for (Feed feed : feeds) {
|
||||||
if (into.getId().equals(feed.getId())) {
|
if (into.getId().equals(feed.getId())) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.commafeed.frontend.model.request;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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 merge Request")
|
||||||
|
public class FeedMergeRequest implements Serializable {
|
||||||
|
|
||||||
|
@ApiProperty(value = "merge into this feed", required = true)
|
||||||
|
private Long intoFeedId;
|
||||||
|
|
||||||
|
@ApiProperty(value = "id of the feeds to merge", required = true)
|
||||||
|
private List<Long> feedIds;
|
||||||
|
|
||||||
|
public Long getIntoFeedId() {
|
||||||
|
return intoFeedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntoFeedId(Long intoFeedId) {
|
||||||
|
this.intoFeedId = intoFeedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Long> getFeedIds() {
|
||||||
|
return feedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFeedIds(List<Long> feedIds) {
|
||||||
|
this.feedIds = feedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -24,32 +24,9 @@ import org.apache.wicket.protocol.http.servlet.ServletWebResponse;
|
|||||||
import org.apache.wicket.request.cycle.RequestCycle;
|
import org.apache.wicket.request.cycle.RequestCycle;
|
||||||
import org.apache.wicket.util.crypt.Base64;
|
import org.apache.wicket.util.crypt.Base64;
|
||||||
|
|
||||||
import com.commafeed.backend.DatabaseCleaner;
|
|
||||||
import com.commafeed.backend.HttpGetter;
|
|
||||||
import com.commafeed.backend.MetricsBean;
|
|
||||||
import com.commafeed.backend.StartupBean;
|
|
||||||
import com.commafeed.backend.dao.FeedCategoryDAO;
|
|
||||||
import com.commafeed.backend.dao.FeedDAO;
|
|
||||||
import com.commafeed.backend.dao.FeedEntryDAO;
|
|
||||||
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
|
||||||
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
|
||||||
import com.commafeed.backend.dao.UserDAO;
|
import com.commafeed.backend.dao.UserDAO;
|
||||||
import com.commafeed.backend.dao.UserRoleDAO;
|
|
||||||
import com.commafeed.backend.dao.UserSettingsDAO;
|
|
||||||
import com.commafeed.backend.feeds.FaviconFetcher;
|
|
||||||
import com.commafeed.backend.feeds.FeedFetcher;
|
|
||||||
import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
|
|
||||||
import com.commafeed.backend.feeds.FeedRefreshUpdater;
|
|
||||||
import com.commafeed.backend.feeds.FeedRefreshWorker;
|
|
||||||
import com.commafeed.backend.feeds.OPMLExporter;
|
|
||||||
import com.commafeed.backend.feeds.OPMLImporter;
|
|
||||||
import com.commafeed.backend.model.User;
|
import com.commafeed.backend.model.User;
|
||||||
import com.commafeed.backend.model.UserRole.Role;
|
import com.commafeed.backend.model.UserRole.Role;
|
||||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
|
||||||
import com.commafeed.backend.services.FeedEntryService;
|
|
||||||
import com.commafeed.backend.services.FeedSubscriptionService;
|
|
||||||
import com.commafeed.backend.services.PasswordEncryptionService;
|
|
||||||
import com.commafeed.backend.services.UserService;
|
|
||||||
import com.commafeed.frontend.CommaFeedApplication;
|
import com.commafeed.frontend.CommaFeedApplication;
|
||||||
import com.commafeed.frontend.CommaFeedSession;
|
import com.commafeed.frontend.CommaFeedSession;
|
||||||
import com.commafeed.frontend.SecurityCheck;
|
import com.commafeed.frontend.SecurityCheck;
|
||||||
@@ -59,82 +36,13 @@ import com.commafeed.frontend.SecurityCheck;
|
|||||||
public abstract class AbstractREST {
|
public abstract class AbstractREST {
|
||||||
|
|
||||||
@Context
|
@Context
|
||||||
HttpServletRequest request;
|
private HttpServletRequest request;
|
||||||
|
|
||||||
@Context
|
@Context
|
||||||
HttpServletResponse response;
|
private HttpServletResponse response;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ApplicationSettingsService applicationSettingsService;
|
private UserDAO userDAO;
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedDAO feedDAO;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedSubscriptionDAO feedSubscriptionDAO;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedSubscriptionService feedSubscriptionService;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedCategoryDAO feedCategoryDAO;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedEntryDAO feedEntryDAO;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedEntryStatusDAO feedEntryStatusDAO;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedEntryService feedEntryService;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
UserDAO userDAO;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
UserService userService;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
StartupBean startupBean;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
UserSettingsDAO userSettingsDAO;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
UserRoleDAO userRoleDAO;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
OPMLImporter opmlImporter;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
OPMLExporter opmlExporter;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
PasswordEncryptionService encryptionService;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedFetcher feedFetcher;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
MetricsBean metricsBean;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedRefreshTaskGiver taskGiver;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedRefreshWorker feedRefreshWorker;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FeedRefreshUpdater feedRefreshUpdater;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
FaviconFetcher faviconFetcher;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
DatabaseCleaner cleaner;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
HttpGetter httpGetter;
|
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.commafeed.frontend.rest.resources;
|
package com.commafeed.frontend.rest.resources;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.ws.rs.DefaultValue;
|
import javax.ws.rs.DefaultValue;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
@@ -17,12 +19,16 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
|
|
||||||
import com.commafeed.backend.StartupBean;
|
import com.commafeed.backend.StartupBean;
|
||||||
import com.commafeed.backend.model.ApplicationSettings;
|
import com.commafeed.backend.model.ApplicationSettings;
|
||||||
|
import com.commafeed.backend.model.Feed;
|
||||||
import com.commafeed.backend.model.User;
|
import com.commafeed.backend.model.User;
|
||||||
import com.commafeed.backend.model.UserRole;
|
import com.commafeed.backend.model.UserRole;
|
||||||
import com.commafeed.backend.model.UserRole.Role;
|
import com.commafeed.backend.model.UserRole.Role;
|
||||||
|
import com.commafeed.backend.services.FeedService;
|
||||||
import com.commafeed.frontend.SecurityCheck;
|
import com.commafeed.frontend.SecurityCheck;
|
||||||
import com.commafeed.frontend.model.UserModel;
|
import com.commafeed.frontend.model.UserModel;
|
||||||
|
import com.commafeed.frontend.model.request.FeedMergeRequest;
|
||||||
import com.commafeed.frontend.model.request.IDRequest;
|
import com.commafeed.frontend.model.request.IDRequest;
|
||||||
|
import com.google.api.client.util.Lists;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
@@ -35,6 +41,9 @@ import com.wordnik.swagger.annotations.ApiParam;
|
|||||||
@Api(value = "/admin", description = "Operations about application administration")
|
@Api(value = "/admin", description = "Operations about application administration")
|
||||||
public class AdminREST extends AbstractResourceREST {
|
public class AdminREST extends AbstractResourceREST {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
FeedService feedService;
|
||||||
|
|
||||||
@Path("/user/save")
|
@Path("/user/save")
|
||||||
@POST
|
@POST
|
||||||
@ApiOperation(value = "Save or update a user", notes = "Save or update a user. If the id is not specified, a new user will be created")
|
@ApiOperation(value = "Save or update a user", notes = "Save or update a user. If the id is not specified, a new user will be created")
|
||||||
@@ -213,4 +222,19 @@ public class AdminREST extends AbstractResourceREST {
|
|||||||
return Response.ok(map).build();
|
return Response.ok(map).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Path("cleanup/merge")
|
||||||
|
@POST
|
||||||
|
public Response mergeFeeds(FeedMergeRequest request) {
|
||||||
|
Feed into = feedDAO.findById(request.getIntoFeedId());
|
||||||
|
|
||||||
|
List<Feed> feeds = Lists.newArrayList();
|
||||||
|
for (Long feedId : request.getFeedIds()) {
|
||||||
|
Feed feed = feedDAO.findById(feedId);
|
||||||
|
feeds.add(feed);
|
||||||
|
}
|
||||||
|
|
||||||
|
feedService.mergeFeeds(into, feeds);
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user