for exploratory and apps the direct VRE Url is passed if the member belongs to the VRE, the page to ask for registration on this VRE othwerise
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/sbd-uploadshare-portlet@164627 82a268e6-3cf1-43bd-a215-b396298e98cfmaster
parent
43e62f42d5
commit
1663600037
@ -0,0 +1,36 @@
|
||||
package org.gcube.portlets.user.sbd;
|
||||
|
||||
import org.gcube.common.portal.GCubePortalConstants;
|
||||
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.model.User;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
|
||||
public class Utils {
|
||||
private static Log _log = LogFactoryUtil.getLog(Utils.class);
|
||||
/**
|
||||
*
|
||||
* @param currentUser
|
||||
* @param urlContainingGroupId
|
||||
* @return the direct VRE Url if the member belongs to the VRE, the page to ask for registration on this VRE othwerise
|
||||
*/
|
||||
public static String getVREFriendlyURL(User currentUser, String urlContainingGroupId) {
|
||||
String[] splits = urlContainingGroupId.split("=");
|
||||
long groupId = -1;
|
||||
try {
|
||||
if (splits.length > 0) {
|
||||
groupId = Long.parseLong(splits[1]);
|
||||
long[] userGroupIds = currentUser.getGroupIds();
|
||||
for (int i = 0; i < userGroupIds.length; i++) {
|
||||
if (groupId == userGroupIds[i])
|
||||
return GCubePortalConstants.PREFIX_GROUP_URL +GroupLocalServiceUtil.getGroup(groupId).getFriendlyURL();
|
||||
}
|
||||
}
|
||||
return urlContainingGroupId;
|
||||
} catch (Exception e) {
|
||||
_log.error("Something is wrong in the url passed: " + urlContainingGroupId);
|
||||
return urlContainingGroupId;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue