diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF deleted file mode 100644 index 360b2e2..0000000 --- a/target/classes/META-INF/MANIFEST.MF +++ /dev/null @@ -1,13 +0,0 @@ -Manifest-Version: 1.0 -Build-Jdk-Spec: 15 -Specification-Title: gCube Social Library stubs -Specification-Version: 1.0 -Implementation-Title: gCube Social Library stubs -Implementation-Version: 1.0.0-SNAPSHOT -Build-Time: 20231127-154438 -Created-By: Maven Integration for Eclipse -SCM-Branch: -SCM-Revision: -SCM-Revision-URL: https://code-repo.d4science.org/gCubeSystem/social-lib - rary-stubs/commit/${buildNumber} - diff --git a/target/classes/org/gcube/portal/databook/GCubeSocialNetworking.gwt.xml b/target/classes/org/gcube/portal/databook/GCubeSocialNetworking.gwt.xml deleted file mode 100644 index d40b2ea..0000000 --- a/target/classes/org/gcube/portal/databook/GCubeSocialNetworking.gwt.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/target/classes/org/gcube/portal/databook/client/GCubeSocialNetworking.java b/target/classes/org/gcube/portal/databook/client/GCubeSocialNetworking.java deleted file mode 100644 index 565127d..0000000 --- a/target/classes/org/gcube/portal/databook/client/GCubeSocialNetworking.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.gcube.portal.databook.client; - -import com.google.gwt.core.client.EntryPoint; - -/** - * Entry point classes define onModuleLoad() and instances the HandlerManager for IPC - */ -public class GCubeSocialNetworking implements EntryPoint { - public static final String USER_PROFILE_OID = "userIdentificationParameter"; - public static final String HASHTAG_OID = "hashtagIdentificationParameter"; - public static final String SEARCH_OID = "elasticSearchIdentificationParameter"; - public static final String SHOW_STATISTICS_ACTION_OID = "showUserStatisticsActionParameter"; // see ShowUserStatisticAction - public static final String GROUP_MEMBERS_OID = "teamIdentificationParameter"; - public void onModuleLoad() { - } - -} diff --git a/target/classes/org/gcube/portal/databook/client/util/Encoder.java b/target/classes/org/gcube/portal/databook/client/util/Encoder.java deleted file mode 100644 index 312a720..0000000 --- a/target/classes/org/gcube/portal/databook/client/util/Encoder.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.gcube.portal.databook.client.util; -/** - * simply encode base64 strings - * @author massi - * - */ -public class Encoder { - public static native String encode(String toEncode) /*-{ - return btoa(toEncode); - }-*/; - - public static native String decode(String toDecode) /*-{ - return atob(toDecode); -}-*/; -} diff --git a/target/classes/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java b/target/classes/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java deleted file mode 100644 index 20724f1..0000000 --- a/target/classes/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java +++ /dev/null @@ -1,945 +0,0 @@ -package org.gcube.portal.databook.server; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import javax.mail.internet.AddressException; - -import org.gcube.portal.databook.shared.*; -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; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Massimiliano Assante ISTI-CNR - * @author Costantino Perciante ISTI-CNR - * This class is used for querying and adding data to Cassandra via Astyanax High Level API - */ -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; - - - /** - * 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) { - 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); - } - - } - /** - * public constructor, no dropping schema is allowed - */ - public DBCassandraAstyanaxImpl() { - 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); - } - - } - - /** - * public constructor, no dropping schema is allowed, infrastructureName is given. - */ - public DBCassandraAstyanaxImpl(String infrastructureName) { - 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); - } - } - - /* - * - ********************** FRIENDSHIPS (CONNECTIONS) *********************** - * - */ - /** - * {@inheritDoc} - */ - @Override - public boolean requestFriendship(String from, String to) { - return true; - } - /** - * {@inheritDoc} - */ - @Override - public boolean approveFriendship(String from, String to) { - return true; - } - /** - * {@inheritDoc} - */ - @Override - public boolean denyFriendship(String from, String to) { - return true; - } - /** - * {@inheritDoc} - */ - @Override - public List getFriends(String userid) { - ArrayList toReturn = new ArrayList(); - return toReturn; - } - /** - * {@inheritDoc} - */ - @Override - public List getPendingFriendRequests(String userid) { - ArrayList toReturn = new ArrayList(); - return toReturn; - } - /* - * - ********************** FEEDS *********************** - * - */ - - 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} - */ - @Deprecated - @Override - public boolean saveUserFeed(Feed post) { - return saveUserPost(feed2post(post)); - } - /** - * {@inheritDoc} - */ - @Override - public boolean saveUserPost(Post post) { - return postClient.saveUserPostLib(post); - } - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public boolean saveUserFeed(Feed feed, List attachments) { - return saveUserPost(feed2post(feed), attachments); - } - /** - * {@inheritDoc} - */ - @Override - public boolean saveUserPost(Post post, List attachments) { - return postClient.saveUserPostLib(post, attachments); - } - - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public boolean saveAppFeed(Feed post) { - return saveAppPost(feed2post(post)); - } - /** - * {@inheritDoc} - */ - @Override - public boolean saveAppPost(Post post) { - return postClient.saveAppPostLib(post); - } - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public boolean saveAppFeed(Feed feed, List attachments) { - return saveAppPost(feed2post(feed), attachments); - } - /** - * {@inheritDoc} - */ - @Override - public boolean saveAppPost(Post post, List attachments) { - return postClient.saveAppPostLib(post, attachments); - } - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException { - return savePostToVRETimeline(feedKey, vreid); - } - /** - * {@inheritDoc} - */ - @Override - public boolean savePostToVRETimeline(String postKey, String vreid) throws FeedIDNotFoundException { - return postClient.savePostToVRETimelineLib(postKey, vreid); - } - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public Feed readFeed(String feedid) - throws PrivacyLevelTypeNotFoundException, - FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException { - - return post2feed(readPost(feedid)); - } - /** - * {@inheritDoc} - */ - @Override - public Post readPost(String postid) - throws PrivacyLevelTypeNotFoundException, - FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException { - return postClient.readPostLib(postid); - } - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public List getRecentFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException { - Date now = new Date(); - if (timeInMillis > now.getTime()) - throw new IllegalArgumentException("the timeInMillis must be before today"); - List posts = getRecentPostsByUserAndDate(userid, timeInMillis); - List feeds = new ArrayList<>(); - for(Post post: posts){ - feeds.add(post2feed(post)); - } - return feeds; - } - /** - * {@inheritDoc} - */ - @Override - public List getRecentPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException { - Date now = new Date(); - if (timeInMillis > now.getTime()) - throw new IllegalArgumentException("the timeInMillis must be before today"); - - return postClient.getRecentPostsByUserAndDateLib(userid, timeInMillis); - } - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public boolean deleteFeed(String feedId) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException { - return deletePost(feedId); - } - /** - * {@inheritDoc} - */ - @Override - public boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException { - return postClient.deletePostLib(postid); - } - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public List getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - List posts = getAllPostsByUser(userid); - List feeds = new ArrayList<>(); - for(Post post: posts){ - feeds.add(post2feed(post)); - } - return feeds; - } - /** - * {@inheritDoc} - */ - @Override - public List getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - return postClient.getAllPostsByUserLib(userid); - } - /** - * {@inheritDoc} - */ - @Override - public List getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - List posts = getAllPostsByApp(appid); - List feeds = new ArrayList<>(); - for(Post post: posts){ - feeds.add(post2feed(post)); - } - return feeds; - } - /** - * {@inheritDoc} - */ - @Override - public List getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - return postClient.getAllPostsByAppLib(appid); - } - /** - * {@inheritDoc} - * @throws Exception - */ - @Deprecated - @Override - public List getRecentCommentedFeedsByUserAndDate(String userid, - long timeInMillis) throws Exception { - List posts = getRecentCommentedPostsByUserAndDate(userid, timeInMillis); - List feeds = new ArrayList<>(); - for(Post post: posts){ - feeds.add(post2feed(post)); - } - return feeds; - } - /** - * {@inheritDoc} - * @throws Exception - */ - @Override - public List getRecentCommentedPostsByUserAndDate(String userid, - long timeInMillis) throws Exception { - return postClient.getRecentCommentedPostsByUserAndDateLib(userid, timeInMillis); - } - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public List getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException { - List posts = getAllPortalPrivacyLevelPosts(); - List feeds = new ArrayList<>(); - for(Post post: posts){ - feeds.add(post2feed(post)); - } - return feeds; - } - @Override - public List getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException { - return postClient.getAllPortalPrivacyLevelPostsLib(); - } - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public List getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - List posts = getRecentPostsByUser(userid, quantity); - List feeds = new ArrayList<>(); - for(Post post: posts){ - feeds.add(post2feed(post)); - } - return feeds; - } - @Override - public List getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - return postClient.getRecentPostsByUserLib(userid, quantity); - } - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public List getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - List posts = getAllPostsByVRE(vreid); - List feeds = new ArrayList<>(); - for(Post post: posts){ - feeds.add(post2feed(post)); - } - return feeds; - } - /** - * {@inheritDoc} - */ - @Override - public List getAllPostsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - return postClient.getAllPostsByVRELib(vreid); - } - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public List getRecentFeedsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - _log.info("\n\n in getRecentFeedsByVRE"); - List posts = getRecentPostsByVRE(vreid, quantity); - _log.info("length of vre posts = " + posts.size()); - List feeds = new ArrayList<>(); - for(Post post: posts){ - feeds.add(post2feed(post)); - } - _log.info("length of vre feeds = " + feeds.size()); - return feeds; - } - @Override - public List getRecentPostsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - _log.info("\n\n in getRecentPostsByVRE"); - return postClient.getRecentPostsByVRELib(vreid, quantity); - } - /** - * {@inheritDoc} - */ - @Override - public RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - RangePosts rangePosts = getRecentPostsByVREAndRange(vreid, from, quantity); - List posts = rangePosts.getPosts(); - ArrayList feeds = new ArrayList<>(); - for(Post post: posts){ - feeds.add(post2feed(post)); - } - RangeFeeds rangeFeeds = new RangeFeeds(rangePosts.getLastReturnedPostTimelineIndex(), feeds); - return rangeFeeds; - } - /** - * {@inheritDoc} - */ - @Override - public RangePosts getRecentPostsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - return postClient.getRecentPostsByVREAndRangeLib(vreid, from, quantity); - } - - /* - * - ********************** NOTIFICATIONS *********************** - * - */ - /** - * {@inheritDoc} - */ - @Override - public boolean saveNotification(Notification n) { - return notificationClient.saveNotificationLib(n); - } - - /** - * {@inheritDoc} - */ - @Override - public Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException { - return notificationClient.readNotificationLib(notificationid); - } - /** - * {@inheritDoc} - */ - @Override - public boolean setNotificationRead(String notificationidToSet) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException { - return notificationClient.setNotificationReadLib(notificationidToSet); - } - - /** - * {@inheritDoc} - */ - @Override - public List getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException { - return notificationClient.getAllNotificationByUserLib(userid, limit); - } - /** - * {@inheritDoc} - */ - @Override - public List getUnreadNotificationsByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException { - return notificationClient.getUnreadNotificationsByUserLib(userid); - } - /** - * {@inheritDoc} - */ - @Override - public List getRangeNotificationsByUser(String userid,int from, int quantity) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException { - return notificationClient.getRangeNotificationsByUserLib(userid, from, quantity); - } - /** - * {@inheritDoc} - */ - @Override - public boolean setAllNotificationReadByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException { - return notificationClient.setAllNotificationReadByUserLib(userid); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean checkUnreadNotifications(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException { - return notificationClient.checkUnreadNotificationsLib(userid); - } - /** - * {@inheritDoc} - */ - @Override - public boolean checkUnreadMessagesNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException { - return notificationClient.checkUnreadMessagesNotificationsLib(userid); - } - /* - * - ********************** NOTIFICATION SETTINGS *********************** - * - */ - /** - * {@inheritDoc} - */ - @Override - public List getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException { - return notificationClient.getUserNotificationChannelsLib(userid, notificationType); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean setUserNotificationPreferences(String userid, Map enabledChannels) { - return notificationClient.setUserNotificationPreferencesLib(userid, enabledChannels); - } - /** - * {@inheritDoc} - * - * by default Workspace and Calendar Notifications are set to Portal - */ - @Override - public Map getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException { - return notificationClient.getUserNotificationPreferencesLib(userid); - } - /* - * - ********************** COMMENTS *********************** - * - */ - /** - * {@inheritDoc} - */ - @Override - public boolean addComment(Comment comment) throws FeedIDNotFoundException { - return commentClient.addCommentLib(comment)!=null; - } - /** - * {@inheritDoc} - */ - public Comment readCommentById(String commentId) throws CommentIDNotFoundException { - return commentClient.readCommentByIdLib(commentId); - } - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public List getAllCommentByFeed(String feedid) { - return getAllCommentByPost(feedid); - } - /** - * {@inheritDoc} - */ - @Override - public List getAllCommentByPost(String postid) { - return commentClient.getAllCommentsByPostIdLib(postid); - } - - /** - * {@inheritDoc} - * @throws Exception - */ - @Override - public List getRecentCommentsByUserAndDate(final String userid, - final long timeInMillis) throws Exception { - - return commentClient.getRecentCommentsByUserAndDateLib(userid, timeInMillis); - } - - - /** - * {@inheritDoc} - */ - @Override - public boolean editComment(Comment comment2Edit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException { - return commentClient.editCommentLib(comment2Edit)!=null; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException { - return commentClient.deleteCommentLib(commentid, feedid); - } - /** - * {@inheritDoc} - */ - @Override - public boolean like(Like like) throws FeedIDNotFoundException { - return likeClient.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); - } - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public List getAllLikedFeedIdsByUser(String userid) { - return getAllLikedPostIdsByUser(userid); - } - /** - * {@inheritDoc} - */ - @Override - public List getAllLikedPostIdsByUser(String userid) { - return likeClient.getAllLikedPostIdsByUserLib(userid); - } - /** - * {@inheritDoc} - */ - @Override - public List getAllLikedFeedsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - ArrayList toReturn = new ArrayList<>(); - List likedPostIDs = getAllLikedPostIdsByUser(userid); - - //check if quantity is greater than user feeds - limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit; - - //need them in reverse order - for (int i = likedPostIDs.size()-1; i >= (likedPostIDs.size()-limit); i--) { - Feed toAdd = readFeed(likedPostIDs.get(i)); - if (toAdd.getType() == FeedType.TWEET || toAdd.getType() == FeedType.SHARE || toAdd.getType() == FeedType.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; - } - /** - * {@inheritDoc} - */ - @Override - public List getAllLikedPostsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException { - ArrayList toReturn = new ArrayList(); - List likedPostIDs = getAllLikedPostIdsByUser(userid); - - //check if quantity is greater than user feeds - limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit; - - //need them in reverse order - 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; - } - - /** - * {@inheritDoc} - */ - @Override - public List getRecentLikedFeedsByUserAndDate(String userid, - long timeInMillis) throws IllegalArgumentException { - - List 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 likedPostsIdsByUser = getAllLikedFeedIdsByUser(userid); - - if(likedPostsIdsByUser != null && !likedPostsIdsByUser.isEmpty()){ - for(int i = likedPostsIdsByUser.size() - 1; i >= 0; i--){ - String postid = likedPostsIdsByUser.get(i); - try{ - - // retrieve the Post - Feed toCheck = readFeed(postid); - boolean isPostOk = (toCheck.getType() == FeedType.TWEET || toCheck.getType() == FeedType.SHARE || toCheck.getType() == FeedType.PUBLISH); - - // retrieve the like of the user for the post - if(isPostOk){ - List likes = getAllLikesByFeed(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); - } - } - } - - // please check consider that if a user made like recently to an old post, well it could happen that this - // post comes first than a newer post in the toReturn list. Thus we need to sort it. - Collections.sort(toReturn, Collections.reverseOrder()); - - return toReturn; - - } - /** - * {@inheritDoc} - */ - @Override - public List getRecentLikedPostsByUserAndDate(String userid, - long timeInMillis) throws IllegalArgumentException { - - List 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 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 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); - } - } - } - - // please check consider that if a user made like recently to an old post, well it could happen that this - // post comes first than a newer post in the toReturn list. Thus we need to sort it. - Collections.sort(toReturn, Collections.reverseOrder()); - - return toReturn; - } - - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public List getAllLikesByFeed(String feedid) { - return getAllLikesByPost(feedid); - } - /** - * {@inheritDoc} - */ - @Override - public List getAllLikesByPost(String postid) { - //possible error index - return likeClient.getAllLikesByPostLib(postid); - } - /* - * - ********************** HASHTAGS *********************** - * - */ - /** - * {@inheritDoc} - */ - @Override - public boolean saveHashTags(String feedid, String vreid, List hashtags) throws FeedIDNotFoundException { - return hashTagClient.saveHashTagsLib(feedid, vreid, hashtags); - } - /** - * {@inheritDoc} - */ - @Override - public boolean deleteHashTags(String feedid, String vreid, List hashtags) throws FeedIDNotFoundException { - return hashTagClient.deleteHashTagsLib(feedid, vreid, hashtags); - } - /** - * {@inheritDoc} - */ - @Override - public boolean saveHashTagsComment(String commentId, String vreid, List hashtags) throws CommentIDNotFoundException { - return hashTagClient.saveHashTagsCommentLib(commentId, vreid, hashtags); - } - /** - * {@inheritDoc} - */ - @Override - public boolean deleteHashTagsComment(String commentId, String vreid, List hashtags) throws CommentIDNotFoundException { - return hashTagClient.deleteHashTagsCommentLib(commentId, vreid, hashtags); - } - /** - * {@inheritDoc} - */ - @Override - public Map getVREHashtagsWithOccurrence(String vreid) { - return hashTagClient.getVREHashtagsWithOccurrenceLib(vreid); - } - /** - * {@inheritDoc} - */ - @Override - public Map getVREHashtagsWithOccurrenceFilteredByTime(String vreid, long timestamp){ - return hashTagClient.getVREHashtagsWithOccurrenceFilteredByTimeLib(vreid, timestamp); - } - - /** - * {@inheritDoc} - */ - @Override - public List getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException { - return null; - } - /** - * {@inheritDoc} - */ - @Override - public List getVREPostsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException { - return hashTagClient.getVREPostsByHashtagLib(vreid, hashtag); - } - /* - * - ********************** Invites *********************** - * - */ - - - /** - * {@inheritDoc} - */ - @Override - public String isExistingInvite(String vreid, String email) { - return inviteClient.isExistingInviteLib(vreid, email); - } - /** - * {@inheritDoc} - */ - @Override - public InviteOperationResult saveInvite(Invite invite) throws AddressException { - return inviteClient.saveInviteLib(invite); - } - /** - * {@inheritDoc} - */ - @Override - public Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException { - return inviteClient.readInviteLib(inviteid); - } - - /** - * {@inheritDoc} - * @throws InviteStatusNotFoundException - */ - @Override - public boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException { - return inviteClient.setInviteStatusLib(vreid, email, status); - } - /** - * {@inheritDoc} - */ - @Override - public List getInvitedEmailsByVRE(String vreid, InviteStatus... status) throws InviteIDNotFoundException, InviteStatusNotFoundException{ - return inviteClient.getInvitedEmailsByVRELib(vreid, status); - } - /** - * {@inheritDoc} - */ - @Override - public List getAttachmentsByFeedId(String feedId) throws FeedIDNotFoundException { - return postClient.getAttachmentsByFeedIdLib(feedId); - } - /** - * {@inheritDoc} - */ - @Override - public void closeConnection() { - } - - @Override - public List getAllVREIds(){ - return postClient.getAllVREIdsLib(); - } -} diff --git a/target/classes/org/gcube/portal/databook/server/DatabookCassandraTest.java b/target/classes/org/gcube/portal/databook/server/DatabookCassandraTest.java deleted file mode 100644 index 8d02836..0000000 --- a/target/classes/org/gcube/portal/databook/server/DatabookCassandraTest.java +++ /dev/null @@ -1,690 +0,0 @@ -package org.gcube.portal.databook.server; -import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - - -public class DatabookCassandraTest { - private static DBCassandraAstyanaxImpl store; - - @BeforeClass - public static void setup() throws Exception { - store = new DBCassandraAstyanaxImpl(); //set to true if you want to drop the KeySpace and recreate it - } - - @AfterClass - public static void close(){ - store.closeConnection(); - System.out.println("End"); - - } - - // @Test - // public void getRecentCommentedFeedsByUserAndDate() throws Exception{ - // String userid = "massimiliano.assante"; - // Calendar oneYearAgo = Calendar.getInstance(); - // oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1); - // - // long init = System.currentTimeMillis(); - // List res = store.getRecentCommentedFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis()); - // long end = System.currentTimeMillis(); - // System.out.println("Result is " + (end - init)); - // - // - // } - // @Test - // public void getRecentCommentsByUserAndDate() throws Exception{ - // - // String userid = "costantino.perciante"; - // Calendar oneYearAgo = Calendar.getInstance(); - // oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1); - // - // List res = store.getRecentCommentsByUserAndDate(userid, oneYearAgo.getTimeInMillis()); - // - // for (Comment comment : res) { - // System.out.println("Result is " + comment); - // } - // - // - // - // - // } - // @Test - // public void getRecentLikedFeedsByUser(){ - // - // String userid = "costantino.perciante"; - // Calendar oneYearAgo = Calendar.getInstance(); - // oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1); - // - // List result = store.getRecentLikedFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis()); - // - // for (Feed feed : result) { - // System.out.println("Result is " + feed); - // } - // } - // @Test - // public void getHashTagsFilteredByTime() throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException{ - // - // int windowSize = 6; // go back windowSize months - // - // String vreUnderTest = "/gcube/devsec/devVRE"; - // - // // reference time - // Calendar calendar = Calendar.getInstance(); - // int currentMonth = calendar.get(Calendar.MONTH); // jan = 0, ..... dec = 11 - // calendar.set(Calendar.MONTH, currentMonth - windowSize); // the year is automatically decreased if needed - // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - // System.out.println("Reference time for trending topics is " + format.format(calendar.getTime())); - // - // Map res = - // store.getVREHashtagsWithOccurrenceFilteredByTime( - // vreUnderTest, calendar.getTimeInMillis()); - // - // // find max score inside the list (counter) - // int max = 0; - // for(Entry entry : res.entrySet()){ - // - // max = max < entry.getValue() ? entry.getValue() : max; - // - // } - // - // // normalize - // Map normalized = new HashMap(); - // for(Entry entry : res.entrySet()){ - // - // normalized.put(entry.getKey(), (double)entry.getValue() / (double)max); - // - // } - // - // // create the weight for each entry as: - // // w = 0.6 * normalized_score + 0.4 * freshness - // // freshness is evaluated as (window_size - latest_feed_for_hashtag_in_window_month)/window_size - // Map scoredList = new HashMap(); - // for(Entry entry : res.entrySet()){ - // - // double weight = 0.6 * normalized.get(entry.getKey()); - // - // // retrieve the last feed for this hashtag and locate it into the window - // List mostRecentFeedForHashtag = store.getVREFeedsByHashtag(vreUnderTest, entry.getKey()); - // - // // retrieve the most recent one among these feeds - // Collections.sort(mostRecentFeedForHashtag, Collections.reverseOrder()); - // - // // locate into the window - // Calendar locateInWindow = Calendar.getInstance(); - // locateInWindow.setTimeInMillis(mostRecentFeedForHashtag.get(0).getTime().getTime()); - // - // // get the month - // int sub = currentMonth - locateInWindow.get(Calendar.MONTH); - // int value = sub >= 0? sub : 12 - Math.abs(sub); - // double freshness = (double)(windowSize - value) / (double)(windowSize); - // System.out.println("freshness is " + freshness + " because the last feed has month " + locateInWindow.get(Calendar.MONTH)); - // - // weight += 0.4 * freshness; - // - // scoredList.put(entry.getKey(), weight); - // } - // - // // print sorted - // Map scoredListSorted = sortByValue(scoredList); - // for(Entry entry : scoredListSorted.entrySet()){ - // - // System.out.println("[hashtag=" + entry.getKey() + " , weight=" + entry.getValue() + "]"); - // } - // } - // - // public static > Map - // sortByValue( Map map ) - // { - // List> list = - // new LinkedList>( map.entrySet() ); - // Collections.sort( list, new Comparator>() - // { - // public int compare( Map.Entry o1, Map.Entry o2 ) - // { - // return (o2.getValue()).compareTo( o1.getValue() ); - // } - // }); - // - // Map result = new LinkedHashMap(); - // for (Map.Entry entry : list) - // { - // result.put( entry.getKey(), entry.getValue() ); - // } - // return result; - // } - - - // @Test - // public void getHashTags() throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException{ - // List resList = store.getVREFeedsByHashtag("/gcube/devsec/devVRE", "#test"); - // - // for (Feed feed : resList) { - // System.out.println(feed.getTime()); - // } - // - // } - - // @Test - // public void getComment(){ - // - // String uuid = "820969b2-4632-4197-9fd6-5aafab781faa"; - // - // Comment c; - // try { - // c = store.readCommentById(uuid); - // System.err.println(c); - // } catch (CommentIDNotFoundException e) { - // // TODO Auto-generated catch block - // System.err.println(e.toString()); - // } - // } - - // @Test - // public void vreIds(){ - // - // try { - // List ids = store.getAllVREIds(); - // System.out.println(ids); - // } catch (ConnectionException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // - // } - - // @Test - // public void testFeedNumberPerUser() { - // String userid = "massimiliano.assante"; - // - // List feeds = null; - // int numComment = 0; - // long init = System.currentTimeMillis(); - // try { - // feeds = store.getAllFeedsByUser(userid); - // - // for (Feed feed : feeds) { - // List comments = store.getAllCommentByFeed(feed.getKey()); - // - // - // for (Comment comment : comments) { - // numComment ++; - // } - // } - // - // } catch (PrivacyLevelTypeNotFoundException | FeedTypeNotFoundException - // | ColumnNameNotFoundException | FeedIDNotFoundException e) { - // // TODO Auto-generated catch block - // System.err.println(e.toString()); - // } - // long end = System.currentTimeMillis(); - // System.err.println("retrieved " + feeds.size() + " and " + numComment + " in " + (end - init) + "ms"); - // } - - // @Test - // public void testAttachments() { - // Attachment a1 = new Attachment(UUID.randomUUID().toString(), "www1", "gattino1", "description1", "http://cdn.tuttozampe.com/wp-content/uploads/2010/09/ipoglicemia-gatto.jpg", "image/jpg"); - // Attachment a2 = new Attachment(UUID.randomUUID().toString(), "www2", "name2", "description2", "http://www.gcomegatto.it/wp-content/uploads/2015/01/09gatto.jpg","image/jpg"); - // Attachment a3 = new Attachment(UUID.randomUUID().toString(), "www3", "name3", "description3", "http://cdn.tuttozampe.com/wp-content/uploads/2010/09/ipoglicemia-gatto.jpg","image/jpg"); - // List toPass = new ArrayList(); - // toPass.add(a1); - // toPass.add(a2); - // toPass.add(a3); - // - // String feedId = UUID.randomUUID().toString(); - // Feed feed = new Feed(feedId, FeedType.TWEET, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE", - // "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg", - // "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg", - // "This post has attachments (gattini) ", PrivacyLevel.SINGLE_VRE, - // "Massimiliano Assante", - // "massimiliano.assante@isti.cnr.it", - // "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg", - // "Gattino", - // "linkDesc", - // "image/jpeg", false); - // feed.setMultiFileUpload(true); - // assertTrue(store.saveUserFeed(feed, toPass)); - // System.out.println("Wrote post? "); - // System.out.println("Feed has the following attachments: "); - // try { - // for (Attachment at : store.getAttachmentsByFeedId(feedId)) { - // System.out.println(at); - // } - // } catch (FeedIDNotFoundException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // - // } - - // @Test - // public void testHashTag() { - // try { - // final String VREID = "/gcube/devsec/devVRE"; - // final String HASHTAG1 = "#testHashTag"; - // final String HASHTAG2 = "#testHashTag3"; - // List hashtags = new LinkedList(); - // hashtags.add(HASHTAG1); - // hashtags.add(HASHTAG2); - // - //// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "massimiliano.assante", new Date(), VREID, - //// "www.d4science.org/monitor", "thumbUri", "This is a feed with " + HASHTAG1 + " and " + HASHTAG2, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host"); - //// assertTrue(store.saveUserFeed(feed)); - //// assertTrue(store.saveHashTags(feed.getKey(), VREID, hashtags)); - //// assertTrue(store.deleteHashTags("d0c64e42-9616-4e24-a65a-7a63a280d676", VREID, hashtags)); - //// System.out.println(feed); - //// - // System.out.println("\ngetting getVREHashtagsWithOccurrence for " + VREID); - // Map hashtagsWithOcc = store.getVREHashtagsWithOccurrence(VREID); - // for (String hashtag : hashtagsWithOcc.keySet()) { - // System.out.println(hashtag + ":" + hashtagsWithOcc.get(hashtag)); - // } - // - // System.out.println("\ngetting getVREFeedsByHashtag for " + VREID + " and " + HASHTAG1); - // for (Feed theFeed : store.getVREFeedsByHashtag(VREID, HASHTAG1)) { - // System.out.println(theFeed); - // } - // - // } catch (Exception e) { - // e.printStackTrace(); - // } - // - // - // } - - -// /** -// * use exclusively to add a new (Static) CF to a keyspace with a secondary index -// */ -// @Test -// public void addAttachmentStaticColumnFamilies() { -// ColumnFamily CF_ATTACHMENTS = ColumnFamily.newColumnFamily(DBCassandraAstyanaxImpl.ATTACHMENTS, StringSerializer.get(), StringSerializer.get()); -// -// try { -// String colNameToIndex = "feedId"; -// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(CF_ATTACHMENTS, ImmutableMap.builder() -// .put("column_metadata", ImmutableMap.builder() -// .put(colNameToIndex, ImmutableMap.builder() -// .put("validation_class", "UTF8Type") -// .put("index_name", "FeedIndex_"+UUID.randomUUID().toString().substring(0,5)) -// .put("index_type", "KEYS") -// .build()) -// .build()) -// .build()); -// -// -// } catch (ConnectionException e) { -// e.printStackTrace(); -// } -// System.out.println("addStaticColumnFamily END"); -// } -// - -// /** -// * use exclusively to add a new (Dynamic) CF to a keyspace -// */ -// @Test -// public void addInvitesDynamicColumnFamilies() { -// System.out.println("UserNotificationsUnread"); -// ColumnFamily cf_UserNotificationsUnreadTimeline = new ColumnFamily( -// DBCassandraAstyanaxImpl.EMAIL_INVITES, // Column Family Name -// StringSerializer.get(), // Key Serializer -// StringSerializer.get()); // Column Serializer -// -// try { -// -// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsUnreadTimeline, ImmutableMap.builder() -// .put("default_validation_class", "UTF8Type") -// .put("key_validation_class", "UTF8Type") -// .put("comparator_type", "UTF8Type") -// .build()); -// -// } catch (ConnectionException e) { -// e.printStackTrace(); -// } -// System.out.println("UserNotificationsUnread END"); -// } - - - // private List getKeys() { - // List toReturn = new ArrayList(); - // try { - // - // OperationResult> rows = store.getConnection().getKeyspace().prepareQuery(DBCassandraAstyanaxImpl.cf_UserNotificationsPreferences) - // .getAllRows() - // .setRowLimit(1000) // This is the page size - // .execute(); - // int i = 1; - // for (Row row : rows.getResult()) { - // System.out.println(i+" ROW: " + row.getKey() + " " + row.getColumns().size()); - // toReturn.add(row.getKey()); - // i++; - // } - // } catch (ConnectionException e) { - // e.printStackTrace(); - // } - // return toReturn; - // } - // - // @Test - // public void testUserNotificationPreferences() { - // System.out.println("Notification type" + NotificationType.POST_ALERT.toString() +" OFF for:"); - // try { - // for (String user : getKeys()) { - // List channels = store.getUserNotificationChannels(user, NotificationType.POST_ALERT); - // if (channels.isEmpty()) { - // System.out.println(user); - // } - // else if (! channels.contains(NotificationChannelType.EMAIL)) { - // System.out.println(user + "->" + channels.toString()); - // } - // } - - - // for (NotificationChannelType channel : store.getUserNotificationChannels("roberto.trasarti", NotificationType.POST_ALERT)) { - // System.out.println(channel); - // } - // } catch (NotificationChannelTypeNotFoundException e) { - // e.printStackTrace(); - // } catch (NotificationTypeNotFoundException e) { - // e.printStackTrace(); - // }; - // - // } - - // @Test - // public void testLikes() { - // int count = 10; - // Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE", - // "http://www.d4science.org/monitor", "thumbUri", "This feed is Liked ", PrivacyLevel.PUBLIC, - // "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false); - // assertTrue(store.saveUserFeed(feed)); - // Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante", - // new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl"); - // - // try { - // assertTrue(store.like(toUnlike)); - // for (int i = 0; i < count; i++) - // assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante", - // new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl"))); - // - // System.out.println("massimiliano.assante liked the following feeds: "); - // for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) { - // System.out.println(feedid); - // } - // - // for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) { - // System.out.println(like); - // } - // System.out.println("massimiliano.assante trying unlike the following feed: " + toUnlike); - // store.unlike("massimiliano.assante", toUnlike.getKey(), toUnlike.getFeedid()); - // - // } catch (Exception e) { - // System.out.println("Exception feed id not found"); - // } - // } - // /** - // * use exclusively to add a new CF to a keyspace - // */ - // @Test - // public void addNotifPreferencesColumnFamily() { - // // ColumnFamily cf_UserNotificationsPreferences = new ColumnFamily( - // // DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES, // Column Family Name - // // StringSerializer.get(), // Key Serializer - // // StringSerializer.get()); // Column Serializer - // // - // // try { - // // new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsPreferences, ImmutableMap.builder() - // // .put("default_validation_class", "UTF8Type") - // // .put("key_validation_class", "UTF8Type") - // // .put("comparator_type", "UTF8Type") - // // .build()); - // // } catch (ConnectionException e) { - // // e.printStackTrace(); - // // } - // } - // - // @Test - // public void testFriendships() { - // assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela")); - // assertTrue(store.requestFriendship("massimiliano.assante", "ermit")); - // assertTrue(store.requestFriendship("massimiliano.assante", "giorgino")); - // assertTrue(store.requestFriendship("barabba", "massimiliano.assante")); - // - // assertTrue(store.approveFriendship("leonardo.candela", "massimiliano.assante")); - // assertTrue(store.approveFriendship("ermit", "massimiliano.assante")); - // - // assertTrue(store.denyFriendship("giorgino", "massimiliano.assante")); - // System.out.println("Pending Connections for massimiliano.assante:"); - // for (String userid: store.getPendingFriendRequests("massimiliano.assante")) { - // System.out.println(userid); - // } - // - // System.out.println("Connections for massimiliano.assante:"); - // for (String userid: store.getFriends("massimiliano.assante")) { - // System.out.println(userid); - // } - // - // } - // @Test - // public void testLikedFeedsRetrieval() { - // try { - // for (Feed feed : store.getAllLikedFeedsByUser("luca.frosini", 10)) { - // System.out.println(feed); - // } - // } catch (Exception e) { - // e.printStackTrace(); - // } - // } - // - // - // - // - // @Test - // public void testSingleNotification() { - // Notification not = new Notification( - // UUID.randomUUID().toString(), - // NotificationType.LIKE, - // "leonardo.candela", - // "MESSAGEID", - // new Date(), - // "uri", - // "This is notification about a like", - // false, - // "leonardo.candela", "Leonardo Candela", - // "thumburl"); - // assertTrue(store.saveNotification(not)); - // - // not = new Notification( - // UUID.randomUUID().toString(), - // NotificationType.MESSAGE, - // "massimiliano.assante", - // "MESSAGEID", - // new Date(), - // "uri", - // "This is notification about a like", - // false, - // "antonio.gioia", "Antonio Gioia", - // "thumburl"); - // assertTrue(store.saveNotification(not)); - // System.out.println("Writing one Notification " + not); - // } - // - // @Test - // public void testNotifications() { - // Notification not = null; - // System.out.println("Writing 18 Notifications"); - // int count = 18; - // for (int i = 0; i < count; i++) { - // if (i % 2 != 0) { - // not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_OK, - // "leonardo.candela", "TWEETID", new Date(), "uri", "This is notification about job completed OK #"+i, false, "pasquale.pagano", "Pasquale Pagano", "thumburl"); - // } else { - // not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_NOK, - // "massimiliano.assante", "MESSAGEID", new Date(), "uri", "This is notification about completed NOK #"+i, false, "leonardo.candela", "Leonardo Candela", "thumburl"); - // } - // assertTrue(store.saveNotification(not)); - // try { - // Thread.sleep(150); - // } catch (InterruptedException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // } - // - // Notification rNot= null; - // try { - // - // //read - // rNot = store.readNotification(not.getKey().toString()); - // assertNotNull(rNot); - // System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType()); - // - // //set Read - // assertTrue(store.setNotificationRead(rNot.getKey().toString())); - // - // System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ"); - // - // not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE, - // "leonardo.candela", "FEEDID", new Date(), "uri", "This is notification of a Liked Leo feed by Massi", false, "massimiliano.assante", "Massimiliano Assante", "thumburl"); - // assertTrue(store.saveNotification(not)); - // try { - // Thread.sleep(150); - // } catch (InterruptedException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // rNot = store.readNotification(not.getKey().toString()); - // System.out.println("Reading another Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " Read:? " + rNot.isRead()); - // // //set Read - // // assertTrue(store.setNotificationRead(rNot.getKey().toString())); - // // System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ subject was this: " + rNot.getSubjectid()); - // // - // Random randomGenerator = new Random(); - // - // System.out.println("leonardo.candela Notifications: "); - // List recentNots = store.getAllNotificationByUser("leonardo.candela", randomGenerator.nextInt(50)); - // assertNotNull(recentNots); - // for (Notification notif :recentNots) - // System.out.println(notif); - // - // - // System.out.println("massimiliano.assante Notifications: "); - // recentNots = store.getUnreadNotificationsByUser("massimiliano.assante"); - // assertNotNull(recentNots); - // for (Notification notif :recentNots) - // System.out.println(notif); - // } catch (Exception e) { - // e.printStackTrace(); - // } - // - // System.out.println("getRangeNotificationsByUser massimiliano.assante: "); - // try { - // int from = 0; - // for (int i = 0; i < 5; i++) { - // System.out.println("\nFROM="+from); - // List range = store.getRangeNotificationsByUser("massimiliano.assante", from, 50); - // for (Notification notification : range) { - // System.out.println(notification.getDescription()); - // from = 1+i * 50; - // } - // } - // } catch (Exception e) { - // e.printStackTrace(); - // } - // } - // - // - // @Test - // public void testFeeds() { - // int count = 18; - // Feed feed = null; - // for (int i = 0; i < count; i++) { - // if (i % 2 != 0) { - // feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE", - // "www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host"); - // } else { - // feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "", - // "www.d4science.org/web/guest", "thumbUri", "This is feed# "+ i, PrivacyLevel.PORTAL, "Leonardo Candela", "leonardo.candela@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host"); - // } - // assertTrue(store.saveUserFeed(feed)); - // try { - // Thread.sleep(150); - // } catch (InterruptedException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // } - // - // Feed rFeed = null; - // try { - // rFeed = store.readFeed(feed.getKey().toString()); - // rFeed = store.readFeed(feed.getKey().toString()); - // rFeed = store.readFeed(feed.getKey().toString()); - // rFeed = store.readFeed(feed.getKey().toString()); - // assertNotNull(rFeed); - // - // String feedIdToDelete = UUID.randomUUID().toString(); - // feed = new Feed(feedIdToDelete, FeedType.PUBLISH, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE", - // "www.d4science.org/monitor", "thumbUri", "This is feed to be deleted", PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false); - // assertTrue(store.saveUserFeed(feed)); - // try { - // Thread.sleep(250); - // } catch (InterruptedException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // System.out.println("Test Delete Feed "); - // assertTrue(store.deleteFeed(feedIdToDelete)); - // - // System.out.println("massimiliano.assante ALL FEEDS: "); - // for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante")) - // System.out.println(recFeed); - // } - // catch (Exception e) { - // e.printStackTrace(); - // } - // } - // - // - // - // @Test - // public void testComments() { - // int count = 10; - // Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE", - // "http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante", - // "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false); - // assertTrue(store.saveUserFeed(feed)); - // - // Comment toDelete = null; - // for (int i = 0; i < count; i++) { - // try { - // toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela", - // new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl"); - // assertTrue(store.addComment(toDelete)); - // - // } catch (FeedIDNotFoundException e) { - // System.out.println("Exception feed id not found"); - // } - // } - // System.out.println("GetAllCOmmentsByFeed "); - // for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) { - // try { - // System.out.println(store.readCommentById(cm.getKey())); - // } catch (CommentIDNotFoundException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // }; - // - // try { - // assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid())); - // } catch (Exception e) { - // System.out.println("Exception feed id not found"); - // } - // } - - -} diff --git a/target/classes/org/gcube/portal/databook/server/DatabookStore.java b/target/classes/org/gcube/portal/databook/server/DatabookStore.java deleted file mode 100644 index 95af072..0000000 --- a/target/classes/org/gcube/portal/databook/server/DatabookStore.java +++ /dev/null @@ -1,667 +0,0 @@ -package org.gcube.portal.databook.server; - -import java.util.List; -import java.util.Map; - -import javax.mail.internet.AddressException; - -import org.gcube.portal.databook.shared.Attachment; -import org.gcube.portal.databook.shared.Comment; -import org.gcube.portal.databook.shared.Feed; -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.RangeFeeds; -import org.gcube.portal.databook.shared.RangePosts; -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; - -/** - * @author Massimiliano Assante ISTI-CNR - * @author Costantino Perciante ISTI-CNR - * DatabookStore is the high level interface for querying and adding data to DatabookStore - */ -public interface DatabookStore { - /** - * userid from requests a friendship to userid to - * @return true if everything went fine - */ - boolean requestFriendship(String from, String to); - /** - * userid from approves a friendship to userid to - * @return true if everything went fine - */ - boolean approveFriendship(String from, String to); - /** - * userid from denies a friendship to userid to - * @return true if everything went fine - */ - boolean denyFriendship(String from, String to); - /** - * @param userid the user id you want to know friends - * @return a List of userid representing the friends for the given userid - */ - List getFriends(String userid); - /** - * @param userid the user id you want to know the pending friend requests - * @return a List of userid representing the friends for the given userid - */ - List getPendingFriendRequests(String userid); - /** - * @deprecated use saveUserPost - * save a Feed instance in the store - * @return true if everything went fine - */ - boolean saveUserFeed(Feed feed); - /** - * save a Post instance in the store - * @return true if everything went fine - */ - boolean saveUserPost(Post feed); - /** - * Save a Feed instance in the store having more than one attachment - * Use this if you need to attach more than one file to the post - * - * @deprecated use saveUserPost - * @param attachments a list of attachments starting from the second - * @return true if everything went fine - */ - boolean saveUserFeed(Feed feed, List attachments); - /** - * Save a Post instance in the store having more than one attachment - * Use this if you need to attach more than one file to the post - * - * @param attachments a list of attachments starting from the second - * @return true if everything went fine - */ - boolean saveUserPost(Post post, List attachments); - /** - * Delete a Feed from the store - * @deprecated use saveUserPost - * @throws FeedIDNotFoundException - * @return true if everything went fine - */ - boolean deleteFeed(String feedid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException; - /** - * delete a Feed from the store - * @throws FeedIDNotFoundException - * @return true if everything went fine - */ - boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException; - /** - * Save a post in the VRES TimeLine in the store - * @deprecated use savePostToVRETimeline - * @param feedKey feedKey - * @param vreid vre identifier - * @throws FeedIDNotFoundException - */ - boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException; - /** - * save a post in the VRES TimeLine in the store - * @param postKey the post id - * @param vreid vre identifier - * @throws FeedIDNotFoundException - */ - boolean savePostToVRETimeline(String postKey, String vreid) throws FeedIDNotFoundException; - /** - * @deprecated use saveAppPost - * save a Post instance in the store - * @return true if everything went fine - */ - boolean saveAppFeed(Feed feed); - /** - * save a Post instance in the store - * @return true if everything went fine - */ - boolean saveAppPost(Post feed); - /** - * @deprecated use saveAppPost - * Save a Post instance in the store - * Use this if your app needs to attach more than one file to the post - * - * @param attachments a list of attachments starting from the second - * @return true if everything went fine - */ - boolean saveAppFeed(Feed feed, List attachments); - /** - * Save a Post instance in the store - * Use this if your app needs to attach more than one file to the post - * - * @param attachments a list of attachments starting from the second - * @return true if everything went fine - */ - boolean saveAppPost(Post feed, List attachments); - /** - * @deprecated use readPost - * read a feed from a given id - * @throws PrivacyLevelTypeNotFoundException - * @throws FeedTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - Feed readFeed(String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; - /** - * read a feed from a given id - * @throws PrivacyLevelTypeNotFoundException - * @throws FeedTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - Post readPost(String postid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; - /** - * @deprecated use getAllPostsByUser instead - * @param userid user identifier - * return all the feeds belonging to the userid - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; - /** - * @param userid user identifier - * return all the feeds belonging to the userid - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; - /** - * @deprecated use getAllPostsByApp instead - * @param appid application identifier - * return all the feeds belonging to the appid - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; - /** - * @param appid application identifier - * return all the feeds belonging to the appid - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; - /** - * @deprecated use getRecentCommentedPostsByUserAndDate instead - * @param userid the user identifier like andrea.rossi - * @param timeInMillis the initial time in millis to be considered - * @return a list of feeds commented by userid starting from timeInMillis - * @throws Exception - */ - List getRecentCommentedFeedsByUserAndDate(String userid, long timeInMillis) throws Exception; - /** - * @param userid the user identifier like andrea.rossi - * @param timeInMillis the initial time in millis to be considered - * @return a list of feeds commented by userid starting from timeInMillis - * @throws Exception - */ - List getRecentCommentedPostsByUserAndDate(String userid, long timeInMillis) throws Exception; - /** - * @deprecated use getAllPortalPrivacyLevelPosts instead - * return all the feeds whose Level is PORTAL - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - * @throws PrivacyLevelTypeNotFoundException - */ - List getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException; - /** - * return all the feeds whose Level is PORTAL - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - * @throws PrivacyLevelTypeNotFoundException - */ - List getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException; - - /** - * return the most recent feeds for this user up to quantity param - * @deprecated - * @param userid user identifier - * @param quantity the number of most recent feeds for this user - * @return a List of most recent feeds for this user - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException; - /** - * return the most recent feeds for this user up to quantity param - * @param userid user identifier - * @param quantity the number of most recent feeds for this user - * @return a List of most recent feeds for this user - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException; - /** - * @deprecated use getAllPostsByVRE - * @param vreid vre identifier - * return all the feeds belonging to the userid - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException; - /** - * @param vreid vre identifier - * return all the feeds belonging to the userid - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getAllPostsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException; - - /** - * @deprecated use getRecentPostsByVRE - * return the most recent feeds for this vre up to quantity param - * @param vreid VRES identifier - * @param quantity the number of most recent feeds for this vre - * @return a List of most recent feeds for this vre - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getRecentFeedsByVRE(String vreid, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException; - /** - * return the most recent posts for this vre up to quantity param - * @param vreid VRES identifier - * @param quantity the number of most recent posts for this vre - * @return a List of most recent posts for this vre - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getRecentPostsByVRE(String vreid, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException; - - /** - * return the most recent posts for this vre up to quantity param and the last index of the feeds in the timeline - * lastReturnedFeedTimelineIndex is usuful to know from where to start the range the second time you ask - * because there are deletions - * - * @deprecated use getRecentPostsByVREAndRange - * @param vreid VRES identifier - * @param from the range start (most recent feeds for this vre) has to be greater than 0 - * @param quantity the number of most recent feeds for this vre starting from "from" param - * @return a lastReturnedFeedTimelineIndex containing of most recent feeds for this vre - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException; - /** - * return the most recent posts for this vre up to quantity param and the last index of the posts in the timeline - * lastReturnedPostTimelineIndex is useful to know from where to start the range the next time you ask, because there are deletions - * - * @param vreid VRES identifier - * @param from the range start (most recent feeds for this vre) has to be greater than 0 - * @param quantity the number of most recent feeds for this vre starting from "from" param - * @return a RangePosts containing of most recent feeds for this vre - * @throws FeedTypeNotFoundException - * @throws PrivacyLevelTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - RangePosts getRecentPostsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException; - - /** - * @deprecated use getRecentPostsByUserAndDate - * @param userid user identifier - * @param timeInMillis time in milliseconds from which you want to start retrieve the feeds - * @return the number of feeds in the range from: today to: timeInMillis - */ - List getRecentFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException; - /** - * @param userid user identifier - * @param timeInMillis time in milliseconds from which you want to start retrieve the feeds - * @return the number of feeds in the range from: today to: timeInMillis - */ - List getRecentPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException; - /** - * save a Notification instance in the store - * @return true if everything went fine - */ - boolean saveNotification(Notification notification); - /** - * set an existing Notification instance in the to read - * @return true if everything went fine - */ - boolean setNotificationRead(String notificationidToSet) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException; - /** - * read a notification from a given id - * @throws {@link ColumnNameNotFoundException} - * @throws {@link NotificationIDNotFoundException} - * @throws {@link NotificationTypeNotFoundException} - */ - Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException; - - /** - * @param userid user identifier - * @param limit set 0 to get everything, an int to get the most recent -limit- notifications - * return all the notifications belonging to the userid up to limit, set 0 to get everything - * @throws NotificationTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException; - /** - * - * @param userid user identifier - * @param from the range start has to be greater than 0 - * @param quantity the number of most recent notifications for this user starting from "from" param - * @return all the notifications for the userid in the range requested - * @throws NotificationTypeNotFoundException - * @throws ColumnNameNotFoundException - * @throws NotificationIDNotFoundException - */ - List getRangeNotificationsByUser(String userid, int from, int quantity) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException; - /** - * This is a fast way to set all notification to read quickly - * @param userid - * @return true if everything went fine - * @throws {@link ColumnNameNotFoundException} - * @throws {@link NotificationIDNotFoundException} - * @throws {@link NotificationTypeNotFoundException} - */ - boolean setAllNotificationReadByUser(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException; - /** - * return the not yet read notifications (not including messages) - * @param userid user identifier - * @return a List of not yet read notifications for this user - * @throws NotificationTypeNotFoundException - * @throws ColumnNameNotFoundException - */ - List getUnreadNotificationsByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException; - /** - * - * @param userid user identifier - * @throws ColumnNameNotFoundException - * @throws NotificationTypeNotFoundException - * @throws NotificationIDNotFoundException - * @return true if there are unread notifications (not including messages), false if they are all read - */ - boolean checkUnreadNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException; - /** - * - * @param userid user identifier - * @throws ColumnNameNotFoundException - * @throws NotificationTypeNotFoundException self explaining - * @throws NotificationChannelTypeNotFoundException self explaining - * @throws NotificationIDNotFoundException - * @return true if there are unread messages notifications (including messages), false if they are all read - */ - boolean checkUnreadMessagesNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException; - - /** - * return the channels a user chose for being notified for a given notification type - * @param userid user identifier - * @param notificationType the type of the notification - * @return a list of NotificationChannelType that represents the channels this user wants to be notified - */ - List getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException; - /** - * set the notification preferences map (enable or disable the channels to be used for notifying the user) - * @param userid user identifier - * @param enabledChannels a map of the channels to which reach the user per notification, empty array or null values to set the key notification type off - * @return true if everything was fine - */ - boolean setUserNotificationPreferences(String userid, Map enabledChannels); - /** - * get the notification preferences map (enableor disable the channels to be used for notifying the user) - * @param userid user identifier - * @return the map - * @throws NotificationTypeNotFoundException self explaining - * @throws NotificationChannelTypeNotFoundException self explaining - */ - Map getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException; - - /** - * @param commentId comment unique identifier - * @return the comment belonging to the commentId - * @throws CommentIDNotFoundException - */ - Comment readCommentById(String commentId) throws CommentIDNotFoundException; - /** - * add a comment to a feed - * @param comment the Comment instance to add - */ - boolean addComment(Comment comment) throws FeedIDNotFoundException; - /** - * @deprecated use getAllCommentByPost - * @param feedid feed identifier - * return all the comments belonging to the feedid - */ - List getAllCommentByFeed(String feedid); - /** - * @param postid the post identifier - * return all the comments belonging to the postid - */ - List getAllCommentByPost(String postid); - /** - * @param userid user identifier - * @param timeInMillis time in milliseconds from which you want to start retrieve the feeds - * @return a list of comments (sorted starting from the most recent one) made by the user since timeInMillis up to now - */ - List getRecentCommentsByUserAndDate(String userid, long timeInMillis) throws Exception; - /** - * edit a comment - * @param comment the comment to edit - * @return true if success, false otherwise - */ - boolean editComment(Comment comment) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException; - /** - * deletes a comment - * @param commentid the comment identifier to delete - * @param feedid the feedid to which the comment is associated - * @return true if success, false otherwise - */ - boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException; - /** - * add a like to a feed - * @param like instance - * @throws FeedIDNotFoundException - */ - boolean like(Like like) throws FeedIDNotFoundException; - /** - * unlike a feed - * @param userid user identifier - * @param likeid the like identifier to delete - * @param feedid the feedid to which the comment is associated - * @return true if success, false otherwise - */ - boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException; - /** - * @deprecated use getAllLikedPostIdsByUser - * @param userid user identifier - * return all the feedids a user has liked - */ - List getAllLikedFeedIdsByUser(String userid); - /** - * @param userid user identifier - * return all the feedids a user has liked - */ - List getAllLikedPostIdsByUser(String userid); - /** - * @deprecated use getAllLikedPostsByUser - * @param userid user identifier - * @param limit set 0 to get everything, an int to get the most recent -limit- liked feeds - * @throws ColumnNameNotFoundException . - * @throws FeedIDNotFoundException . - * @throws FeedTypeNotFoundException . - * @throws PrivacyLevelTypeNotFoundException - * @throws FeedIDNotFoundException . - * return all the feeds a user has liked - */ - List getAllLikedFeedsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; - - /** - * @param userid user identifier - * @param limit set 0 to get everything, an int to get the most recent -limit- liked posts - * @throws ColumnNameNotFoundException . - * @throws FeedIDNotFoundException . - * @throws FeedTypeNotFoundException . - * @throws PrivacyLevelTypeNotFoundException - * @throws FeedIDNotFoundException . - * return all the feeds a user has liked - */ - List getAllLikedPostsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; - - /** - * @deprecated use getRecentLikedPostsByUserAndDate - * @param userid user identifier - * @param timeInMillis time in milliseconds from which you want to start retrieve the feeds - * @return the likes made to feeds in the range from: today to: timeInMillis - */ - List getRecentLikedFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException; - /** - * @param userid user identifier - * @param timeInMillis time in milliseconds from which you want to start retrieve the feeds - * @return the likes made to feeds in the range from: today to: timeInMillis - */ - List getRecentLikedPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException; - /** - * @deprecated use getAllLikesByPost - * @param postid postid identifier - * return all the likes belonging to the postid - */ - List getAllLikesByFeed(String postid); - /** - * @param postid postid identifier - * return all the likes belonging to the postid - */ - List getAllLikesByPost(String postid); - /** - * - * @param hashtags the hashtag including the '#' - * @param postid the postid to which the hashtag is associated - * @param vreid VRE identifier - * @return true if success, false otherwise - * @throws FeedIDNotFoundException - */ - boolean saveHashTags(String postid, String vreid, List hashtags) throws FeedIDNotFoundException; - /** - * - * @param hashtags the hashtag including the '#' - * @param commentId the commentId to which the hashtag is associated - * @param vreid VRE identifier - * @return true if success, false otherwise - * @throws CommentIDNotFoundException - */ - boolean saveHashTagsComment(String commentId, String vreid, List hashtags) throws CommentIDNotFoundException; - /** - * - * @param hashtags the hashtag including the '#' - * @param postid the postid to which the hashtag is associated - * @param vreid VRE identifier - * @return true if success, false otherwise - * @throws FeedIDNotFoundException - */ - boolean deleteHashTags(String postid, String vreid, List hashtags) throws FeedIDNotFoundException; - /** - * - * @param hashtags the hashtag including the '#' - * @param commentId the commentId to which the hashtag is associated - * @param vreid VRE identifier - * @return true if success, false otherwise - * @throws CommentIDNotFoundException - */ - boolean deleteHashTagsComment(String commentId, String vreid, List hashtags) throws CommentIDNotFoundException; - /** - * get a map of vre hashtags where the key is the hashtag and the value is the occurrence of the hashtag in the VRE - * @param vreid vre identifier (scope) - * @return a HashMap of vre Hashtags associated with their occurrence - */ - Map getVREHashtagsWithOccurrence(String vreid); - /** - * get a map of vre hashtags where the key is the hashtag and the value is the occurrence of the hashtag in the VRE - * @param vreid vre identifier (scope) - * @param timestamp do not consider hashtags used before timestamp - * @return a HashMap of vre Hashtags associated with their occurrence - */ - Map getVREHashtagsWithOccurrenceFilteredByTime(String vreid, long timestamp); - /** - * @deprecated use getVREPostsByHashtag - * @param vreid VRE identifier - * @param hashtag the hashtag to look for including the '#', it is case sensitive - * @throws ColumnNameNotFoundException . - * @throws FeedIDNotFoundException . - * @throws FeedTypeNotFoundException . - * @throws PrivacyLevelTypeNotFoundException - * @throws FeedIDNotFoundException . - * @return all the feeds having the hashtag passed as parameter - */ - List getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; - /** - * - * @param vreid VRE identifier - * @param hashtag the hashtag to look for including the '#', it is case sensitive - * @throws ColumnNameNotFoundException . - * @throws FeedIDNotFoundException . - * @throws FeedTypeNotFoundException . - * @throws PrivacyLevelTypeNotFoundException - * @throws FeedIDNotFoundException . - * @return all the feeds having the hashtag passed as parameter - */ - List getVREPostsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; - - /** - * Save the invite for a given email into a given vre - * @param invite the invite object instanc to save - * @return {@link InviteOperationResult} SUCCESS, FAILED or ALREADY_INVITED (if an invite is sent to en existing email in the same environment more than once) - */ - InviteOperationResult saveInvite(Invite invite) throws AddressException; - /** - * - * @param vreid the environment where you want to check the invite - * @param email the email of the invite to check in the environmnet - * @return the InviteId if present, null otherwise - */ - String isExistingInvite(String vreid, String email); - /** - * read an invite from a given id - * @throws InviteIDNotFoundException - * @throws InviteStatusNotFoundException - */ - Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException; - /** - * set the status of an invite, see {@link InviteStatus} - * @throws InviteIDNotFoundException - */ - boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException; - /** - * Use to get the list of invites per VRE - * @param vreid the vre id - * @param status optional, if you want to restict on the status, e.g. all pending invites - * @return return the list of invites - * @throws InviteIDNotFoundException - * @throws InviteStatusNotFoundException - */ - List getInvitedEmailsByVRE(String vreid, InviteStatus... status) throws InviteIDNotFoundException, InviteStatusNotFoundException; - /** - * - * @param feedId - * @return the list of attachments of the feed feedId, starting from the second one (first attachment is included in Feed instance already) - */ - List getAttachmentsByFeedId(String feedId) throws FeedIDNotFoundException; - - /** - * Retrieve all the ids of the vre - * @return the set of ids of the vre available or empty list in case of errors. - */ - public List getAllVREIds(); - - /** - * close the connection to the underlying database - */ - void closeConnection(); -} diff --git a/target/classes/org/gcube/portal/databook/server/RunningCluster.java b/target/classes/org/gcube/portal/databook/server/RunningCluster.java deleted file mode 100644 index f137a9d..0000000 --- a/target/classes/org/gcube/portal/databook/server/RunningCluster.java +++ /dev/null @@ -1,220 +0,0 @@ -package org.gcube.portal.databook.server; - -import static org.gcube.resources.discovery.icclient.ICFactory.clientFor; -import static org.gcube.resources.discovery.icclient.ICFactory.queryFor; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.Serializable; -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.gcube.common.portal.GCubePortalConstants; -import org.gcube.common.portal.PortalContext; -import org.gcube.common.resources.gcore.ServiceEndpoint; -import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; -import org.gcube.common.scope.api.ScopeProvider; -import org.gcube.portal.databook.shared.ex.TooManyRunningClustersException; -import org.gcube.resources.discovery.client.api.DiscoveryClient; -import org.gcube.resources.discovery.client.queries.api.SimpleQuery; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -/** - * @author Massimiliano Assante ISTI-CNR - * @author Ahmed Salah Tawfik Ibrahim ISTI-CNR - * - * @version 2.0.0 October 2023 - * - */ -@SuppressWarnings("serial") -public class RunningCluster implements Serializable { - /** - * logger - */ - private static final Logger _log = LoggerFactory.getLogger(RunningCluster.class); - - /** - * properties to read - */ - private static final String HOST_PROPERTY = "host"; - private static final String HOST_PORT_PROPERTY = "port"; - private static final String DATACENTER_NAME_PROPERTY = "datacenter"; - private static final String KEY_SPACE_NAME_PROPERTY = "keyspace"; - /** - * other constants - */ - private final static String RUNTIME_RESOURCE_NAME = "SocialPortalDataStore"; - private final static String PLATFORM_NAME = "Cassandra"; - - private static final String DEFAULT_CONFIGURATION = "/org/gcube/portal/databook/server/resources/databook.properties"; - - private static RunningCluster singleton; - /** - * Host - */ - private String host; - /** - * Cluster Name - */ - private String datacenterName; - /** - * Keyspace Name - */ - private String keyspaceName; //to be modified - - /** - * @param infrastructureName could be null - * @return an instance of the RunningCluster - */ - public static synchronized RunningCluster getInstance(String infrastructureName) { - if (singleton == null) { - singleton = new RunningCluster(infrastructureName); - } - return singleton; - } - /** - * private constructor - */ - private RunningCluster(String infrastructureName) { - //Query the IS (for the future) - /*List resources = getConfigurationFromIS(infrastructureName); - if (resources.size() > 1) { - _log.error("Too many Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" in this scope "); - throw new TooManyRunningClustersException("There exist more than 1 Runtime Resource in this scope having name " - + RUNTIME_RESOURCE_NAME + " and Platform " + PLATFORM_NAME + ". Only one allowed per infrasrtucture."); - } - else if (resources.size() == 0){ - _log.error("There is no Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" and Platform " + PLATFORM_NAME + " in this scope. Using default configuration properties: " + DEFAULT_CONFIGURATION); - loadDefaultConfiguration(); - } - else { - for (ServiceEndpoint res : resources) { - AccessPoint found = res.profile().accessPoints().iterator().next(); - host = found.address(); - clusterName = found.description(); - keyspaceName = found.name(); - } - } - } catch (Exception e) { - e.printStackTrace(); - }*/ - - host = "10.1.28.55:9042, 10.1.30.142:9042, 10.1.28.100:9042"; - datacenterName = "1"; - keyspaceName = "dev_mig_new_schema_test"; - } - - /** - * - * @return the - * @throws Exception - */ - private List getConfigurationFromIS(String infrastructureName) throws Exception { - _log.debug("getConfigurationFromIS infrastructureName="+infrastructureName ); - String scope = "/"; - if(infrastructureName != null && !infrastructureName.isEmpty()) - scope += infrastructureName; - else { - scope += readInfrastructureName(); - _log.debug("infrastrucute name is null, setting root scope=" + scope); - } - String currScope = ScopeProvider.instance.get(); - ScopeProvider.instance.set(scope); - SimpleQuery query = queryFor(ServiceEndpoint.class); - query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_RESOURCE_NAME +"'"); - query.addCondition("$resource/Profile/Platform/Name/text() eq '"+ PLATFORM_NAME +"'"); - DiscoveryClient client = clientFor(ServiceEndpoint.class); - List toReturn = client.submit(query); - ScopeProvider.instance.set(currScope); - return toReturn; - } - - private String readInfrastructureName() { - - Properties props = new Properties(); - try { - StringBuilder sb = new StringBuilder(getCatalinaHome()); - sb.append(File.separator) - .append(PortalContext.CONFIGURATION_FOLDER) - .append(File.separator) - .append(PortalContext.INFRA_PROPERTY_FILENAME); - String propertyfile = sb.toString(); - File propsFile = new File(propertyfile); - FileInputStream fis = new FileInputStream(propsFile); - props.load( fis); - return props.getProperty(GCubePortalConstants.INFRASTRUCTURE_NAME); - } - catch(IOException e) { - _log.error("infrastructure.properties file not found under $CATALINA_HOME/conf/ dir, setting default infrastructure Name " + "gcube"); - return "gcube"; - } - } - - - /** - * - */ - private void loadDefaultConfiguration() { - Properties props = new Properties(); - try { - props.load(CassandraClusterConnection.class.getResourceAsStream(DEFAULT_CONFIGURATION)); - host = props.getProperty(HOST_PROPERTY) + ":" + props.getProperty(HOST_PORT_PROPERTY); - datacenterName = props.getProperty(DATACENTER_NAME_PROPERTY); - keyspaceName = props.getProperty(KEY_SPACE_NAME_PROPERTY); - } catch (IOException e) { - e.printStackTrace(); - } - } - - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - - public String getKeyspaceName() { - return keyspaceName; - } - - - public void setKeyspaceName(String keyspaceName) { - this.keyspaceName = keyspaceName; - } - - @Override - public String toString() { - return "RunningCluster [host=" + host + ", datacenterName=" + datacenterName - + ", keyspaceName=" + keyspaceName + "]"; - } - /** - * - * @return $CATALINA_HOME - */ - private static String getCatalinaHome() { - return (System.getenv("CATALINA_HOME").endsWith("/") ? System.getenv("CATALINA_HOME") : System.getenv("CATALINA_HOME")+"/"); - } - public void setDatacenterName(String datacenterName){ - this.datacenterName = datacenterName; - } - - public String getDatacenterName() { - return datacenterName; - } - - public List getHosts() { - List hosts = new ArrayList<>(); - String [] ips = host.split(", "); - for (String ip: ips){ - String[] ip_port = ip.split(":"); - hosts.add(new InetSocketAddress(ip_port[0], Integer.parseInt(ip_port[1]))); - } - return hosts; - } -} \ No newline at end of file diff --git a/target/classes/org/gcube/portal/databook/server/Schema.java b/target/classes/org/gcube/portal/databook/server/Schema.java deleted file mode 100644 index 522093e..0000000 --- a/target/classes/org/gcube/portal/databook/server/Schema.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.gcube.portal.databook.server; - -public class Schema { - //Tables - public static final String NOTIFICATIONS = "Notifications"; - public static final String POSTS = "Posts"; - public static final String COMMENTS = "Comments"; - public static final String LIKES = "Likes"; - public static final String INVITES = "Invites"; - public static final String VRE_TIMELINE_POSTS = "VRETimeline"; - public static final String USER_TIMELINE_POSTS = "UserTimeline"; - public static final String APP_TIMELINE_POSTS = "AppTimeline"; - public static final String USER_LIKED_POSTS = "UserLikes"; - public static final String USER_NOTIFICATIONS = "UserNotifications"; // regular user notifications timeline (both read and unread, messages are included) - public static final String USER_NOTIFICATIONS_UNREAD = "UserUnreadNotifications"; // only unread user notifications/ notifications messages - public static final String USER_NOTIFICATIONS_PREFERENCES = "UserNotificationsPreferences"; // preferences for notifications - public static final String HASHTAGS_COUNTER = "HashtagsCounter"; // count the hashtags per group and type - public static final String HASHTAGGED_POSTS = "HashtaggedPosts"; // contains hashtags per type associated with vre and POST - public static final String HASHTAGGED_COMMENTS = "HashtaggedComments"; // contains hashtags per type associated with vre and comment - public static final String VRE_INVITES = "VREInvites"; //contains the emails that were invited per VRE - public static final String EMAIL_INVITES = "EmailInvites"; //contains the list of invitation per email - public static final String ATTACHMENTS = "Attachments"; //contains the list of all the attachments in a POST - - //columns - public static final String USER_ID = "userid"; //text - public static final String TYPE = "type"; //text - public static final String PREFERENCE = "preference"; //text - public static final String TIMESTAMP = "timestamp"; //timestamp - public static final String NOT_ID = "notid"; //UUID - public static final String VRE_ID = "vreid"; //text - public static final String POST_ID = "postid"; //UUID - public static final String APP_ID = "appid"; //text - public static final String HASHTAG = "hashtag"; //text - public static final String COMMENT_ID = "commentid"; //UUID - public static final String COUNT = "count"; //big int - public static final String LIKE_ID = "likeid"; //UUID - public static final String INVITE_ID = "inviteid"; //UUID - public static final String STATUS = "status"; //text - public static final String EMAIL = "email"; //text - public static final String ATTACH_ID = "attachid"; //UUID - public static final String URI = "uri"; //text - public static final String NAME = "name"; //text - public static final String DESCRIPTION = "description"; //text - public static final String URI_THUMBNAIL = "urithumbnail"; //text - public static final String MIME_TYPE = "mimetype"; //text - public static final String SENDER_USER_ID = "senderuserid"; //text - public static final String CONTROL_CODE = "controlcode"; //text - public static final String SENDER_FULL_NAME = "senderfullname"; //text - public static final String FULL_NAME = "fullname"; //text - public static final String THUMBNAIL_URL = "thumbnailurl"; //text - public static final String COMMENT = "comment"; //text - public static final String IS_EDIT = "isedit"; //bool - public static final String LAST_EDIT_TIME = "lastedittime"; //timestamp - public static final String SUBJECT_ID = "subjectid"; //text - public static final String SENDER_ID = "senderid"; //text - public static final String SENDER_THUMBNAIL_URL = "senderthumbnailurl"; //text - public static final String IS_READ = "isread"; //bool - public static final String LINK_HOST = "linkhost"; //text - public static final String LIKES_NO = "likesno"; //big int - public static final String LINK_DESCRIPTION = "linkdescription"; //text - public static final String IS_APPLICATION_POST = "isapplicationpost"; //bool --> - public static final String ENTITY_ID = "entityid"; //text - public static final String PRIVACY = "privacy"; //text - public static final String MULTI_FILE_UPLOAD = "multifileupload"; //bool - public static final String COMMENTS_NO = "commentsno"; //big int - public static final String LINK_TITLE = "linktitle"; //text - -} \ No newline at end of file diff --git a/target/classes/org/gcube/portal/databook/server/Tester.java b/target/classes/org/gcube/portal/databook/server/Tester.java deleted file mode 100644 index 522de5b..0000000 --- a/target/classes/org/gcube/portal/databook/server/Tester.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.gcube.portal.databook.server; - -import org.gcube.portal.databook.shared.*; -import org.gcube.portal.databook.shared.ex.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; - -public class Tester { - private static DBCassandraAstyanaxImpl store; - private static Logger LOGGER = LoggerFactory.getLogger(Tester.class); - - public Tester() { - store = new DBCassandraAstyanaxImpl("gcube"); //set to true if you want to drop the KeySpace and recreate it - } - - public static void main(String[] args) throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException { - Tester test = new Tester(); - //test.getComment(); - test.testFunc(); - System.exit(0); - - } - public void testFunc() throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException { - String postIdToUpdate = "047c601d-2291-4974-9224-d6732b1fbe26"; - Post read = store.readPost(postIdToUpdate); - - List readC = store.getAllCommentByPost("047c601d-2291-4974-9224-d6732b1fbe26"); - System.out.println(read); - readC.forEach(c -> System.out.println(c.getText())); - } - public void getComment(){ - String uuid = "820969b2-4632-4197-9fd6-5aafab781faa"; - - Comment c; - try { - c = store.readCommentById(uuid); - System.out.println(c); - } catch (CommentIDNotFoundException e) { - // TODO Auto-generated catch block - System.err.println(e.toString()); - } - } -} \ No newline at end of file diff --git a/target/classes/org/gcube/portal/databook/server/resources/databook.properties b/target/classes/org/gcube/portal/databook/server/resources/databook.properties deleted file mode 100644 index c0fad71..0000000 --- a/target/classes/org/gcube/portal/databook/server/resources/databook.properties +++ /dev/null @@ -1,4 +0,0 @@ -host = node1.d.cassandra.research-infrastructures.eu -port = 9160 -cluster = D4Science Cluster -keyspace = DevKeySpace \ No newline at end of file diff --git a/target/classes/org/gcube/portal/databook/shared/ApplicationProfile.java b/target/classes/org/gcube/portal/databook/shared/ApplicationProfile.java deleted file mode 100644 index ef7593c..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ApplicationProfile.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; - -/** - * - * @author Massimiliano Assante, ISTI-CNR - * @version 0.1 Dec 2012 - * - */ -@SuppressWarnings("serial") -public class ApplicationProfile implements Serializable { - - private String key; - private String name; - private String description; - private String imageUrl; - private String scope; - private String url; - - public ApplicationProfile() { - super(); - } - - public ApplicationProfile(String key, String name, String description, String imageUrl, String scope, String url) { - super(); - this.key = key; - this.name = name; - this.description = description; - this.imageUrl = imageUrl; - this.scope = scope; - this.url = url; - } - public String getKey() { - return key; - } - public void setKey(String key) { - this.key = key; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - public String getImageUrl() { - return imageUrl; - } - public void setImageUrl(String imageUrl) { - this.imageUrl = imageUrl; - } - public String getScope() { - return scope; - } - public void setScope(String scope) { - this.scope = scope; - } - - public String getUrl() { - return url; - } - public void setUrl(String url) { - this.url = url; - } - @Override - public String toString() { - return "ApplicationProfile [key=" + key + ", name=" + name + ", description=" - + description + ", imageUrl=" + imageUrl + ", scope=" + scope - + ", url=" + url + "]"; - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/Attachment.java b/target/classes/org/gcube/portal/databook/shared/Attachment.java deleted file mode 100644 index 5b8e337..0000000 --- a/target/classes/org/gcube/portal/databook/shared/Attachment.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; - -import org.jsonmaker.gwt.client.Jsonizer; - -@SuppressWarnings("serial") -public class Attachment implements Serializable { - - public interface AttachmentJsonizer extends Jsonizer {} - - private String id; - private String uri; - private String name; - private String description; - private String thumbnailURL; - private String mimeType; - - public Attachment() { - super(); - } - - /** - * @param id the id in the cassandra CF - * @param uri where you can download the file from - * @param name the name of the attached file - * @param description the description of the attached file - * @param thumbnailURL the URL of the image representing the attached file - * @param mimeType the type of file - */ - public Attachment(String id, String uri, String name, String description, - String thumbnailURL, String mimeType) { - super(); - this.id = id; - this.uri = uri; - this.name = name; - this.description = description; - this.thumbnailURL = thumbnailURL; - this.mimeType = mimeType; - } - - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - - public String getName() { - return name; - } - - - public void setName(String name) { - this.name = name; - } - - - public String getDescription() { - return description; - } - - - public void setDescription(String description) { - this.description = description; - } - - - public String getThumbnailURL() { - return thumbnailURL; - } - - - public void setThumbnailURL(String thumbnailURL) { - this.thumbnailURL = thumbnailURL; - } - - public String getMimeType() { - return mimeType; - } - - public void setMimeType(String mimeType) { - this.mimeType = mimeType; - } - - @Override - public String toString() { - return "Attachment [uri=" + uri + ", name=" + name + ", description=" - + description + ", thumbnailURL=" + thumbnailURL - + ", mimeType=" + mimeType + "]"; - } - - - - -} diff --git a/target/classes/org/gcube/portal/databook/shared/ClientAttachment.java b/target/classes/org/gcube/portal/databook/shared/ClientAttachment.java deleted file mode 100644 index 13acb08..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ClientAttachment.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.gcube.portal.databook.shared; - -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object") -public class ClientAttachment { - public String id; - public String uri; - public String name; - public String description; - public String thumbnailURL; - public String mimeType; - /** - * @param id the id in the cassandra CF - * @param uri where you can download the file from - * @param name the name of the attached file - * @param description the description of the attached file - * @param thumbnailURL the URL of the image representing the attached file - * @param mimeType the type of file - */ - @JsOverlay - public static ClientAttachment create(String id, String uri, String name, String description, String thumbnailURL, String mimeType) { - ClientAttachment o = new ClientAttachment(); - o.id = id; - o.uri = uri; - o.name = name; - o.description = description; - o.thumbnailURL = thumbnailURL; - o.mimeType = mimeType; - return o; - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/ClientFeed.java b/target/classes/org/gcube/portal/databook/shared/ClientFeed.java deleted file mode 100644 index 07fe349..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ClientFeed.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -import org.jsonmaker.gwt.client.Jsonizer; - - -/** - * - * @author Massimiliano Assante, ISTI-CNR - * - */ -@SuppressWarnings("serial") -public class ClientFeed implements Serializable { - - public interface ClientFeedJsonizer extends Jsonizer {} - - private String key; - private String type; - private String userid; - private Date time; - private String uri; - private String description; - private String fullName; - private String email; - private String thumbnailURL; - private String linkTitle; - private String linkDescription; - private String linkUrlThumbnail; - private String linkHost; - private List attachments; - - public ClientFeed() { - super(); - } - - public ClientFeed(String key, String type, String userid, Date time, - String uri, String description, String fullName, String email, - String thumbnailURL, String linkTitle, String linkDescription, - String linkUrlThumbnail, String linkHost, List attachments) { - super(); - this.key = key; - this.type = type; - this.userid = userid; - this.time = time; - this.uri = uri; - this.description = description; - this.fullName = fullName; - this.email = email; - this.thumbnailURL = thumbnailURL; - this.linkTitle = linkTitle; - this.linkDescription = linkDescription; - this.linkUrlThumbnail = linkUrlThumbnail; - this.linkHost = linkHost; - this.attachments = attachments; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getUserid() { - return userid; - } - - public void setUserid(String userid) { - this.userid = userid; - } - - public Date getTime() { - return time; - } - - public void setTime(Date time) { - this.time = time; - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getThumbnailURL() { - return thumbnailURL; - } - - public void setThumbnailURL(String thumbnailURL) { - this.thumbnailURL = thumbnailURL; - } - - public String getLinkTitle() { - return linkTitle; - } - - public void setLinkTitle(String linkTitle) { - this.linkTitle = linkTitle; - } - - public String getLinkDescription() { - return linkDescription; - } - - public void setLinkDescription(String linkDescription) { - this.linkDescription = linkDescription; - } - - public String getLinkUrlThumbnail() { - return linkUrlThumbnail; - } - - public void setLinkUrlThumbnail(String linkUrlThumbnail) { - this.linkUrlThumbnail = linkUrlThumbnail; - } - - public String getLinkHost() { - return linkHost; - } - - public void setLinkHost(String linkHost) { - this.linkHost = linkHost; - } - - - public List getAttachments() { - return attachments; - } - - public void setAttachments(List attachments) { - this.attachments = attachments; - } - - @Override - public String toString() { - return "ClientFeed [key=" + key + ", type=" + type + ", userid=" - + userid + ", time=" + time + ", uri=" + uri + ", description=" - + description + ", fullName=" + fullName + ", email=" + email - + ", thumbnailURL=" + thumbnailURL + ", linkTitle=" + linkTitle - + ", linkDescription=" + linkDescription - + ", linkUrlThumbnail=" + linkUrlThumbnail + ", linkHost=" - + linkHost + ", attachments=" + attachments + "]"; - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/ClientPost.java b/target/classes/org/gcube/portal/databook/shared/ClientPost.java deleted file mode 100644 index 2fab59b..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ClientPost.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.util.Date; - -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -/** - * - * @author Massimiliano Assante, CNR-ISTI - * Uses JsInterop annotations to deserialize the object - */ -@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object") -public class ClientPost { - public String key; - public String type; - public String userid; - public Date time; - public String uri; - public String description; - public String fullName; - public String email; - public String thumbnailURL; - public String linkTitle; - public String linkDescription; - public String linkUrlThumbnail; - public String linkHost; - public ClientAttachment[] attachments; - @JsOverlay - public static ClientPost create(String key, String type, String userid, Date time, - String uri, String description, String fullName, String email, - String thumbnailURL, String linkTitle, String linkDescription, - String linkUrlThumbnail, String linkHost, ClientAttachment[] attachments) { - ClientPost o = new ClientPost(); - o.key = key; - o.type = type; - o.userid = userid; - o.time = time; - o.uri = uri; - o.description = description; - o.fullName = fullName; - o.email = email; - o.thumbnailURL = thumbnailURL; - o.linkTitle = linkTitle; - o.linkDescription = linkDescription; - o.linkUrlThumbnail = linkUrlThumbnail; - o.linkHost = linkHost; - o.attachments = attachments; - return o; - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/Comment.java b/target/classes/org/gcube/portal/databook/shared/Comment.java deleted file mode 100644 index f8042e8..0000000 --- a/target/classes/org/gcube/portal/databook/shared/Comment.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.Date; - -/** - * - * @author Massimiliano Assante, ISTI-CNR - * @version 0.1 July 2012 - * - */ -@SuppressWarnings("serial") -public class Comment implements Serializable, Comparable { - - private String key; - private String userid; - private Date time; - private String feedid; - private String text; - private String fullName; - private String thumbnailURL; - private boolean isEdit; // false default - private Date lastEditTime; // null default - - /** - * - */ - public Comment() { - super(); - } - /** - * - * @param key - * @param userid - * @param time - * @param feedid - * @param text - * @param fullName - * @param thumbnailURL - */ - public Comment(String key, String userid, Date time, String feedid, - String text, String fullName, String thumbnailURL) { - super(); - this.key = key; - this.userid = userid; - this.time = time; - this.feedid = feedid; - this.text = text; - this.fullName = fullName; - this.thumbnailURL = thumbnailURL; - this.isEdit = false; - this.lastEditTime = null; - - } - - /** - * Constructor for edited comment - * @param key - * @param userid - * @param time - * @param feedid - * @param text - * @param fullName - * @param thumbnailURL - * @param isEdit - * @param editDate - */ - public Comment(String key, String userid, Date time, String feedid, - String text, String fullName, String thumbnailURL, boolean isEdit, Date editDate) { - super(); - this.key = key; - this.userid = userid; - this.time = time; - this.feedid = feedid; - this.text = text; - this.fullName = fullName; - this.thumbnailURL = thumbnailURL; - this.isEdit = isEdit; - this.lastEditTime = editDate; - } - - /** - * - * @return the text - */ - public String getText() { - return text; - } - /** - * - * @param text text to add as string - */ - public void setText(String text) { - this.text = text; - } - /** - * - * @return the uuid - */ - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getUserid() { - return userid; - } - - public void setUserid(String userid) { - this.userid = userid; - } - - public Date getTime() { - return time; - } - - public void setTime(Date time) { - this.time = time; - } - - public String getFeedid() { - return feedid; - } - - public void setFeedid(String feedid) { - this.feedid = feedid; - } - - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public String getThumbnailURL() { - return thumbnailURL; - } - - public void setThumbnailURL(String thumbnailURL) { - this.thumbnailURL = thumbnailURL; - } - - public boolean isEdit() { - return isEdit; - } - public void setEdit(boolean isEdit) { - this.isEdit = isEdit; - } - public Date getLastEditTime() { - return lastEditTime; - } - public void setLastEditTime(Date lastEditTime) { - this.lastEditTime = lastEditTime; - } - public int compareTo(Comment toCompare) { - if (this.time.after(toCompare.getTime())) - return 1; - if (this.time.before(toCompare.getTime())) - return -1; - return 0; - } - - @Override - public String toString() { - return "Comment [key=" + key + ", userid=" + userid + ", time=" + time - + ", feedid=" + feedid + ", text=" + text + ", fullName=" - + fullName + ", thumbnailURL=" + thumbnailURL + ", isEdit=" - + isEdit + ", lastEditTime=" + lastEditTime + "]"; - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/EnhancedFeed.java b/target/classes/org/gcube/portal/databook/shared/EnhancedFeed.java deleted file mode 100644 index f258516..0000000 --- a/target/classes/org/gcube/portal/databook/shared/EnhancedFeed.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.ArrayList; -/** - * - * @author massi - * This class contains addtional user related information about a Feed - * e.g. if this user has liked it - */ -@SuppressWarnings("serial") -public class EnhancedFeed implements Serializable{ - private Feed feed; - private boolean liked; - private boolean isUsers; - private ArrayList comments; - private ArrayList attachments; - - - public EnhancedFeed() { - super(); - } - public EnhancedFeed(Feed feed, boolean liked, boolean isUsers) { - super(); - this.feed = feed; - this.liked = liked; - this.isUsers = isUsers; - } - - public EnhancedFeed(Feed feed, boolean liked, boolean isUsers, ArrayList comments) { - super(); - this.isUsers = isUsers; - this.feed = feed; - this.liked = liked; - this.comments = comments; - } - - - public EnhancedFeed(Feed feed, boolean liked, boolean isUsers, - ArrayList comments, ArrayList attachments) { - super(); - this.feed = feed; - this.liked = liked; - this.isUsers = isUsers; - this.comments = comments; - this.attachments = attachments; - } - public ArrayList getComments() { - return comments; - } - public void setComments(ArrayList comments) { - this.comments = comments; - } - public Feed getFeed() { - return feed; - } - public void setFeed(Feed feed) { - this.feed = feed; - } - public boolean isLiked() { - return liked; - } - public void setLiked(boolean liked) { - this.liked = liked; - } - public boolean isUsers() { - return isUsers; - } - public void setUsers(boolean isUsers) { - this.isUsers = isUsers; - } - public ArrayList getAttachments() { - return attachments; - } - public void setAttachments(ArrayList attachments) { - this.attachments = attachments; - } - @Override - public String toString() { - return "EnhancedFeed [feed=" + feed + ", liked=" + liked + ", isUsers=" - + isUsers + ", comments=" + comments + ", attachments=" - + attachments + "]"; - } - -} diff --git a/target/classes/org/gcube/portal/databook/shared/Feed.java b/target/classes/org/gcube/portal/databook/shared/Feed.java deleted file mode 100644 index 514a0db..0000000 --- a/target/classes/org/gcube/portal/databook/shared/Feed.java +++ /dev/null @@ -1,322 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.Date; - -/** - * - * @author Massimiliano Assante, ISTI-CNR - * @deprecated use org.gcube.portal.databook.shared.Post instead - */ -@SuppressWarnings("serial") -public class Feed implements Serializable, Comparable { - - private String key; - private FeedType type; - private String entityId; - private Date time; - private String vreid; - private String uri; - private String uriThumbnail; - private String description; - private PrivacyLevel privacy; - private String fullName; - private String email; - private String thumbnailURL; - private String commentsNo; - private String likesNo; - private String linkTitle; - private String linkDescription; - private String linkHost; - boolean applicationFeed; - /** - * this boolean indicates that the attachments to the post are > 1 - */ - boolean multiFileUpload; - /** - * default constructor - */ - public Feed() { - super(); - } - /** - * To use ONLY for USER Feeds - * - * - * @param key a UUID - * @param type an instance of FeedType - * @param entityId the user or the app unique indentifier - * @param time when - * @param vreid a unique vre id - * @param uri optional uri - * @param uriThumbnail the thumbnail for the link posted - * @param description optional description - * @param privacy the privacy level of PrivacyLevel - * @param fullName - * @param email - * @param thumbnailURL this is the user thumbnail url - * @param linkTitle optional to be used when posting links - * @param linkDescription optional to be used when posting links - * @param linkHost option to be used when posting linkgs - */ - public Feed(String key, FeedType type, String entityId, Date time, - String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy, - String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost) { - this.key = key; - this.type = type; - this.entityId = entityId; - this.time = time; - this.vreid = vreid; - this.uri = uri; - this.uriThumbnail = uriThumbnail; - this.description = description; - this.privacy = privacy; - this.fullName = fullName; - this.email = email; - this.thumbnailURL = thumbnailURL; - this.commentsNo = "0"; - this.likesNo = "0"; - this.linkDescription = linkDescription; - this.linkTitle = linkTitle; - this.linkHost = linkHost; - this.applicationFeed = false; - } - /** - * To use for USER and ApplicationProfile Feeds - * - * @param key a UUID - * @param type an instance of FeedType - * @param entityId the user or the app unique indentifier - * @param time when - * @param vreid a unique vre id - * @param uri optional uri - * @param uriThumbnail the thumbnail for the link posted - * @param description optional description - * @param privacy the privacy level of PrivacyLevel - * @param fullName - * @param email - * @param thumbnailURL this is the user thumbnail url - * @param linkTitle optional to be used when posting links - * @param linkDescription optional to be used when posting links - * @param applicationFeed tell if this is an application feed or a user feed - */ - public Feed(String key, FeedType type, String entityId, Date time, - String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy, - String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed) { - this(key, type, entityId, time, vreid, uri, uriThumbnail, description, privacy, fullName, email, thumbnailURL, linkTitle, linkDescription, linkHost); - this.applicationFeed = applicationFeed; - } - - - /** - * for serialization purposes - * @param key a UUID - * @param type an instance of FeedType - * @param entityId the user or the app unique indentifier - * @param time when - * @param vreid a unique vre id - * @param uri optional uri - * @param uriThumbnail the thumbnail for the link posted - * @param description optional description - * @param privacy the privacy level of PrivacyLevel - * @param fullName - * @param email - * @param thumbnailURL this is the user thumbnail url - * @param linkTitle optional to be used when posting links - * @param linkDescription optional to be used when posting links - */ - public Feed(String key, FeedType type, String entityId, Date time, - String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy, - String fullName, String email, String thumbnailURL, String commentsNo, - String likesNo, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed, boolean multiFileUpload) { - super(); - this.key = key; - this.type = type; - this.entityId = entityId; - this.time = time; - this.vreid = vreid; - this.uri = uri; - this.uriThumbnail = uriThumbnail; - this.description = description; - this.privacy = privacy; - this.fullName = fullName; - this.email = email; - this.thumbnailURL = thumbnailURL; - this.commentsNo = commentsNo; - this.likesNo = likesNo; - this.linkDescription = linkDescription; - this.linkTitle = linkTitle; - this.linkHost = linkHost; - this.applicationFeed = applicationFeed; - this.multiFileUpload = multiFileUpload; - } - /** - * - * @return the key - */ - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public FeedType getType() { - return type; - } - - public void setType(FeedType type) { - this.type = type; - } - /** - * - * @return the User or the App id - */ - public String getEntityId() { - return entityId; - } - /** - * set the User or the App id - * @param entityId the UserId or the AppId id - */ - public void setEntityId(String entityId) { - this.entityId = entityId; - } - - public Date getTime() { - return time; - } - - public void setTime(Date time) { - this.time = time; - } - - public String getVreid() { - return vreid; - } - - public void setVreid(String vreid) { - this.vreid = vreid; - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public PrivacyLevel getPrivacy() { - return privacy; - } - - public void setPrivacy(PrivacyLevel privacy) { - this.privacy = privacy; - } - - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getThumbnailURL() { - return thumbnailURL; - } - - public void setThumbnailURL(String thumbnailURL) { - this.thumbnailURL = thumbnailURL; - } - - public String getCommentsNo() { - return commentsNo; - } - public void setCommentsNo(String commentsNo) { - this.commentsNo = commentsNo; - } - public String getLikesNo() { - return likesNo; - } - public void setLikesNo(String likesNo) { - this.likesNo = likesNo; - } - public String getUriThumbnail() { - return uriThumbnail; - } - public void setUriThumbnail(String uriThumbnail) { - this.uriThumbnail = uriThumbnail; - } - - public String getLinkTitle() { - return linkTitle; - } - public void setLinkTitle(String linkTitle) { - this.linkTitle = linkTitle; - } - public String getLinkDescription() { - return linkDescription; - } - public void setLinkDescription(String linkDescription) { - this.linkDescription = linkDescription; - } - public int compareTo(Feed toCompare) { - if (this.time.after(toCompare.getTime())) - return 1; - if (this.time.before(toCompare.getTime())) - return -1; - return 0; - } - public String getLinkHost() { - return linkHost; - } - public void setLinkHost(String linkHost) { - this.linkHost = linkHost; - } - - public boolean isApplicationFeed() { - return applicationFeed; - } - public void setApplicationFeed(boolean applicationFeed) { - this.applicationFeed = applicationFeed; - } - public boolean isMultiFileUpload() { - return multiFileUpload; - } - public void setMultiFileUpload(boolean multiFileUpload) { - this.multiFileUpload = multiFileUpload; - } - @Override - public String toString() { - return "Feed [key=" + key + ", type=" + type + ", entityId=" + entityId - + ", time=" + time + ", vreid=" + vreid + ", uri=" + uri - + ", uriThumbnail=" + uriThumbnail + ", description=" - + description + ", privacy=" + privacy + ", fullName=" - + fullName + ", email=" + email + ", thumbnailURL=" - + thumbnailURL + ", commentsNo=" + commentsNo + ", likesNo=" - + likesNo + ", linkTitle=" + linkTitle + ", linkDescription=" - + linkDescription + ", linkHost=" + linkHost - + ", applicationFeed=" + applicationFeed - + ", multiFileUpload=" + multiFileUpload + "]"; - } - -} diff --git a/target/classes/org/gcube/portal/databook/shared/FeedType.java b/target/classes/org/gcube/portal/databook/shared/FeedType.java deleted file mode 100644 index 71fe688..0000000 --- a/target/classes/org/gcube/portal/databook/shared/FeedType.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.gcube.portal.databook.shared; - -/** - * @author Massimiliano Assante ISTI-CNR - * @deprecated use PostType - * @version 1.2 October 2012 - */ -public enum FeedType { - JOIN, SHARE, PUBLISH, TWEET, CONNECTED, - /** - * Special case used when accounting - */ - ACCOUNTING, - /** - * Special case used when a Feed is removed - */ - DISABLED; -} - diff --git a/target/classes/org/gcube/portal/databook/shared/ImageType.java b/target/classes/org/gcube/portal/databook/shared/ImageType.java deleted file mode 100644 index 15f2719..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ImageType.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.gcube.portal.databook.shared; - -public enum ImageType { - JPG, GIF, PNG, TIFF, PDF, BMP; -} diff --git a/target/classes/org/gcube/portal/databook/shared/Invite.java b/target/classes/org/gcube/portal/databook/shared/Invite.java deleted file mode 100644 index be1548d..0000000 --- a/target/classes/org/gcube/portal/databook/shared/Invite.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.Date; -/** - * - * @author Massimiliano Assante, ISTI-CNR - * - */ -@SuppressWarnings("serial") -public class Invite implements Serializable { - - private String key; - private String senderUserId; - private String vreid; - private String invitedEmail; - private String controlCode; - private InviteStatus status; - private Date time; - private String senderFullName; - - - public Invite() { - super(); - } - - - - - public Invite(String key, String senderUserId, String vreid, - String invitedEmail, String controlCode, InviteStatus status, - Date time, String senderFullName) { - super(); - this.key = key; - this.senderUserId = senderUserId; - this.vreid = vreid; - this.invitedEmail = invitedEmail; - this.controlCode = controlCode; - this.status = status; - this.time = time; - this.senderFullName = senderFullName; - } - - - - - public String getKey() { - return key; - } - - - - - public void setKey(String key) { - this.key = key; - } - - - - - public String getSenderUserId() { - return senderUserId; - } - - - public void setSenderUserId(String senderUserId) { - this.senderUserId = senderUserId; - } - - - public String getVreid() { - return vreid; - } - - - public void setVreid(String vreid) { - this.vreid = vreid; - } - - - public String getInvitedEmail() { - return invitedEmail; - } - - - public void setInvitedEmail(String invitedEmail) { - this.invitedEmail = invitedEmail; - } - - - public String getControlCode() { - return controlCode; - } - - - public void setControlCode(String controlCode) { - this.controlCode = controlCode; - } - - - public InviteStatus getStatus() { - return status; - } - - - public void setStatus(InviteStatus status) { - this.status = status; - } - - - public Date getTime() { - return time; - } - - - public void setTime(Date time) { - this.time = time; - } - - - public String getSenderFullName() { - return senderFullName; - } - - - public void setSenderFullName(String senderFullName) { - this.senderFullName = senderFullName; - } - - - - - @Override - public String toString() { - return "Invite [key=" + key + ", senderUserId=" + senderUserId - + ", vreid=" + vreid + ", invitedEmail=" + invitedEmail - + ", controlCode=" + controlCode + ", status=" + status - + ", time=" + time + ", senderFullName=" + senderFullName + "]"; - } - - - - -} diff --git a/target/classes/org/gcube/portal/databook/shared/InviteOperationResult.java b/target/classes/org/gcube/portal/databook/shared/InviteOperationResult.java deleted file mode 100644 index da0327f..0000000 --- a/target/classes/org/gcube/portal/databook/shared/InviteOperationResult.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared; - -public enum InviteOperationResult { - SUCCESS, - FAILED, - //If I send an invite the same email in the same environment more than once - ALREADY_INVITED; -} diff --git a/target/classes/org/gcube/portal/databook/shared/InviteStatus.java b/target/classes/org/gcube/portal/databook/shared/InviteStatus.java deleted file mode 100644 index 62df7ea..0000000 --- a/target/classes/org/gcube/portal/databook/shared/InviteStatus.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.gcube.portal.databook.shared; - -public enum InviteStatus { - /** - * First status of anyh invite - */ - PENDING, - /** - * User accepted the invite - */ - ACCEPTED, - /** - * User rejected the invite - */ - REJECTED, - /** - * Manager withdrawed the invite - */ - RETRACTED; -} diff --git a/target/classes/org/gcube/portal/databook/shared/JSON.java b/target/classes/org/gcube/portal/databook/shared/JSON.java deleted file mode 100644 index 7a660f0..0000000 --- a/target/classes/org/gcube/portal/databook/shared/JSON.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.gcube.portal.databook.shared; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType(isNative = true, namespace = JsPackage.GLOBAL) -public class JSON { - public static native String stringify(Object o); - public static native O parse(String json); -} diff --git a/target/classes/org/gcube/portal/databook/shared/JobStatusType.java b/target/classes/org/gcube/portal/databook/shared/JobStatusType.java deleted file mode 100644 index 126aaea..0000000 --- a/target/classes/org/gcube/portal/databook/shared/JobStatusType.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.gcube.portal.databook.shared; -/** - * - * @author Massimiliano Assante, ISTI-CNR - * @version 0.1 Dec 2012 - * - */ -public enum JobStatusType { - /** - * The job has been cancelled. - */ - CANCELLED, - /** - * The job is in the process of being cancelled. - */ - CANCELLING, - /** - * The job has been deleted. - */ - DELETED, - /** - * The job is in the process of being deleted. - */ - DELETING,// - /** - * The job is being executed by job processor. - */ - EXECUTING,// - /** - * he job execution has failed. - */ - FAILED, - /** - * The job is new. - */ - NEW,// - /** - * The job is submitted for execution. - */ - SUBMITTED, - /** - * The job has completed successfully - */ - SUCCEEDED, - /** - * The job execution has timed out. - */ - TIMED_OUT, - /** - * The job is waiting for available job processor. - */ - WAITING -} diff --git a/target/classes/org/gcube/portal/databook/shared/Like.java b/target/classes/org/gcube/portal/databook/shared/Like.java deleted file mode 100644 index d772865..0000000 --- a/target/classes/org/gcube/portal/databook/shared/Like.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.Date; -/** - * - * @author Massimiliano Assante, ISTI-CNR - * @version 0.1 July 2012 - * - */ -@SuppressWarnings("serial") -public class Like implements Serializable { - - private String key; - private String userid; - private Date time; - private String feedid; - private String fullName; - private String thumbnailURL; - - public Like() { - super(); - } - - public Like(String key, String userid, Date time, String feedid, - String fullName, String thumbnailURL) { - super(); - this.key = key; - this.userid = userid; - this.time = time; - this.feedid = feedid; - this.fullName = fullName; - this.thumbnailURL = thumbnailURL; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getUserid() { - return userid; - } - - public void setUserid(String userid) { - this.userid = userid; - } - - public Date getTime() { - return time; - } - - public void setTime(Date time) { - this.time = time; - } - - public String getFeedid() { - return feedid; - } - - public void setFeedid(String feedid) { - this.feedid = feedid; - } - - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public String getThumbnailURL() { - return thumbnailURL; - } - - public void setThumbnailURL(String thumbnailURL) { - this.thumbnailURL = thumbnailURL; - } - - public String toString() { - return "KEY: " + key + " Time: "+ time + "\nuserid: "+userid + " Full name: " + fullName; - - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/Notification.java b/target/classes/org/gcube/portal/databook/shared/Notification.java deleted file mode 100644 index 36ee57d..0000000 --- a/target/classes/org/gcube/portal/databook/shared/Notification.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.Date; - -/** - * - * @author Massimiliano Assante, ISTI-CNR - * - */ -@SuppressWarnings("serial") -public class Notification implements Serializable { - - private String key; - private NotificationType type; - private String userid; - private String subjectid; - private Date time; - private String uri; - private String description; - private boolean read; - private String senderid; - private String senderFullName; - private String senderThumbnail; - private String commentKey; - - - /** - * default constructor - */ - public Notification() { - super(); - } - - - - /** - * - * @param key - * @param type - * @param userid - * @param subjectid the subject id of this notification, if is a like on a feed then is the feedid, it is a message then is the messageid and so on - * @param time - * @param uri - * @param description - * @param read - * @param senderid - * @param senderFullName - * @param senderThumbnail - */ - public Notification(String key, NotificationType type, String userid, - String subjectid, Date time, String uri, String description, - boolean read, String senderid, String senderFullName, - String senderThumbnail) { - super(); - this.key = key; - this.type = type; - this.userid = userid; - this.subjectid = subjectid; - this.time = time; - this.uri = uri; - this.description = description; - this.read = read; - this.senderid = senderid; - this.senderFullName = senderFullName; - this.senderThumbnail = senderThumbnail; - } - - /** - * - * @param key - * @param type - * @param userid - * @param subjectid the subject id of this notification, if is a like on a feed then is the feedid, it is a message then is the messageid and so on - * @param time - * @param uri - * @param description - * @param read - * @param senderid - * @param senderFullName - * @param senderThumbnail - * @param commentKey when a mail notification must be sent, stop the embedded discussion at this comment - */ - public Notification(String key, NotificationType type, String userid, - String subjectid, Date time, String uri, String description, - boolean read, String senderid, String senderFullName, - String senderThumbnail, String commentKey) { - super(); - this.key = key; - this.type = type; - this.userid = userid; - this.subjectid = subjectid; - this.time = time; - this.uri = uri; - this.description = description; - this.read = read; - this.senderid = senderid; - this.senderFullName = senderFullName; - this.senderThumbnail = senderThumbnail; - this.commentKey = commentKey; - } - - /** - * - * @return . - */ - public String getKey() { - return key; - } - public void setKey(String key) { - this.key = key; - } - public NotificationType getType() { - return type; - } - public void setType(NotificationType type) { - this.type = type; - } - public String getUserid() { - return userid; - } - public void setUserid(String userid) { - this.userid = userid; - } - public Date getTime() { - return time; - } - public void setTime(Date time) { - this.time = time; - } - public String getUri() { - return uri; - } - public void setUri(String uri) { - this.uri = uri; - } - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - public boolean isRead() { - return read; - } - public void setRead(boolean read) { - this.read = read; - } - public String getSenderid() { - return senderid; - } - public void setSenderid(String senderid) { - this.senderid = senderid; - } - public String getSenderFullName() { - return senderFullName; - } - public void setSenderFullName(String senderFullName) { - this.senderFullName = senderFullName; - } - public String getSenderThumbnail() { - return senderThumbnail; - } - public void setSenderThumbnail(String senderThumbnail) { - this.senderThumbnail = senderThumbnail; - } - public String getSubjectid() { - return subjectid; - } - public void setSubjectid(String subjectid) { - this.subjectid = subjectid; - } - - public String getCommentKey() { - return commentKey; - } - - - - public void setCommentKey(String commentKey) { - this.commentKey = commentKey; - } - - @Override - public String toString() { - return "Notification [key=" + key + ", type=" + type + ", userid=" - + userid + ", subjectid=" + subjectid + ", time=" + time - + ", uri=" + uri + ", description=" + description + ", read=" - + read + ", senderid=" + senderid + ", senderFullName=" - + senderFullName + ", senderThumbnail=" + senderThumbnail - + ", commentKey=" + commentKey + "]"; - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/NotificationChannelType.java b/target/classes/org/gcube/portal/databook/shared/NotificationChannelType.java deleted file mode 100644 index d66a0ed..0000000 --- a/target/classes/org/gcube/portal/databook/shared/NotificationChannelType.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.gcube.portal.databook.shared; -/** - * @author Massimiliano Assante ISTI-CNR - * - * @version 1.0 January 2012 - */ -public enum NotificationChannelType { - /** - * PORTAL - */ - PORTAL, - /** - * EMAIL - */ - EMAIL, - /** - * TWITTER - */ - TWITTER; -} diff --git a/target/classes/org/gcube/portal/databook/shared/NotificationType.java b/target/classes/org/gcube/portal/databook/shared/NotificationType.java deleted file mode 100644 index 36ddfa9..0000000 --- a/target/classes/org/gcube/portal/databook/shared/NotificationType.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.gcube.portal.databook.shared; - - - -/** - * @author Massimiliano Assante ISTI-CNR - * - * TODO: Buggy if NotificationType for WP_* are refactored see DBCassandraAstyanaxImpl#getUserNotificationPreferences(String userid) - * introduced due to urgent matters - */ -public enum NotificationType { - /** - * use to notify a user he got a Tabular Resource shared - */ - TDM_TAB_RESOURCE_SHARE, - /** - * use to notify a user he got a TDM Rule shared - */ - TDM_RULE_SHARE, - /** - * use to notify a user he got a TDM Templated shared - */ - TDM_TEMPLATE_SHARE, - /** - * use to notify a user he got a workspace folder shared - */ - WP_FOLDER_SHARE, - /** - * use to notify a user that a user in the share unshared - */ - WP_FOLDER_UNSHARE, - /** - * use to notify a user that he got upgraded to administrator of a shared folder - */ - WP_ADMIN_UPGRADE, - /** - * use to notify a user that he got downgraded from administrator of a shared folder - */ - WP_ADMIN_DOWNGRADE, - /** - * use to notify a user that a new user was added in on of his workspace shared folder - */ - WP_FOLDER_ADDEDUSER, - /** - * use to notify a user that an existing user was removed from one of his workspace shared folder - */ - WP_FOLDER_REMOVEDUSER, - /** - * use to notify a user he got a workspace folder renamed - */ - WP_FOLDER_RENAMED, - /** - * use to notify a user he got a workspace item deleted from one of his workspace shared folder - */ - WP_ITEM_DELETE, - /** - * use to notify a user he got a workspace item updated from one of his workspace shared folder - */ - WP_ITEM_UPDATED, - /** - * use to notify a user he got a workspace item renamed from one of his workspace shared folder - */ - WP_ITEM_RENAMED, - /** - * use to notify a user he got a workspace item new in some of his workspace shared folder - */ - WP_ITEM_NEW, - /** - * use to notify a user he got one of his feed commented - */ - OWN_COMMENT, - /** - * use to notify a user that commented on a feed (Not his) that someone commented too - */ - COMMENT, - /** - * use to notify a user that he got mentioned in one post - */ - MENTION, - /** - * use to notify a user he got one of his feed liked - */ - LIKE, - /** - * use to notify a user he got a message - */ - MESSAGE, - /** - * use to notify every user of a VRE/Group that the post was made - */ - POST_ALERT, - /** - * use to notify a user that someone in his VRE created a new Event in the Calendar - */ - CALENDAR_ADDED_EVENT, - /** - * use to notify a user that someone in his VRE updated an Event in the Calendar - */ - CALENDAR_UPDATED_EVENT, - /** - * use to notify a user that someone in his VRE deleted an Event in the Calendar - */ - CALENDAR_DELETED_EVENT, - /** - * use to notify a user he got a connections request - */ - REQUEST_CONNECTION, - /** - * use to notify a user he got a job completed ok - */ - JOB_COMPLETED_OK, - /** - * use to notify a user he got a job completed not ok - */ - JOB_COMPLETED_NOK, - /** - * use to notify a document workflow owner that someone - * has edited a document involved in a worflow he created - */ - @Deprecated - DOCUMENT_WORKFLOW_EDIT, - /** - * use to notify a document workflow owner that someone - * has viewed a document involved in a worflow he created - */ - @Deprecated - DOCUMENT_WORKFLOW_VIEW, - /** - * use to notify a document workflow user (user that in the same document workflow) - * that forwarded to a step where he is requested to do a task - */ - @Deprecated - DOCUMENT_WORKFLOW_STEP_REQUEST_TASK, - /** - * use to notify a document workflow user that he was involved into a new Document Workflow - * and he is requested to do a task - */ - @Deprecated - DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT, - /** - * use to notify a document workflow owner that a user performed a forward action to another step a document worflow he created - */ - @Deprecated - DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER, - /** - * use to notify a document workflow owner that someone - * forwarded and the workflow moved to another step a document worflow he created - */ - @Deprecated - DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER, - /** - * use to notify a document workflow peer (user that in the same step has your same role) - * that someone performed a forward action to another step in a document worflow he is involved into - */ - @Deprecated - DOCUMENT_WORKFLOW_STEP_FORWARD_PEER, - /** - * catalogue, use to notify someone submits an item for consideration - */ - CAT_ITEM_SUBMITTED, - /** - * catalogue, use to notify someone rejected a submitted item - */ - CAT_ITEM_REJECTED, - /** - * catalogue, use to notify someone published an item - */ - CAT_ITEM_PUBLISHED, - /** - * catalogue, use to notify someone updated an item - */ - CAT_ITEM_UPDATED, - /** - * catalogue, use to notify someone removed an item - */ - CAT_ITEM_DELETE, - /** - * generic notification - */ - GENERIC; -} diff --git a/target/classes/org/gcube/portal/databook/shared/Post.java b/target/classes/org/gcube/portal/databook/shared/Post.java deleted file mode 100644 index 517d1ff..0000000 --- a/target/classes/org/gcube/portal/databook/shared/Post.java +++ /dev/null @@ -1,322 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.Date; - -/** - * - * @author Massimiliano Assante, ISTI-CNR - * - */ -@SuppressWarnings("serial") -public class Post implements Serializable, Comparable { - - private String key; - private PostType type; - private String entityId; - private Date time; - private String vreid; - private String uri; - private String uriThumbnail; - private String description; - private PrivacyLevel privacy; - private String fullName; - private String email; - private String thumbnailURL; - private String commentsNo; - private String likesNo; - private String linkTitle; - private String linkDescription; - private String linkHost; - boolean applicationFeed; - /** - * this boolean indicates that the attachments to the post are > 1 - */ - boolean multiFileUpload; - /** - * default constructor - */ - public Post() { - super(); - } - /** - * To use ONLY for USER Feeds - * - * - * @param key a UUID - * @param type an instance of PostType - * @param entityId the user or the app unique indentifier - * @param time when - * @param vreid a unique vre id - * @param uri optional uri - * @param uriThumbnail the thumbnail for the link posted - * @param description optional description - * @param privacy the privacy level of PrivacyLevel - * @param fullName - * @param email - * @param thumbnailURL this is the user thumbnail url - * @param linkTitle optional to be used when posting links - * @param linkDescription optional to be used when posting links - * @param linkHost option to be used when posting linkgs - */ - public Post(String key, PostType type, String entityId, Date time, - String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy, - String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost) { - this.key = key; - this.type = type; - this.entityId = entityId; - this.time = time; - this.vreid = vreid; - this.uri = uri; - this.uriThumbnail = uriThumbnail; - this.description = description; - this.privacy = privacy; - this.fullName = fullName; - this.email = email; - this.thumbnailURL = thumbnailURL; - this.commentsNo = "0"; - this.likesNo = "0"; - this.linkDescription = linkDescription; - this.linkTitle = linkTitle; - this.linkHost = linkHost; - this.applicationFeed = false; - } - /** - * To use for USER and ApplicationProfile Feeds - * - * @param key a UUID - * @param type an instance of FeedType - * @param entityId the user or the app unique indentifier - * @param time when - * @param vreid a unique vre id - * @param uri optional uri - * @param uriThumbnail the thumbnail for the link posted - * @param description optional description - * @param privacy the privacy level of PrivacyLevel - * @param fullName - * @param email - * @param thumbnailURL this is the user thumbnail url - * @param linkTitle optional to be used when posting links - * @param linkDescription optional to be used when posting links - * @param applicationFeed tell if this is an application feed or a user feed - */ - public Post(String key, PostType type, String entityId, Date time, - String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy, - String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed) { - this(key, type, entityId, time, vreid, uri, uriThumbnail, description, privacy, fullName, email, thumbnailURL, linkTitle, linkDescription, linkHost); - this.applicationFeed = applicationFeed; - } - - - /** - * for serialization purposes - * @param key a UUID - * @param type an instance of PostType - * @param entityId the user or the app unique indentifier - * @param time when - * @param vreid a unique vre id - * @param uri optional uri - * @param uriThumbnail the thumbnail for the link posted - * @param description optional description - * @param privacy the privacy level of PrivacyLevel - * @param fullName - * @param email - * @param thumbnailURL this is the user thumbnail url - * @param linkTitle optional to be used when posting links - * @param linkDescription optional to be used when posting links - */ - public Post(String key, PostType type, String entityId, Date time, - String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy, - String fullName, String email, String thumbnailURL, String commentsNo, - String likesNo, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed, boolean multiFileUpload) { - super(); - this.key = key; - this.type = type; - this.entityId = entityId; - this.time = time; - this.vreid = vreid; - this.uri = uri; - this.uriThumbnail = uriThumbnail; - this.description = description; - this.privacy = privacy; - this.fullName = fullName; - this.email = email; - this.thumbnailURL = thumbnailURL; - this.commentsNo = commentsNo; - this.likesNo = likesNo; - this.linkDescription = linkDescription; - this.linkTitle = linkTitle; - this.linkHost = linkHost; - this.applicationFeed = applicationFeed; - this.multiFileUpload = multiFileUpload; - } - /** - * - * @return post id - */ - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public PostType getType() { - return type; - } - - public void setType(PostType type) { - this.type = type; - } - /** - * - * @return the User or the App id - */ - public String getEntityId() { - return entityId; - } - /** - * set the User or the App id - * @param entityId the UserId or the AppId id - */ - public void setEntityId(String entityId) { - this.entityId = entityId; - } - - public Date getTime() { - return time; - } - - public void setTime(Date time) { - this.time = time; - } - - public String getVreid() { - return vreid; - } - - public void setVreid(String vreid) { - this.vreid = vreid; - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public PrivacyLevel getPrivacy() { - return privacy; - } - - public void setPrivacy(PrivacyLevel privacy) { - this.privacy = privacy; - } - - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getThumbnailURL() { - return thumbnailURL; - } - - public void setThumbnailURL(String thumbnailURL) { - this.thumbnailURL = thumbnailURL; - } - - public String getCommentsNo() { - return commentsNo; - } - public void setCommentsNo(String commentsNo) { - this.commentsNo = commentsNo; - } - public String getLikesNo() { - return likesNo; - } - public void setLikesNo(String likesNo) { - this.likesNo = likesNo; - } - public String getUriThumbnail() { - return uriThumbnail; - } - public void setUriThumbnail(String uriThumbnail) { - this.uriThumbnail = uriThumbnail; - } - - public String getLinkTitle() { - return linkTitle; - } - public void setLinkTitle(String linkTitle) { - this.linkTitle = linkTitle; - } - public String getLinkDescription() { - return linkDescription; - } - public void setLinkDescription(String linkDescription) { - this.linkDescription = linkDescription; - } - public int compareTo(Post toCompare) { - if (this.time.after(toCompare.getTime())) - return 1; - if (this.time.before(toCompare.getTime())) - return -1; - return 0; - } - public String getLinkHost() { - return linkHost; - } - public void setLinkHost(String linkHost) { - this.linkHost = linkHost; - } - - public boolean isApplicationFeed() { - return applicationFeed; - } - public void setApplicationFeed(boolean applicationFeed) { - this.applicationFeed = applicationFeed; - } - public boolean isMultiFileUpload() { - return multiFileUpload; - } - public void setMultiFileUpload(boolean multiFileUpload) { - this.multiFileUpload = multiFileUpload; - } - @Override - public String toString() { - return "Post [key=" + key + ", type=" + type + ", entityId=" + entityId - + ", time=" + time + ", vreid=" + vreid + ", uri=" + uri - + ", uriThumbnail=" + uriThumbnail + ", description=" - + description + ", privacy=" + privacy + ", fullName=" - + fullName + ", email=" + email + ", thumbnailURL=" - + thumbnailURL + ", commentsNo=" + commentsNo + ", likesNo=" - + likesNo + ", linkTitle=" + linkTitle + ", linkDescription=" - + linkDescription + ", linkHost=" + linkHost - + ", applicationFeed=" + applicationFeed - + ", multiFileUpload=" + multiFileUpload + "]"; - } - -} diff --git a/target/classes/org/gcube/portal/databook/shared/PostType.java b/target/classes/org/gcube/portal/databook/shared/PostType.java deleted file mode 100644 index b86c0c7..0000000 --- a/target/classes/org/gcube/portal/databook/shared/PostType.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.gcube.portal.databook.shared; - -/** - * @author Massimiliano Assante ISTI-CNR - * - */ -public enum PostType { - JOIN, SHARE, PUBLISH, TWEET, CONNECTED, - /** - * Special case used when accounting - */ - ACCOUNTING, - /** - * Special case used when a Feed is removed - */ - DISABLED; -} - diff --git a/target/classes/org/gcube/portal/databook/shared/PrivacyLevel.java b/target/classes/org/gcube/portal/databook/shared/PrivacyLevel.java deleted file mode 100644 index 9f21298..0000000 --- a/target/classes/org/gcube/portal/databook/shared/PrivacyLevel.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.gcube.portal.databook.shared; -/** - * @author Massimiliano Assante ISTI-CNR - * - * @version 1.0 July 6th 2012 - */ -public enum PrivacyLevel { - PRIVATE, CONNECTION, VRES, SINGLE_VRE, PORTAL, PUBLIC; -} diff --git a/target/classes/org/gcube/portal/databook/shared/RangeFeeds.java b/target/classes/org/gcube/portal/databook/shared/RangeFeeds.java deleted file mode 100644 index 50d90bb..0000000 --- a/target/classes/org/gcube/portal/databook/shared/RangeFeeds.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.ArrayList; -/** - * - * @author Massimiliano Assante, ISTI-CNR - * @deprecated use RangePosts - */ -@SuppressWarnings("serial") -public class RangeFeeds implements Serializable { - - private int lastReturnedFeedTimelineIndex; - private ArrayList feeds; - - public RangeFeeds() { - super(); - } - - public RangeFeeds(int lastReturnedFeedTimelineIndex, ArrayList feeds) { - super(); - this.lastReturnedFeedTimelineIndex = lastReturnedFeedTimelineIndex; - this.feeds = feeds; - } - - public int getLastReturnedFeedTimelineIndex() { - return lastReturnedFeedTimelineIndex; - } - public void setLastReturnedFeedTimelineIndex(int lastReturnedFeedTimelineIndex) { - this.lastReturnedFeedTimelineIndex = lastReturnedFeedTimelineIndex; - } - public ArrayList getFeeds() { - return feeds; - } - public void setFeeds(ArrayList feeds) { - this.feeds = feeds; - } - - -} diff --git a/target/classes/org/gcube/portal/databook/shared/RangePosts.java b/target/classes/org/gcube/portal/databook/shared/RangePosts.java deleted file mode 100644 index 4e645b5..0000000 --- a/target/classes/org/gcube/portal/databook/shared/RangePosts.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.ArrayList; -/** - * - * @author Massimiliano Assante, ISTI-CNR - * - */ -@SuppressWarnings("serial") -public class RangePosts implements Serializable { - - private int lastReturnedPostTimelineIndex; - private ArrayList posts; - - public RangePosts() { - super(); - } - - public RangePosts(int lastReturnedPostTimelineIndex, ArrayList feeds) { - super(); - this.lastReturnedPostTimelineIndex = lastReturnedPostTimelineIndex; - this.posts = feeds; - } - - public int getLastReturnedPostTimelineIndex() { - return lastReturnedPostTimelineIndex; - } - public void setLastReturnedPostTimelineIndex(int lastReturnedPostTimelineIndex) { - this.lastReturnedPostTimelineIndex = lastReturnedPostTimelineIndex; - } - public ArrayList getPosts() { - return posts; - } - public void setPosts(ArrayList posts) { - this.posts = posts; - } - - -} diff --git a/target/classes/org/gcube/portal/databook/shared/RunningJob.java b/target/classes/org/gcube/portal/databook/shared/RunningJob.java deleted file mode 100644 index a69cd74..0000000 --- a/target/classes/org/gcube/portal/databook/shared/RunningJob.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; - -/** - * The RunningJob class. - * @author Massimiliano Assante, ISTI-CNR (massimiliano.assante@isti.cnr.it) - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) - */ -@SuppressWarnings("serial") -public class RunningJob implements Serializable { - - private String jobId; - private String jobName; - private JobStatusType status; - private String message; - private String serviceName; // i.e., Dataminer, SmartExecutor.. - - public RunningJob() { - super(); - } - - /** Buind a RunningJob object. - * @param jobId - * @param jobName - * @param status - * @param message - * @param serviceName - */ - public RunningJob(String jobId, String jobName, JobStatusType status, - String message, String serviceName) { - super(); - this.jobId = jobId; - this.jobName = jobName; - this.status = status; - this.message = message; - this.serviceName = serviceName; - } - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getJobId() { - return jobId; - } - public void setJobId(String jobId) { - this.jobId = jobId; - } - public String getJobName() { - return jobName; - } - public void setJobName(String jobName) { - this.jobName = jobName; - } - public JobStatusType getStatus() { - return status; - } - public void setStatus(JobStatusType status) { - this.status = status; - } - - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - @Override - public String toString() { - return "RunningJob [" + (jobId != null ? "jobId=" + jobId + ", " : "") - + (jobName != null ? "jobName=" + jobName + ", " : "") - + (status != null ? "status=" + status + ", " : "") - + (message != null ? "message=" + message + ", " : "") - + (serviceName != null ? "serviceName=" + serviceName : "") - + "]"; - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/ShowUserStatisticAction.java b/target/classes/org/gcube/portal/databook/shared/ShowUserStatisticAction.java deleted file mode 100644 index 25278f6..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ShowUserStatisticAction.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.gcube.portal.databook.shared; - -/** - * Enum class that specify the possible actions to take when the GCubeSocialNetworking.SHOW_STATISTICS_ACTION_OID parameter - * is found in the page url - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) - */ -public enum ShowUserStatisticAction { - - POSTS_MADE_BY_USER("Your recent posts"), - LIKES_MADE_BY_USER("Posts you liked"), - COMMENTS_MADE_BY_USER("Posts you commented"), - LIKES_GOT_BY_USER("Likes to your posts"), - COMMENTS_GOT_BY_USER("Replies to your posts"); - - private final String actionHumanFriendly; - - private ShowUserStatisticAction(String s) { - actionHumanFriendly = s; - } - - public String getHumanFriendlyAction() { - return this.actionHumanFriendly; - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/UserInfo.java b/target/classes/org/gcube/portal/databook/shared/UserInfo.java deleted file mode 100644 index 74f9c2a..0000000 --- a/target/classes/org/gcube/portal/databook/shared/UserInfo.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.gcube.portal.databook.shared; - -import java.io.Serializable; -import java.util.HashMap; - -/** - * @author Massimiliano Assante ISTI-CNR - */ -@SuppressWarnings("serial") -public class UserInfo implements Serializable { - - public transient final static String USER_INFO_ATTR = "USER_INFO_ATTR"; - - private String username; - - private String fullName; - - private String avatarId; - - private String emailaddress; - - private String accountURL; - - private boolean male; - - private boolean admin; - - private HashMap ownVREs; - - public UserInfo() { - super(); - } - - public UserInfo(String username, String fullName, String avatarId, - String emailaddress, String accountURL, boolean male, - boolean admin, HashMap ownVREs) { - super(); - this.username = username; - this.fullName = fullName; - this.avatarId = avatarId; - this.emailaddress = emailaddress; - this.accountURL = accountURL; - this.male = male; - this.admin = admin; - this.ownVREs = ownVREs; - } - - public String getAccountURL() { - return accountURL; - } - - public void setAccountURL(String accountURL) { - this.accountURL = accountURL; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public String getAvatarId() { - return avatarId; - } - - public void setAvatarId(String avatarId) { - this.avatarId = avatarId; - } - - public String getEmailaddress() { - return emailaddress; - } - - public void setEmailaddress(String emailaddress) { - this.emailaddress = emailaddress; - } - - public boolean isMale() { - return male; - } - - public void setMale(boolean male) { - this.male = male; - } - - public HashMap getOwnVREs() { - return ownVREs; - } - - public void setOwnVREs(HashMap vreMap) { - this.ownVREs = vreMap; - } - - public boolean isAdmin() { - return admin; - } - - public void setAdmin(boolean admin) { - this.admin = admin; - } - - @Override - public String toString() { - return "UserInfo [username=" + username + ", fullName=" + fullName - + ", avatarId=" + avatarId + ", emailaddress=" + emailaddress - + ", accountURL=" + accountURL + ", male=" + male + ", admin=" - + admin + ", ownVREs=" + ownVREs + "]"; - } - - -} diff --git a/target/classes/org/gcube/portal/databook/shared/ex/ColumnNameNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/ColumnNameNotFoundException.java deleted file mode 100644 index 536e6a6..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/ColumnNameNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class ColumnNameNotFoundException extends Exception { - public ColumnNameNotFoundException(String message) { - super(message); - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/ex/CommentIDNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/CommentIDNotFoundException.java deleted file mode 100644 index 605d8f7..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/CommentIDNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class CommentIDNotFoundException extends Exception { - public CommentIDNotFoundException(String message) { - super(message); - } -} \ No newline at end of file diff --git a/target/classes/org/gcube/portal/databook/shared/ex/FeedIDNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/FeedIDNotFoundException.java deleted file mode 100644 index 52c2dce..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/FeedIDNotFoundException.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - - -@SuppressWarnings("serial") -public class FeedIDNotFoundException extends Exception { - public FeedIDNotFoundException(String message, String postId) { - super("The Post having id: " + postId + " is not present in the database: " + message); - } -} \ No newline at end of file diff --git a/target/classes/org/gcube/portal/databook/shared/ex/FeedTypeNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/FeedTypeNotFoundException.java deleted file mode 100644 index a39d6dc..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/FeedTypeNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class FeedTypeNotFoundException extends Exception { - public FeedTypeNotFoundException(String message) { - super(message); - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/ex/InviteIDNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/InviteIDNotFoundException.java deleted file mode 100644 index a7d5cb0..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/InviteIDNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class InviteIDNotFoundException extends Exception { - public InviteIDNotFoundException(String message) { - super(message); - } -} \ No newline at end of file diff --git a/target/classes/org/gcube/portal/databook/shared/ex/InviteStatusNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/InviteStatusNotFoundException.java deleted file mode 100644 index 5f4f9c2..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/InviteStatusNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class InviteStatusNotFoundException extends Exception { - public InviteStatusNotFoundException(String message) { - super(message); - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/ex/LikeIDNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/LikeIDNotFoundException.java deleted file mode 100644 index f0fe653..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/LikeIDNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class LikeIDNotFoundException extends Exception { - public LikeIDNotFoundException(String message) { - super(message); - } -} \ No newline at end of file diff --git a/target/classes/org/gcube/portal/databook/shared/ex/NotificationChannelTypeNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/NotificationChannelTypeNotFoundException.java deleted file mode 100644 index e70f779..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/NotificationChannelTypeNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class NotificationChannelTypeNotFoundException extends Exception { - public NotificationChannelTypeNotFoundException(String message) { - super(message); - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/ex/NotificationIDNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/NotificationIDNotFoundException.java deleted file mode 100644 index 13c0ebb..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/NotificationIDNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class NotificationIDNotFoundException extends Exception { - public NotificationIDNotFoundException(String message) { - super(message); - } -} \ No newline at end of file diff --git a/target/classes/org/gcube/portal/databook/shared/ex/NotificationTypeNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/NotificationTypeNotFoundException.java deleted file mode 100644 index a4700e4..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/NotificationTypeNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class NotificationTypeNotFoundException extends Exception { - public NotificationTypeNotFoundException(String message) { - super(message); - } -} diff --git a/target/classes/org/gcube/portal/databook/shared/ex/PrivacyLevelTypeNotFoundException.java b/target/classes/org/gcube/portal/databook/shared/ex/PrivacyLevelTypeNotFoundException.java deleted file mode 100644 index 10fc82b..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/PrivacyLevelTypeNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class PrivacyLevelTypeNotFoundException extends Exception { - public PrivacyLevelTypeNotFoundException(String message) { - super(message); - } -} \ No newline at end of file diff --git a/target/classes/org/gcube/portal/databook/shared/ex/TooManyRunningClustersException.java b/target/classes/org/gcube/portal/databook/shared/ex/TooManyRunningClustersException.java deleted file mode 100644 index 7afbe1d..0000000 --- a/target/classes/org/gcube/portal/databook/shared/ex/TooManyRunningClustersException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.gcube.portal.databook.shared.ex; - -@SuppressWarnings("serial") -public class TooManyRunningClustersException extends Exception { - public TooManyRunningClustersException(String message) { - super(message); - } -} \ No newline at end of file