From 0a523dfa94ad28dad7c581655dcc1dde25950a9b Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Thu, 23 Apr 2020 09:34:29 +0200 Subject: [PATCH] fixed bug allowing to autoregister to VRE if it had a vhost associated --- distro/changelog.xml | 3 +++ pom.xml | 6 ++--- .../landingpage/LandingPageManager.java | 22 +++++++++++-------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index a1e935c..8519497 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,5 +1,8 @@ + + Check that Site is a Gateway before redirecting and registering the user to it. + First Release diff --git a/pom.xml b/pom.xml index 165d29c..94fd170 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.gcube.portal landing-page-library - 1.3.0-SNAPSHOT + 1.3.1 jar scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git @@ -92,8 +92,8 @@ maven-compiler-plugin UTF-8 - 1.8 - 1.8 + ${maven.compiler.source} + ${maven.compiler.target} diff --git a/src/main/java/org/gcube/portal/landingpage/LandingPageManager.java b/src/main/java/org/gcube/portal/landingpage/LandingPageManager.java index 53c360a..de3766e 100644 --- a/src/main/java/org/gcube/portal/landingpage/LandingPageManager.java +++ b/src/main/java/org/gcube/portal/landingpage/LandingPageManager.java @@ -77,15 +77,19 @@ public class LandingPageManager { } } if (! isRegistered) { - _log.info("But user " + currentUser.getFullName() + " is not registered to " + site.getName() + ". going to register ..."); - String portalURL = PortalContext.getConfiguration().getGatewayURL(request); - registerUserToSite(currentUser, site, portalURL); - //only for SBD Gateway we check if the user belongs to resource catalogue VRE and SoBigDataLab VRE - if (currentVirtualHost.equalsIgnoreCase(SBD_GATEWAY_VHOST)) { - _log.debug("currentVirtualHost.equalsIgnoreCase ->" + SBD_GATEWAY_VHOST); - Thread resourceCatalogueSBDThread = new Thread(new ResourceCatalogueAndSBDLabRegistrationThread(userSites, currentUser, portalURL)); - resourceCatalogueSBDThread.start(); - } + _log.info("But user " + currentUser.getFullName() + " is not registered to " + site.getName()); + boolean siteIsGateway = site.getParentGroupId() < 1; + _log.info("Is this a Gateway? " + (siteIsGateway) +". If true going to register ..."); + if (siteIsGateway) { + String portalURL = PortalContext.getConfiguration().getGatewayURL(request); + registerUserToSite(currentUser, site, portalURL); + //only for SBD Gateway we check if the user belongs to resource catalogue VRE and SoBigDataLab VRE + if (currentVirtualHost.equalsIgnoreCase(SBD_GATEWAY_VHOST)) { + _log.debug("currentVirtualHost.equalsIgnoreCase ->" + SBD_GATEWAY_VHOST); + Thread resourceCatalogueSBDThread = new Thread(new ResourceCatalogueAndSBDLabRegistrationThread(userSites, currentUser, portalURL)); + resourceCatalogueSBDThread.start(); + } + } } break; }