only fot SBD Gateway we check if the user belongs to resource catalogue VRE, if not we register the user automatically
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/liferay62-plugins/landing-page-library@162062 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
65fa07c99a
commit
e83127bff8
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>landing-page-library</artifactId>
|
<artifactId>landing-page-library</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>landing-page-library</name>
|
<name>landing-page-library</name>
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class LandingPageManager {
|
||||||
public static final String GUEST_GROUP_FRIENDLY_URL = "/guest";
|
public static final String GUEST_GROUP_FRIENDLY_URL = "/guest";
|
||||||
public static final String PRIVATE_GROUP_SERVLET_MAPPING = PropsUtil.get(PropsKeys.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING);
|
public static final String PRIVATE_GROUP_SERVLET_MAPPING = PropsUtil.get(PropsKeys.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING);
|
||||||
public static final String PORTAL_CONTEXT = PortalUtil.getPathContext();
|
public static final String PORTAL_CONTEXT = PortalUtil.getPathContext();
|
||||||
|
private static final String SBD_GATEWAY_VHOST = "sobigdata.d4science.org";
|
||||||
|
|
||||||
public static String getLandingPagePath(final HttpServletRequest request) throws PortalException, SystemException {
|
public static String getLandingPagePath(final HttpServletRequest request) throws PortalException, SystemException {
|
||||||
User currentUser = PortalUtil.getUser(request);
|
User currentUser = PortalUtil.getUser(request);
|
||||||
|
@ -78,6 +79,11 @@ public class LandingPageManager {
|
||||||
_log.debug("But user " + currentUser.getFullName() + " is not registered to " + site.getName() + ". going to register ...");
|
_log.debug("But user " + currentUser.getFullName() + " is not registered to " + site.getName() + ". going to register ...");
|
||||||
String portalURL = PortalContext.getConfiguration().getGatewayURL(request);
|
String portalURL = PortalContext.getConfiguration().getGatewayURL(request);
|
||||||
registerUserToSite(currentUser, site, portalURL);
|
registerUserToSite(currentUser, site, portalURL);
|
||||||
|
//only fot SBD Gateway we check if the user belongs to resource catalogue VRE
|
||||||
|
if (currentVirtualHost.equalsIgnoreCase(SBD_GATEWAY_VHOST)) {
|
||||||
|
Thread resourceCatalogueSBDThread = new Thread(new ResourceCatalogueRegistrationThread(userSites, currentUser, portalURL));
|
||||||
|
resourceCatalogueSBDThread.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +95,7 @@ public class LandingPageManager {
|
||||||
}
|
}
|
||||||
return sitePath;
|
return sitePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method is used to register the user to the group if does not belong to it yet
|
* this method is used to register the user to the group if does not belong to it yet
|
||||||
* IMPORTANT: it does not add the user to the Site's private pages if the Site Membership type is different from Private
|
* IMPORTANT: it does not add the user to the Site's private pages if the Site Membership type is different from Private
|
||||||
|
@ -97,7 +103,7 @@ public class LandingPageManager {
|
||||||
* @param site
|
* @param site
|
||||||
* @throws SystemException
|
* @throws SystemException
|
||||||
*/
|
*/
|
||||||
private static void registerUserToSite(User user, Group site, String siteURL) throws SystemException {
|
protected static void registerUserToSite(User user, Group site, String siteURL) throws SystemException {
|
||||||
UserLocalServiceUtil.addGroupUser(site.getGroupId(), user.getUserId());
|
UserLocalServiceUtil.addGroupUser(site.getGroupId(), user.getUserId());
|
||||||
_log.debug("User " + user.getScreenName() +" registered to " + site.getName());
|
_log.debug("User " + user.getScreenName() +" registered to " + site.getName());
|
||||||
Thread emailSiteManagersThread = new Thread(new NewUserSiteRegistrationNotificationThread(new LiferayUserManager(), new LiferayRoleManager() ,user, site, siteURL));
|
Thread emailSiteManagersThread = new Thread(new NewUserSiteRegistrationNotificationThread(new LiferayUserManager(), new LiferayRoleManager() ,user, site, siteURL));
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
package org.gcube.portal.landingpage;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.liferay.portal.kernel.exception.SystemException;
|
||||||
|
import com.liferay.portal.model.Group;
|
||||||
|
import com.liferay.portal.model.User;
|
||||||
|
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author massi
|
||||||
|
* register the user to the group having the given group id
|
||||||
|
*/
|
||||||
|
public class ResourceCatalogueRegistrationThread implements Runnable {
|
||||||
|
private static Logger _log = LoggerFactory.getLogger(ResourceCatalogueRegistrationThread.class);
|
||||||
|
private static long RESOURCE_CATALOGUE_GROUPID = 459909;
|
||||||
|
private User user;
|
||||||
|
private Group resourceCatalogueGroup;
|
||||||
|
private String siteURL;
|
||||||
|
List<Group> userSites;
|
||||||
|
|
||||||
|
public ResourceCatalogueRegistrationThread(List<Group> userSites, User user, String siteURL) {
|
||||||
|
super();
|
||||||
|
this.user = user;
|
||||||
|
this.userSites = userSites;
|
||||||
|
this.siteURL = siteURL;
|
||||||
|
try {
|
||||||
|
resourceCatalogueGroup = GroupLocalServiceUtil.getGroup(RESOURCE_CATALOGUE_GROUPID);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
boolean isRegistered = false;
|
||||||
|
for (Group group : userSites) {
|
||||||
|
if (group.getGroupId() == resourceCatalogueGroup.getGroupId()) {
|
||||||
|
isRegistered = true;
|
||||||
|
_log.debug("user " + user.getFullName() + " is already registered to the VRE " + resourceCatalogueGroup.getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isRegistered) {
|
||||||
|
try {
|
||||||
|
_log.info("SBD Hook " + user.getFullName() + " is not registered to the Resource Catalogue VRE, forcing registration.");
|
||||||
|
LandingPageManager.registerUserToSite(user, resourceCatalogueGroup, siteURL);
|
||||||
|
} catch (SystemException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue