Group of people is now supported.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/social-networking/social-util-library@128818 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
59d03674ff
commit
4da6326f0b
4
.project
4
.project
|
@ -16,12 +16,12 @@
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
disabled=06target
|
||||||
|
eclipse.preferences.version=1
|
|
@ -17,9 +17,13 @@ import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||||
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
||||||
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
|
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
|
||||||
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.impl.LiferayGroupManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeTeam;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.htmlparser.beans.StringBean;
|
import org.htmlparser.beans.StringBean;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -47,51 +51,75 @@ public class Utils {
|
||||||
*
|
*
|
||||||
* @param session the Asl Session
|
* @param session the Asl Session
|
||||||
* @param withinPortal true when is on Liferay portal
|
* @param withinPortal true when is on Liferay portal
|
||||||
* @return the users belonging to the current organization (scope)
|
* @return the users plus the groups belonging to the current organization (scope)
|
||||||
*/
|
*/
|
||||||
public static ArrayList<ItemBean> getOrganizationUsers(String scope, String currUser, boolean withinPortal) {
|
public static ArrayList<ItemBean> getDisplayableItemBeans(String scope, String currUser, boolean withinPortal) {
|
||||||
ArrayList<ItemBean> portalUsers = new ArrayList<ItemBean>();
|
ArrayList<ItemBean> portalBeans = new ArrayList<ItemBean>();
|
||||||
try {
|
try {
|
||||||
if (withinPortal) {
|
if (withinPortal) {
|
||||||
UserManager um = new LiferayUserManager();
|
UserManager um = new LiferayUserManager();
|
||||||
GroupManager gm = new LiferayGroupManager();
|
GroupManager gm = new LiferayGroupManager();
|
||||||
|
RoleManager rm = new LiferayRoleManager();
|
||||||
ScopeBean sb = new ScopeBean(scope);
|
ScopeBean sb = new ScopeBean(scope);
|
||||||
List<GCubeUser> users = null;
|
List<GCubeUser> users = null;
|
||||||
|
List<GCubeTeam> teams = null;
|
||||||
|
|
||||||
if (sb.is(Type.INFRASTRUCTURE))
|
if (sb.is(Type.INFRASTRUCTURE)){
|
||||||
users = um.listUsersByGroup(gm.getRootVO().getGroupId());
|
users = um.listUsersByGroup(gm.getRootVO().getGroupId());
|
||||||
|
|
||||||
|
// we need to retrieve vres to whom the current user belongs and then retrieve their teams
|
||||||
|
List<GCubeGroup> groupsOfCurrentUser = gm.listGroupsByUser(um.getUserId(currUser));
|
||||||
|
|
||||||
|
teams = new ArrayList<GCubeTeam>();
|
||||||
|
|
||||||
|
// retrieve the teams of each group
|
||||||
|
for (GCubeGroup gCubeGroup : groupsOfCurrentUser) {
|
||||||
|
List<GCubeTeam> partialTeamList = rm.listTeamsByGroup(gCubeGroup.getGroupId());
|
||||||
|
if(partialTeamList != null && !partialTeamList.isEmpty())
|
||||||
|
teams.addAll(partialTeamList);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("Teams retrieved are " + teams);
|
||||||
|
|
||||||
|
}
|
||||||
else if (sb.is(Type.VRE)) { //must be in VRE
|
else if (sb.is(Type.VRE)) { //must be in VRE
|
||||||
//get the name from the scope
|
//get the name from the scope
|
||||||
String orgName = scope.substring(scope.lastIndexOf("/")+1, scope.length());
|
String orgName = scope.substring(scope.lastIndexOf("/")+1, scope.length());
|
||||||
//ask the users
|
//ask the users
|
||||||
users = um.listUsersByGroup(gm.getGroupId(orgName));
|
users = um.listUsersByGroup(gm.getGroupId(orgName));
|
||||||
|
// ask the teams
|
||||||
|
teams = rm.listTeamsByGroup(gm.getGroupId(orgName));
|
||||||
|
logger.debug("Teams retrieved are " + teams);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.error("Error, you must be in SCOPE VRE OR INFRASTURCTURE, you are in VO SCOPE returning no users");
|
logger.error("Error, you must be in SCOPE VRE OR INFRASTURCTURE, you are in VO SCOPE returning no users");
|
||||||
return portalUsers;
|
return portalBeans;
|
||||||
}
|
}
|
||||||
for (GCubeUser user : users) {
|
for (GCubeUser user : users) {
|
||||||
if (user.getUsername().compareTo("test.user") != 0 && user.getUsername().compareTo(currUser) != 0) { //skip test.user & current user
|
if (user.getUsername().compareTo("test.user") != 0 && user.getUsername().compareTo(currUser) != 0) { //skip test.user & current user
|
||||||
portalUsers.add(new ItemBean(user.getUserId()+"", user.getUsername(), user.getFullname(), user.getUserAvatarURL()));
|
portalBeans.add(new ItemBean(user.getUserId()+"", user.getUsername(), user.getFullname(), user.getUserAvatarURL()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (GCubeTeam gCubeTeam : teams) {
|
||||||
|
portalBeans.add(new ItemBean(gCubeTeam.getTeamId()+"", gCubeTeam.getTeamName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else { //test users
|
else { //test users
|
||||||
portalUsers.add(new ItemBean("12111", "massimiliano.assante", "Test User #1", ""));
|
portalBeans.add(new ItemBean("12111", "massimiliano.assante", "Test User #1", ""));
|
||||||
portalUsers.add(new ItemBean("14111", "massimiliano.assante", "Test Second User #2", ""));
|
portalBeans.add(new ItemBean("14111", "massimiliano.assante", "Test Second User #2", ""));
|
||||||
portalUsers.add(new ItemBean("11511", "massimiliano.assante", "Test Third User", ""));
|
portalBeans.add(new ItemBean("11511", "massimiliano.assante", "Test Third User", ""));
|
||||||
portalUsers.add(new ItemBean("11611", "massimiliano.assante", "Test Fourth User", ""));
|
portalBeans.add(new ItemBean("11611", "massimiliano.assante", "Test Fourth User", ""));
|
||||||
portalUsers.add(new ItemBean("11711", "massimiliano.assante", "Test Fifth User", ""));
|
portalBeans.add(new ItemBean("11711", "massimiliano.assante", "Test Fifth User", ""));
|
||||||
portalUsers.add(new ItemBean("11811", "massimiliano.assante", "Test Sixth User", ""));
|
portalBeans.add(new ItemBean("11811", "massimiliano.assante", "Test Sixth User", ""));
|
||||||
portalUsers.add(new ItemBean("15811", "massimiliano.assante", "Ninth Testing User", ""));
|
portalBeans.add(new ItemBean("15811", "massimiliano.assante", "Ninth Testing User", ""));
|
||||||
portalUsers.add(new ItemBean("15811", "massimiliano.assante", "Eighth Testing User", ""));
|
portalBeans.add(new ItemBean("15811", "massimiliano.assante", "Eighth Testing User", ""));
|
||||||
portalUsers.add(new ItemBean("11211", "giogio.giorgi", "Seventh Test User", ""));
|
portalBeans.add(new ItemBean("11211", "giogio.giorgi", "Seventh Test User", ""));
|
||||||
portalUsers.add(new ItemBean("2222", "pino.pinetti", "Tenth Testing User", ""));
|
portalBeans.add(new ItemBean("2222", "pino.pinetti", "Tenth Testing User", ""));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error in server get all contacts ", e);
|
logger.error("Error in server get all contacts ", e);
|
||||||
}
|
}
|
||||||
return portalUsers;
|
return portalBeans;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,20 +247,41 @@ public class Utils {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* convert the mentioned people in HTML anchor and also Encode the params Base64
|
* convert the mentioned people in HTML anchor and also Encode the params Base64
|
||||||
* @param escapedFeedText
|
* @param escapedFeedText
|
||||||
* @param taggedPeople
|
* @param taggedPeople
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList<ItemBean> taggedPeople, HttpServletRequest request) {
|
public static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList<ItemBean> taggedPeople, HttpServletRequest request) {
|
||||||
String userProfilePageURL = "";
|
String pageToRedirectURL = "";
|
||||||
userProfilePageURL = PortalContext.getConfiguration().getSiteLandingPagePath(request)+GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
|
String httpGETAttrName = "";
|
||||||
|
String httpGETAttrValue ="";
|
||||||
|
|
||||||
for (ItemBean tagged : taggedPeople) {
|
for (ItemBean tagged : taggedPeople) {
|
||||||
String taggedHTML = "<a class=\"link\" href=\""+userProfilePageURL
|
if (! tagged.isItemGroup()) {
|
||||||
|
pageToRedirectURL = PortalContext.getConfiguration().getSiteLandingPagePath(request)+GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
|
||||||
|
httpGETAttrName = GCubeSocialNetworking.USER_PROFILE_OID;
|
||||||
|
httpGETAttrValue = tagged.getName();
|
||||||
|
} else {
|
||||||
|
long teamId = Long.parseLong(tagged.getId());
|
||||||
|
try {
|
||||||
|
GCubeTeam theTeam = new LiferayRoleManager().getTeam(teamId);
|
||||||
|
//returns the VRE url e.g. /group/devVRE
|
||||||
|
String vreURL = new LiferayGroupManager().getGroup(theTeam.getGroupId()).getFriendlyURL();
|
||||||
|
//append the members url
|
||||||
|
pageToRedirectURL= vreURL + GCubePortalConstants.GROUP_MEMBERS_FRIENDLY_URL;
|
||||||
|
httpGETAttrName = GCubeSocialNetworking.GROUP_MEMBERS_OID;
|
||||||
|
httpGETAttrValue = tagged.getId();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String taggedHTML = "<a class=\"link\" href=\""+pageToRedirectURL
|
||||||
+"?"+
|
+"?"+
|
||||||
new String(Base64.encodeBase64(GCubeSocialNetworking.USER_PROFILE_OID.getBytes()))+"="+
|
new String(Base64.encodeBase64(httpGETAttrName.getBytes()))+"="+
|
||||||
new String(Base64.encodeBase64(tagged.getName().getBytes()))+"\">"+tagged.getAlternativeName()+"</a> ";
|
new String(Base64.encodeBase64(httpGETAttrValue.getBytes()))+"\">"+tagged.getAlternativeName()+"</a> ";
|
||||||
escapedFeedText = escapedFeedText.replace(tagged.getAlternativeName(), taggedHTML);
|
escapedFeedText = escapedFeedText.replace(tagged.getAlternativeName(), taggedHTML);
|
||||||
}
|
}
|
||||||
return escapedFeedText;
|
return escapedFeedText;
|
||||||
|
|
Loading…
Reference in New Issue