Fixed readme and added native log support on Landing Page manager
This commit is contained in:
parent
6558eab61f
commit
a753d29747
|
@ -1,6 +1,6 @@
|
||||||
# gCube System - VRE Folder Hook
|
# gCube System - Landing page Library
|
||||||
|
|
||||||
This component is a library used in different hooks that understands from which sites the user enter the gateway and redirects accordingly.
|
This component is a shared library (used in different hooks) that figures out from which sites the user enter the gateway and redirects accordingly.
|
||||||
|
|
||||||
## Structure of the project
|
## Structure of the project
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
package org.gcube.portal.landingpage;
|
package org.gcube.portal.landingpage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.portal.notifications.thread.NewUserSiteRegistrationNotificationThread;
|
import org.gcube.portal.notifications.thread.NewUserSiteRegistrationNotificationThread;
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.liferay.portal.kernel.exception.PortalException;
|
import com.liferay.portal.kernel.exception.PortalException;
|
||||||
import com.liferay.portal.kernel.exception.SystemException;
|
import com.liferay.portal.kernel.exception.SystemException;
|
||||||
|
import com.liferay.portal.kernel.log.Log;
|
||||||
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||||
import com.liferay.portal.kernel.util.PropsKeys;
|
import com.liferay.portal.kernel.util.PropsKeys;
|
||||||
import com.liferay.portal.kernel.util.PropsUtil;
|
import com.liferay.portal.kernel.util.PropsUtil;
|
||||||
import com.liferay.portal.kernel.util.StringBundler;
|
import com.liferay.portal.kernel.util.StringBundler;
|
||||||
|
@ -35,7 +33,7 @@ import com.liferay.portal.util.PortalUtil;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LandingPageManager {
|
public class LandingPageManager {
|
||||||
private static final Logger _log = LoggerFactory.getLogger(LandingPageManager.class);
|
private static Log _log = LogFactoryUtil.getLog(LandingPageManager.class);
|
||||||
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();
|
||||||
|
@ -43,6 +41,7 @@ public class LandingPageManager {
|
||||||
|
|
||||||
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);
|
||||||
|
_log.info("getLandingPagePath called for user " + currentUser.getScreenName());
|
||||||
return getLandingPagePath(request, currentUser);
|
return getLandingPagePath(request, currentUser);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +56,7 @@ public class LandingPageManager {
|
||||||
String sitePath = StringPool.BLANK;
|
String sitePath = StringPool.BLANK;
|
||||||
|
|
||||||
String currentVirtualHost = request.getServerName();
|
String currentVirtualHost = request.getServerName();
|
||||||
_log.debug("currentHost is " + currentVirtualHost);
|
_log.info("currentHost is " + currentVirtualHost);
|
||||||
Group site = null;
|
Group site = null;
|
||||||
List<VirtualHost> vHosts = VirtualHostLocalServiceUtil.getVirtualHosts(0, VirtualHostLocalServiceUtil.getVirtualHostsCount());
|
List<VirtualHost> vHosts = VirtualHostLocalServiceUtil.getVirtualHosts(0, VirtualHostLocalServiceUtil.getVirtualHostsCount());
|
||||||
for (VirtualHost virtualHost : vHosts) {
|
for (VirtualHost virtualHost : vHosts) {
|
||||||
|
@ -81,8 +80,6 @@ public class LandingPageManager {
|
||||||
_log.info("But user " + currentUser.getFullName() + " is not registered to " + site.getName() + ". going to register ...");
|
_log.info("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);
|
||||||
|
|
||||||
_log.info("currentVirtualHost = " + currentVirtualHost);
|
|
||||||
//only for SBD Gateway we check if the user belongs to resource catalogue VRE and SoBigDataLab VRE
|
//only for SBD Gateway we check if the user belongs to resource catalogue VRE and SoBigDataLab VRE
|
||||||
if (currentVirtualHost.equalsIgnoreCase(SBD_GATEWAY_VHOST)) {
|
if (currentVirtualHost.equalsIgnoreCase(SBD_GATEWAY_VHOST)) {
|
||||||
_log.debug("currentVirtualHost.equalsIgnoreCase ->" + SBD_GATEWAY_VHOST);
|
_log.debug("currentVirtualHost.equalsIgnoreCase ->" + SBD_GATEWAY_VHOST);
|
||||||
|
|
Loading…
Reference in New Issue