added getLandingPage path method
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/portal-manager@126225 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
92dcadac5c
commit
26aac386fe
34
pom.xml
34
pom.xml
|
@ -25,7 +25,7 @@
|
|||
<distroDirectory>distro</distroDirectory>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
|
||||
<liferay.version>6.2.5</liferay.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
@ -33,9 +33,39 @@
|
|||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<version>2.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.portlet</groupId>
|
||||
<artifactId>portlet-api</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>util-java</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>util-bridges</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>util-taglib</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
package org.gcube.common.portal;
|
||||
|
||||
import com.liferay.portal.kernel.util.PropsKeys;
|
||||
import com.liferay.portal.kernel.util.PropsUtil;
|
||||
|
||||
public class GCubePortalConstants {
|
||||
public static final String PREFIX_GROUP_URL = "/group";
|
||||
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 INFRASTRUCTURE_NAME = "infrastructure";
|
||||
public static final String SCOPES = "scopes";
|
||||
|
|
|
@ -12,6 +12,19 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.kernel.util.StringBundler;
|
||||
import com.liferay.portal.kernel.util.StringPool;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.model.User;
|
||||
import com.liferay.portal.model.VirtualHost;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
import com.liferay.portal.service.LayoutSetLocalServiceUtil;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
import com.liferay.portal.service.VirtualHostLocalServiceUtil;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -24,6 +37,9 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class PortalContext {
|
||||
private static final Logger _log = LoggerFactory.getLogger(PortalContext.class);
|
||||
public static final String PORTAL_CONTEXT = PortalUtil.getPathContext();
|
||||
|
||||
|
||||
private static PortalContext singleton = new PortalContext();
|
||||
|
||||
private String infra;
|
||||
|
@ -111,7 +127,53 @@ public class PortalContext {
|
|||
toReturn += (httpServletRequest.getServerPort() == 80) ? "" : ":"+httpServletRequest.getServerPort() ;
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request
|
||||
* @return the landing page path of the current Site e.g. "/group/i-marine"
|
||||
* @throws PortalException
|
||||
* @throws SystemException
|
||||
*/
|
||||
public String getSiteLandingPagePath(final HttpServletRequest request) throws PortalException, SystemException {
|
||||
String sitePath = StringPool.BLANK;
|
||||
String serverName = request.getServerName();
|
||||
_log.debug("currentHost is " + serverName);
|
||||
Group site = null;
|
||||
List<VirtualHost> vHosts = VirtualHostLocalServiceUtil.getVirtualHosts(0, VirtualHostLocalServiceUtil.getVirtualHostsCount());
|
||||
for (VirtualHost virtualHost : vHosts) {
|
||||
_log.debug("Found " + virtualHost.getHostname());
|
||||
if (virtualHost.getHostname().compareTo("localhost") != 0 &&
|
||||
virtualHost.getLayoutSetId() != 0 &&
|
||||
virtualHost.getHostname().compareTo(serverName) == 0) {
|
||||
long layoutSetId = virtualHost.getLayoutSetId();
|
||||
site = LayoutSetLocalServiceUtil.getLayoutSet(layoutSetId).getGroup();
|
||||
_log.debug("Found match! Your site is " + site.getName());
|
||||
}
|
||||
}
|
||||
if (site.getPrivateLayoutsPageCount() > 0) {
|
||||
sitePath = getGroupFriendlyURL(request, site);
|
||||
} else {
|
||||
_log.debug(site.getName() + " site doesn't have any private page. Default landing page will be used");
|
||||
}
|
||||
return sitePath;
|
||||
}
|
||||
/**
|
||||
* @param request
|
||||
* @param currentGroup
|
||||
* @param isPrivate
|
||||
* @param isUser
|
||||
* @return
|
||||
* @throws PortalException
|
||||
* @throws SystemException
|
||||
*/
|
||||
private static String getGroupFriendlyURL(final HttpServletRequest request, final Group currentGroup) throws PortalException, SystemException {
|
||||
String friendlyURL = GCubePortalConstants.PRIVATE_GROUP_SERVLET_MAPPING;
|
||||
StringBundler sb = new StringBundler();
|
||||
sb.append(PORTAL_CONTEXT);
|
||||
sb.append(friendlyURL);
|
||||
sb.append(currentGroup.getFriendlyURL());
|
||||
return sb.toString();
|
||||
}
|
||||
/**
|
||||
* read the infrastructure gateway name from a property file and returns it
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue