social-networking-library/src/main/java/org/gcube/portal/databook/server/DatabookStore.java

278 lines
12 KiB
Java

package org.gcube.portal.databook.server;
import java.util.List;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
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.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.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
*
* @version 0.5 Oct 5th 2012
* <class>DatabookStore</class> 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<String> 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<String> getPendingFriendRequests(String userid);
/**
* save a Feed instance in the store
* @return true if everything went fine
*/
boolean saveUserFeed(Feed feed);
/**
* delete a Feed from the store
* @throws FeedIDNotFoundException
* @return true if everything went fine
*/
boolean deleteFeed(String feedid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException;
/**
* save a Feed in the VRES TimeLine in the store
* @param feedKey feedKey
* @param vreid vre identifier
* @return
* @throws FeedIDNotFoundException
*/
boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException;
/**
* save a Feed instance in the store
* @return true if everything went fine
*/
boolean saveAppFeed(Feed feed);
/**
* read a feed from a given id
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
Feed readFeed(String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @param userid user identifier
* return all the feeds belonging to the userid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @param appid application identifier
* return all the feeds belonging to the appid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* return all the feeds whose Level is PORTAL
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
* @throws PrivacyLevelTypeNotFoundException
*/
List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException;
/**
* 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 <class>List</class> of most recent feeds for this user
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* @param vreid vre identifier
* return all the feeds belonging to the userid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* 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 <class>List</class> of most recent feeds for this vre
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* 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 -limit- notifications
* return all the notifications belonging to the userid up to limit, set 0 to get everything
* @throws NotificationTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Notification> getAllNotificationByUser(String userid, int limit) 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 <class>List</class> of not yet read notifications for this user
* @throws NotificationTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Notification> getUnreadNotificationsByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
/**
* return the not yet read notification messages
* @param userid user identifier
* @return a <class>List</class> of not yet read notifications for this user
* @throws NotificationTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Notification> getUnreadNotificationMessagesByUser(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
* @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
* @param userid user identifier
* @return a list of <class>NotificationChannelType</class> that represents the channels this user wants to be notified
*/
List<NotificationChannelType> getUserNotificationChannels(String userid) throws NotificationChannelTypeNotFoundException;
/**
* enable or disable the channels to be used for notifying the user
* @param userid user identifier
* @param channel the type of the channel
* @param enabled is you want it to be enabled or not
* @return true if everything was fine
*/
boolean setUserNotificationChannel(String userid, NotificationChannelType channel, boolean enabled);
/**
* add a comment to a feed
* @param comment the Comment instance to add
*/
boolean addComment(Comment comment) throws FeedIDNotFoundException;
/**
* @param feedid feed identifier
* return all the comments belonging to the feedid
*/
List<Comment> getAllCommentByFeed(String feedid);
/**
* edit a comment
* @param commentid the comment identifier to edit
* @return true if success, false otherwise
*/
boolean editComment(Comment comment) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
/**
* delete a comment
* @param commentid the comment identifier to delete
* @parma feedid the feedid to shich 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 the like instance
* @throws FeedIDNotFoundException
*/
boolean like(Like like) throws FeedIDNotFoundException;
/**
* unlike a feed
* @param likeid the like identifier to delete
* @parma feedid the feedid to shich the comment is associated
* @return true if success, false otherwise
*/
boolean unlike(String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
/**
* @param userid user identifier
* return all the feedids a user has liked
*/
List<String> getAllLikedFeedIdsByUser(String userid);
/**
* @param feedid feed identifier
* return all the likes belonging to the feedid
*/
List<Like> getAllLikesByFeed(String feedid);
/**
* close the connection to the underlying database
*/
void closeConnection();
}