Compare commits

...

5 Commits

13 changed files with 123 additions and 125 deletions

View File

@ -4,10 +4,10 @@
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).
## [v1.8.0] - 2022-05-05
- fixed some notification methods
- Compatible with social model 2.0.0 (#26421)
## [v1.0.0] - 2016-06-01

21
pom.xml
View File

@ -47,15 +47,22 @@
<artifactId>rmp-common-library</artifactId>
<version>[2.8.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<!--needs to be provided -->
<groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-client</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<scope>provided</scope>
<!--needs to be provided -->
<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.dvos</groupId>
@ -163,6 +170,14 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

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.AccessPoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.FeedType;
import org.gcube.portal.databook.shared.ImageType;
import org.gcube.portal.databook.shared.PrivacyLevel;
import org.gcube.social_networking.socialnetworking.model.shared.Post;
import org.gcube.social_networking.socialnetworking.model.shared.PostType;
import org.gcube.social_networking.socialnetworking.model.shared.ImageType;
import org.gcube.social_networking.socialnetworking.model.shared.PrivacyLevel;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
*
* @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 {
@ -56,42 +56,42 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
* {@inheritDoc}
*/
@Override
public boolean shareApplicationUpdate(String feedText) {
return getStoreInstance().saveAppFeed(buildFeed(feedText, "", "", "", ""));
public boolean shareApplicationUpdate(String postText) {
return getStoreInstance().saveAppPostLib(buildPost(postText, "", "", "", ""));
}
/**
* {@inheritDoc}
*/
@Override
public boolean shareApplicationUpdate(String feedText, String uriParams) {
return getStoreInstance().saveAppFeed(buildFeed(feedText, uriParams, "", "", ""));
public boolean shareApplicationUpdate(String postText, String uriParams) {
return getStoreInstance().saveAppPostLib(buildPost(postText, uriParams, "", "", ""));
}
/**
* {@inheritDoc}
*/
@Override
public boolean shareApplicationUpdate(String feedText, String uriParams, String previewTitle, String previewDescription, String previewThumbnailUrl) {
return getStoreInstance().saveAppFeed(buildFeed(feedText, uriParams, previewTitle, previewDescription, previewThumbnailUrl));
public boolean shareApplicationUpdate(String postText, String uriParams, String previewTitle, String previewDescription, String previewThumbnailUrl) {
return getStoreInstance().saveAppPostLib(buildPost(postText, uriParams, previewTitle, previewDescription, previewThumbnailUrl));
}
/**
* {@inheritDoc}
*/
@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);
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 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 previewDescription the description 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 uri = applicationProfile.getUrl();
@ -99,9 +99,9 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
if (uriParams != null && uriParams.compareTo("") != 0)
uri += "?"+uriParams;
String scope = currScope;
Feed toReturn = new Feed(
Post toReturn = new Post(
UUID.randomUUID().toString(),
FeedType.PUBLISH,
PostType.PUBLISH,
applicationProfile.getKey(),
new Date(),
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.SocialNetworkingUser;
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
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.RunningJob;
import org.gcube.social_networking.socialnetworking.model.shared.Notification;
import org.gcube.social_networking.socialnetworking.model.shared.NotificationChannelType;
import org.gcube.social_networking.socialnetworking.model.shared.NotificationType;
import org.gcube.social_networking.socialnetworking.model.shared.RunningJob;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
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,
* make sure you create your application profile on the infrastructure.
* </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 currUser an instance of {@link SocialNetworkingUser} filled with the required user 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,
* make sure you create your application profile on the infrastructure.
* </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 scope the current scope
* @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)
* @param request
* @param site
* @throws SystemException
* @throws PortalException
*/
@ -142,13 +142,13 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
}
List<NotificationChannelType> channels = null;
try {
channels = getStoreInstance().getUserNotificationChannels(notification2Save.getUserid(), notification2Save.getType());
channels = getStoreInstance().getUserNotificationChannelsLib(notification2Save.getUserid(), notification2Save.getType());
} catch (Exception e) {
e.printStackTrace();
}
boolean result = false;
if (channels.contains(NotificationChannelType.PORTAL)) {
result = getStoreInstance().saveNotification(notification2Save);
result = getStoreInstance().saveNotificationLib(notification2Save);
if (result)
_log.trace("Notification Saved Successfully! ");
else
@ -177,13 +177,13 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
}
List<NotificationChannelType> channels = null;
try {
channels = getStoreInstance().getUserNotificationChannels(notification2Save.getUserid(), notification2Save.getType());
channels = getStoreInstance().getUserNotificationChannelsLib(notification2Save.getUserid(), notification2Save.getType());
} catch (Exception e) {
e.printStackTrace();
}
boolean result = false;
if (channels.contains(NotificationChannelType.PORTAL)) {
result = getStoreInstance().saveNotification(notification2Save);
result = getStoreInstance().saveNotificationLib(notification2Save);
if (result)
_log.trace("Notification Saved Successfully! ");
else
@ -215,7 +215,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
}
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyFolderSharing(String userIdToNotify, SocialSharedFolder sharedFolder) {
@ -305,7 +304,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyFolderRenaming(String userIdToNotify, String previousName, String newName, String renamedFolderId) {
@ -418,7 +416,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
}
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyAddedItem(String userIdToNotify, SocialFileItem item, SocialSharedFolder sharedFolder) {
@ -443,7 +440,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
}
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyMovedItem(String userIdToNotify, SocialFileItem item, SocialSharedFolder sharedFolder) {
@ -467,7 +463,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
}
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyRemovedItem(String userIdToNotify, String itemName, SocialSharedFolder sharedFolder) {
@ -491,7 +486,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
}
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyUpdatedItem(String userIdToNotify, SocialFileItem item, SocialSharedFolder sharedFolder) {
@ -515,7 +509,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
}
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyItemRenaming(String userIdToNotify, String previousName, SocialFileItem renamedItem, SocialSharedFolder rootSharedFolder) {
@ -647,13 +640,13 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* {@inheritDoc}
*/
@Override
public boolean notifyCommentReply(String userIdToNotify, String postId, String commentText, String feedOwnerFullName, String feedOwnerId, String commentKey) {
String notificationText = (currUser.getUsername().compareTo(feedOwnerId) == 0) ?
public boolean notifyCommentReply(String userIdToNotify, String postId, String commentText, String postOwnerFullName, String postOwnerId, String commentKey) {
String notificationText = (currUser.getUsername().compareTo(postOwnerId) == 0) ?
"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;\">\""
+ 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;\">\""
+ commentText +"\"</div>";
Notification not = new Notification(
@ -725,14 +718,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* {@inheritDoc}
*/
@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) {
Notification not = new Notification(

View File

@ -2,7 +2,7 @@ package org.gcube.applicationsupportlayer.social;
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.SocialSharedFolder;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.RunningJob;
import org.gcube.social_networking.socialnetworking.model.shared.NotificationType;
import org.gcube.social_networking.socialnetworking.model.shared.RunningJob;
import org.gcube.vomanagement.usermanagement.UserManager;
/**
*
@ -70,7 +70,7 @@ public interface NotificationsManager {
* @param userIdToNotify the user you want to notify
* @param sharedFolder the shared {@link SocialSharedFolder} instance
* @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
*/
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 sharedFolder the shared {@link SocialSharedFolder} instance
* @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
*/
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
* @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
* @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
* @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}
* @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
* @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}
* @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
* @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}
* @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 itemId the item unique identifier
* @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
*/
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 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
* @return true if the notification is correctly delivered, false otherwise
*/
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
*

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.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
import org.gcube.portal.databook.server.DatabookStore;
import org.gcube.portal.databook.shared.ApplicationProfile;
import org.gcube.social_networking.social_networking_client_library.LibClient;
import org.gcube.social_networking.socialnetworking.model.shared.ApplicationProfile;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
@ -38,7 +37,7 @@ public class SocialPortalBridge {
protected SocialNetworkingUser currUser;
protected ApplicationProfile applicationProfile;
//unique instance
private static DatabookStore store;
private static LibClient libClient;
/**
*
* @param scope the current scope
@ -67,11 +66,15 @@ public class SocialPortalBridge {
*
* @return the unique instance of the store
*/
public static synchronized DatabookStore getStoreInstance() {
if (store == null) {
store = new DBCassandraAstyanaxImpl();
public static synchronized LibClient getStoreInstance() {
if (libClient == null) {
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

View File

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

View File

@ -3,7 +3,7 @@ package org.gcube.applicationsupportlayer.social.mailing;
import java.util.ArrayList;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -13,12 +13,11 @@ import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
import org.gcube.portal.databook.server.DatabookStore;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.social_networking.social_networking_client_library.LibClient;
import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.social_networking.socialnetworking.model.shared.Post;
import org.gcube.social_networking.socialnetworking.model.shared.Notification;
import org.gcube.social_networking.socialnetworking.model.shared.NotificationType;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger;
@ -40,7 +39,17 @@ public class NotificationMail {
private String siteLandingPagePath;
private String[] hashtags;
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) {
super();
@ -102,19 +111,19 @@ public class NotificationMail {
msg2Return.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
// retrieve post/comments from its id (if possible)
Feed post = null;
Post post = null;
List<Comment> comments = null;
String commentKey = null;
String vreNameFromFeed = null;
String vreNameFromPost = null;
if (notification2Send.getType() == NotificationType.COMMENT ||
notification2Send.getType() == NotificationType.OWN_COMMENT ||
notification2Send.getType() == NotificationType.LIKE ||
notification2Send.getType() == NotificationType.MENTION) {
try{
String feedId = notification2Send.getSubjectid();
post = store.readFeed(feedId);
comments = store.getAllCommentByFeed(feedId);
String postId = notification2Send.getSubjectid();
post = libClient.readPostLib(postId);
comments = libClient.getAllCommentsByPostIdLib(postId);
Collections.sort(comments); // sort them
commentKey = notification2Send.getCommentKey();
@ -123,23 +132,23 @@ public class NotificationMail {
if(vreName == null)
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) ||
notification2Send.getType().equals(NotificationType.OWN_COMMENT) ||
notification2Send.getType().equals(NotificationType.LIKE) ||
notification2Send.getType().equals(NotificationType.MENTION)
)
vreNameFromFeed = splittedVREName[splittedVREName.length - 1];
vreNameFromPost = splittedVREName[splittedVREName.length - 1];
} catch(Exception 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 "
+ vreNameToUse + "[vreNameFromFeed is " + vreNameFromFeed + ", vreName is " + vreName + "]");
+ vreNameToUse + "[vreNameFromPost is " + vreNameFromPost + ", vreName is " + vreName + "]");
try{
// set subject
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.common.portal.GCubePortalConstants;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.social_networking.socialnetworking.model.shared.Post;
import org.gcube.social_networking.socialnetworking.model.shared.Notification;
import org.gcube.social_networking.socialnetworking.model.shared.NotificationType;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@ -39,7 +39,7 @@ public class SocialMailingUtil {
* @param siteLandingPagePath
* @param email
* @param vreName
* @param feed
* @param post
* @param comments
* @param commentKey
* @param hashtags
@ -50,13 +50,13 @@ public class SocialMailingUtil {
String portalURL,
String siteLandingPagePath,
String email,
Feed feed,
Post post,
List<Comment> comments,
String commentKey,
String ... hashtags) {
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 + "?";
if (notification2Save.getUri() != null) {
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(getActionLink(notification2Save, portalURL)) //Goto
.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("</div><br/>")
.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 siteLandingPagePath
* @param email
* @param feed
* @param post
* @param comments
* @param commentKey
* @param hashtags
@ -138,7 +138,7 @@ public class SocialMailingUtil {
String portalURL,
String siteLandingPagePath,
String email,
Feed feed,
Post post,
List<Comment> comments,
String commentKey,
String[] hashtags) {
@ -177,7 +177,7 @@ public class SocialMailingUtil {
.append("\n").append(sender).append(" ").append(removedMarkup) // has done something
.append("\nsee: ").append(portalURL).append(notification2Save.getUri())
.append(attachmentsNotice)
.append(SocialMailingUtil.buildPlainTextDiscussion(notification2Save, feed, comments, commentKey))
.append(SocialMailingUtil.buildPlainTextDiscussion(notification2Save, post, comments, commentKey))
.append("\n----\n")
.append("This message was sent to ")
.append(email)
@ -196,7 +196,6 @@ public class SocialMailingUtil {
/**
* construct the subjec of the email
* @param notification2Save
* @param portalURL
* @param vreName
* @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 post
* @param comments
* @param commentKey if not null, when building the discussion stop at this comment.
* @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{
@ -501,13 +500,13 @@ public class SocialMailingUtil {
}
/**
* Build a plain text discussion given a feed and its comments.
* @param feed
* Build a plain text discussion given a post and its comments.
* @param post
* @param comments
* @param commentKey if not null, when building the discussion stop at this comment.
* @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{
@ -523,15 +522,15 @@ public class SocialMailingUtil {
Format formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm a");
// escape html
String feedTextNoHtml = convertHTML2Text(feed.getDescription());
String postTextNoHtml = convertHTML2Text(post.getDescription());
// build up post + comments
discussion +=
"\n"
+ "[" + formatter.format(feed.getTime()) + "] "
+ feed.getFullName()
+ "[" + formatter.format(post.getTime()) + "] "
+ post.getFullName()
+ ": "
+ (feedTextNoHtml.length() > 200 ? feedTextNoHtml.substring(0, 200) + " ..." : feedTextNoHtml)
+ (postTextNoHtml.length() > 200 ? postTextNoHtml.substring(0, 200) + " ..." : postTextNoHtml)
+ "\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.AccessPoint;
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.queries.api.SimpleQuery;
import org.slf4j.Logger;

View File

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