minor fix for vre's teams mentions
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@141947 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a094714ee0
commit
e4aa59ec06
|
@ -5,9 +5,6 @@
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<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"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
<dependent-module archiveName="gcube-widgets-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
|
||||||
<dependency-type>uses</dependency-type>
|
|
||||||
</dependent-module>
|
|
||||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||||
<property name="context-root" value="share-updates"/>
|
<property name="context-root" value="share-updates"/>
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
|
@ -10,10 +10,12 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
@ -54,6 +56,7 @@ import org.gcube.portlets.user.shareupdates.shared.UserSettings;
|
||||||
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
|
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
|
||||||
import org.gcube.social_networking.socialutillibrary.Utils;
|
import org.gcube.social_networking.socialutillibrary.Utils;
|
||||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.TeamRetrievalFault;
|
import org.gcube.vomanagement.usermanagement.exception.TeamRetrievalFault;
|
||||||
|
@ -86,12 +89,15 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
private DatabookStore store;
|
private DatabookStore store;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* connect to cassandra at startup
|
* Connect to cassandra at startup
|
||||||
*/
|
*/
|
||||||
public void init() {
|
public void init() {
|
||||||
store = new DBCassandraAstyanaxImpl();
|
store = new DBCassandraAstyanaxImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close connection pool on close
|
||||||
|
*/
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
store.closeConnection();
|
store.closeConnection();
|
||||||
}
|
}
|
||||||
|
@ -209,7 +215,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
|
|
||||||
|
|
||||||
// check if is needed to notify people in the vre
|
// check if is needed to notify people in the vre
|
||||||
notifyPeopleGroup(pLevel, vreOrgId, notifyGroup, username, email, fullName, thumbnailAvatarURL, toShare, hashtags, vreScope2Set, escapedFeedText);
|
notifyPeopleGroup(pLevel, vreOrgId, notifyGroup, username, email, fullName, thumbnailAvatarURL, toShare, hashtags, vreScope2Set, escapedFeedText, mentionedUsers);
|
||||||
|
|
||||||
//send the notification to the mentioned users
|
//send the notification to the mentioned users
|
||||||
if (mentionedUsers != null && mentionedUsers.size() > 0)
|
if (mentionedUsers != null && mentionedUsers.size() > 0)
|
||||||
|
@ -384,7 +390,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
|
|
||||||
|
|
||||||
// check if is needed to notify people in the vre
|
// check if is needed to notify people in the vre
|
||||||
notifyPeopleGroup(pLevel, vreOrgId, notifyGroup, username, email, fullName, thumbnailAvatarURL, toShare, hashtags, vreScope2Set, textToPost);
|
notifyPeopleGroup(pLevel, vreOrgId, notifyGroup, username, email, fullName, thumbnailAvatarURL, toShare, hashtags, vreScope2Set, textToPost, mentionedUsers);
|
||||||
|
|
||||||
//send the notification to the mentioned users
|
//send the notification to the mentioned users
|
||||||
if (mentionedUsers != null && mentionedUsers.size() > 0)
|
if (mentionedUsers != null && mentionedUsers.size() > 0)
|
||||||
|
@ -416,7 +422,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
private void notifyPeopleGroup(PrivacyLevel pLevel, Long vreOrgId,
|
private void notifyPeopleGroup(PrivacyLevel pLevel, Long vreOrgId,
|
||||||
boolean notifyGroup, String username, String email,
|
boolean notifyGroup, String username, String email,
|
||||||
String fullName, String thumbnailAvatarURL, Feed toShare,
|
String fullName, String thumbnailAvatarURL, Feed toShare,
|
||||||
List<String> hashtags, String vreScope2Set, String postText) {
|
List<String> hashtags, String vreScope2Set, String postText, ArrayList<ItemBean> mentionedUsers) {
|
||||||
|
|
||||||
//send the notification about this posts to everyone in the group if notifyGroup is true
|
//send the notification about this posts to everyone in the group if notifyGroup is true
|
||||||
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) {
|
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) {
|
||||||
|
@ -425,7 +431,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
vreScope2Set,
|
vreScope2Set,
|
||||||
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
|
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
|
||||||
NEWS_FEED_PORTLET_CLASSNAME);
|
NEWS_FEED_PORTLET_CLASSNAME);
|
||||||
Thread thread = new Thread(new PostNotificationsThread(toShare.getKey(), postText, ""+vreOrgId, nm, hashtags));
|
Thread thread = new Thread(new PostNotificationsThread(new LiferayUserManager(), toShare.getKey(), postText, ""+vreOrgId, nm, new HashSet<String>(hashtags), getVreGroupsNames(mentionedUsers)));
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -449,6 +455,28 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract mentioned VRE's group names
|
||||||
|
* @return Set<String> of vre groups' names
|
||||||
|
*/
|
||||||
|
private static Set<String> getVreGroupsNames(ArrayList<ItemBean> mentionedUsers){
|
||||||
|
|
||||||
|
Set<String> toReturn = new HashSet<String>();
|
||||||
|
RoleManager rManager = new LiferayRoleManager();
|
||||||
|
for (ItemBean itemBean : mentionedUsers) {
|
||||||
|
|
||||||
|
if(itemBean.isItemGroup())
|
||||||
|
try {
|
||||||
|
toReturn.add(rManager.getTeam(Long.parseLong(itemBean.getId())).getTeamName());
|
||||||
|
} catch (NumberFormatException | UserManagementSystemException
|
||||||
|
| TeamRetrievalFault e) {
|
||||||
|
_log.warn("Unable to add this team", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common method to notify users.
|
* Common method to notify users.
|
||||||
|
|
Loading…
Reference in New Issue