added feature recognising the gateway URL from the name
minor css adjustments
This commit is contained in:
parent
4088666593
commit
aea46e7d4b
|
@ -1,6 +1,8 @@
|
||||||
package org.gcube.portlets.user.vreyard;
|
package org.gcube.portlets.user.vreyard;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.portlet.PortletException;
|
import javax.portlet.PortletException;
|
||||||
import javax.portlet.RenderRequest;
|
import javax.portlet.RenderRequest;
|
||||||
|
@ -10,9 +12,19 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.DetachedREsClient;
|
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.DetachedREsClient;
|
||||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs;
|
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs;
|
||||||
|
import org.gcube.portlets.user.thematicgateways.Gateway;
|
||||||
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.util.ManagementUtils;
|
||||||
|
|
||||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||||
import com.liferay.portal.kernel.util.PrefsPropsUtil;
|
import com.liferay.portal.kernel.util.PrefsPropsUtil;
|
||||||
|
import com.liferay.portal.model.Group;
|
||||||
|
import com.liferay.portal.model.LayoutSet;
|
||||||
|
import com.liferay.portal.model.VirtualHost;
|
||||||
|
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||||
|
import com.liferay.portal.service.LayoutSetLocalServiceUtil;
|
||||||
|
import com.liferay.portal.service.VirtualHostLocalServiceUtil;
|
||||||
import com.liferay.portal.util.PortalUtil;
|
import com.liferay.portal.util.PortalUtil;
|
||||||
import com.liferay.util.bridges.mvc.MVCPortlet;
|
import com.liferay.util.bridges.mvc.MVCPortlet;
|
||||||
|
|
||||||
|
@ -27,11 +39,6 @@ public class VreYard extends MVCPortlet {
|
||||||
public static final String DEFAULT_CONTEXT_PROPERTY = "d4science.publicportlets.context";
|
public static final String DEFAULT_CONTEXT_PROPERTY = "d4science.publicportlets.context";
|
||||||
public static final String DEFAULT_TOKEN_PROPERTY = "d4science.publicportlets.token";
|
public static final String DEFAULT_TOKEN_PROPERTY = "d4science.publicportlets.token";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final String DEFAULT_SCOPE_PROPERTY = "/d4science.research-infrastructures.eu/";
|
|
||||||
public static final String DEFAULT_TOKEN = "8effc529-44ec-4895-b727-ed0dc14ad113-843339462";
|
|
||||||
|
|
||||||
public static final String DEFAULT_ROLE = "OrganizationMember";
|
public static final String DEFAULT_ROLE = "OrganizationMember";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,5 +66,47 @@ public class VreYard extends MVCPortlet {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gatewayName e.g.DESIRA Gateway
|
||||||
|
* @return the url of the gateway that matches the name, or null there is no match
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String getGatewayHTTPURLByName(String gatewayName) throws Exception {
|
||||||
|
List<Gateway> theGateways = getGateways(new LiferayGroupManager());
|
||||||
|
List<VirtualHost> vHosts = VirtualHostLocalServiceUtil.getVirtualHosts(0, VirtualHostLocalServiceUtil.getVirtualHostsCount());
|
||||||
|
for (Gateway gateway : theGateways) {
|
||||||
|
if (gateway.getSite().getName().compareToIgnoreCase(gatewayName) == 0) {
|
||||||
|
LayoutSet lSet = LayoutSetLocalServiceUtil.getLayoutSet(gateway.getSite().getGroupId(), false);
|
||||||
|
for (VirtualHost vHost : vHosts) {
|
||||||
|
long layoutSetId = vHost.getLayoutSetId();
|
||||||
|
if (lSet.getLayoutSetId() == layoutSetId) {
|
||||||
|
return "https://"+vHost.getHostname()+"/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Gateway> getGateways(GroupManager groupsManager) {
|
||||||
|
List<Gateway> toReturn = new ArrayList<>();
|
||||||
|
try{
|
||||||
|
List<Group> candidateGateways = GroupLocalServiceUtil.getGroups(ManagementUtils.getCompany().getCompanyId(), 0, true);
|
||||||
|
// real gateways have no children as well
|
||||||
|
for (Group group : candidateGateways) {
|
||||||
|
List<Group> children = group.getChildren(true);
|
||||||
|
if(children == null || children.isEmpty())
|
||||||
|
if(! (group.getFriendlyURL().equals("/guest") || group.getFriendlyURL().equals("/global") )) {// skipping these sites
|
||||||
|
ArrayList<String> theVRENames = new ArrayList<>();
|
||||||
|
toReturn.add(new Gateway(group, theVRENames));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(Exception e){
|
||||||
|
_log.error("Failed to retrieve the list of gateways", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,10 @@ div.vre-yard-portlet h1 {
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
line-height: 25px;
|
line-height: 25px;
|
||||||
color: #555;
|
color: #555;
|
||||||
|
font-weight: 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.vre-yard-portlet h1 > small {
|
div.vre-yard-portlet h1 > small {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
font-weight: 200;
|
||||||
}
|
}
|
|
@ -48,12 +48,15 @@
|
||||||
<%@ page import="com.liferay.portal.webserver.WebServerServletTokenUtil" %>
|
<%@ page import="com.liferay.portal.webserver.WebServerServletTokenUtil" %>
|
||||||
<%@ page import="com.liferay.portal.service.VirtualHostLocalServiceUtil" %>
|
<%@ page import="com.liferay.portal.service.VirtualHostLocalServiceUtil" %>
|
||||||
<%@ page import="org.gcube.portlets.user.thematicgateways.*" %>
|
<%@ page import="org.gcube.portlets.user.thematicgateways.*" %>
|
||||||
|
<%@ page import="org.gcube.portlets.user.vreyard.VreYard" %>
|
||||||
<%@ page import="org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs"%>
|
<%@ page import="org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs"%>
|
||||||
<%@ page import="org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.Gateway"%>
|
<%@ page import="org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.Gateway"%>
|
||||||
<%@ page import="org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VO"%>
|
<%@ page import="org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VO"%>
|
||||||
<%@ page import="org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE"%>
|
<%@ page import="org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE"%>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<portlet:defineObjects />
|
<portlet:defineObjects />
|
||||||
<liferay-theme:defineObjects />
|
<liferay-theme:defineObjects />
|
||||||
<theme:defineObjects />
|
<theme:defineObjects />
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
</script>
|
</script>
|
||||||
<p class="lead">We couldn't find the page you were looking
|
<p class="lead">We couldn't find the page you were looking
|
||||||
for, perhaps you were interested in one of the following Virtual
|
for, perhaps you were interested in one of the following Virtual
|
||||||
Research Environment, that have been hosted on D4Science in the past.</p>
|
Research Environments, that have been hosted on D4Science in the past.</p>
|
||||||
<div class="vre-yard-portlet">
|
<div class="vre-yard-portlet">
|
||||||
<%
|
<%
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
@ -32,9 +32,14 @@
|
||||||
pageContext.setAttribute("gatewayVREs", gatewayVREs);
|
pageContext.setAttribute("gatewayVREs", gatewayVREs);
|
||||||
|
|
||||||
String gatewayDisplayName = gateway.getName().replace("Detached ", "");
|
String gatewayDisplayName = gateway.getName().replace("Detached ", "");
|
||||||
|
String gatewayURL = VreYard.getGatewayHTTPURLByName(gatewayDisplayName);
|
||||||
|
if (gatewayURL != null) {
|
||||||
%>
|
%>
|
||||||
|
<h1><a target="_blank" href="<%=gatewayURL%>"><%=gatewayDisplayName%></a><br> <small><%=gateway.getDescription()%></small>
|
||||||
|
<%}
|
||||||
|
else {%>
|
||||||
<h1><%=gatewayDisplayName%><br> <small><%=gateway.getDescription()%></small>
|
<h1><%=gatewayDisplayName%><br> <small><%=gateway.getDescription()%></small>
|
||||||
|
<%} %>
|
||||||
</h1>
|
</h1>
|
||||||
<div style="width: 100%; text-align: left;">
|
<div style="width: 100%; text-align: left;">
|
||||||
<table>
|
<table>
|
||||||
|
|
Loading…
Reference in New Issue