Added Implementation of deprecated methods.

This commit is contained in:
Ahmed Salah Tawfik Ibrahim 2023-11-23 13:39:03 +01:00
parent 60ddd56e8e
commit c75c501644
1 changed files with 79 additions and 32 deletions

View File

@ -8,21 +8,7 @@ import java.util.Map;
import javax.mail.internet.AddressException; import javax.mail.internet.AddressException;
import org.gcube.portal.databook.shared.Attachment; import org.gcube.portal.databook.shared.*;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.FeedType;
import org.gcube.portal.databook.shared.Invite;
import org.gcube.portal.databook.shared.InviteOperationResult;
import org.gcube.portal.databook.shared.InviteStatus;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.Post;
import org.gcube.portal.databook.shared.PostType;
import org.gcube.portal.databook.shared.RangeFeeds;
import org.gcube.portal.databook.shared.RangePosts;
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException; import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException; import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException; import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
@ -160,13 +146,28 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
* *
*/ */
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;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Deprecated @Deprecated
@Override @Override
public boolean saveUserFeed(Feed post) { public boolean saveUserFeed(Feed post) {
return true; return saveUserPost(feed2post(post));
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -181,7 +182,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Deprecated @Deprecated
@Override @Override
public boolean saveUserFeed(Feed feed, List<Attachment> attachments) { public boolean saveUserFeed(Feed feed, List<Attachment> attachments) {
return true; return saveUserPost(feed2post(feed), attachments);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -197,7 +198,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Override @Override
@Deprecated @Deprecated
public boolean saveAppFeed(Feed post) { public boolean saveAppFeed(Feed post) {
return true; return saveAppPost(feed2post(post));
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -212,7 +213,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Deprecated @Deprecated
@Override @Override
public boolean saveAppFeed(Feed feed, List<Attachment> attachments) { public boolean saveAppFeed(Feed feed, List<Attachment> attachments) {
return true; return saveAppPost(feed2post(feed), attachments);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -227,7 +228,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Deprecated @Deprecated
@Override @Override
public boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException { public boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException {
return true; return savePostToVRETimeline(feedKey, vreid);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -245,7 +246,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
throws PrivacyLevelTypeNotFoundException, throws PrivacyLevelTypeNotFoundException,
FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException { FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
return null; return post2feed(readPost(feedid));
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -265,8 +266,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
Date now = new Date(); Date now = new Date();
if (timeInMillis > now.getTime()) if (timeInMillis > now.getTime())
throw new IllegalArgumentException("the timeInMillis must be before today"); throw new IllegalArgumentException("the timeInMillis must be before today");
List<Post> posts = getRecentPostsByUserAndDate(userid, timeInMillis);
return null; List<Feed> feeds = new ArrayList<>();
for(Post post: posts){
feeds.add(post2feed(post));
}
return feeds;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -285,7 +290,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Deprecated @Deprecated
@Override @Override
public boolean deleteFeed(String feedId) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException { public boolean deleteFeed(String feedId) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException {
return true; return deletePost(feedId);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -300,7 +305,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Deprecated @Deprecated
@Override @Override
public List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { public List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return null; List<Post> posts = getAllPostsByUser(userid);
List<Feed> feeds = new ArrayList<>();
for(Post post: posts){
feeds.add(post2feed(post));
}
return feeds;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -314,7 +324,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/ */
@Override @Override
public List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { public List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return null; List<Post> posts = getAllPostsByApp(appid);
List<Feed> feeds = new ArrayList<>();
for(Post post: posts){
feeds.add(post2feed(post));
}
return feeds;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -331,7 +346,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Override @Override
public List<Feed> getRecentCommentedFeedsByUserAndDate(String userid, public List<Feed> getRecentCommentedFeedsByUserAndDate(String userid,
long timeInMillis) throws Exception { long timeInMillis) throws Exception {
return null; List<Post> posts = getRecentCommentedPostsByUserAndDate(userid, timeInMillis);
List<Feed> feeds = new ArrayList<>();
for(Post post: posts){
feeds.add(post2feed(post));
}
return feeds;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -348,7 +368,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Deprecated @Deprecated
@Override @Override
public List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException { public List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
return null; List<Post> posts = getAllPortalPrivacyLevelPosts();
List<Feed> feeds = new ArrayList<>();
for(Post post: posts){
feeds.add(post2feed(post));
}
return feeds;
} }
@Override @Override
public List<Post> getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException { public List<Post> getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
@ -360,7 +385,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Override @Override
@Deprecated @Deprecated
public List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { public List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return null; List<Post> posts = getRecentPostsByUser(userid, quantity);
List<Feed> feeds = new ArrayList<>();
for(Post post: posts){
feeds.add(post2feed(post));
}
return feeds;
} }
@Override @Override
public List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { public List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
@ -372,7 +402,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Override @Override
@Deprecated @Deprecated
public List<Feed> getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { public List<Feed> getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return null; List<Post> posts = getAllPostsByVRE(vreid);
List<Feed> feeds = new ArrayList<>();
for(Post post: posts){
feeds.add(post2feed(post));
}
return feeds;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -387,7 +422,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Deprecated @Deprecated
@Override @Override
public List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { public List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return null; List<Post> posts = getRecentPostsByVRE(vreid, quantity);
List<Feed> feeds = new ArrayList<>();
for(Post post: posts){
feeds.add(post2feed(post));
}
return feeds;
} }
@Override @Override
public List<Post> getRecentPostsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { public List<Post> getRecentPostsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
@ -398,7 +438,14 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/ */
@Override @Override
public RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { public RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return null; 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;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}