New social client

This commit is contained in:
Ahmed Salah Tawfik Ibrahim 2023-11-28 19:37:40 +01:00
parent 430ff56ab6
commit 4ec40fb58c
1 changed files with 57 additions and 82 deletions

View File

@ -20,12 +20,7 @@ import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundExcept
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;
import org.gcube.social_networking.social_networking_client_library.LibClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -40,12 +35,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
* logger
*/
private static final Logger _log = LoggerFactory.getLogger(DBCassandraAstyanaxImpl.class);
private static PostClient postClient;
private static NotificationClient notificationClient;
private static HashTagClient hashTagClient;
private static InviteClient inviteClient;
private static CommentClient commentClient;
private static LikeClient likeClient;
private static LibClient libClient;
/**
@ -54,12 +44,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
protected DBCassandraAstyanaxImpl(boolean dropSchema) {
try {
postClient = new PostClient();
notificationClient = new NotificationClient();
hashTagClient = new HashTagClient();
commentClient = new CommentClient();
inviteClient = new InviteClient();
likeClient = new LikeClient();
libClient = new LibClient();
} catch (Exception e) {
throw new RuntimeException(e);
}
@ -70,12 +55,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
public DBCassandraAstyanaxImpl() {
try {
postClient = new PostClient();
notificationClient = new NotificationClient();
hashTagClient = new HashTagClient();
commentClient = new CommentClient();
inviteClient = new InviteClient();
likeClient = new LikeClient();
libClient = new LibClient();
} catch (Exception e) {
throw new RuntimeException(e);
}
@ -87,12 +67,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
public DBCassandraAstyanaxImpl(String infrastructureName) {
try {
postClient = new PostClient();
notificationClient = new NotificationClient();
hashTagClient = new HashTagClient();
commentClient = new CommentClient();
inviteClient = new InviteClient();
likeClient = new LikeClient();
libClient = new LibClient();
} catch (Exception e) {
throw new RuntimeException(e);
}
@ -174,7 +149,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean saveUserPost(Post post) {
return postClient.saveUserPostLib(post);
return libClient.saveUserPostLib(post);
}
/**
* {@inheritDoc}
@ -189,7 +164,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean saveUserPost(Post post, List<Attachment> attachments) {
return postClient.saveUserPostLib(post, attachments);
return libClient.saveUserPostLib(post, attachments);
}
/**
@ -205,7 +180,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean saveAppPost(Post post) {
return postClient.saveAppPostLib(post);
return libClient.saveAppPostLib(post);
}
/**
* {@inheritDoc}
@ -220,7 +195,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean saveAppPost(Post post, List<Attachment> attachments) {
return postClient.saveAppPostLib(post, attachments);
return libClient.saveAppPostLib(post, attachments);
}
/**
* {@inheritDoc}
@ -235,7 +210,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean savePostToVRETimeline(String postKey, String vreid) throws FeedIDNotFoundException {
return postClient.savePostToVRETimelineLib(postKey, vreid);
return libClient.savePostToVRETimelineLib(postKey, vreid);
}
/**
* {@inheritDoc}
@ -255,7 +230,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
public Post readPost(String postid)
throws PrivacyLevelTypeNotFoundException,
FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
return postClient.readPostLib(postid);
return libClient.readPostLib(postid);
}
/**
* {@inheritDoc}
@ -282,7 +257,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
if (timeInMillis > now.getTime())
throw new IllegalArgumentException("the timeInMillis must be before today");
return postClient.getRecentPostsByUserAndDateLib(userid, timeInMillis);
return libClient.getRecentPostsByUserAndDateLib(userid, timeInMillis);
}
/**
* {@inheritDoc}
@ -297,7 +272,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException {
return postClient.deletePostLib(postid);
return libClient.deletePostLib(postid);
}
/**
* {@inheritDoc}
@ -317,7 +292,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public List<Post> getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return postClient.getAllPostsByUserLib(userid);
return libClient.getAllPostsByUserLib(userid);
}
/**
* {@inheritDoc}
@ -336,7 +311,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public List<Post> getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return postClient.getAllPostsByAppLib(appid);
return libClient.getAllPostsByAppLib(appid);
}
/**
* {@inheritDoc}
@ -360,7 +335,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Override
public List<Post> getRecentCommentedPostsByUserAndDate(String userid,
long timeInMillis) throws Exception {
return postClient.getRecentCommentedPostsByUserAndDateLib(userid, timeInMillis);
return libClient.getRecentCommentedPostsByUserAndDateLib(userid, timeInMillis);
}
/**
* {@inheritDoc}
@ -377,7 +352,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
}
@Override
public List<Post> getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
return postClient.getAllPortalPrivacyLevelPostsLib();
return libClient.getAllPortalPrivacyLevelPostsLib();
}
/**
* {@inheritDoc}
@ -394,7 +369,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
}
@Override
public List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return postClient.getRecentPostsByUserLib(userid, quantity);
return libClient.getRecentPostsByUserLib(userid, quantity);
}
/**
* {@inheritDoc}
@ -414,7 +389,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public List<Post> getAllPostsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return postClient.getAllPostsByVRELib(vreid);
return libClient.getAllPostsByVRELib(vreid);
}
/**
* {@inheritDoc}
@ -435,7 +410,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Override
public List<Post> getRecentPostsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
_log.info("\n\n in getRecentPostsByVRE");
return postClient.getRecentPostsByVRELib(vreid, quantity);
return libClient.getRecentPostsByVRELib(vreid, quantity);
}
/**
* {@inheritDoc}
@ -456,7 +431,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public RangePosts getRecentPostsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
return postClient.getRecentPostsByVREAndRangeLib(vreid, from, quantity);
return libClient.getRecentPostsByVREAndRangeLib(vreid, from, quantity);
}
/*
@ -469,7 +444,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean saveNotification(Notification n) {
return notificationClient.saveNotificationLib(n);
return libClient.saveNotificationLib(n);
}
/**
@ -477,14 +452,14 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
return notificationClient.readNotificationLib(notificationid);
return libClient.readNotificationLib(notificationid);
}
/**
* {@inheritDoc}
*/
@Override
public boolean setNotificationRead(String notificationidToSet) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
return notificationClient.setNotificationReadLib(notificationidToSet);
return libClient.setNotificationReadLib(notificationidToSet);
}
/**
@ -492,28 +467,28 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public List<Notification> getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
return notificationClient.getAllNotificationByUserLib(userid, limit);
return libClient.getAllNotificationByUserLib(userid, limit);
}
/**
* {@inheritDoc}
*/
@Override
public List<Notification> getUnreadNotificationsByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException {
return notificationClient.getUnreadNotificationsByUserLib(userid);
return libClient.getUnreadNotificationsByUserLib(userid);
}
/**
* {@inheritDoc}
*/
@Override
public List<Notification> getRangeNotificationsByUser(String userid,int from, int quantity) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException {
return notificationClient.getRangeNotificationsByUserLib(userid, from, quantity);
return libClient.getRangeNotificationsByUserLib(userid, from, quantity);
}
/**
* {@inheritDoc}
*/
@Override
public boolean setAllNotificationReadByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
return notificationClient.setAllNotificationReadByUserLib(userid);
return libClient.setAllNotificationReadByUserLib(userid);
}
/**
@ -521,14 +496,14 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean checkUnreadNotifications(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
return notificationClient.checkUnreadNotificationsLib(userid);
return libClient.checkUnreadNotificationsLib(userid);
}
/**
* {@inheritDoc}
*/
@Override
public boolean checkUnreadMessagesNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
return notificationClient.checkUnreadMessagesNotificationsLib(userid);
return libClient.checkUnreadMessagesNotificationsLib(userid);
}
/*
*
@ -540,7 +515,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public List<NotificationChannelType> getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException {
return notificationClient.getUserNotificationChannelsLib(userid, notificationType);
return libClient.getUserNotificationChannelsLib(userid, notificationType);
}
/**
@ -548,7 +523,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean setUserNotificationPreferences(String userid, Map<NotificationType, NotificationChannelType[]> enabledChannels) {
return notificationClient.setUserNotificationPreferencesLib(userid, enabledChannels);
return libClient.setUserNotificationPreferencesLib(userid, enabledChannels);
}
/**
* {@inheritDoc}
@ -557,7 +532,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public Map<NotificationType, NotificationChannelType[]> getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException {
return notificationClient.getUserNotificationPreferencesLib(userid);
return libClient.getUserNotificationPreferencesLib(userid);
}
/*
*
@ -569,13 +544,13 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean addComment(Comment comment) throws FeedIDNotFoundException {
return commentClient.addCommentLib(comment)!=null;
return libClient.addCommentLib(comment)!=null;
}
/**
* {@inheritDoc}
*/
public Comment readCommentById(String commentId) throws CommentIDNotFoundException {
return commentClient.readCommentByIdLib(commentId);
return libClient.readCommentByIdLib(commentId);
}
/**
* {@inheritDoc}
@ -590,7 +565,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public List<Comment> getAllCommentByPost(String postid) {
return commentClient.getAllCommentsByPostIdLib(postid);
return libClient.getAllCommentsByPostIdLib(postid);
}
/**
@ -601,7 +576,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
public List<Comment> getRecentCommentsByUserAndDate(final String userid,
final long timeInMillis) throws Exception {
return commentClient.getRecentCommentsByUserAndDateLib(userid, timeInMillis);
return libClient.getRecentCommentsByUserAndDateLib(userid, timeInMillis);
}
@ -610,7 +585,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean editComment(Comment comment2Edit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException {
return commentClient.editCommentLib(comment2Edit)!=null;
return libClient.editCommentLib(comment2Edit)!=null;
}
/**
@ -618,21 +593,21 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException {
return commentClient.deleteCommentLib(commentid, feedid);
return libClient.deleteCommentLib(commentid, feedid);
}
/**
* {@inheritDoc}
*/
@Override
public boolean like(Like like) throws FeedIDNotFoundException {
return likeClient.likeLib(like);
return libClient.likeLib(like);
}
/**
* {@inheritDoc}
*/
@Override
public boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException {
return likeClient.unlikeLib(userid, likeid, feedid);
return libClient.unlikeLib(userid, likeid, feedid);
}
/**
* {@inheritDoc}
@ -647,7 +622,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public List<String> getAllLikedPostIdsByUser(String userid) {
return likeClient.getAllLikedPostIdsByUserLib(userid);
return libClient.getAllLikedPostIdsByUserLib(userid);
}
/**
* {@inheritDoc}
@ -816,7 +791,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Override
public List<Like> getAllLikesByPost(String postid) {
//possible error index
return likeClient.getAllLikesByPostLib(postid);
return libClient.getAllLikesByPostLib(postid);
}
/*
*
@ -828,42 +803,42 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean saveHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException {
return hashTagClient.saveHashTagsLib(feedid, vreid, hashtags);
return libClient.saveHashTagsLib(feedid, vreid, hashtags);
}
/**
* {@inheritDoc}
*/
@Override
public boolean deleteHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException {
return hashTagClient.deleteHashTagsLib(feedid, vreid, hashtags);
return libClient.deleteHashTagsLib(feedid, vreid, hashtags);
}
/**
* {@inheritDoc}
*/
@Override
public boolean saveHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException {
return hashTagClient.saveHashTagsCommentLib(commentId, vreid, hashtags);
return libClient.saveHashTagsCommentLib(commentId, vreid, hashtags);
}
/**
* {@inheritDoc}
*/
@Override
public boolean deleteHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException {
return hashTagClient.deleteHashTagsCommentLib(commentId, vreid, hashtags);
return libClient.deleteHashTagsCommentLib(commentId, vreid, hashtags);
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, Integer> getVREHashtagsWithOccurrence(String vreid) {
return hashTagClient.getVREHashtagsWithOccurrenceLib(vreid);
return libClient.getVREHashtagsWithOccurrenceLib(vreid);
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, Integer> getVREHashtagsWithOccurrenceFilteredByTime(String vreid, long timestamp){
return hashTagClient.getVREHashtagsWithOccurrenceFilteredByTimeLib(vreid, timestamp);
return libClient.getVREHashtagsWithOccurrenceFilteredByTimeLib(vreid, timestamp);
}
/**
@ -878,7 +853,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public List<Post> getVREPostsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
return hashTagClient.getVREPostsByHashtagLib(vreid, hashtag);
return libClient.getVREPostsByHashtagLib(vreid, hashtag);
}
/*
*
@ -892,21 +867,21 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public String isExistingInvite(String vreid, String email) {
return inviteClient.isExistingInviteLib(vreid, email);
return libClient.isExistingInviteLib(vreid, email);
}
/**
* {@inheritDoc}
*/
@Override
public InviteOperationResult saveInvite(Invite invite) throws AddressException {
return inviteClient.saveInviteLib(invite);
return libClient.saveInviteLib(invite);
}
/**
* {@inheritDoc}
*/
@Override
public Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException {
return inviteClient.readInviteLib(inviteid);
return libClient.readInviteLib(inviteid);
}
/**
@ -915,21 +890,21 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException {
return inviteClient.setInviteStatusLib(vreid, email, status);
return libClient.setInviteStatusLib(vreid, email, status);
}
/**
* {@inheritDoc}
*/
@Override
public List<Invite> getInvitedEmailsByVRE(String vreid, InviteStatus... status) throws InviteIDNotFoundException, InviteStatusNotFoundException{
return inviteClient.getInvitedEmailsByVRELib(vreid, status);
return libClient.getInvitedEmailsByVRELib(vreid, status);
}
/**
* {@inheritDoc}
*/
@Override
public List<Attachment> getAttachmentsByFeedId(String feedId) throws FeedIDNotFoundException {
return postClient.getAttachmentsByFeedIdLib(feedId);
return libClient.getAttachmentsByFeedIdLib(feedId);
}
/**
* {@inheritDoc}
@ -940,6 +915,6 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
@Override
public List<String> getAllVREIds(){
return postClient.getAllVREIdsLib();
return libClient.getAllVREIdsLib();
}
}