updated 2 notification methods

Feature/23194
Massimiliano Assante 2 years ago
parent 67b4e9b81e
commit cf37f90b4d

@ -0,0 +1,14 @@
# Changelog for ASL Social
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-SNAPSHOT] - 2022-05-05
- fixed some notification methods
## [v1.0.0] - 2016-06-01
- First release

@ -0,0 +1,26 @@
# Acknowledgments
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
- the Seventh Framework Programme for research, technological development and demonstration
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
- the H2020 research and innovation programme
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);

@ -1,8 +1,8 @@
# gCube System - ASLSocial Library
Social Portal ASL Extension is an abstraction over the Social Networking Library to be used from within you gCube Portlets.
The ASL Social Extension is formed by different modules, each of these is delegated to one specific task. Every module inherits from a super class called SocialPortalBridge.
# gCube System - ASL Social
The ASL Social Extension is formed by different modules, each of these is delegated to one specific task. Every module inherits from a super class called SocialPortalBridge. Currently there are two modules available:
Application News Manager: to be used by gCube Applications when they need to post news on their user news feeds;
User Notifications Manager: to be used by gCube Applications when they need to notify their users about some events.
## Structure of the project
@ -15,19 +15,20 @@ The ASL Social Extension is formed by different modules, each of these is delega
## Documentation
* Use of this service is described in the [Wiki](https://gcube.wiki.gcube-system.org/gcube/Social_Networking_Library#ASL_Social_Extension).
* Use of this service is described in the [Wiki](https://wiki.gcube-system.org/gcube/Social_Networking_Library#ASL_Social_Extension).
## Change log
See [Releases](https://code-repo.d4science.org/gCubeSystem/aslsocial/releases).
## Authors
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
## Maintainers
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
## License
@ -40,12 +41,4 @@ open-source software toolkit used for building and operating Hybrid Data
Infrastructures enabling the dynamic deployment of Virtual Research Environments
by favouring the realisation of reuse oriented policies.
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- DILIGENT (grant no. 004260);
- the Seventh Framework Programme for research, technological development and demonstration
- D4Science (grant no. 212488), D4Science-II (grant no.239019), ENVRI (grant no. 283465), EUBrazilOpenBio (grant no. 288754), iMarine(grant no. 283644);
- the H2020 research and innovation programme
- BlueBRIDGE (grant no. 675680), EGIEngage (grant no. 654142), ENVRIplus (grant no. 654182), Parthenos (grant no. 654119), SoBigData (grant no. 654024),DESIRA (grant no. 818194), ARIADNEplus (grant no. 823914), RISIS2 (grant no. 824091), PerformFish (grant no. 727610), AGINFRAplus (grant no. 731001);
The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md)

@ -11,7 +11,7 @@
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId>
<version>1.7.3</version>
<version>1.8.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Social Portal ASL Extension</name>
<description>
@ -19,9 +19,9 @@
The ASL Social Extension is formed by different modules, each of these is delegated to one specific task. Every module inherits from a super class called SocialPortalBridge.
</description>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/aslsocial.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/aslsocial.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/aslsocial</url>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
</scm>
<properties>
<distroDirectory>distro</distroDirectory>
@ -35,7 +35,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>LATEST</version>
<version>3.6.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -145,51 +145,6 @@
</resource>
</resources>
<plugins>
<!-- SA Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-profile</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>

@ -322,6 +322,13 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
return saveNotification(not);
}
/**
* @Deprecated
*/
@Deprecated
public boolean notifyFolderAddedUser(String userIdToNotify, SocialSharedFolder sharedFolder, String newAddedUserId) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
return notifyFolderAddedUser(userIdToNotify, sharedFolder, newAddedUserId, new LiferayUserManager());
}
/**
* {@inheritDoc}
* @throws UserManagementPortalException
@ -329,8 +336,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* @throws UserManagementSystemException
*/
@Override
public boolean notifyFolderAddedUser(String userIdToNotify, SocialSharedFolder sharedFolder, String newAddedUserId) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
UserManager um = new LiferayUserManager();
public boolean notifyFolderAddedUser(String userIdToNotify, SocialSharedFolder sharedFolder, String newAddedUserId, UserManager um) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
GCubeUser user = um.getUserByUsername(newAddedUserId);
Notification not = new Notification(
UUID.randomUUID().toString(),
@ -347,6 +353,14 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
return saveNotification(not);
}
/**
* @Deprecated
*/
@Deprecated
public boolean notifyFolderAddedUsers(String userIdToNotify, SocialSharedFolder sharedFolder, List<String> newAddedUserIds) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
return notifyFolderAddedUsers(userIdToNotify, sharedFolder, newAddedUserIds, new LiferayUserManager());
}
/**
* {@inheritDoc}
* @throws UserManagementPortalException
@ -354,12 +368,11 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* @throws UserManagementSystemException
*/
@Override
public boolean notifyFolderAddedUsers(String userIdToNotify, SocialSharedFolder sharedFolder, List<String> newAddedUserIds) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
public boolean notifyFolderAddedUsers(String userIdToNotify, SocialSharedFolder sharedFolder, List<String> newAddedUserIds, UserManager um) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
if (newAddedUserIds != null && newAddedUserIds.size() > 0) {
if (newAddedUserIds.size() == 1)
return notifyFolderAddedUser(userIdToNotify, sharedFolder, newAddedUserIds.get(0));
return notifyFolderAddedUser(userIdToNotify, sharedFolder, newAddedUserIds.get(0), um);
StringBuilder addedUsersFullNames = new StringBuilder();
UserManager um = new LiferayUserManager();
for (String userId : newAddedUserIds)
addedUsersFullNames.append(um.getUserByUsername(userId).getFullname()).append(" ");

@ -8,6 +8,7 @@ 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.vomanagement.usermanagement.UserManager;
/**
*
* @author Massimiliano Assante, ISTI-CNR
@ -58,24 +59,34 @@ public interface NotificationsManager {
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyFolderRenaming(String userIdToNotify, String previousName, String newName, String renamedFolderId) throws Exception;
/**
* @deprecated user notifyFolderAddedUser passing UserManager class
*/
boolean notifyFolderAddedUser(String userIdToNotify, SocialSharedFolder sharedFolder, String newAddedUserId) throws Exception;
/**
* use to notify a user that a new user was added in on of his workspace shared folder
*
* @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
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyFolderAddedUser(String userIdToNotify, SocialSharedFolder sharedFolder, String newAddedUserId) throws Exception;
boolean notifyFolderAddedUser(String userIdToNotify, SocialSharedFolder sharedFolder, String newAddedUserId, UserManager um) throws Exception;
/**
* @deprecated user notifyFolderAddedUser passing UserManager class
*/
boolean notifyFolderAddedUsers(String userIdToNotify, SocialSharedFolder sharedFolder, List<String> newAddedUserIds) throws Exception;
/**
* use to notify a user that a new user was added in on of his workspace shared folder
*
* @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
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyFolderAddedUsers(String userIdToNotify, SocialSharedFolder sharedFolder, List<String> newAddedUserIds) throws Exception;
boolean notifyFolderAddedUsers(String userIdToNotify, SocialSharedFolder sharedFolder, List<String> newAddedUserIds, UserManager um) throws Exception;
/**
* use to notify a user that an existing user was removed from one of his workspace shared folder
*

@ -68,7 +68,7 @@ public class NotificationMail {
String email = user.getEmail();
Message msg2Return = new MimeMessage(session);
if (notification2Send.getType() == NotificationType.POST_ALERT ||
notification2Send.getType() == NotificationType.COMMENT ||
notification2Send.getType() == NotificationType.MENTION ||
@ -102,7 +102,7 @@ public class NotificationMail {
msg2Return.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
// retrieve post/comments from its id (if possible)
Feed feed = null;
Feed post = null;
List<Comment> comments = null;
String commentKey = null;
String vreNameFromFeed = null;
@ -113,13 +113,13 @@ public class NotificationMail {
notification2Send.getType() == NotificationType.MENTION) {
try{
String feedId = notification2Send.getSubjectid();
feed = store.readFeed(feedId);
post = store.readFeed(feedId);
comments = store.getAllCommentByFeed(feedId);
Collections.sort(comments); // sort them
commentKey = notification2Send.getCommentKey();
// try to set vreName when notification is created in infrastructure scope
String[] splittedVREName = feed.getVreid().split("/");
String[] splittedVREName = post.getVreid().split("/");
if(vreName == null)
vreName = splittedVREName[splittedVREName.length - 1];
@ -140,24 +140,25 @@ public class NotificationMail {
_log.debug("VRE Name for the email's subject is going to be "
+ vreNameToUse + "[vreNameFromFeed is " + vreNameFromFeed + ", vreName is " + vreName + "]");
// set subject
msg2Return.setSubject(SocialMailingUtil.getSubjectByNotificationType(notification2Send, vreNameToUse, user.getFirstName(), mentionedVReGroups, hashtags));
final MimeBodyPart textPart = new MimeBodyPart();
textPart.setContent(SocialMailingUtil.getTextEmail(notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, feed, comments, commentKey, hashtags), "text/plain; charset=UTF-8");
final MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(SocialMailingUtil.getHTMLEmail(vreNameToUse, notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, feed, comments, commentKey, hashtags), "text/html; charset=UTF-8");
final Multipart mp = new MimeMultipart("alternative");
mp.addBodyPart(textPart);
mp.addBodyPart(htmlPart);
// Set Multipart as the message's content
msg2Return.setContent(mp);
msg2Return.setSentDate(new Date());
try{
// set subject
msg2Return.setSubject(SocialMailingUtil.getSubjectByNotificationType(notification2Send, vreNameToUse, user.getFirstName(), mentionedVReGroups, hashtags));
_log.debug("message subject set");
final MimeBodyPart textPart = new MimeBodyPart();
textPart.setContent(SocialMailingUtil.getTextEmail(notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, post, comments, commentKey, hashtags), "text/plain; charset=UTF-8");
final MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(SocialMailingUtil.getHTMLEmail(vreNameToUse, notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, post, comments, commentKey, hashtags), "text/html; charset=UTF-8");
final Multipart mp = new MimeMultipart("alternative");
mp.addBodyPart(textPart);
mp.addBodyPart(htmlPart);
_log.debug("message added body parts");
// Set Multipart as the message's content
msg2Return.setContent(mp);
_log.debug("message setContent DONE");
msg2Return.setSentDate(new Date());
} catch(Exception e){
e.printStackTrace();
}
return msg2Return;
}

@ -58,13 +58,15 @@ public class SocialMailingUtil {
//notification2Save uri contains the absoulte path to the feed in the correct channel, e.g. /group/ustore_vre?oid=f1637958-34d0-48fc-b5ad-13b1116e389d
String pathToVRE = siteLandingPagePath + "?";
if (notification2Save.getUri().split("\\?").length > 0) {
pathToVRE = notification2Save.getUri().split("\\?")[0];
}
if (notification2Save.getUri() != null) {
if (notification2Save.getUri().split("\\?").length > 0) {
pathToVRE = notification2Save.getUri().split("\\?")[0];
}
}
_log.debug("editing hyperlinks for mail client");
removedMarkup = removedMarkup.replaceAll("href=\"/group/", "href=\""+portalURL + "/group/"); //because there is no indication of the portal (for mentions)
removedMarkup = removedMarkup.replace("href=\"?", "href=\""+portalURL + pathToVRE + "?"); //because there is no indication of the portal (for hashtags)
String sender = notification2Save.getSenderFullName();
String portalHost = portalURL.replaceAll("https://", "");
portalHost = portalHost.replaceAll("http://", "");
@ -86,7 +88,7 @@ public class SocialMailingUtil {
body.append("<div>").append(WRITE_ABOVE_MESSAGE_REPLY).append("</div><br />");
attachmentsNotice = "<br/><p>Please note that email replies do not support attachments.</p>";
}
String userProfileLink = new StringBuffer(getVREUrl(portalURL, vreName))
.append("/").append(getUserProfileLink(notification2Save.getSenderid())).toString();
@ -207,7 +209,7 @@ public class SocialMailingUtil {
case MESSAGE:
String messageSubject = (optionalParams != null && optionalParams.length > 0) ?
optionalParams[0] : notification2Save.getSenderFullName()+" sent you a message";
return messageSubject;
return messageSubject;
case WP_FOLDER_ADDEDUSER:
return "New user in a shared folder";
case WP_FOLDER_REMOVEDUSER:
@ -371,7 +373,7 @@ public class SocialMailingUtil {
buffer.append(" ");
}
}
if (node instanceof TextNode) {
TextNode textNode = (TextNode) node;
buffer.append(textNode.text().trim());
@ -408,8 +410,8 @@ public class SocialMailingUtil {
if (notification2Save.getType() == NotificationType.COMMENT ||
notification2Save.getType() == NotificationType.OWN_COMMENT ||
notification2Save.getType() == NotificationType.LIKE ||
notification2Save.getType() == NotificationType.MENTION){
notification2Save.getType() == NotificationType.LIKE ||
notification2Save.getType() == NotificationType.MENTION){
String htmlPost = "<br />" + "<br />----<p>Original post:</p>";
// data formatter
@ -419,8 +421,8 @@ public class SocialMailingUtil {
String postTextNoHtml = post.getDescription().replaceAll("&amp;", "&");
postTextNoHtml = postTextNoHtml.replaceAll("href=\"/group/", "href=\""+portalURL + "/group/"); //because there is no indication of the portal (for mentions)
postTextNoHtml = postTextNoHtml.replace("href=\"?", "href=\""+portalURL + pathToVRE + "?"); //because there is no indication of the portal (for hashtags)
// build up html post + comments
if(notification2Save.getType() == NotificationType.POST_ALERT || (comments.size() == 0 && notification2Save.getType() == NotificationType.MENTION))
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px;padding-left: 15px; "
@ -445,7 +447,7 @@ public class SocialMailingUtil {
if(comments != null)
for (int i = 0; i < comments.size(); i++) {
String commentTextNoHtml = comments.get(i).getText().replaceAll("&amp;", "&");
commentTextNoHtml = commentTextNoHtml.replaceAll("href=\"/group/", "href=\""+portalURL + "/group/"); //because there is no indication of the portal (for mentions)
commentTextNoHtml = commentTextNoHtml.replace("href=\"?", "href=\""+portalURL + pathToVRE + "?"); //because there is no indication of the portal (for hashtags)
@ -497,8 +499,8 @@ public class SocialMailingUtil {
if (notification2Save.getType() == NotificationType.COMMENT ||
notification2Save.getType() == NotificationType.OWN_COMMENT ||
notification2Save.getType() == NotificationType.LIKE ||
notification2Save.getType() == NotificationType.MENTION){
notification2Save.getType() == NotificationType.LIKE ||
notification2Save.getType() == NotificationType.MENTION){
// build discussion
String discussion = "\n\n----\n\nOriginal post:";
@ -564,7 +566,7 @@ public class SocialMailingUtil {
return "profile?"+ new String(
Base64.getEncoder().encodeToString(GCubePortalConstants.USER_PROFILE_OID.getBytes())+
"="+
new String( Base64.getEncoder().encodeToString(username.getBytes()) )
);
new String( Base64.getEncoder().encodeToString(username.getBytes()) )
);
}
}

Loading…
Cancel
Save