Compatible with social model 2.0.0

This commit is contained in:
Ahmed Salah Tawfik Ibrahim 2024-01-18 17:52:46 +01:00
parent 2495cc56ff
commit dad57acadf
13 changed files with 116 additions and 125 deletions

View File

@ -4,6 +4,9 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2.0.0] - 2022-05-05
- Fix compatability issues with social service and social model 2.0.0
## [v1.8.0] - 2022-05-05 ## [v1.8.0] - 2022-05-05

13
pom.xml
View File

@ -11,7 +11,7 @@
<groupId>org.gcube.applicationsupportlayer</groupId> <groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId> <artifactId>aslsocial</artifactId>
<version>1.8.0</version> <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Social Portal ASL Extension</name> <name>Social Portal ASL Extension</name>
<description> <description>
@ -47,15 +47,20 @@
<artifactId>rmp-common-library</artifactId> <artifactId>rmp-common-library</artifactId>
<version>[2.8.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> <version>[2.8.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-client</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.common.portal</groupId> <groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId> <artifactId>portal-manager</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.social-networking</groupId>
<artifactId>social-networking-library</artifactId> <artifactId>social-service-model</artifactId>
<scope>provided</scope> <version>[1.2.0-SNAPSHOT, 2.0.0)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.dvos</groupId> <groupId>org.gcube.dvos</groupId>

View File

@ -18,10 +18,10 @@ import org.gcube.common.encryption.StringEncrypter;
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.shared.Feed; import org.gcube.social_networking.socialnetworking.model.shared.Post;
import org.gcube.portal.databook.shared.FeedType; import org.gcube.social_networking.socialnetworking.model.shared.PostType;
import org.gcube.portal.databook.shared.ImageType; import org.gcube.social_networking.socialnetworking.model.shared.ImageType;
import org.gcube.portal.databook.shared.PrivacyLevel; import org.gcube.social_networking.socialnetworking.model.shared.PrivacyLevel;
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.slf4j.Logger; import org.slf4j.Logger;
@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
* *
* @author Massimiliano Assante, ISTI-CNR * @author Massimiliano Assante, ISTI-CNR
* *
* use to share updates from within your applicationProfile, the update will be published in the Users News Feed belonging to the VRE your applicationProfile runs into * use to share updates from within your applicationProfile, the update will be published in the Users News Post belonging to the VRE your applicationProfile runs into
*/ */
public class ApplicationNewsManager extends SocialPortalBridge implements NewsManager { public class ApplicationNewsManager extends SocialPortalBridge implements NewsManager {
@ -56,42 +56,42 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean shareApplicationUpdate(String feedText) { public boolean shareApplicationUpdate(String postText) {
return getStoreInstance().saveAppFeed(buildFeed(feedText, "", "", "", "")); return getStoreInstance().saveAppPostLib(buildPost(postText, "", "", "", ""));
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean shareApplicationUpdate(String feedText, String uriParams) { public boolean shareApplicationUpdate(String postText, String uriParams) {
return getStoreInstance().saveAppFeed(buildFeed(feedText, uriParams, "", "", "")); return getStoreInstance().saveAppPostLib(buildPost(postText, uriParams, "", "", ""));
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean shareApplicationUpdate(String feedText, String uriParams, String previewTitle, String previewDescription, String previewThumbnailUrl) { public boolean shareApplicationUpdate(String postText, String uriParams, String previewTitle, String previewDescription, String previewThumbnailUrl) {
return getStoreInstance().saveAppFeed(buildFeed(feedText, uriParams, previewTitle, previewDescription, previewThumbnailUrl)); return getStoreInstance().saveAppPostLib(buildPost(postText, uriParams, previewTitle, previewDescription, previewThumbnailUrl));
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean shareApplicationUpdate(String feedText, String uriParams, String previewTitle, String previewDescription, InputStream previewThumbnailInputStream, ImageType imageExtension) { public boolean shareApplicationUpdate(String postText, String uriParams, String previewTitle, String previewDescription, InputStream previewThumbnailInputStream, ImageType imageExtension) {
String httpImageUrl = uploadImageOnFTPServer(previewThumbnailInputStream, imageExtension); String httpImageUrl = uploadImageOnFTPServer(previewThumbnailInputStream, imageExtension);
return shareApplicationUpdate(feedText, uriParams, previewTitle, previewDescription, httpImageUrl); return shareApplicationUpdate(postText, uriParams, previewTitle, previewDescription, httpImageUrl);
} }
/** /**
* buid a an ApplicationProfile Feed * buid a an ApplicationProfile Post
* *
* @param description add a description for the update you are sharing * @param description add a description for the update you are sharing
* @param uriParams the additional parameteres your applicationProfile needs to open the subject of this update e.g. id=12345&type=foo * @param uriParams the additional parameteres your applicationProfile needs to open the subject of this update e.g. id=12345&type=foo
* @param previewTitle the title to show in the preview * @param previewTitle the title to show in the preview
* @param previewDescription the description to show in the preview * @param previewDescription the description to show in the preview
* @param previewThumbnailUrl the image url to show in the preview * @param previewThumbnailUrl the image url to show in the preview
* @return a feed instance ready to be written * @return a post instance ready to be written
*/ */
private Feed buildFeed(String description, String uriParams, String previewTitle, String previewDescription, String previewThumbnailUrl) { private Post buildPost(String description, String uriParams, String previewTitle, String previewDescription, String previewThumbnailUrl) {
String descToAdd = escapeHtml(description); String descToAdd = escapeHtml(description);
String uri = applicationProfile.getUrl(); String uri = applicationProfile.getUrl();
@ -99,9 +99,9 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
if (uriParams != null && uriParams.compareTo("") != 0) if (uriParams != null && uriParams.compareTo("") != 0)
uri += "?"+uriParams; uri += "?"+uriParams;
String scope = currScope; String scope = currScope;
Feed toReturn = new Feed( Post toReturn = new Post(
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
FeedType.PUBLISH, PostType.PUBLISH,
applicationProfile.getKey(), applicationProfile.getKey(),
new Date(), new Date(),
scope, scope,

View File

@ -13,10 +13,10 @@ import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder; import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
import org.gcube.portal.databook.shared.Notification; import org.gcube.social_networking.socialnetworking.model.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType; import org.gcube.social_networking.socialnetworking.model.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType; import org.gcube.social_networking.socialnetworking.model.shared.NotificationType;
import org.gcube.portal.databook.shared.RunningJob; import org.gcube.social_networking.socialnetworking.model.shared.RunningJob;
import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException; import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
@ -82,8 +82,8 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* Use this constructor if you do need notifications to point back to your applications, * Use this constructor if you do need notifications to point back to your applications,
* make sure you create your application profile on the infrastructure. * make sure you create your application profile on the infrastructure.
* </p> * </p>
* @see http://wiki.gcube-system.org/gcube/index.php/Social_Networking_Library#Create_Your_Application_Profile * @see <a href="http://wiki.gcube-system.org/gcube/index.php/Social_Networking_Library#Create_Your_Application_Profile">...</a>
* *
* @param scope the current scope * @param scope the current scope
* @param currUser an instance of {@link SocialNetworkingUser} filled with the required user data * @param currUser an instance of {@link SocialNetworkingUser} filled with the required user data
* @param site an instance of {@link SocialNetworkingSite} filled with the required data * @param site an instance of {@link SocialNetworkingSite} filled with the required data
@ -99,8 +99,8 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* Use this constructor if your artifact is not deployed on the portal and you do need notifications to point back to your applications, * Use this constructor if your artifact is not deployed on the portal and you do need notifications to point back to your applications,
* make sure you create your application profile on the infrastructure. * make sure you create your application profile on the infrastructure.
* </p> * </p>
* @see http://wiki.gcube-system.org/gcube/index.php/Social_Networking_Library#Create_Your_Application_Profile * @see <a href="http://wiki.gcube-system.org/gcube/index.php/Social_Networking_Library#Create_Your_Application_Profile">...</a>
* *
* @param userManager a remote implementation of {@link UserManager},see {@link LiferayWSUserManager} * @param userManager a remote implementation of {@link UserManager},see {@link LiferayWSUserManager}
* @param scope the current scope * @param scope the current scope
* @param currUser an instance of {@link SocialNetworkingUser} filled with the required user data * @param currUser an instance of {@link SocialNetworkingUser} filled with the required user data
@ -114,7 +114,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
} }
/** /**
* set the current portal context (name, emal, url) * set the current portal context (name, emal, url)
* @param request * @param site
* @throws SystemException * @throws SystemException
* @throws PortalException * @throws PortalException
*/ */
@ -142,13 +142,13 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
} }
List<NotificationChannelType> channels = null; List<NotificationChannelType> channels = null;
try { try {
channels = getStoreInstance().getUserNotificationChannels(notification2Save.getUserid(), notification2Save.getType()); channels = getStoreInstance().getUserNotificationChannelsLib(notification2Save.getUserid(), notification2Save.getType());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
boolean result = false; boolean result = false;
if (channels.contains(NotificationChannelType.PORTAL)) { if (channels.contains(NotificationChannelType.PORTAL)) {
result = getStoreInstance().saveNotification(notification2Save); result = getStoreInstance().saveNotificationLib(notification2Save);
if (result) if (result)
_log.trace("Notification Saved Successfully! "); _log.trace("Notification Saved Successfully! ");
else else
@ -177,13 +177,13 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
} }
List<NotificationChannelType> channels = null; List<NotificationChannelType> channels = null;
try { try {
channels = getStoreInstance().getUserNotificationChannels(notification2Save.getUserid(), notification2Save.getType()); channels = getStoreInstance().getUserNotificationChannelsLib(notification2Save.getUserid(), notification2Save.getType());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
boolean result = false; boolean result = false;
if (channels.contains(NotificationChannelType.PORTAL)) { if (channels.contains(NotificationChannelType.PORTAL)) {
result = getStoreInstance().saveNotification(notification2Save); result = getStoreInstance().saveNotificationLib(notification2Save);
if (result) if (result)
_log.trace("Notification Saved Successfully! "); _log.trace("Notification Saved Successfully! ");
else else
@ -215,7 +215,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* @throws InternalErrorException
*/ */
@Override @Override
public boolean notifyFolderSharing(String userIdToNotify, SocialSharedFolder sharedFolder) { public boolean notifyFolderSharing(String userIdToNotify, SocialSharedFolder sharedFolder) {
@ -305,7 +304,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
/** /**
* {@inheritDoc} * {@inheritDoc}
* @throws InternalErrorException
*/ */
@Override @Override
public boolean notifyFolderRenaming(String userIdToNotify, String previousName, String newName, String renamedFolderId) { public boolean notifyFolderRenaming(String userIdToNotify, String previousName, String newName, String renamedFolderId) {
@ -418,7 +416,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* @throws InternalErrorException
*/ */
@Override @Override
public boolean notifyAddedItem(String userIdToNotify, SocialFileItem item, SocialSharedFolder sharedFolder) { public boolean notifyAddedItem(String userIdToNotify, SocialFileItem item, SocialSharedFolder sharedFolder) {
@ -443,7 +440,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* @throws InternalErrorException
*/ */
@Override @Override
public boolean notifyMovedItem(String userIdToNotify, SocialFileItem item, SocialSharedFolder sharedFolder) { public boolean notifyMovedItem(String userIdToNotify, SocialFileItem item, SocialSharedFolder sharedFolder) {
@ -467,7 +463,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* @throws InternalErrorException
*/ */
@Override @Override
public boolean notifyRemovedItem(String userIdToNotify, String itemName, SocialSharedFolder sharedFolder) { public boolean notifyRemovedItem(String userIdToNotify, String itemName, SocialSharedFolder sharedFolder) {
@ -491,7 +486,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* @throws InternalErrorException
*/ */
@Override @Override
public boolean notifyUpdatedItem(String userIdToNotify, SocialFileItem item, SocialSharedFolder sharedFolder) { public boolean notifyUpdatedItem(String userIdToNotify, SocialFileItem item, SocialSharedFolder sharedFolder) {
@ -515,7 +509,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* @throws InternalErrorException
*/ */
@Override @Override
public boolean notifyItemRenaming(String userIdToNotify, String previousName, SocialFileItem renamedItem, SocialSharedFolder rootSharedFolder) { public boolean notifyItemRenaming(String userIdToNotify, String previousName, SocialFileItem renamedItem, SocialSharedFolder rootSharedFolder) {
@ -647,13 +640,13 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean notifyCommentReply(String userIdToNotify, String postId, String commentText, String feedOwnerFullName, String feedOwnerId, String commentKey) { public boolean notifyCommentReply(String userIdToNotify, String postId, String commentText, String postOwnerFullName, String postOwnerId, String commentKey) {
String notificationText = (currUser.getUsername().compareTo(feedOwnerId) == 0) ? String notificationText = (currUser.getUsername().compareTo(postOwnerId) == 0) ?
"also commented on his post: " "also commented on his post: "
+ "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; border-left: 3px solid #ccc; font-style: italic;\">\"" + "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; border-left: 3px solid #ccc; font-style: italic;\">\""
+ commentText +"\"</div>" + commentText +"\"</div>"
: :
"also commented on " + feedOwnerFullName + "'s post: " "also commented on " + postOwnerFullName + "'s post: "
+ "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; border-left: 3px solid #ccc; font-style: italic;\">\"" + "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; border-left: 3px solid #ccc; font-style: italic;\">\""
+ commentText +"\"</div>"; + commentText +"\"</div>";
Notification not = new Notification( Notification not = new Notification(
@ -725,14 +718,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
@Deprecated
public boolean notifyLikedFeed(String userIdToNotify, String postId, String postText) {
return notifyLikedPost(userIdToNotify, postId, postText);
}
/**
* {@inheritDoc}
*/
@Override
public boolean notifyLikedPost(String userIdToNotify, String postId, String postText) { public boolean notifyLikedPost(String userIdToNotify, String postId, String postText) {
Notification not = new Notification( Notification not = new Notification(

View File

@ -2,7 +2,7 @@ package org.gcube.applicationsupportlayer.social;
import java.io.InputStream; import java.io.InputStream;
import org.gcube.portal.databook.shared.ImageType; import org.gcube.social_networking.socialnetworking.model.shared.ImageType;

View File

@ -7,8 +7,8 @@ import java.util.Set;
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem; import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder; import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
import org.gcube.portal.databook.shared.NotificationType; import org.gcube.social_networking.socialnetworking.model.shared.NotificationType;
import org.gcube.portal.databook.shared.RunningJob; import org.gcube.social_networking.socialnetworking.model.shared.RunningJob;
import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.UserManager;
/** /**
* *
@ -70,7 +70,7 @@ public interface NotificationsManager {
* @param userIdToNotify the user you want to notify * @param userIdToNotify the user you want to notify
* @param sharedFolder the shared {@link SocialSharedFolder} instance * @param sharedFolder the shared {@link SocialSharedFolder} instance
* @param newAddedUserId the new user that was added * @param newAddedUserId the new user that was added
* @param UserManager UserManager class instance * @param um UserManager class instance
* @return true if the notification is correctly delivered, false otherwise * @return true if the notification is correctly delivered, false otherwise
*/ */
boolean notifyFolderAddedUser(String userIdToNotify, SocialSharedFolder sharedFolder, String newAddedUserId, UserManager um) throws Exception; boolean notifyFolderAddedUser(String userIdToNotify, SocialSharedFolder sharedFolder, String newAddedUserId, UserManager um) throws Exception;
@ -84,7 +84,7 @@ public interface NotificationsManager {
* @param userIdToNotify the user you want to notify * @param userIdToNotify the user you want to notify
* @param sharedFolder the shared {@link SocialSharedFolder} instance * @param sharedFolder the shared {@link SocialSharedFolder} instance
* @param newAddedUserIds List of new users that were added * @param newAddedUserIds List of new users that were added
* @param UserManager UserManager class instance * @param um UserManager class instance
* @return true if the notification is correctly delivered, false otherwise * @return true if the notification is correctly delivered, false otherwise
*/ */
boolean notifyFolderAddedUsers(String userIdToNotify, SocialSharedFolder sharedFolder, List<String> newAddedUserIds, UserManager um) throws Exception; boolean notifyFolderAddedUsers(String userIdToNotify, SocialSharedFolder sharedFolder, List<String> newAddedUserIds, UserManager um) throws Exception;
@ -99,7 +99,7 @@ public interface NotificationsManager {
/** /**
* use to notify a user he got a workspace item new in some of his workspace shared folder * use to notify a user he got a workspace item new in some of his workspace shared folder
* @param userIdToNotify the user you want to notify * @param userIdToNotify the user you want to notify
* @param newItem the new shared {@link SocialFileItem} instance * @param item the new shared {@link SocialFileItem} instance
* @param sharedFolder the shared folder {@link SocialSharedFolder} instance * @param sharedFolder the shared folder {@link SocialSharedFolder} instance
* @return true if the notification is correctly delivered, false otherwise * @return true if the notification is correctly delivered, false otherwise
*/ */
@ -107,7 +107,7 @@ public interface NotificationsManager {
/** /**
* use to notify a user he got a workspace item deleted from one of his workspace shared folder * use to notify a user he got a workspace item deleted from one of his workspace shared folder
* @param userIdToNotify the user you want to notify * @param userIdToNotify the user you want to notify
* @param removedItem the removed item instance of {@link SocialFileItem} * @param item the removed item instance of {@link SocialFileItem}
* @param sharedFolder the shared folder {@link SocialSharedFolder} * @param sharedFolder the shared folder {@link SocialSharedFolder}
* @return true if the notification is correctly delivered, false otherwise * @return true if the notification is correctly delivered, false otherwise
*/ */
@ -115,7 +115,7 @@ public interface NotificationsManager {
/** /**
* use to notify a user he got a workspace item deleted from one of his workspace shared folder * use to notify a user he got a workspace item deleted from one of his workspace shared folder
* @param userIdToNotify the user you want to notify * @param userIdToNotify the user you want to notify
* @param removedItem the removed name * @param item the removed name
* @param sharedFolder the shared folder {@link SocialSharedFolder} * @param sharedFolder the shared folder {@link SocialSharedFolder}
* @return true if the notification is correctly delivered, false otherwise * @return true if the notification is correctly delivered, false otherwise
*/ */
@ -123,7 +123,7 @@ public interface NotificationsManager {
/** /**
* use to notify a user he got a workspace item updated from one of his workspace shared folder * use to notify a user he got a workspace item updated from one of his workspace shared folder
* @param userIdToNotify the user you want to notify * @param userIdToNotify the user you want to notify
* @param updatedItem the updated shared {@link SocialFileItem} * @param item the updated shared {@link SocialFileItem}
* @param sharedFolder the shared folder {@link SocialSharedFolder} * @param sharedFolder the shared folder {@link SocialSharedFolder}
* @return true if the notification is correctly delivered, false otherwise * @return true if the notification is correctly delivered, false otherwise
*/ */
@ -154,7 +154,7 @@ public interface NotificationsManager {
* @param userIdToNotify the user you want to notify * @param userIdToNotify the user you want to notify
* @param itemId the item unique identifier * @param itemId the item unique identifier
* @param notifyText the text of the notification * @param notifyText the text of the notification
* @param the resolver URL pointing to the item * @param url resolver URL pointing to the item
* @return true if the notification is correctly delivered, false otherwise * @return true if the notification is correctly delivered, false otherwise
*/ */
boolean notifyCatalogueEvent(NotificationType type, String userIdToNotify, String itemId, String notifyText, URL url) throws Exception; boolean notifyCatalogueEvent(NotificationType type, String userIdToNotify, String itemId, String notifyText, URL url) throws Exception;
@ -242,22 +242,11 @@ public interface NotificationsManager {
* *
* @param userIdToNotify the user you want to notify * @param userIdToNotify the user you want to notify
* @param postid the liked postid * @param postid the liked postid
* @param feedText the liked feed text or a portion of it * @param commentText the liked post text or a portion of it
* @param commentKey when sending email, stop the shown discussion at that comment * @param commentKey when sending email, stop the shown discussion at that comment
* @return true if the notification is correctly delivered, false otherwise * @return true if the notification is correctly delivered, false otherwise
*/ */
boolean notifyUserTag(String userIdToNotify, String postid, String commentText, String commentKey); boolean notifyUserTag(String userIdToNotify, String postid, String commentText, String commentKey);
/**
* use to notify a user he got one of his post liked
*
* @param userIdToNotify the user you want to notify
* @param postid the liked postid
* @param postText the liked post text or a portion of it
* @return true if the notification is correctly delivered, false otherwise
* @deprecated use notifyLikedPost
*/
@Deprecated
boolean notifyLikedFeed(String userIdToNotify, String postid, String postText);
/** /**
* use to notify a user he got one of his post liked * use to notify a user he got one of his post liked
* *

View File

@ -13,9 +13,8 @@ import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.common.resources.gcore.utils.XPathHelper; import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.social_networking.social_networking_client_library.LibClient;
import org.gcube.portal.databook.server.DatabookStore; import org.gcube.social_networking.socialnetworking.model.shared.ApplicationProfile;
import org.gcube.portal.databook.shared.ApplicationProfile;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query; import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox; import org.gcube.resources.discovery.client.queries.impl.QueryBox;
@ -38,7 +37,7 @@ public class SocialPortalBridge {
protected SocialNetworkingUser currUser; protected SocialNetworkingUser currUser;
protected ApplicationProfile applicationProfile; protected ApplicationProfile applicationProfile;
//unique instance //unique instance
private static DatabookStore store; private static LibClient libClient;
/** /**
* *
* @param scope the current scope * @param scope the current scope
@ -67,11 +66,15 @@ public class SocialPortalBridge {
* *
* @return the unique instance of the store * @return the unique instance of the store
*/ */
public static synchronized DatabookStore getStoreInstance() { public static synchronized LibClient getStoreInstance() {
if (store == null) { if (libClient == null) {
store = new DBCassandraAstyanaxImpl(); try {
libClient = new LibClient();
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
return store; return libClient;
} }
/** /**
* Escape an html string. Escaping data received from the client helps to * Escape an html string. Escaping data received from the client helps to

View File

@ -77,7 +77,7 @@ public class EmailNotificationsConsumer extends Thread {
} }
/** /**
* *
* @param context * @param infraContext
* @return the * @return the
* @throws Exception * @throws Exception
*/ */

View File

@ -3,7 +3,7 @@ package org.gcube.applicationsupportlayer.social.mailing;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Set; import java.util.Set;
import org.gcube.portal.databook.shared.Notification; import org.gcube.social_networking.socialnetworking.model.shared.Notification;
import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.UserManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -13,12 +13,11 @@ import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeMultipart;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.social_networking.social_networking_client_library.LibClient;
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.Notification;
import org.gcube.portal.databook.shared.Notification; import org.gcube.social_networking.socialnetworking.model.shared.NotificationType;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -40,7 +39,17 @@ public class NotificationMail {
private String siteLandingPagePath; private String siteLandingPagePath;
private String[] hashtags; private String[] hashtags;
private Set<String> mentionedVReGroups; private Set<String> mentionedVReGroups;
private static DatabookStore store = new DBCassandraAstyanaxImpl();
private static LibClient libClient;
static {
try {
libClient = new LibClient();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
//private static DatabookStore store = new DBCassandraAstyanaxImpl();
public NotificationMail(UserManager userManager, String portalURL, String siteLandingPagePath, Notification notification2Send, String vreName, String portalName, String senderEmail, Set<String> mentionedVReGroups, String ... hashtags) { public NotificationMail(UserManager userManager, String portalURL, String siteLandingPagePath, Notification notification2Send, String vreName, String portalName, String senderEmail, Set<String> mentionedVReGroups, String ... hashtags) {
super(); super();
@ -102,19 +111,19 @@ public class NotificationMail {
msg2Return.addRecipient(Message.RecipientType.TO, new InternetAddress(email)); msg2Return.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
// retrieve post/comments from its id (if possible) // retrieve post/comments from its id (if possible)
Feed post = null; Post post = null;
List<Comment> comments = null; List<Comment> comments = null;
String commentKey = null; String commentKey = null;
String vreNameFromFeed = null; String vreNameFromPost = null;
if (notification2Send.getType() == NotificationType.COMMENT || if (notification2Send.getType() == NotificationType.COMMENT ||
notification2Send.getType() == NotificationType.OWN_COMMENT || notification2Send.getType() == NotificationType.OWN_COMMENT ||
notification2Send.getType() == NotificationType.LIKE || notification2Send.getType() == NotificationType.LIKE ||
notification2Send.getType() == NotificationType.MENTION) { notification2Send.getType() == NotificationType.MENTION) {
try{ try{
String feedId = notification2Send.getSubjectid(); String postId = notification2Send.getSubjectid();
post = store.readFeed(feedId); post = libClient.readPostLib(postId);
comments = store.getAllCommentByFeed(feedId); comments = libClient.getAllCommentsByPostIdLib(postId);
Collections.sort(comments); // sort them Collections.sort(comments); // sort them
commentKey = notification2Send.getCommentKey(); commentKey = notification2Send.getCommentKey();
@ -123,23 +132,23 @@ public class NotificationMail {
if(vreName == null) if(vreName == null)
vreName = splittedVREName[splittedVREName.length - 1]; vreName = splittedVREName[splittedVREName.length - 1];
// if the notification is a comment, extract the vre name from the feed and not from the scope // if the notification is a comment, extract the vre name from the post and not from the scope
if(notification2Send.getType().equals(NotificationType.COMMENT) || if(notification2Send.getType().equals(NotificationType.COMMENT) ||
notification2Send.getType().equals(NotificationType.OWN_COMMENT) || notification2Send.getType().equals(NotificationType.OWN_COMMENT) ||
notification2Send.getType().equals(NotificationType.LIKE) || notification2Send.getType().equals(NotificationType.LIKE) ||
notification2Send.getType().equals(NotificationType.MENTION) notification2Send.getType().equals(NotificationType.MENTION)
) )
vreNameFromFeed = splittedVREName[splittedVREName.length - 1]; vreNameFromPost = splittedVREName[splittedVREName.length - 1];
} catch(Exception e){ } catch(Exception e){
_log.error("Unable to retrieve posts/comments", e); _log.error("Unable to retrieve posts/comments", e);
} }
} }
String vreNameToUse = (vreNameFromFeed == null) ? vreName : vreNameFromFeed; String vreNameToUse = (vreNameFromPost == null) ? vreName : vreNameFromPost;
_log.debug("VRE Name for the email's subject is going to be " _log.debug("VRE Name for the email's subject is going to be "
+ vreNameToUse + "[vreNameFromFeed is " + vreNameFromFeed + ", vreName is " + vreName + "]"); + vreNameToUse + "[vreNameFromPost is " + vreNameFromPost + ", vreName is " + vreName + "]");
try{ try{
// set subject // set subject
msg2Return.setSubject(SocialMailingUtil.getSubjectByNotificationType(notification2Send, vreNameToUse, user.getFirstName(), mentionedVReGroups, hashtags)); msg2Return.setSubject(SocialMailingUtil.getSubjectByNotificationType(notification2Send, vreNameToUse, user.getFirstName(), mentionedVReGroups, hashtags));

View File

@ -10,10 +10,10 @@ import java.util.Set;
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.portal.databook.shared.Comment; import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.portal.databook.shared.Feed; import org.gcube.social_networking.socialnetworking.model.shared.Post;
import org.gcube.portal.databook.shared.Notification; import org.gcube.social_networking.socialnetworking.model.shared.Notification;
import org.gcube.portal.databook.shared.NotificationType; import org.gcube.social_networking.socialnetworking.model.shared.NotificationType;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
@ -39,7 +39,7 @@ public class SocialMailingUtil {
* @param siteLandingPagePath * @param siteLandingPagePath
* @param email * @param email
* @param vreName * @param vreName
* @param feed * @param post
* @param comments * @param comments
* @param commentKey * @param commentKey
* @param hashtags * @param hashtags
@ -50,13 +50,13 @@ public class SocialMailingUtil {
String portalURL, String portalURL,
String siteLandingPagePath, String siteLandingPagePath,
String email, String email,
Feed feed, Post post,
List<Comment> comments, List<Comment> comments,
String commentKey, String commentKey,
String ... hashtags) { String ... hashtags) {
String removedMarkup = notification2Save.getDescription().replaceAll("&amp;", "&"); String removedMarkup = notification2Save.getDescription().replaceAll("&amp;", "&");
//notification2Save uri contains the absoulte path to the feed in the correct channel, e.g. /group/ustore_vre?oid=f1637958-34d0-48fc-b5ad-13b1116e389d //notification2Save uri contains the absoulte path to the post in the correct channel, e.g. /group/ustore_vre?oid=f1637958-34d0-48fc-b5ad-13b1116e389d
String pathToVRE = siteLandingPagePath + "?"; String pathToVRE = siteLandingPagePath + "?";
if (notification2Save.getUri() != null) { if (notification2Save.getUri() != null) {
if (notification2Save.getUri().split("\\?").length > 0) { if (notification2Save.getUri().split("\\?").length > 0) {
@ -96,7 +96,7 @@ public class SocialMailingUtil {
.append("<p><a href=\"").append(userProfileLink).append("\">").append(sender).append("</a> ").append(removedMarkup) // has done something .append("<p><a href=\"").append(userProfileLink).append("\">").append(sender).append("</a> ").append(removedMarkup) // has done something
.append(getActionLink(notification2Save, portalURL)) //Goto .append(getActionLink(notification2Save, portalURL)) //Goto
.append(attachmentsNotice) .append(attachmentsNotice)
.append(SocialMailingUtil.buildHtmlDiscussion(portalURL, pathToVRE, notification2Save, feed, comments, commentKey)) // the original discussion .append(SocialMailingUtil.buildHtmlDiscussion(portalURL, pathToVRE, notification2Save, post, comments, commentKey)) // the original discussion
.append("</p>") .append("</p>")
.append("</div><br/>") .append("</div><br/>")
.append("<p><div style=\"color:#999999; font-size:11px; font-family:'lucida grande',tahoma,verdana,arial,sans-serif;\">") .append("<p><div style=\"color:#999999; font-size:11px; font-family:'lucida grande',tahoma,verdana,arial,sans-serif;\">")
@ -126,7 +126,7 @@ public class SocialMailingUtil {
* @param portalURL * @param portalURL
* @param siteLandingPagePath * @param siteLandingPagePath
* @param email * @param email
* @param feed * @param post
* @param comments * @param comments
* @param commentKey * @param commentKey
* @param hashtags * @param hashtags
@ -138,7 +138,7 @@ public class SocialMailingUtil {
String portalURL, String portalURL,
String siteLandingPagePath, String siteLandingPagePath,
String email, String email,
Feed feed, Post post,
List<Comment> comments, List<Comment> comments,
String commentKey, String commentKey,
String[] hashtags) { String[] hashtags) {
@ -177,7 +177,7 @@ public class SocialMailingUtil {
.append("\n").append(sender).append(" ").append(removedMarkup) // has done something .append("\n").append(sender).append(" ").append(removedMarkup) // has done something
.append("\nsee: ").append(portalURL).append(notification2Save.getUri()) .append("\nsee: ").append(portalURL).append(notification2Save.getUri())
.append(attachmentsNotice) .append(attachmentsNotice)
.append(SocialMailingUtil.buildPlainTextDiscussion(notification2Save, feed, comments, commentKey)) .append(SocialMailingUtil.buildPlainTextDiscussion(notification2Save, post, comments, commentKey))
.append("\n----\n") .append("\n----\n")
.append("This message was sent to ") .append("This message was sent to ")
.append(email) .append(email)
@ -196,7 +196,6 @@ public class SocialMailingUtil {
/** /**
* construct the subjec of the email * construct the subjec of the email
* @param notification2Save * @param notification2Save
* @param portalURL
* @param vreName * @param vreName
* @return * @return
*/ */
@ -411,14 +410,14 @@ public class SocialMailingUtil {
} }
/** /**
* Build up a discussion given the feed and its comments. * Build up a discussion given the post and its comments.
* @param notification2Save * @param notification2Save
* @param post * @param post
* @param comments * @param comments
* @param commentKey if not null, when building the discussion stop at this comment. * @param commentKey if not null, when building the discussion stop at this comment.
* @return an html string representing the discussion * @return an html string representing the discussion
*/ */
protected static String buildHtmlDiscussion(String portalURL, String pathToVRE, Notification notification2Save, Feed post, List<Comment> comments, String commentKey){ protected static String buildHtmlDiscussion(String portalURL, String pathToVRE, Notification notification2Save, Post post, List<Comment> comments, String commentKey){
try{ try{
@ -501,13 +500,13 @@ public class SocialMailingUtil {
} }
/** /**
* Build a plain text discussion given a feed and its comments. * Build a plain text discussion given a post and its comments.
* @param feed * @param post
* @param comments * @param comments
* @param commentKey if not null, when building the discussion stop at this comment. * @param commentKey if not null, when building the discussion stop at this comment.
* @return a string representing the discussion * @return a string representing the discussion
*/ */
protected static String buildPlainTextDiscussion(Notification notification2Save, Feed feed, List<Comment> comments, String commentKey){ protected static String buildPlainTextDiscussion(Notification notification2Save, Post post, List<Comment> comments, String commentKey){
try{ try{
@ -523,15 +522,15 @@ public class SocialMailingUtil {
Format formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm a"); Format formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm a");
// escape html // escape html
String feedTextNoHtml = convertHTML2Text(feed.getDescription()); String postTextNoHtml = convertHTML2Text(post.getDescription());
// build up post + comments // build up post + comments
discussion += discussion +=
"\n" "\n"
+ "[" + formatter.format(feed.getTime()) + "] " + "[" + formatter.format(post.getTime()) + "] "
+ feed.getFullName() + post.getFullName()
+ ": " + ": "
+ (feedTextNoHtml.length() > 200 ? feedTextNoHtml.substring(0, 200) + " ..." : feedTextNoHtml) + (postTextNoHtml.length() > 200 ? postTextNoHtml.substring(0, 200) + " ..." : postTextNoHtml)
+ "\n"; + "\n";

View File

@ -18,7 +18,7 @@ import org.gcube.common.encryption.StringEncrypter;
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.shared.ImageType; import org.gcube.social_networking.socialnetworking.model.shared.ImageType;
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.slf4j.Logger; import org.slf4j.Logger;

View File

@ -22,7 +22,6 @@ public class UrlEncoderUtil {
public static Logger logger = Logger.getLogger(UrlEncoderUtil.class); public static Logger logger = Logger.getLogger(UrlEncoderUtil.class);
/** /**
* *
* @param url
* @param parameters * @param parameters
* @return * @return
*/ */
@ -46,7 +45,6 @@ public class UrlEncoderUtil {
/** /**
* *
* @param url
* @param parameters * @param parameters
* @return * @return
*/ */