feature completed and alpha tested

Feature/22340
Massimiliano Assante 2 years ago
parent d144b5d7b6
commit e85206c33b

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/resource-management-7.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry including="**/*.java" kind="src" output="target/resource-management-portlet-7.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/resource-management-7.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/resource-management-portlet-7.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -41,5 +41,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/resource-management-7.0.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/resource-management-portlet-7.0.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

@ -41,17 +41,17 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>com.gwtplugins.gdt.eclipse.core.webAppProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.gwtplugins.gdt.eclipse.core.webAppProjectValidator</name>
<name>com.gwtplugins.gwt.eclipse.core.gwtProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.gwtplugins.gwt.eclipse.core.gwtProjectValidator</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>

@ -1,4 +1,4 @@
eclipse.preferences.version=1
lastWarOutDir=/Users/massi/Documents/workspace/resource-management/target/resource-management-6.7.0-SNAPSHOT
lastWarOutDir=/Users/massi/workspace/resource-management-portlet/target/resource-management-portlet-7.0.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

@ -3,7 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7

@ -1,10 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="resource-management">
<wb-module deploy-name="resource-management-portlet">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="resource-management"/>
</wb-module>
<dependent-module archiveName="rmp-common-library-2.8.4.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/rmp-common-library/rmp-common-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="resource-management-portlet"/>
</wb-module>
</project-modules>

@ -4,6 +4,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v7.1.0-SNAPSHOT] - 2021-12-27
- Please add a resource to the VRE which indicates the gateway through it is accessible
## [v7.0.0] - 2020-07-21
Ported to git

@ -0,0 +1,26 @@
# Acknowledgments
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
- the Seventh Framework Programme for research, technological development and demonstration
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
- the H2020 research and innovation programme
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>resource-management-portlet</artifactId>
<version>7.0.0</version>
<version>7.1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>gCube Resource Management Portlet</name>
<description>
@ -104,7 +104,7 @@
<dependency>
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>rmp-common-library</artifactId>
<version>[2.8.2-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<version>[2.8.4-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency>
<!-- FWS DEPS -->
<dependency>
@ -125,7 +125,7 @@
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<scope>provided</scope>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.gcube.resourcemanagement</groupId>

@ -17,6 +17,8 @@
package org.gcube.portlets.admin.resourcemanagement.client;
import java.util.List;
import org.gcube.portlets.admin.ishealthmonitor.client.dialog.ISMonitor;
import org.gcube.portlets.admin.resourcemanagement.client.forms.genericresources.DeployVirtualCollection;
import org.gcube.portlets.admin.resourcemanagement.client.remote.ProxyRegistry;
@ -621,7 +623,7 @@ public class ResourceManagementPortlet implements EntryPoint {
protected void onClick(final ComponentEvent be) {
super.onClick(be);
Dialog dlg = new Dialog();
dlg.setHeading("About - Resource Management");
dlg.setHeading("About - Infrastructure Monitor");
dlg.addText("<br/>This software is part of the gCube Project.<br/>" +
"Site: <a href=\"http://www.gcube-system.org/\">http://www.gcube-system.org/</a>" +
"<p>The gCube/gCore software is licensed as Free Open Source software " +
@ -630,10 +632,7 @@ public class ResourceManagementPortlet implements EntryPoint {
"\"as is\" and no expressed or " +
"implied warranty is given for its use, quality or fitness for a " +
"particular case.</p>" +
"" +
"<p><b>Issues</b> can be submitted <a href=\"https://support.d4science.research-infrastructures.eu/\">here</a>.</p>" +
"<p><b>Notice:</b> specify this Component: <br/><i>Repository Path: /org/gcube/portlets/admin/resource-management</i></p>" +
"<br/>This software was built over the <a href=\"http://gcube.wiki.gcube-system.org/gcube/index.php/Featherweight_Stack\">gCube Featherweight Stack (FWS) </a> and <a href=\"http://www.gwtproject.org\">Google Webtool Kit (GWT)</a> technologies.<br/>" +
"<p><b>Issues</b> can be submitted <a href=\"https://support.d4science.org/\">here</a>.</p>" +
"<br/>");
dlg.setClosable(true);
@ -715,7 +714,7 @@ public class ResourceManagementPortlet implements EntryPoint {
statusbar.add(new FillToolItem());
statusbar.add(new Label("Current Context:&nbsp;&nbsp;"));
Text scopeInfo = new Text(Messages.NO_SCOPE_SELECTED);
final Text scopeInfo = new Text(Messages.NO_SCOPE_SELECTED);
scopeInfo.setWidth(350);
statusbar.add(scopeInfo);
WidgetsRegistry.registerWidget(UIIdentifiers.STATUS_SCOPE_INFO_ID, scopeInfo);
@ -732,6 +731,48 @@ public class ResourceManagementPortlet implements EntryPoint {
copy2Clipboard.setText("Copy");
copy2Clipboard.setStyleAttribute("margin-top", "-12px");
statusbar.add(copy2Clipboard);
Button locateVREButton = new Button() {
@Override
protected void onClick(final ComponentEvent ce) {
String currentContext = StatusHandler.getStatus().getCurrentScope();
String[] splits = currentContext.split("/");
if (splits.length < 4) { //check if the context is a VRE (4 splits)
Window.alert("Locate function only applicable to VRE contexts");
} else {
ProxyRegistry.getProxyInstance().getGatewayURLsGivenVREContext(currentContext, new AsyncCallback<List<String>>() {
public void onSuccess(List<String> result) {
Dialog dlg = new Dialog();
dlg.setHeading("VRE is available on:");
String markup = "<p><ul>";
for (String gatewayURL : result) {
markup += "<li><a href=\""+gatewayURL+"\" target=\"_blank\">"+gatewayURL+"</a></li>";
}
markup += "</ul></p>";
dlg.addText(markup);
dlg.setClosable(true);
dlg.setModal(true);
dlg.setHideOnButtonClick(true);
dlg.show();
}
public void onFailure(Throwable caught) {
Window.alert("An error occurred: " + caught.getMessage());
}
});
}
}
};
locateVREButton.setIconStyle("pluginVM-icon");
locateVREButton.setToolTip("Shows in which D4Science Gateway the VRE is available");
locateVREButton.setText("Locate");
locateVREButton.setStyleAttribute("margin-top", "-12px");
statusbar.add(locateVREButton);
statusbar.add(new Label("&nbsp;&nbsp;Resources No.:&nbsp;"));
Status loadedResources = new Status();
loadedResources.setWidth(35);

@ -48,6 +48,8 @@ public interface ServiceProxy extends RemoteService {
void initScopes(boolean doClean);
void setSuperUser(boolean superUser);
List<String> getGatewayURLsGivenVREContext(String vreContext);
/**
* This way the servlet stores the scope in the session.

@ -60,6 +60,9 @@ public interface ServiceProxyAsync {
void getGenericResourceDescriptor(String scope, String resID, AsyncCallback<ResourceDescriptor> callback);
void getGatewayURLsGivenVREContext(String vreContext, AsyncCallback<List<String>> callback);
/**
* @see ServiceProxy#getAvailableScopes()
*/

@ -195,6 +195,7 @@ public class Commands {
}
public static final void doGetResourceProfileByID(final Object caller, final String scope, final String resourceID) {
GWT.log("Commands.java doGetResourceProfileByID");
ProxyRegistry.getProxyInstance().getResourceByID(
scope,
null, // no type specified
@ -203,6 +204,7 @@ public class Commands {
}
public static final void doGetResourceProfile(final Object caller, final String scope, String resourceType, final String resourceID) {
GWT.log("doGetResourceProfile =" + resourceType);
/**
* Patch (i know do not tell me about it)
*/

@ -0,0 +1,33 @@
package org.gcube.portlets.admin.resourcemanagement.server;
import java.util.ArrayList;
import com.liferay.portal.model.Group;
public class Gateway {
private Group site;
private ArrayList<String> vres;
public Gateway(Group site, ArrayList<String> vres) {
super();
this.site = site;
this.vres = vres;
}
public Group getSite() {
return site;
}
public void setSite(Group site) {
this.site = site;
}
public ArrayList<String> getVres() {
return vres;
}
public void setVres(ArrayList<String> vres) {
this.vres = vres;
}
@Override
public String toString() {
return "Gateway [site=" + site + ", vres=" + vres + "]";
}
}

@ -23,6 +23,7 @@ import java.io.StringReader;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
@ -62,11 +63,22 @@ import org.gcube.resourcemanagement.support.shared.util.Assertion;
import org.gcube.resourcemanagement.support.shared.util.Configuration;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.impl.QueryTemplate;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
import org.gcube.vomanagement.usermanagement.model.VirtualGroup;
import org.gcube.vremanagement.resourcemanager.client.RMReportingLibrary;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.LayoutSet;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.service.VirtualHostLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
/**
* @author Daniele Strollo
@ -440,8 +452,8 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
public final CompleteResourceProfile getResourceByID(final String scope, final String type, final String resID) {
try {
CompleteResourceProfile profile = ISClientRequester.getResourceByID(this.getXML2HTMLMapping(), new ScopeBean(scope), type, resID);
System.out.println("****\n\n\n CompleteResourceProfile getResourceByID(final String scope, final String type, final String resID) *****");
System.out.println("****CompleteResourceProfile getResourceByID("+scope+","+type+","+resID+") *****\n\n");
System.out.println("Resource found XML:"+profile.getXmlRepresentation());
return profile;
} catch (Exception e) {
ServerConsole.error(LOG_PREFIX, e);
@ -536,6 +548,194 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
ServerConsole.info(LOG_PREFIX, "FAILED ATTEMPT SUPER USER MODE FROM IP: " + ipAddressCaller);
return matched;
}
/**
* return the list of URLS for a given VRE Context
*/
@Override
public List<String> getGatewayURLsGivenVREContext(String vreContext) {
List<Gateway> theGateways= getGateways(new LiferayGroupManager());
List<String> gatewayURLs = new ArrayList<>();
for (Gateway gateway : theGateways) {
LayoutSet layoutSet = null;
if (gateway.getSite().hasPublicLayouts())
layoutSet = gateway.getSite().getPublicLayoutSet();
else
layoutSet = gateway.getSite().getPrivateLayoutSet();
final long companyId = PortalUtil.getDefaultCompanyId();
long layoutSetId = layoutSet.getLayoutSetId();
String vHost = "";
try {
vHost = VirtualHostLocalServiceUtil.getVirtualHost(companyId, layoutSetId).getHostname();
} catch (PortalException | SystemException e) {
e.printStackTrace();
}
String theURL = "https://"+vHost+"/";
gatewayURLs.add(theURL);
}
return gatewayURLs;
}
private List<Gateway> getGateways(GroupManager groupsManager) {
List<Gateway> toReturn = new ArrayList<>();
try{
List<Group> candidateGateways = GroupLocalServiceUtil.getGroups(org.gcube.vomanagement.usermanagement.util.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<>();
LinkedHashMap<VRECategory, ArrayList<VRE>> sites = getPortalSitesMappedToVRE(group.getGroupId(), groupsManager);
for (VRECategory cat : sites.keySet()) {
for (VRE vre : sites.get(cat)) {
theVRENames.add(vre.getName());
}
}
toReturn.add(new Gateway(group, theVRENames));
ServerConsole.debug("Gateway " + group.getName() + " has " + theVRENames.size() + " VREs");
}
}
} catch(Exception e){
ServerConsole.error("Failed to retrieve the list of gateways", e);
return null;
}
return toReturn;
}
/**
*
* @return the Virtual groups with their VREs in the order estabilished in
* the LR Control Panel
*/
private LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE(long currentSiteGroupId, GroupManager groupsManager) throws Exception {
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
List<VirtualGroup> currentSiteVGroups = groupsManager.getVirtualGroups(currentSiteGroupId);
for (VirtualGroup vg : currentSiteVGroups) {
ArrayList<VRE> toCreate = new ArrayList<VRE>();
VRECategory cat = new VRECategory(1L, vg.getName(), vg.getDescription());
toReturn.put(cat, toCreate);
}
GCubeGroup rootGroupVO = groupsManager.getRootVO();
try {
ServerConsole.debug("root: " + rootGroupVO.getGroupName());
} catch (NullPointerException e) {
ServerConsole.warn(
"Cannot find root organziation, please check gcube-data.properties file in $CATALINA_HOME/conf folder, unless your installing the Bundle");
return toReturn;
}
// for each root sub organizations (VO)
for (GCubeGroup vOrg : rootGroupVO.getChildren()) {
for (GCubeGroup vreSite : vOrg.getChildren()) {
long vreID = vreSite.getGroupId();
String vreName = vreSite.getGroupName();
String vreDescription = vreSite.getDescription();
List<VirtualGroup> vreGroups = groupsManager.getVirtualGroups(vreID);
for (VirtualGroup vreGroup : vreGroups) {
for (VRECategory vre : toReturn.keySet()) {
if (vre.getName().compareTo(vreGroup.getName()) == 0) {
ArrayList<VRE> toUpdate = toReturn.get(vre);
VRE toAdd = new VRE(vreName, vreDescription, vreID, "", "");
toUpdate.add(toAdd);
}
}
}
}
}
return toReturn;
}
private class VRECategory {
private long categoryID;
private String name;
private String description;
public VRECategory(long categoryID, String name, String description) {
super();
this.categoryID = categoryID;
this.name = name;
this.description = description;
}
@SuppressWarnings("unused")
public long getCategoryID() {
return categoryID;
}
@SuppressWarnings("unused")
public String getDescription() {
return description;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "VRECategory [categoryID=" + categoryID + ", name=" + name + ", description=" + description + "]";
}
}
private class VRE implements Comparable<VRE> {
private String name;
private String description;
private long id;
private String url;
private String scope;
public VRE(String name, String description, long id, String url, String scope) {
super();
this.name = name;
this.description = description;
this.id = id;
this.url = url;
this.scope = scope;
}
@SuppressWarnings("unused")
public String getDescription() {
return description;
}
@SuppressWarnings("unused")
public long getId() {
return id;
}
public String getName() {
return name;
}
@SuppressWarnings("unused")
public String getScope() {
return scope;
}
@SuppressWarnings("unused")
public String getUrl() {
return url;
}
@Override
public String toString() {
return "VRE [name=" + name + ", description=" + description + ", id=" + id + ", url=" + url + ", scope="
+ scope + "]";
}
@Override
public int compareTo(VRE vre) {
return this.getName().compareTo(vre.getName());
}
}
}

Loading…
Cancel
Save