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-b396298e98cf
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,5 +7,4 @@ import com.liferay.util.bridges.mvc.MVCPortlet;
|
|||
*/
|
||||
public class AccessExploratory extends MVCPortlet {
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<%@include file="init.jsp"%>
|
||||
<%@ page import="org.gcube.portlets.user.sbd.Utils" %>
|
||||
<%@ page import="com.liferay.portal.model.User" %>
|
||||
<%@ page import="com.liferay.portal.util.PortalUtil" %>
|
||||
|
||||
<%
|
||||
long groupId = themeDisplay.getLayout().getGroupId();
|
||||
User currentUser = PortalUtil.getUser( request );
|
||||
pageContext.setAttribute("icondocURL",
|
||||
GetterUtil.getString(portletPreferences.getValue("icondocURL", StringPool.BLANK)));
|
||||
|
||||
|
@ -18,12 +23,15 @@
|
|||
long applicationName3DocumentId = GetterUtil
|
||||
.getLong(portletPreferences.getValue("applicationName3-DocumentId", StringPool.BLANK));
|
||||
|
||||
pageContext.setAttribute("application1Url",
|
||||
GetterUtil.getString(portletPreferences.getValue("application1-Url", StringPool.BLANK)));
|
||||
pageContext.setAttribute("application2Url",
|
||||
GetterUtil.getString(portletPreferences.getValue("application2-Url", StringPool.BLANK)));
|
||||
pageContext.setAttribute("application3Url",
|
||||
GetterUtil.getString(portletPreferences.getValue("application3-Url", StringPool.BLANK)));
|
||||
|
||||
String url1 = GetterUtil.getString(portletPreferences.getValue("application1-Url", StringPool.BLANK));
|
||||
pageContext.setAttribute("application1Url", Utils.getVREFriendlyURL(currentUser, url1));
|
||||
|
||||
String url2 = GetterUtil.getString(portletPreferences.getValue("application2-Url", StringPool.BLANK));
|
||||
pageContext.setAttribute("application2Url", Utils.getVREFriendlyURL(currentUser, url2));
|
||||
|
||||
String url3 = GetterUtil.getString(portletPreferences.getValue("application3-Url", StringPool.BLANK));
|
||||
pageContext.setAttribute("application3Url", Utils.getVREFriendlyURL(currentUser, url3));
|
||||
|
||||
String content1 = "";
|
||||
if (applicationName1DocumentId > 0) {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
<%@include file="init.jsp"%>
|
||||
<%@ page import="org.gcube.portlets.user.sbd.Utils" %>
|
||||
<%@ page import="com.liferay.portal.model.User" %>
|
||||
<%@ page import="com.liferay.portal.util.PortalUtil" %>
|
||||
|
||||
<%
|
||||
long groupId = themeDisplay.getLayout().getGroupId();
|
||||
User currentUser = PortalUtil.getUser( request );
|
||||
|
||||
pageContext.setAttribute("icondocURL",
|
||||
GetterUtil.getString(portletPreferences.getValue("icondocURL", StringPool.BLANK)));
|
||||
|
||||
|
@ -18,12 +24,14 @@
|
|||
long exploratoryName3DocumentId = GetterUtil
|
||||
.getLong(portletPreferences.getValue("exploratoryName3-DocumentId", StringPool.BLANK));
|
||||
|
||||
pageContext.setAttribute("exploratory1Url",
|
||||
GetterUtil.getString(portletPreferences.getValue("exploratory1-Url", StringPool.BLANK)));
|
||||
pageContext.setAttribute("exploratory2Url",
|
||||
GetterUtil.getString(portletPreferences.getValue("exploratory2-Url", StringPool.BLANK)));
|
||||
pageContext.setAttribute("exploratory3Url",
|
||||
GetterUtil.getString(portletPreferences.getValue("exploratory3-Url", StringPool.BLANK)));
|
||||
String url1 = GetterUtil.getString(portletPreferences.getValue("exploratory1-Url", StringPool.BLANK));
|
||||
pageContext.setAttribute("exploratory1Url", Utils.getVREFriendlyURL(currentUser, url1));
|
||||
|
||||
String url2 = GetterUtil.getString(portletPreferences.getValue("exploratory2-Url", StringPool.BLANK));
|
||||
pageContext.setAttribute("exploratory2Url", Utils.getVREFriendlyURL(currentUser, url2));
|
||||
|
||||
String url3 = GetterUtil.getString(portletPreferences.getValue("exploratory3-Url", StringPool.BLANK));
|
||||
pageContext.setAttribute("exploratory3Url", Utils.getVREFriendlyURL(currentUser, url3));
|
||||
|
||||
String content1 = "";
|
||||
if (exploratoryName1DocumentId > 0) {
|
||||
|
|
Loading…
Reference in New Issue