Compatible with social model 2.0.0
This commit is contained in:
parent
f769c3d1ce
commit
c3f9453653
|
@ -10,6 +10,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
|
|
||||||
- Removed HomeLibrary Dependency
|
- Removed HomeLibrary Dependency
|
||||||
|
|
||||||
|
- Feature #26536 Removed social networking library dependency
|
||||||
|
|
||||||
## [v2.4.0] - 2019-12-30
|
## [v2.4.0] - 2019-12-30
|
||||||
|
|
||||||
- Ported to git
|
- Ported to git
|
||||||
|
|
17
pom.xml
17
pom.xml
|
@ -66,6 +66,18 @@
|
||||||
<artifactId>aslcore</artifactId>
|
<artifactId>aslcore</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--needs to be provided -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.social-networking</groupId>
|
||||||
|
<artifactId>social-service-model</artifactId>
|
||||||
|
<version>[1.2.0-SNAPSHOT, 2.0.0)</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.social-networking</groupId>
|
||||||
|
<artifactId>social-service-client</artifactId>
|
||||||
|
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||||
<artifactId>aslsocial</artifactId>
|
<artifactId>aslsocial</artifactId>
|
||||||
|
@ -75,11 +87,6 @@
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-library</artifactId>
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.portal</groupId>
|
|
||||||
<artifactId>social-networking-library</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
|
|
@ -22,12 +22,11 @@ import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
|
||||||
import org.gcube.portal.databook.server.DatabookStore;
|
|
||||||
import org.gcube.portal.socialmail.EmailPopAccount;
|
import org.gcube.portal.socialmail.EmailPopAccount;
|
||||||
import org.gcube.portal.socialmail.PeriodicTask;
|
import org.gcube.portal.socialmail.PeriodicTask;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
|
import org.gcube.social_networking.social_networking_client_library.LibClient;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys;
|
import org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys;
|
||||||
|
@ -51,10 +50,14 @@ public class PortalSchedulerService extends HttpServlet {
|
||||||
private static final String POP3_SERVER_NAME = "Pop3MailServer";
|
private static final String POP3_SERVER_NAME = "Pop3MailServer";
|
||||||
|
|
||||||
|
|
||||||
private static DatabookStore store;
|
private static LibClient libClient;
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
store = new DBCassandraAstyanaxImpl();
|
try {
|
||||||
|
libClient = new LibClient();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +77,7 @@ public class PortalSchedulerService extends HttpServlet {
|
||||||
int pollingInterval = getPollingInterval();
|
int pollingInterval = getPollingInterval();
|
||||||
|
|
||||||
ScheduledExecutorService pop3Scheduler = Executors.newScheduledThreadPool(1);
|
ScheduledExecutorService pop3Scheduler = Executors.newScheduledThreadPool(1);
|
||||||
pop3Scheduler.scheduleAtFixedRate(new PeriodicTask(store, popAccount, request), 0, pollingInterval, TimeUnit.MINUTES);
|
pop3Scheduler.scheduleAtFixedRate(new PeriodicTask(libClient, popAccount, request), 0, pollingInterval, TimeUnit.MINUTES);
|
||||||
String portalName = "unknown";
|
String portalName = "unknown";
|
||||||
try {
|
try {
|
||||||
popAccount.getPortalName() ;
|
popAccount.getPortalName() ;
|
||||||
|
|
|
@ -42,18 +42,18 @@ import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
import org.gcube.common.storagehub.client.proxies.MessageManagerClient;
|
import org.gcube.common.storagehub.client.proxies.MessageManagerClient;
|
||||||
import org.gcube.common.storagehub.model.exceptions.IdNotFoundException;
|
import org.gcube.common.storagehub.model.exceptions.IdNotFoundException;
|
||||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
import org.gcube.portal.databook.server.DatabookStore;
|
import org.gcube.social_networking.socialnetworking.model.shared.Comment;
|
||||||
import org.gcube.portal.databook.shared.Comment;
|
import org.gcube.social_networking.socialnetworking.model.shared.Post;
|
||||||
import org.gcube.portal.databook.shared.Feed;
|
import org.gcube.social_networking.socialnetworking.model.shared.Like;
|
||||||
import org.gcube.portal.databook.shared.Like;
|
import org.gcube.social_networking.socialnetworking.model.shared.exceptions.ColumnNameNotFoundException;
|
||||||
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
|
import org.gcube.social_networking.socialnetworking.model.shared.exceptions.PostIDNotFoundException;
|
||||||
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
|
import org.gcube.social_networking.socialnetworking.model.shared.exceptions.PostTypeNotFoundException;
|
||||||
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
|
import org.gcube.social_networking.socialnetworking.model.shared.exceptions.PrivacyLevelTypeNotFoundException;
|
||||||
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
|
|
||||||
import org.gcube.portal.notifications.bean.GenericItemBean;
|
import org.gcube.portal.notifications.bean.GenericItemBean;
|
||||||
import org.gcube.portal.notifications.thread.CommentNotificationsThread;
|
import org.gcube.portal.notifications.thread.CommentNotificationsThread;
|
||||||
import org.gcube.portal.notifications.thread.LikeNotificationsThread;
|
import org.gcube.portal.notifications.thread.LikeNotificationsThread;
|
||||||
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
|
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
|
||||||
|
import org.gcube.social_networking.social_networking_client_library.LibClient;
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
@ -71,13 +71,13 @@ public class PeriodicTask implements Runnable {
|
||||||
private static final Log _log = LogFactoryUtil.getLog(PeriodicTask.class);
|
private static final Log _log = LogFactoryUtil.getLog(PeriodicTask.class);
|
||||||
private static final String APP_ID_NEWSFEED = "org.gcube.portlets.user.newsfeed.server.NewsServiceImpl";
|
private static final String APP_ID_NEWSFEED = "org.gcube.portlets.user.newsfeed.server.NewsServiceImpl";
|
||||||
|
|
||||||
private DatabookStore socialStore;
|
private LibClient libClient;
|
||||||
private EmailPopAccount popAccount;
|
private EmailPopAccount popAccount;
|
||||||
private SocialNetworkingSite site;
|
private SocialNetworkingSite site;
|
||||||
|
|
||||||
public PeriodicTask(DatabookStore store, EmailPopAccount popAccount, HttpServletRequest request) {
|
public PeriodicTask(LibClient libClient, EmailPopAccount popAccount, HttpServletRequest request) {
|
||||||
super();
|
super();
|
||||||
this.socialStore = store;
|
this.libClient = libClient;
|
||||||
this.popAccount = popAccount;
|
this.popAccount = popAccount;
|
||||||
this.site = new SocialNetworkingSite(request);
|
this.site = new SocialNetworkingSite(request);
|
||||||
String serverName = request.getServerName();
|
String serverName = request.getServerName();
|
||||||
|
@ -204,8 +204,8 @@ public class PeriodicTask implements Runnable {
|
||||||
if (fakeSession != null && subAddressField != null) {
|
if (fakeSession != null && subAddressField != null) {
|
||||||
if (subAddressField.endsWith(AppType.POST.toString()) || subAddressField.endsWith(AppType.POST.toString().toLowerCase())) { //it is a post, a comment on a post or a mention
|
if (subAddressField.endsWith(AppType.POST.toString()) || subAddressField.endsWith(AppType.POST.toString().toLowerCase())) { //it is a post, a comment on a post or a mention
|
||||||
_log.debug("Looks like a post, a comment on a post or a mention to me");
|
_log.debug("Looks like a post, a comment on a post or a mention to me");
|
||||||
String feedId = extractIdentifier(subAddressField);
|
String postId = extractIdentifier(subAddressField);
|
||||||
handlePostReply(portalName, feedId, message, fakeSession);
|
handlePostReply(portalName, postId, message, fakeSession);
|
||||||
}
|
}
|
||||||
else if (subAddressField.endsWith(AppType.MSG.toString()) || subAddressField.endsWith(AppType.MSG.toString().toLowerCase())) { //it is a message
|
else if (subAddressField.endsWith(AppType.MSG.toString()) || subAddressField.endsWith(AppType.MSG.toString().toLowerCase())) { //it is a message
|
||||||
_log.debug("Looks like a message reply to me");
|
_log.debug("Looks like a message reply to me");
|
||||||
|
@ -370,7 +370,7 @@ public class PeriodicTask implements Runnable {
|
||||||
/**
|
/**
|
||||||
* this method manages the replies coming from post notifications
|
* this method manages the replies coming from post notifications
|
||||||
* @param portalName
|
* @param portalName
|
||||||
* @param postId the identifier in the System managing the feeds
|
* @param postId the identifier in the System managing the posts
|
||||||
* @param message the javax mail Message instance
|
* @param message the javax mail Message instance
|
||||||
* @param fakeSession
|
* @param fakeSession
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
@ -391,13 +391,8 @@ public class PeriodicTask implements Runnable {
|
||||||
|
|
||||||
_log.debug("The EscapedCommentText =>" + escapedCommentText);
|
_log.debug("The EscapedCommentText =>" + escapedCommentText);
|
||||||
boolean commentCommitResult = false;
|
boolean commentCommitResult = false;
|
||||||
try {
|
if (libClient.addCommentLib(comment))
|
||||||
if (socialStore.addComment(comment))
|
|
||||||
commentCommitResult = true;
|
commentCommitResult = true;
|
||||||
} catch (FeedIDNotFoundException e) {
|
|
||||||
_log.error("Related post not found for this comment " + e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (commentCommitResult) { //the notifications should start
|
if (commentCommitResult) { //the notifications should start
|
||||||
notifyUsersInvolved(comment, escapedCommentText, postId, fakeSession);
|
notifyUsersInvolved(comment, escapedCommentText, postId, fakeSession);
|
||||||
}
|
}
|
||||||
|
@ -412,7 +407,7 @@ public class PeriodicTask implements Runnable {
|
||||||
*/
|
*/
|
||||||
private void likePost(String postId, ASLSession fakeSession) {
|
private void likePost(String postId, ASLSession fakeSession) {
|
||||||
if (postId == null || postId.compareTo("") == 0) {
|
if (postId == null || postId.compareTo("") == 0) {
|
||||||
_log.warn("Found email with no feedId from " + fakeSession.getUserEmailAddress() + ". Going to trash it");
|
_log.warn("Found email with no postId from " + fakeSession.getUserEmailAddress() + ". Going to trash it");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,18 +416,13 @@ public class PeriodicTask implements Runnable {
|
||||||
new Date(), postId, fakeSession.getUserFullName(), fakeSession.getUserAvatarId());
|
new Date(), postId, fakeSession.getUserFullName(), fakeSession.getUserAvatarId());
|
||||||
|
|
||||||
boolean likeCommitResult = false;
|
boolean likeCommitResult = false;
|
||||||
try {
|
if (libClient.likeLib(like));
|
||||||
if (socialStore.like(like));
|
|
||||||
likeCommitResult = true;
|
likeCommitResult = true;
|
||||||
} catch (FeedIDNotFoundException e) {
|
|
||||||
_log.error("Related post not found for this like " + e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (likeCommitResult) { //the notification should be delivered to the post owner
|
if (likeCommitResult) { //the notification should be delivered to the post owner
|
||||||
try {
|
try {
|
||||||
Feed post = socialStore.readFeed(postId);
|
Post post = libClient.readPostLib(postId);
|
||||||
String feedOwnerId = post.getEntityId();
|
String postOwnerId = post.getEntityId();
|
||||||
boolean isAppFeed = post.isApplicationFeed();
|
boolean isApppost = post.isApplicationPost();
|
||||||
|
|
||||||
NotificationsManager nm = new ApplicationNotificationsManager(
|
NotificationsManager nm = new ApplicationNotificationsManager(
|
||||||
site,
|
site,
|
||||||
|
@ -440,8 +430,8 @@ public class PeriodicTask implements Runnable {
|
||||||
new SocialNetworkingUser(fakeSession.getUsername(), fakeSession.getUserEmailAddress(), fakeSession.getUserFullName(), fakeSession.getUserAvatarId()),
|
new SocialNetworkingUser(fakeSession.getUsername(), fakeSession.getUserEmailAddress(), fakeSession.getUserFullName(), fakeSession.getUserAvatarId()),
|
||||||
APP_ID_NEWSFEED
|
APP_ID_NEWSFEED
|
||||||
);
|
);
|
||||||
if (! fakeSession.getUsername().equals(feedOwnerId) && (!isAppFeed)) {
|
if (! fakeSession.getUsername().equals(postOwnerId) && (!isApppost)) {
|
||||||
boolean result = nm.notifyLikedFeed(feedOwnerId, postId, "");
|
boolean result = nm.notifyLikedPost(postOwnerId, postId, "");
|
||||||
_log.trace("Like Notification to post owner added? " + result);
|
_log.trace("Like Notification to post owner added? " + result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,48 +443,48 @@ public class PeriodicTask implements Runnable {
|
||||||
/**
|
/**
|
||||||
* this method take care of notify all the users that need to be notified when someone comment
|
* this method take care of notify all the users that need to be notified when someone comment
|
||||||
* @param comment
|
* @param comment
|
||||||
* @param feedId
|
* @param postId
|
||||||
* @param fakeSession
|
* @param fakeSession
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
* @throws PrivacyLevelTypeNotFoundException
|
||||||
* @throws FeedTypeNotFoundException
|
* @throws PostTypeNotFoundException
|
||||||
* @throws FeedIDNotFoundException
|
* @throws PostIDNotFoundException
|
||||||
* @throws ColumnNameNotFoundException
|
* @throws ColumnNameNotFoundException
|
||||||
*/
|
*/
|
||||||
private void notifyUsersInvolved(Comment comment, String commentText, String feedId, ASLSession fakeSession) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
private void notifyUsersInvolved(Comment comment, String commentText, String postId, ASLSession fakeSession) throws PrivacyLevelTypeNotFoundException, PostTypeNotFoundException, PostIDNotFoundException, ColumnNameNotFoundException {
|
||||||
Feed post = socialStore.readFeed(feedId);
|
Post post = libClient.readPostLib(postId);
|
||||||
String feedOwnerId = post.getEntityId();
|
String postOwnerId = post.getEntityId();
|
||||||
boolean isAppFeed = post.isApplicationFeed();
|
boolean isApppost = post.isApplicationPost();
|
||||||
|
|
||||||
//if the user who commented this post is not the user who posted it notifies the poster user (Feed owner)
|
//if the user who commented this post is not the user who posted it notifies the poster user (post owner)
|
||||||
NotificationsManager nm = new ApplicationNotificationsManager(
|
NotificationsManager nm = new ApplicationNotificationsManager(
|
||||||
site,
|
site,
|
||||||
post.getVreid(),
|
post.getVreid(),
|
||||||
new SocialNetworkingUser(fakeSession.getUsername(), fakeSession.getUserEmailAddress(), fakeSession.getUserFullName(), fakeSession.getUserAvatarId()),
|
new SocialNetworkingUser(fakeSession.getUsername(), fakeSession.getUserEmailAddress(), fakeSession.getUserFullName(), fakeSession.getUserAvatarId()),
|
||||||
APP_ID_NEWSFEED
|
APP_ID_NEWSFEED
|
||||||
);
|
);
|
||||||
if (! fakeSession.getUsername().equals(feedOwnerId) && (!isAppFeed)) {
|
if (! fakeSession.getUsername().equals(postOwnerId) && (!isApppost)) {
|
||||||
boolean result = nm.notifyOwnCommentReply(feedOwnerId, feedId, commentText, comment.getKey());
|
boolean result = nm.notifyOwnCommentReply(postOwnerId, postId, commentText, comment.getKey());
|
||||||
_log.trace("Comment Notification to post owner added? " + result);
|
_log.trace("Comment Notification to post owner added? " + result);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if there are users who liked this post they get notified, asynchronously with this thread
|
//if there are users who liked this post they get notified, asynchronously with this thread
|
||||||
ArrayList<Like> likes = getAllLikesByFeed(feedId);
|
ArrayList<Like> likes = getAllLikesByPost(postId);
|
||||||
Thread likesThread = new Thread(new LikeNotificationsThread(commentText, nm, likes, feedOwnerId, comment.getKey()));
|
Thread likesThread = new Thread(new LikeNotificationsThread(commentText, nm, likes, postOwnerId, comment.getKey()));
|
||||||
likesThread.start();
|
likesThread.start();
|
||||||
|
|
||||||
UserManager userManager = new LiferayUserManager();
|
UserManager userManager = new LiferayUserManager();
|
||||||
//notify the other users who commented this post (excluding the ones above)
|
//notify the other users who commented this post (excluding the ones above)
|
||||||
Thread commentsNotificationthread = new Thread(new CommentNotificationsThread(socialStore, userManager, fakeSession.getUsername(), comment.getFeedid(), commentText, nm, feedOwnerId, comment.getKey(), likes));
|
Thread commentsNotificationthread = new Thread(new CommentNotificationsThread(userManager, fakeSession.getUsername(), comment.getPostid(), commentText, nm, postOwnerId, comment.getKey(), likes));
|
||||||
commentsNotificationthread.start();
|
commentsNotificationthread.start();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param feedid
|
* @param postid
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ArrayList<Like> getAllLikesByFeed(String feedid) {
|
public ArrayList<Like> getAllLikesByPost(String postid) {
|
||||||
_log.trace("Asking likes for " + feedid);
|
_log.trace("Asking likes for " + postid);
|
||||||
ArrayList<Like> toReturn = (ArrayList<Like>) socialStore.getAllLikesByFeed(feedid);
|
ArrayList<Like> toReturn = (ArrayList<Like>) libClient.getAllLikesByPostLib(postid);
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue