added VRE Yard page

This commit is contained in:
Massimiliano Assante 2020-10-09 15:56:10 +02:00
parent 32ae6ee2cc
commit 2e2b84cb9c
11 changed files with 247 additions and 9 deletions

View File

@ -6,11 +6,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false

13
pom.xml
View File

@ -13,13 +13,13 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>thematic-gateways-portlet</artifactId>
<packaging>war</packaging>
<name>thematic-gateways-portlet Portlet</name>
<version>7.0.0</version>
<name>thematic-gateways-portlet Portlets</name>
<version>7.1.0-SNAPSHOT</version>
<description>
Thematic Gateways Portlet
</description>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/thematic-gateways-portlet.git</connection>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/thematic-gateways-portlet.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/thematic-gateways-portlet.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/thematic-gateways-portlet</url>
</scm>
@ -39,13 +39,18 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>LATEST</version>
<version>3.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.infrastructure.detachedres</groupId>
<artifactId>detachedres-library</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>

View File

@ -0,0 +1,95 @@
package org.gcube.portlets.user.vreyard;
import java.io.IOException;
import java.util.List;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.PrefsPropsUtil;
import com.liferay.portal.util.PortalUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.DetachedREsClient;
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.DetachedREsJAXB;
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.GatewayJAXB;
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.VOJAXB;
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.VREJAXB;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.Gateway;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VO;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE;
/**
* Portlet implementation class VreYard
*/
public class VreYard extends MVCPortlet {
private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil.getLog(VreYard.class);
//these props are read from portal.ext.properties file
public static final String DEFAULT_USER_PROPERTY = "d4science.publicportlets.user";
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_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";
@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
try {
String context = PrefsPropsUtil.getString(PortalUtil.getCompanyId(renderRequest), DEFAULT_CONTEXT_PROPERTY);
String token = PrefsPropsUtil.getString(PortalUtil.getCompanyId(renderRequest), DEFAULT_TOKEN_PROPERTY);
ScopeProvider.instance.set(context);
SecurityTokenProvider.instance.set(token);
DetachedREsClient detachedREsClient = new DetachedREsClient();
DetachedREs detachedREs = detachedREsClient.getDetachedREs();
renderRequest.setAttribute("thedetachedREs", detachedREs);
int totalVREDimissed = 0;
for (Gateway gateway : detachedREs.getGateways().values()) {
_log.info("\n\n");
_log.info("Gateway: " + gateway.getName() + " \nDesc:\n" + gateway.getDescription().trim());
int vreDismissedPerGatew = 0;
for (VO vo : gateway.getVos().values()) {
_log.debug("VO: " + vo.getName());
for (VRE vre : vo.getVres().values()) {
_log.info("VRE name: " + vre.getName() + "\ndescription: " + vre.getDescription().trim()
+ "\nVRE catalogue url: " + vre.getCatalogUrl() + " VRE catalog Portlet URL: "
+ vre.getCatalogPortletURL());
vreDismissedPerGatew++;
}
}
_log.info("\n\t\t\t******** VREs dismissed per " + gateway.getName() + " are: "
+ vreDismissedPerGatew);
totalVREDimissed += vreDismissedPerGatew;
}
_log.debug("\n\nTotal VREs dismissed: " + totalVREDimissed);
} catch (Exception e) {
_log.error(e.getLocalizedMessage(), e);
}
//renderRequest.setAttribute("theGateways", theGateways);
super.render(renderRequest, renderResponse);
}
}

View File

@ -4,5 +4,6 @@
<display>
<category name="gCube Applications">
<portlet id="thematic-gateways-portlet"></portlet>
<portlet id="vre-yard"></portlet>
</category>
</display>

View File

@ -12,6 +12,16 @@
</footer-portlet-javascript>
<css-class-wrapper>thematic-gateways-portlet</css-class-wrapper>
</portlet>
<portlet>
<portlet-name>vre-yard</portlet-name>
<icon>/icon.png</icon>
<header-portlet-css>/css/main.css</header-portlet-css>
<header-portlet-css>/css/jquery-ui.min.css</header-portlet-css>
<footer-portlet-javascript>
/js/main.js
</footer-portlet-javascript>
<css-class-wrapper>vre-yard-portlet</css-class-wrapper>
</portlet>
<role-mapper>
<role-name>administrator</role-name>
<role-link>Administrator</role-link>

View File

@ -34,4 +34,37 @@
<role-name>user</role-name>
</security-role-ref>
</portlet>
<portlet>
<portlet-name>vre-yard</portlet-name>
<display-name>Vre Yard</display-name>
<portlet-class>
org.gcube.portlets.user.vreyard.VreYard
</portlet-class>
<init-param>
<name>view-template</name>
<value>/html/vreyard/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>Oops ... we couldn't find the page!</title>
<short-title>Oops!</short-title>
<keywords></keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
</portlet-app>

7
src/main/webapp/css/jquery-ui.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
span.entry-description {
font-size: 1.3em;
}
@ -8,4 +9,15 @@ span.entry-title-text {
div.app-view-entry-taglib .entry-thumbnail img {
max-width: 90px;
}
div.vre-yard-portlet h1 {
margin-top: 50px;
font-size: 2em;
line-height: 25px;
color: #555;
}
div.vre-yard-portlet h1 > small {
font-size: 15px;
}

View File

@ -48,6 +48,10 @@
<%@ page import="com.liferay.portal.webserver.WebServerServletTokenUtil" %>
<%@ page import="com.liferay.portal.service.VirtualHostLocalServiceUtil" %>
<%@ page import="org.gcube.portlets.user.thematicgateways.*" %>
<%@ 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.VO"%>
<%@ page import="org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE"%>
<portlet:defineObjects />

View File

@ -0,0 +1,74 @@
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@include file="../init.jsp"%>
<portlet:defineObjects />
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(function() {
$('.vreInfo').tooltip();
});
</script>
<p class="lead">We couldn't find the page you were looking
for, perhaps you were interested in one of the following Virtual
Research Environment, that have been hosted on D4Science in the past.</p>
<div class="vre-yard-portlet">
<%
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdfToDisplay = new SimpleDateFormat("dd MMM yyyy");
DetachedREs detachedREs = (DetachedREs) request.getAttribute("thedetachedREs");
for (Gateway gateway : detachedREs.getGateways().values()) {
List<VRE> gatewayVREs = new ArrayList<VRE>();
for (VO vo : gateway.getVos().values()) {
for (VRE vre : vo.getVres().values()) {
Date date = sdf.parse(vre.getStartDate());
vre.setStartDate(sdfToDisplay.format(date));
date = sdf.parse(vre.getEndDate());
vre.setEndDate(sdfToDisplay.format(date));
gatewayVREs.add(vre);
}
} // end for VO
pageContext.setAttribute("gatewayVREs", gatewayVREs);
String gatewayDisplayName = gateway.getName().replace("Detached", "");
%>
<h1><%=gatewayDisplayName%><br> <small><%=gateway.getDescription()%></small>
</h1>
<div style="width: 100%; text-align: left;">
<table>
<thead>
<th class="span3">VRE name</th>
<th class="span2">Operational from</th>
<th class="span2">Operational to</th>
<th class="span2">Managers</th>
</thead>
<tbody>
<c:forEach var="vre" items="${gatewayVREs}">
<tr style="border-bottom: 1px solid #CCC;">
<td><button title="${vre.description}" type="button"
class="btn btn-link vreInfo" data-placement='bottom'>
${vre.name}</button></td>
<td>${vre.startDate}</td>
<td>${vre.endDate}</td>
<td>${vre.managers}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<%
} //end for Gateway
%>
<div style="width: 100%; text-align: center; margin-top: 75px; margin-bottom: 75px;">
<h3>Could not find what you are looking for?
<p>
<button class="btn btn-large btn-primary"
onclick="location.href='https://support.d4science.org'"
type="button">Visit D4Science Support page</button> or
<button class="btn btn-large btn-primary"
onclick="location.href='https://services.d4science.org/thematic-gateways'"
type="button">Visit the active Gateways</button></p></h3>
</div>
</div>