From f44a79de76347d01ab351750b1c9666d393098ac Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Tue, 5 Jul 2016 15:03:49 +0000 Subject: [PATCH] added support for new user site registration email to Site Managers git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/liferay62-plugins/landing-page-library@129955 82a268e6-3cf1-43bd-a215-b396298e98cf --- pom.xml | 27 ++++++++++++++----- .../landingpage/LandingPageManager.java | 15 ++++++++--- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index c7d97d7..00b2c15 100644 --- a/pom.xml +++ b/pom.xml @@ -18,24 +18,41 @@ UTF-8 6.2.5 - + + + + org.gcube.distribution + maven-portal-bom + LATEST + pom + import + + + + + org.gcube.common.portal + portal-manager + provided + + + org.gcube.portal + notifications-common-library + provided + com.liferay.portal portal-service - ${liferay.version} provided com.liferay.portal util-java - ${liferay.version} provided javax.portlet portlet-api - 2.0 provided @@ -53,12 +70,10 @@ org.slf4j slf4j-log4j12 - 1.6.4 org.slf4j slf4j-api - 1.6.4 diff --git a/src/main/java/org/gcube/portal/landingpage/LandingPageManager.java b/src/main/java/org/gcube/portal/landingpage/LandingPageManager.java index 08aa1a1..8846e47 100644 --- a/src/main/java/org/gcube/portal/landingpage/LandingPageManager.java +++ b/src/main/java/org/gcube/portal/landingpage/LandingPageManager.java @@ -5,6 +5,8 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; +import org.gcube.common.portal.PortalContext; +import org.gcube.portal.notifications.thread.NewUserSiteRegistrationNotificationThread; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +35,7 @@ public class LandingPageManager { 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 PORTAL_CONTEXT = PortalUtil.getPathContext(); - + public static String getLandingPagePath(final HttpServletRequest request) throws PortalException, SystemException { User currentUser = PortalUtil.getUser(request); return getLandingPagePath(request, currentUser); @@ -70,9 +72,11 @@ public class LandingPageManager { break; } } - if (! isRegistered) + if (! isRegistered) { _log.debug("But user " + currentUser.getFullName() + " is not registered to " + site.getName() + ". going to register ..."); - registerUserToSite(currentUser, site); + String portalURL = PortalContext.getConfiguration().getGatewayURL(request); + registerUserToSite(currentUser, site, portalURL); + } break; } } @@ -83,6 +87,7 @@ public class LandingPageManager { } return sitePath; } + /** * 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 @@ -90,9 +95,11 @@ public class LandingPageManager { * @param site * @throws SystemException */ - private static void registerUserToSite(User user, Group site) throws SystemException { + private static void registerUserToSite(User user, Group site, String siteURL) throws SystemException { UserLocalServiceUtil.addGroupUser(site.getGroupId(), user.getUserId()); _log.debug("User " + user.getScreenName() +" registered to " + site.getName()); + Thread emailSiteManagersThread = new Thread(new NewUserSiteRegistrationNotificationThread(user, site, siteURL)); + emailSiteManagersThread.start(); } public static List getSites(final long userId) throws PortalException, SystemException {