fix for ticket #1911
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@78905 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e7b89c36bd
commit
28ab028a07
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/share-updates-0.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/share-updates-0.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -31,5 +31,5 @@
|
|||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/share-updates-0.4.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/share-updates-0.5.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#Sun Jun 02 00:32:02 CEST 2013
|
||||
#Wed Jul 10 16:38:29 CEST 2013
|
||||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/share-updates/target/share-updates-0.4.0-SNAPSHOT
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/share-updates/target/share-updates-0.5.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
<dependent-module archiveName="pickuser-widget-0.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickuser-widget/pickuser-widget">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="share-updates"/>
|
||||
</wb-module>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>share-updates</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>0.4.0-SNAPSHOT</version>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
|
||||
<name>gCube Share Updates Portlet</name>
|
||||
<description>
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
|
||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
||||
import org.gcube.portlets.user.pickuser.shared.PickingUser;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -16,22 +17,22 @@ public class MentionNotificationsThread implements Runnable {
|
|||
private String postText;
|
||||
private String postId;
|
||||
private NotificationsManager nm;
|
||||
private ArrayList<String> userIds;
|
||||
private ArrayList<PickingUser> users;
|
||||
|
||||
|
||||
public MentionNotificationsThread(String postId, String postText, NotificationsManager nm, ArrayList<String> userIds) {
|
||||
public MentionNotificationsThread(String postId, String postText, NotificationsManager nm, ArrayList<PickingUser> users) {
|
||||
super();
|
||||
this.postId = postId;
|
||||
this.postText = postText;
|
||||
this.nm = nm;
|
||||
this.userIds = userIds;
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (String userIdToNotify : userIds) {
|
||||
boolean result = nm.notifyUserTag(userIdToNotify, postId, postText);
|
||||
_log.trace("Sending Notification for post mention to: " + userIdToNotify + " result?"+ result);
|
||||
for (PickingUser userToNotify : users) {
|
||||
boolean result = nm.notifyUserTag(userToNotify.getUsername(), postId, postText);
|
||||
_log.trace("Sending Notification for post mention to: " + userToNotify.getUsername() + " result?"+ result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
|||
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
||||
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
||||
import org.gcube.portal.databook.server.DatabookStore;
|
||||
import org.gcube.portal.databook.shared.ClientFeed;
|
||||
|
@ -124,9 +125,18 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public ClientFeed share(String postText, FeedType feedType, PrivacyLevel pLevel, String vreId, String linkTitle, String linkDesc, String url, String urlThumbnail, String host, ArrayList<String> mentionedUserFullNames) {
|
||||
public ClientFeed share(String postText, FeedType feedType, PrivacyLevel pLevel,
|
||||
String vreId, String linkTitle, String linkDesc, String url, String urlThumbnail, String host, ArrayList<String> mentionedUserFullNames) {
|
||||
|
||||
String escapedFeedText = escapeHtml(postText);
|
||||
|
||||
ArrayList<PickingUser> mentionedUsers = null;
|
||||
if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) {
|
||||
mentionedUsers = getSelectedUserIds(mentionedUserFullNames);
|
||||
escapedFeedText = convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers);
|
||||
}
|
||||
|
||||
|
||||
ASLSession session = getASLSession();
|
||||
String username = session.getUsername();
|
||||
String email = username+"@isti.cnr.it";
|
||||
|
@ -184,10 +194,10 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
toShare.getUriThumbnail(), toShare.getLinkHost());
|
||||
|
||||
//send the notification to the mentioned users
|
||||
ArrayList<String> mentionedUserIds = getSelectedUserIds(mentionedUserFullNames);
|
||||
if (mentionedUserIds != null && mentionedUserIds.size() > 0) {
|
||||
|
||||
if (mentionedUsers != null && mentionedUsers.size() > 0) {
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(session);
|
||||
Thread thread = new Thread(new MentionNotificationsThread(toShare.getKey(), escapedFeedText, nm, mentionedUserIds));
|
||||
Thread thread = new Thread(new MentionNotificationsThread(toShare.getKey(), escapedFeedText, nm, mentionedUsers));
|
||||
thread.start();
|
||||
}
|
||||
|
||||
|
@ -195,7 +205,13 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
|
||||
}
|
||||
|
||||
|
||||
private String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList<PickingUser> taggedPeople) {
|
||||
for (PickingUser tagged : taggedPeople) {
|
||||
String taggedHTML = "<a class=\"link\" style=\"font-size:14px;\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"?uid="+ tagged.getUsername() + "\">"+tagged.getFullName()+"</a> ";
|
||||
escapedFeedText = escapedFeedText.replace(tagged.getFullName(), taggedHTML);
|
||||
}
|
||||
return escapedFeedText;
|
||||
}
|
||||
|
||||
private UserSettings getUserSettingsFromSession() {
|
||||
return (UserSettings) getASLSession().getAttribute(UserInfo.USER_INFO_ATTR);
|
||||
|
@ -617,16 +633,16 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
*
|
||||
* @return the screennames of the addressee (user logins e.g. pino.pini)
|
||||
*/
|
||||
public ArrayList<String> getSelectedUserIds(ArrayList<String> fullNames) {
|
||||
public ArrayList<PickingUser> getSelectedUserIds(ArrayList<String> fullNames) {
|
||||
if (fullNames == null)
|
||||
return new ArrayList<String>();
|
||||
return new ArrayList<PickingUser>();
|
||||
else {
|
||||
ArrayList<PickingUser> allUsers = getPortalUsers();
|
||||
ArrayList<String> toReturn = new ArrayList<String>();
|
||||
ArrayList<PickingUser> toReturn = new ArrayList<PickingUser>();
|
||||
for (String fullName : fullNames)
|
||||
for (PickingUser puser : allUsers) {
|
||||
if (puser.getFullName().compareTo(fullName) == 0) {
|
||||
toReturn.add(puser.getUsername());
|
||||
toReturn.add(puser);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue