2013-01-10 14:19:53 +01:00
|
|
|
package org.gcube.portal.databook.server;
|
|
|
|
|
2023-11-23 12:28:32 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2013-01-10 14:19:53 +01:00
|
|
|
|
2015-06-25 18:25:37 +02:00
|
|
|
import javax.mail.internet.AddressException;
|
|
|
|
|
2023-11-23 13:39:03 +01:00
|
|
|
import org.gcube.portal.databook.shared.*;
|
2023-11-23 12:28:32 +01:00
|
|
|
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.InviteIDNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.InviteStatusNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.NotificationIDNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
|
|
|
|
import org.gcube.social_networking.social_networking_client_library.CommentClient;
|
|
|
|
import org.gcube.social_networking.social_networking_client_library.HashTagClient;
|
|
|
|
import org.gcube.social_networking.social_networking_client_library.InviteClient;
|
|
|
|
import org.gcube.social_networking.social_networking_client_library.LikeClient;
|
|
|
|
import org.gcube.social_networking.social_networking_client_library.NotificationClient;
|
|
|
|
import org.gcube.social_networking.social_networking_client_library.PostClient;
|
2013-09-25 15:42:08 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2013-01-10 14:19:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Massimiliano Assante ISTI-CNR
|
2016-08-02 17:25:27 +02:00
|
|
|
* @author Costantino Perciante ISTI-CNR
|
2013-01-10 14:19:53 +01:00
|
|
|
* This class is used for querying and adding data to Cassandra via Astyanax High Level API
|
|
|
|
*/
|
|
|
|
public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* logger
|
|
|
|
*/
|
2013-09-25 15:42:08 +02:00
|
|
|
private static final Logger _log = LoggerFactory.getLogger(DBCassandraAstyanaxImpl.class);
|
2023-11-21 14:12:19 +01:00
|
|
|
private static PostClient postClient;
|
|
|
|
private static NotificationClient notificationClient;
|
|
|
|
private static HashTagClient hashTagClient;
|
|
|
|
private static InviteClient inviteClient;
|
|
|
|
private static CommentClient commentClient;
|
|
|
|
private static LikeClient likeClient;
|
|
|
|
|
2013-06-03 18:12:13 +02:00
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* use this constructor carefully from test classes
|
|
|
|
* @param dropSchema set true if you want do drop the current and set up new one
|
|
|
|
*/
|
|
|
|
protected DBCassandraAstyanaxImpl(boolean dropSchema) {
|
2023-11-21 14:12:19 +01:00
|
|
|
try {
|
|
|
|
postClient = new PostClient();
|
|
|
|
notificationClient = new NotificationClient();
|
|
|
|
hashTagClient = new HashTagClient();
|
|
|
|
commentClient = new CommentClient();
|
|
|
|
inviteClient = new InviteClient();
|
|
|
|
likeClient = new LikeClient();
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* public constructor, no dropping schema is allowed
|
|
|
|
*/
|
|
|
|
public DBCassandraAstyanaxImpl() {
|
2023-11-21 14:12:19 +01:00
|
|
|
try {
|
|
|
|
postClient = new PostClient();
|
|
|
|
notificationClient = new NotificationClient();
|
|
|
|
hashTagClient = new HashTagClient();
|
|
|
|
commentClient = new CommentClient();
|
|
|
|
inviteClient = new InviteClient();
|
|
|
|
likeClient = new LikeClient();
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2016-04-04 12:46:24 +02:00
|
|
|
|
2016-02-04 16:52:46 +01:00
|
|
|
/**
|
|
|
|
* public constructor, no dropping schema is allowed, infrastructureName is given.
|
|
|
|
*/
|
|
|
|
public DBCassandraAstyanaxImpl(String infrastructureName) {
|
2023-11-21 14:12:19 +01:00
|
|
|
try {
|
|
|
|
postClient = new PostClient();
|
|
|
|
notificationClient = new NotificationClient();
|
|
|
|
hashTagClient = new HashTagClient();
|
|
|
|
commentClient = new CommentClient();
|
|
|
|
inviteClient = new InviteClient();
|
|
|
|
likeClient = new LikeClient();
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
2016-02-04 16:52:46 +01:00
|
|
|
}
|
2016-04-04 12:46:24 +02:00
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
/*
|
2023-10-30 18:52:02 +01:00
|
|
|
*
|
2013-01-10 14:19:53 +01:00
|
|
|
********************** FRIENDSHIPS (CONNECTIONS) ***********************
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean requestFriendship(String from, String to) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean approveFriendship(String from, String to) {
|
2023-10-30 18:52:02 +01:00
|
|
|
return true;
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean denyFriendship(String from, String to) {
|
2023-10-30 18:52:02 +01:00
|
|
|
return true;
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<String> getFriends(String userid) {
|
|
|
|
ArrayList<String> toReturn = new ArrayList<String>();
|
|
|
|
return toReturn;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<String> getPendingFriendRequests(String userid) {
|
|
|
|
ArrayList<String> toReturn = new ArrayList<String>();
|
|
|
|
return toReturn;
|
|
|
|
}
|
|
|
|
/*
|
2023-10-30 18:52:02 +01:00
|
|
|
*
|
2013-01-10 14:19:53 +01:00
|
|
|
********************** FEEDS ***********************
|
|
|
|
*
|
|
|
|
*/
|
2023-10-30 18:52:02 +01:00
|
|
|
|
2023-11-23 13:39:03 +01:00
|
|
|
private static Post feed2post(Feed feed){
|
|
|
|
Post post = new Post(feed.getKey(), PostType.valueOf(feed.getType().toString()), feed.getEntityId(), feed.getTime(),
|
|
|
|
feed.getVreid(), feed.getUri(), feed.getUriThumbnail(), feed.getDescription(), feed.getPrivacy(),
|
|
|
|
feed.getFullName(), feed.getEmail(), feed.getThumbnailURL(), feed.getCommentsNo(),
|
|
|
|
feed.getLikesNo(), feed.getLinkTitle(), feed.getLinkDescription(), feed.getLinkHost(), feed.isApplicationFeed(), feed.isMultiFileUpload());
|
|
|
|
return post;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static Feed post2feed(Post post){
|
|
|
|
Feed feed = new Feed(post.getKey(), FeedType.valueOf(post.getType().toString()), post.getEntityId(), post.getTime(),
|
|
|
|
post.getVreid(), post.getUri(), post.getUriThumbnail(), post.getDescription(), post.getPrivacy(),
|
|
|
|
post.getFullName(), post.getEmail(), post.getThumbnailURL(), post.getCommentsNo(),
|
|
|
|
post.getLikesNo(), post.getLinkTitle(), post.getLinkDescription(), post.getLinkHost(), post.isApplicationFeed(), post.isMultiFileUpload());
|
|
|
|
return feed;
|
|
|
|
}
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2022-09-20 17:00:25 +02:00
|
|
|
@Deprecated
|
2013-01-10 14:19:53 +01:00
|
|
|
@Override
|
2023-10-30 18:52:02 +01:00
|
|
|
public boolean saveUserFeed(Feed post) {
|
2023-11-23 13:39:03 +01:00
|
|
|
return saveUserPost(feed2post(post));
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2016-01-14 18:37:03 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
public boolean saveUserPost(Post post) {
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.saveUserPostLib(post);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
2016-01-14 18:37:03 +01:00
|
|
|
public boolean saveUserFeed(Feed feed, List<Attachment> attachments) {
|
2023-11-23 13:39:03 +01:00
|
|
|
return saveUserPost(feed2post(feed), attachments);
|
2016-01-14 18:37:03 +01:00
|
|
|
}
|
2022-09-20 17:00:25 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean saveUserPost(Post post, List<Attachment> attachments) {
|
2023-11-21 18:37:45 +01:00
|
|
|
return postClient.saveUserPostLib(post, attachments);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
2016-02-02 15:19:10 +01:00
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
@Deprecated
|
2023-10-30 18:52:02 +01:00
|
|
|
public boolean saveAppFeed(Feed post) {
|
2023-11-23 13:39:03 +01:00
|
|
|
return saveAppPost(feed2post(post));
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
public boolean saveAppPost(Post post) {
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.saveAppPostLib(post);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
2016-01-15 17:07:44 +01:00
|
|
|
public boolean saveAppFeed(Feed feed, List<Attachment> attachments) {
|
2023-11-23 13:39:03 +01:00
|
|
|
return saveAppPost(feed2post(feed), attachments);
|
2016-01-15 17:07:44 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
public boolean saveAppPost(Post post, List<Attachment> attachments) {
|
2023-11-21 18:37:45 +01:00
|
|
|
return postClient.saveAppPostLib(post, attachments);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
2013-01-10 14:19:53 +01:00
|
|
|
public boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException {
|
2023-11-23 13:39:03 +01:00
|
|
|
return savePostToVRETimeline(feedKey, vreid);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
public boolean savePostToVRETimeline(String postKey, String vreid) throws FeedIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.savePostToVRETimelineLib(postKey, vreid);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
2013-01-10 14:19:53 +01:00
|
|
|
public Feed readFeed(String feedid)
|
|
|
|
throws PrivacyLevelTypeNotFoundException,
|
|
|
|
FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
2023-11-15 18:14:57 +01:00
|
|
|
|
2023-11-23 13:39:03 +01:00
|
|
|
return post2feed(readPost(feedid));
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
public Post readPost(String postid)
|
|
|
|
throws PrivacyLevelTypeNotFoundException,
|
|
|
|
FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.readPostLib(postid);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Deprecated
|
2015-12-02 16:50:26 +01:00
|
|
|
public List<Feed> getRecentFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException {
|
|
|
|
Date now = new Date();
|
|
|
|
if (timeInMillis > now.getTime())
|
2016-01-14 18:37:03 +01:00
|
|
|
throw new IllegalArgumentException("the timeInMillis must be before today");
|
2023-11-23 13:39:03 +01:00
|
|
|
List<Post> posts = getRecentPostsByUserAndDate(userid, timeInMillis);
|
|
|
|
List<Feed> feeds = new ArrayList<>();
|
|
|
|
for(Post post: posts){
|
|
|
|
feeds.add(post2feed(post));
|
|
|
|
}
|
|
|
|
return feeds;
|
2015-12-02 16:50:26 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
public List<Post> getRecentPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException {
|
|
|
|
Date now = new Date();
|
|
|
|
if (timeInMillis > now.getTime())
|
|
|
|
throw new IllegalArgumentException("the timeInMillis must be before today");
|
|
|
|
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.getRecentPostsByUserAndDateLib(userid, timeInMillis);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
2013-01-10 14:19:53 +01:00
|
|
|
public boolean deleteFeed(String feedId) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException {
|
2023-11-23 13:39:03 +01:00
|
|
|
return deletePost(feedId);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
public boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.deletePostLib(postid);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
2013-01-10 14:19:53 +01:00
|
|
|
public List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
2023-11-23 13:39:03 +01:00
|
|
|
List<Post> posts = getAllPostsByUser(userid);
|
|
|
|
List<Feed> feeds = new ArrayList<>();
|
|
|
|
for(Post post: posts){
|
|
|
|
feeds.add(post2feed(post));
|
|
|
|
}
|
|
|
|
return feeds;
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
public List<Post> getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.getAllPostsByUserLib(userid);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2013-01-10 14:19:53 +01:00
|
|
|
public List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
2023-11-23 13:39:03 +01:00
|
|
|
List<Post> posts = getAllPostsByApp(appid);
|
|
|
|
List<Feed> feeds = new ArrayList<>();
|
|
|
|
for(Post post: posts){
|
|
|
|
feeds.add(post2feed(post));
|
|
|
|
}
|
|
|
|
return feeds;
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2022-09-20 17:00:25 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<Post> getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.getAllPostsByAppLib(appid);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
2016-08-02 20:15:50 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
2023-10-30 18:52:02 +01:00
|
|
|
* @throws Exception
|
2016-08-02 20:15:50 +02:00
|
|
|
*/
|
2022-09-20 17:00:25 +02:00
|
|
|
@Deprecated
|
2016-08-02 20:15:50 +02:00
|
|
|
@Override
|
|
|
|
public List<Feed> getRecentCommentedFeedsByUserAndDate(String userid,
|
|
|
|
long timeInMillis) throws Exception {
|
2023-11-23 13:39:03 +01:00
|
|
|
List<Post> posts = getRecentCommentedPostsByUserAndDate(userid, timeInMillis);
|
|
|
|
List<Feed> feeds = new ArrayList<>();
|
|
|
|
for(Post post: posts){
|
|
|
|
feeds.add(post2feed(post));
|
|
|
|
}
|
|
|
|
return feeds;
|
2016-08-02 20:15:50 +02:00
|
|
|
}
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
2022-09-20 17:00:25 +02:00
|
|
|
* {@inheritDoc}
|
2023-10-30 18:52:02 +01:00
|
|
|
* @throws Exception
|
2022-09-20 17:00:25 +02:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<Post> getRecentCommentedPostsByUserAndDate(String userid,
|
|
|
|
long timeInMillis) throws Exception {
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.getRecentCommentedPostsByUserAndDateLib(userid, timeInMillis);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
2023-11-21 14:12:19 +01:00
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
|
|
|
public List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
|
2023-11-23 13:39:03 +01:00
|
|
|
List<Post> posts = getAllPortalPrivacyLevelPosts();
|
|
|
|
List<Feed> feeds = new ArrayList<>();
|
|
|
|
for(Post post: posts){
|
|
|
|
feeds.add(post2feed(post));
|
|
|
|
}
|
|
|
|
return feeds;
|
2023-11-21 14:12:19 +01:00
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public List<Post> getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
|
|
|
|
return postClient.getAllPortalPrivacyLevelPostsLib();
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2022-09-20 17:00:25 +02:00
|
|
|
/**
|
2023-11-21 14:12:19 +01:00
|
|
|
* {@inheritDoc}
|
2022-09-20 17:00:25 +02:00
|
|
|
*/
|
2023-11-21 14:12:19 +01:00
|
|
|
@Override
|
|
|
|
@Deprecated
|
|
|
|
public List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
2023-11-23 13:39:03 +01:00
|
|
|
List<Post> posts = getRecentPostsByUser(userid, quantity);
|
|
|
|
List<Feed> feeds = new ArrayList<>();
|
|
|
|
for(Post post: posts){
|
|
|
|
feeds.add(post2feed(post));
|
|
|
|
}
|
|
|
|
return feeds;
|
2023-11-21 14:12:19 +01:00
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
|
|
|
return postClient.getRecentPostsByUserLib(userid, quantity);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
2023-11-21 14:12:19 +01:00
|
|
|
* {@inheritDoc}
|
2013-01-10 14:19:53 +01:00
|
|
|
*/
|
2023-11-21 14:12:19 +01:00
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
@Deprecated
|
2023-11-21 14:12:19 +01:00
|
|
|
public List<Feed> getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
2023-11-23 13:39:03 +01:00
|
|
|
List<Post> posts = getAllPostsByVRE(vreid);
|
|
|
|
List<Feed> feeds = new ArrayList<>();
|
|
|
|
for(Post post: posts){
|
|
|
|
feeds.add(post2feed(post));
|
|
|
|
}
|
|
|
|
return feeds;
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2022-09-20 17:00:25 +02:00
|
|
|
/**
|
2023-11-21 14:12:19 +01:00
|
|
|
* {@inheritDoc}
|
2022-09-20 17:00:25 +02:00
|
|
|
*/
|
2023-11-21 14:12:19 +01:00
|
|
|
@Override
|
|
|
|
public List<Post> getAllPostsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
|
|
|
return postClient.getAllPostsByVRELib(vreid);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
2015-07-16 16:27:33 +02:00
|
|
|
/**
|
2023-11-21 14:12:19 +01:00
|
|
|
* {@inheritDoc}
|
2015-07-16 16:27:33 +02:00
|
|
|
*/
|
2023-11-21 14:12:19 +01:00
|
|
|
@Deprecated
|
|
|
|
@Override
|
|
|
|
public List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
2023-11-23 13:39:03 +01:00
|
|
|
List<Post> posts = getRecentPostsByVRE(vreid, quantity);
|
|
|
|
List<Feed> feeds = new ArrayList<>();
|
|
|
|
for(Post post: posts){
|
|
|
|
feeds.add(post2feed(post));
|
|
|
|
}
|
|
|
|
return feeds;
|
2023-11-21 14:12:19 +01:00
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public List<Post> getRecentPostsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
|
|
|
return postClient.getRecentPostsByVRELib(vreid, quantity);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
2023-11-21 14:12:19 +01:00
|
|
|
* {@inheritDoc}
|
2022-09-20 17:00:25 +02:00
|
|
|
*/
|
2023-11-21 14:12:19 +01:00
|
|
|
@Override
|
|
|
|
public RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
2023-11-23 13:39:03 +01:00
|
|
|
RangePosts rangePosts = getRecentPostsByVREAndRange(vreid, from, quantity);
|
|
|
|
List<Post> posts = rangePosts.getPosts();
|
|
|
|
ArrayList<Feed> feeds = new ArrayList<>();
|
|
|
|
for(Post post: posts){
|
|
|
|
feeds.add(post2feed(post));
|
|
|
|
}
|
|
|
|
RangeFeeds rangeFeeds = new RangeFeeds(rangePosts.getLastReturnedPostTimelineIndex(), feeds);
|
|
|
|
return rangeFeeds;
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
2023-11-21 14:12:19 +01:00
|
|
|
* {@inheritDoc}
|
2022-09-20 17:00:25 +02:00
|
|
|
*/
|
2023-11-21 14:12:19 +01:00
|
|
|
@Override
|
|
|
|
public RangePosts getRecentPostsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
|
|
|
return postClient.getRecentPostsByVREAndRangeLib(vreid, from, quantity);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
2023-10-30 18:52:02 +01:00
|
|
|
|
2023-11-21 14:12:19 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
********************** NOTIFICATIONS ***********************
|
|
|
|
*
|
|
|
|
*/
|
2022-09-20 17:00:25 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public boolean saveNotification(Notification n) {
|
|
|
|
return notificationClient.saveNotificationLib(n);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2023-11-15 18:14:57 +01:00
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
|
|
|
return notificationClient.readNotificationLib(notificationid);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2023-10-30 18:52:02 +01:00
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public boolean setNotificationRead(String notificationidToSet) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
|
|
|
return notificationClient.setNotificationReadLib(notificationidToSet);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2023-11-21 14:12:19 +01:00
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public List<Notification> getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
|
|
|
return notificationClient.getAllNotificationByUserLib(userid, limit);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public List<Notification> getUnreadNotificationsByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException {
|
|
|
|
return notificationClient.getUnreadNotificationsByUserLib(userid);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2023-11-21 14:12:19 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2022-09-20 17:00:25 +02:00
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public List<Notification> getRangeNotificationsByUser(String userid,int from, int quantity) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException {
|
|
|
|
return notificationClient.getRangeNotificationsByUserLib(userid, from, quantity);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
2014-03-11 16:03:57 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public boolean setAllNotificationReadByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
|
|
|
return notificationClient.setAllNotificationReadByUserLib(userid);
|
2014-03-11 16:03:57 +01:00
|
|
|
}
|
2023-11-21 14:12:19 +01:00
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
2022-09-20 17:00:25 +02:00
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public boolean checkUnreadNotifications(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
|
|
|
return notificationClient.checkUnreadNotificationsLib(userid);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2022-09-20 17:00:25 +02:00
|
|
|
/**
|
2023-11-21 14:12:19 +01:00
|
|
|
* {@inheritDoc}
|
2022-09-20 17:00:25 +02:00
|
|
|
*/
|
2023-11-21 14:12:19 +01:00
|
|
|
@Override
|
|
|
|
public boolean checkUnreadMessagesNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
|
|
|
return notificationClient.checkUnreadMessagesNotificationsLib(userid);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
2013-01-10 14:19:53 +01:00
|
|
|
/*
|
2023-10-30 18:52:02 +01:00
|
|
|
*
|
2023-11-21 14:12:19 +01:00
|
|
|
********************** NOTIFICATION SETTINGS ***********************
|
2013-01-10 14:19:53 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public List<NotificationChannelType> getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException {
|
|
|
|
return notificationClient.getUserNotificationChannelsLib(userid, notificationType);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2014-10-01 17:08:38 +02:00
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public boolean setUserNotificationPreferences(String userid, Map<NotificationType, NotificationChannelType[]> enabledChannels) {
|
|
|
|
return notificationClient.setUserNotificationPreferencesLib(userid, enabledChannels);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
2023-11-21 14:12:19 +01:00
|
|
|
*
|
|
|
|
* by default Workspace and Calendar Notifications are set to Portal
|
2013-01-10 14:19:53 +01:00
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public Map<NotificationType, NotificationChannelType[]> getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException {
|
|
|
|
return notificationClient.getUserNotificationPreferencesLib(userid);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2023-11-21 14:12:19 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
********************** COMMENTS ***********************
|
2023-10-30 18:52:02 +01:00
|
|
|
*
|
2016-04-04 12:46:24 +02:00
|
|
|
*/
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public boolean addComment(Comment comment) throws FeedIDNotFoundException {
|
|
|
|
return commentClient.addCommentLib(comment)!=null;
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2023-11-21 14:12:19 +01:00
|
|
|
public Comment readCommentById(String commentId) throws CommentIDNotFoundException {
|
|
|
|
return commentClient.readCommentByIdLib(commentId);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
@Deprecated
|
|
|
|
public List<Comment> getAllCommentByFeed(String feedid) {
|
|
|
|
return getAllCommentByPost(feedid);
|
2014-04-02 18:03:42 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public List<Comment> getAllCommentByPost(String postid) {
|
|
|
|
return commentClient.getAllCommentsByPostIdLib(postid);
|
2013-01-30 00:54:50 +01:00
|
|
|
}
|
2013-01-10 14:19:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
2023-11-21 14:12:19 +01:00
|
|
|
* @throws Exception
|
2013-01-10 14:19:53 +01:00
|
|
|
*/
|
|
|
|
@Override
|
2023-11-21 14:12:19 +01:00
|
|
|
public List<Comment> getRecentCommentsByUserAndDate(final String userid,
|
|
|
|
final long timeInMillis) throws Exception {
|
2013-01-10 14:19:53 +01:00
|
|
|
|
2023-11-21 14:12:19 +01:00
|
|
|
return commentClient.getRecentCommentsByUserAndDateLib(userid, timeInMillis);
|
|
|
|
}
|
2016-04-04 18:02:46 +02:00
|
|
|
|
2016-08-02 17:25:27 +02:00
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean editComment(Comment comment2Edit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return commentClient.editCommentLib(comment2Edit)!=null;
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2016-01-14 18:37:03 +01:00
|
|
|
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return commentClient.deleteCommentLib(commentid, feedid);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean like(Like like) throws FeedIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return likeClient.likeLib(like);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2014-04-08 23:36:51 +02:00
|
|
|
public boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return likeClient.unlikeLib(userid, likeid, feedid);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 17:00:25 +02:00
|
|
|
@Deprecated
|
2013-01-10 14:19:53 +01:00
|
|
|
public List<String> getAllLikedFeedIdsByUser(String userid) {
|
2022-09-20 17:00:25 +02:00
|
|
|
return getAllLikedPostIdsByUser(userid);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<String> getAllLikedPostIdsByUser(String userid) {
|
2023-11-21 14:12:19 +01:00
|
|
|
return likeClient.getAllLikedPostIdsByUserLib(userid);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2013-02-02 18:21:56 +01:00
|
|
|
/**
|
2023-10-30 18:52:02 +01:00
|
|
|
* {@inheritDoc}
|
2013-02-02 18:21:56 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<Feed> getAllLikedFeedsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
2023-10-30 18:52:02 +01:00
|
|
|
ArrayList<Feed> toReturn = new ArrayList<>();
|
|
|
|
List<String> likedPostIDs = getAllLikedPostIdsByUser(userid);
|
2013-02-02 18:21:56 +01:00
|
|
|
|
|
|
|
//check if quantity is greater than user feeds
|
2023-10-30 18:52:02 +01:00
|
|
|
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
2013-02-02 18:21:56 +01:00
|
|
|
|
2023-10-30 18:52:02 +01:00
|
|
|
//need them in reverse order
|
|
|
|
for (int i = likedPostIDs.size()-1; i >= (likedPostIDs.size()-limit); i--) {
|
|
|
|
Feed toAdd = readFeed(likedPostIDs.get(i));
|
2013-02-02 18:21:56 +01:00
|
|
|
if (toAdd.getType() == FeedType.TWEET || toAdd.getType() == FeedType.SHARE || toAdd.getType() == FeedType.PUBLISH) {
|
|
|
|
toReturn.add(toAdd);
|
2023-10-30 18:52:02 +01:00
|
|
|
_log.trace("Read recent post: " + likedPostIDs.get(i));
|
2013-02-02 18:21:56 +01:00
|
|
|
} else {
|
2023-10-30 18:52:02 +01:00
|
|
|
_log.trace("Read and skipped post: " + likedPostIDs.get(i) + " (Removed post)");
|
2013-02-02 18:21:56 +01:00
|
|
|
limit += 1; //increase the quantity in case of removed feed
|
|
|
|
//check if quantity is greater than user feeds
|
2023-10-30 18:52:02 +01:00
|
|
|
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
2013-02-02 18:21:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return toReturn;
|
|
|
|
}
|
2022-09-20 17:00:25 +02:00
|
|
|
/**
|
2023-10-30 18:52:02 +01:00
|
|
|
* {@inheritDoc}
|
2022-09-20 17:00:25 +02:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<Post> getAllLikedPostsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
|
|
|
ArrayList<Post> toReturn = new ArrayList<Post>();
|
|
|
|
List<String> likedPostIDs = getAllLikedPostIdsByUser(userid);
|
|
|
|
|
|
|
|
//check if quantity is greater than user feeds
|
|
|
|
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
|
|
|
|
2023-10-30 18:52:02 +01:00
|
|
|
//need them in reverse order
|
2022-09-20 17:00:25 +02:00
|
|
|
for (int i = likedPostIDs.size()-1; i >= (likedPostIDs.size()-limit); i--) {
|
|
|
|
Post toAdd = readPost(likedPostIDs.get(i));
|
|
|
|
if (toAdd.getType() == PostType.TWEET || toAdd.getType() == PostType.SHARE || toAdd.getType() == PostType.PUBLISH) {
|
|
|
|
toReturn.add(toAdd);
|
|
|
|
_log.trace("Read recent post: " + likedPostIDs.get(i));
|
|
|
|
} else {
|
|
|
|
_log.trace("Read and skipped post: " + likedPostIDs.get(i) + " (Removed post)");
|
|
|
|
limit += 1; //increase the quantity in case of removed feed
|
|
|
|
//check if quantity is greater than user feeds
|
|
|
|
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return toReturn;
|
|
|
|
}
|
2013-02-02 18:21:56 +01:00
|
|
|
|
2016-08-02 17:25:27 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<Feed> getRecentLikedFeedsByUserAndDate(String userid,
|
|
|
|
long timeInMillis) throws IllegalArgumentException {
|
|
|
|
|
2023-10-30 18:52:02 +01:00
|
|
|
List<Feed> toReturn = new ArrayList<>();
|
2016-08-02 17:25:27 +02:00
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
if (timeInMillis > now.getTime())
|
|
|
|
throw new IllegalArgumentException("the timeInMillis must be before today");
|
|
|
|
|
|
|
|
if(userid == null || userid.isEmpty())
|
|
|
|
throw new IllegalArgumentException("the userId parameter cannot be null/empty");
|
|
|
|
|
|
|
|
// get the list of liked feeds
|
2023-10-30 18:52:02 +01:00
|
|
|
List<String> likedPostsIdsByUser = getAllLikedFeedIdsByUser(userid);
|
2016-08-02 17:25:27 +02:00
|
|
|
|
2023-10-30 18:52:02 +01:00
|
|
|
if(likedPostsIdsByUser != null && !likedPostsIdsByUser.isEmpty()){
|
|
|
|
for(int i = likedPostsIdsByUser.size() - 1; i >= 0; i--){
|
|
|
|
String postid = likedPostsIdsByUser.get(i);
|
2016-08-02 17:25:27 +02:00
|
|
|
try{
|
|
|
|
|
2023-10-30 18:52:02 +01:00
|
|
|
// retrieve the Post
|
|
|
|
Feed toCheck = readFeed(postid);
|
|
|
|
boolean isPostOk = (toCheck.getType() == FeedType.TWEET || toCheck.getType() == FeedType.SHARE || toCheck.getType() == FeedType.PUBLISH);
|
2016-08-02 17:25:27 +02:00
|
|
|
|
2023-10-30 18:52:02 +01:00
|
|
|
// retrieve the like of the user for the post
|
|
|
|
if(isPostOk){
|
|
|
|
List<Like> likes = getAllLikesByFeed(postid);
|
2016-08-02 17:25:27 +02:00
|
|
|
for (Like like : likes) {
|
|
|
|
if(like.getTime().getTime() >= timeInMillis && like.getUserid().equals(userid))
|
|
|
|
toReturn.add(toCheck);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}catch(Exception e){
|
2023-10-30 18:52:02 +01:00
|
|
|
_log.error("Skipped post with id " + postid, e);
|
2016-08-02 17:25:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-30 18:52:02 +01:00
|
|
|
// please check consider that if a user made like recently to an old post, well it could happen that this
|
2016-08-02 17:25:27 +02:00
|
|
|
// post comes first than a newer post in the toReturn list. Thus we need to sort it.
|
|
|
|
Collections.sort(toReturn, Collections.reverseOrder());
|
|
|
|
|
|
|
|
return toReturn;
|
2023-10-30 18:52:02 +01:00
|
|
|
|
2016-08-02 17:25:27 +02:00
|
|
|
}
|
2022-09-20 17:00:25 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<Post> getRecentLikedPostsByUserAndDate(String userid,
|
|
|
|
long timeInMillis) throws IllegalArgumentException {
|
|
|
|
|
|
|
|
List<Post> toReturn = new ArrayList<>();
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
if (timeInMillis > now.getTime())
|
|
|
|
throw new IllegalArgumentException("the timeInMillis must be before today");
|
|
|
|
|
|
|
|
if(userid == null || userid.isEmpty())
|
|
|
|
throw new IllegalArgumentException("the userId parameter cannot be null/empty");
|
|
|
|
|
|
|
|
// get the list of liked feeds
|
|
|
|
List<String> likedPostsIdsByUser = getAllLikedPostIdsByUser(userid);
|
|
|
|
|
|
|
|
if(likedPostsIdsByUser != null && !likedPostsIdsByUser.isEmpty()){
|
|
|
|
for(int i = likedPostsIdsByUser.size() - 1; i >= 0; i--){
|
|
|
|
String postid = likedPostsIdsByUser.get(i);
|
|
|
|
try{
|
|
|
|
|
|
|
|
// retrieve the Post
|
|
|
|
Post toCheck = readPost(postid);
|
|
|
|
boolean isPostOk = (toCheck.getType() == PostType.TWEET || toCheck.getType() == PostType.SHARE || toCheck.getType() == PostType.PUBLISH);
|
|
|
|
|
|
|
|
// retrieve the like of the user for the post
|
|
|
|
if(isPostOk){
|
|
|
|
List<Like> likes = getAllLikesByPost(postid);
|
|
|
|
for (Like like : likes) {
|
|
|
|
if(like.getTime().getTime() >= timeInMillis && like.getUserid().equals(userid))
|
|
|
|
toReturn.add(toCheck);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
_log.error("Skipped post with id " + postid, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-30 18:52:02 +01:00
|
|
|
// please check consider that if a user made like recently to an old post, well it could happen that this
|
2022-09-20 17:00:25 +02:00
|
|
|
// post comes first than a newer post in the toReturn list. Thus we need to sort it.
|
|
|
|
Collections.sort(toReturn, Collections.reverseOrder());
|
|
|
|
|
|
|
|
return toReturn;
|
|
|
|
}
|
2016-08-02 17:25:27 +02:00
|
|
|
|
2022-09-20 18:39:38 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
|
|
|
public List<Like> getAllLikesByFeed(String feedid) {
|
|
|
|
return getAllLikesByPost(feedid);
|
|
|
|
}
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2022-09-20 18:39:38 +02:00
|
|
|
public List<Like> getAllLikesByPost(String postid) {
|
2023-10-30 18:52:02 +01:00
|
|
|
//possible error index
|
2023-11-21 14:12:19 +01:00
|
|
|
return likeClient.getAllLikesByPostLib(postid);
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|
2014-10-01 17:27:03 +02:00
|
|
|
/*
|
2023-10-30 18:52:02 +01:00
|
|
|
*
|
2014-10-01 17:27:03 +02:00
|
|
|
********************** HASHTAGS ***********************
|
|
|
|
*
|
|
|
|
*/
|
2013-01-10 14:19:53 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2014-10-01 17:08:38 +02:00
|
|
|
public boolean saveHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return hashTagClient.saveHashTagsLib(feedid, vreid, hashtags);
|
2014-10-01 17:27:03 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean deleteHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return hashTagClient.deleteHashTagsLib(feedid, vreid, hashtags);
|
2014-10-01 17:08:38 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2017-05-16 16:07:37 +02:00
|
|
|
public boolean saveHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return hashTagClient.saveHashTagsCommentLib(commentId, vreid, hashtags);
|
2017-05-16 16:07:37 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean deleteHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return hashTagClient.deleteHashTagsCommentLib(commentId, vreid, hashtags);
|
2017-05-16 16:07:37 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2014-10-01 17:08:38 +02:00
|
|
|
public Map<String, Integer> getVREHashtagsWithOccurrence(String vreid) {
|
2023-11-21 14:12:19 +01:00
|
|
|
return hashTagClient.getVREHashtagsWithOccurrenceLib(vreid);
|
2014-10-01 17:08:38 +02:00
|
|
|
}
|
2016-05-10 12:14:46 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Map<String, Integer> getVREHashtagsWithOccurrenceFilteredByTime(String vreid, long timestamp){
|
2023-11-21 14:12:19 +01:00
|
|
|
return hashTagClient.getVREHashtagsWithOccurrenceFilteredByTimeLib(vreid, timestamp);
|
2016-05-10 12:14:46 +02:00
|
|
|
}
|
|
|
|
|
2014-10-01 17:08:38 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
2023-11-21 18:37:45 +01:00
|
|
|
return null;
|
2014-10-01 17:08:38 +02:00
|
|
|
}
|
2022-09-20 17:00:25 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<Post> getVREPostsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return hashTagClient.getVREPostsByHashtagLib(vreid, hashtag);
|
2022-09-20 17:00:25 +02:00
|
|
|
}
|
2015-06-25 18:25:37 +02:00
|
|
|
/*
|
2023-10-30 18:52:02 +01:00
|
|
|
*
|
2015-06-25 18:25:37 +02:00
|
|
|
********************** Invites ***********************
|
|
|
|
*
|
|
|
|
*/
|
2023-10-30 18:52:02 +01:00
|
|
|
|
|
|
|
|
2015-06-25 18:25:37 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String isExistingInvite(String vreid, String email) {
|
2023-11-21 14:12:19 +01:00
|
|
|
return inviteClient.isExistingInviteLib(vreid, email);
|
2015-06-25 18:25:37 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2015-06-30 12:15:18 +02:00
|
|
|
public InviteOperationResult saveInvite(Invite invite) throws AddressException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return inviteClient.saveInviteLib(invite);
|
2015-06-25 18:25:37 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return inviteClient.readInviteLib(inviteid);
|
2015-06-25 18:25:37 +02:00
|
|
|
}
|
2015-06-29 17:49:49 +02:00
|
|
|
|
2015-06-25 18:25:37 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
2023-10-30 18:52:02 +01:00
|
|
|
* @throws InviteStatusNotFoundException
|
2015-06-25 18:25:37 +02:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return inviteClient.setInviteStatusLib(vreid, email, status);
|
2015-06-25 18:25:37 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2015-06-29 17:49:49 +02:00
|
|
|
public List<Invite> getInvitedEmailsByVRE(String vreid, InviteStatus... status) throws InviteIDNotFoundException, InviteStatusNotFoundException{
|
2023-11-21 14:12:19 +01:00
|
|
|
return inviteClient.getInvitedEmailsByVRELib(vreid, status);
|
2015-06-25 18:25:37 +02:00
|
|
|
}
|
2014-10-01 17:08:38 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2016-01-15 17:07:44 +01:00
|
|
|
public List<Attachment> getAttachmentsByFeedId(String feedId) throws FeedIDNotFoundException {
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.getAttachmentsByFeedIdLib(feedId);
|
2016-01-15 17:07:44 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2013-01-10 14:19:53 +01:00
|
|
|
public void closeConnection() {
|
|
|
|
}
|
2015-06-29 17:49:49 +02:00
|
|
|
|
2016-02-02 15:19:10 +01:00
|
|
|
@Override
|
2023-10-30 18:52:02 +01:00
|
|
|
public List<String> getAllVREIds(){
|
2023-11-21 14:12:19 +01:00
|
|
|
return postClient.getAllVREIdsLib();
|
2016-02-02 15:19:10 +01:00
|
|
|
}
|
2013-01-10 14:19:53 +01:00
|
|
|
}
|