removed customAttributeKeys from portalManager
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/portal-manager@126883 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
703458577b
commit
199462799b
5
pom.xml
5
pom.xml
|
@ -41,6 +41,11 @@
|
|||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package org.gcube.common.portal;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, CNR-ISTI
|
||||
* For gCube Portal Bundle (Site) Custom Attributes keys
|
||||
*
|
||||
*/
|
||||
public enum CustomAttributeKeys {
|
||||
MANDATORY("Mandatory"),
|
||||
IS_EXTERNAL("Isexternal"),
|
||||
URL("Url"),
|
||||
POST_NOTIFICATION("Postnotificationviaemail"),
|
||||
VIRTUAL_GROUP("Virtualgroup");
|
||||
|
||||
private String name;
|
||||
|
||||
private CustomAttributeKeys(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getKeyName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ import java.util.Properties;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -34,7 +37,10 @@ import com.liferay.portal.service.VirtualHostLocalServiceUtil;
|
|||
public class PortalContext {
|
||||
private static final Logger _log = LoggerFactory.getLogger(PortalContext.class);
|
||||
|
||||
|
||||
private static final String DEFAULT_INFRA_NAME = "gcube";
|
||||
private static final String DEFAULT_VO_NAME = "devsec";
|
||||
private static final String DEFAULT_GATEWAY_NAME = "D4science Gateway";
|
||||
private static final String DEFAULT_GATEWAY_EMAIL = "do-not-reply@d4science.org";
|
||||
|
||||
private static PortalContext singleton = new PortalContext();
|
||||
|
||||
|
@ -63,9 +69,9 @@ public class PortalContext {
|
|||
vos = props.getProperty(GCubePortalConstants.SCOPES);
|
||||
}
|
||||
catch(IOException e) {
|
||||
infra = "gcube";
|
||||
vos = "devsec";
|
||||
_log.error("infrastructure.properties file not found under $CATALINA_HOME/conf/ dir, setting default infrastructure Name and devsec as VO Name" + infra);
|
||||
infra = DEFAULT_INFRA_NAME;
|
||||
vos = DEFAULT_VO_NAME;
|
||||
_log.error("infrastructure.properties file not found under $CATALINA_HOME/conf/ dir, setting default infrastructure Name " + infra + " and VO Name " + vos);
|
||||
}
|
||||
_log.info("PortalContext configurator correctly initialized on " + infra);
|
||||
}
|
||||
|
@ -132,6 +138,22 @@ public class PortalContext {
|
|||
*/
|
||||
public String getSiteLandingPagePath(final HttpServletRequest request) throws PortalException, SystemException {
|
||||
String sitePath = StringPool.BLANK;
|
||||
Group site = getSiteFromServletRequest(request);
|
||||
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
|
||||
* @return the current Group instance based on the request
|
||||
* @throws PortalException
|
||||
* @throws SystemException
|
||||
*/
|
||||
private Group getSiteFromServletRequest(final HttpServletRequest request) throws PortalException, SystemException {
|
||||
String serverName = request.getServerName();
|
||||
_log.debug("currentHost is " + serverName);
|
||||
Group site = null;
|
||||
|
@ -144,14 +166,10 @@ public class PortalContext {
|
|||
long layoutSetId = virtualHost.getLayoutSetId();
|
||||
site = LayoutSetLocalServiceUtil.getLayoutSet(layoutSetId).getGroup();
|
||||
_log.debug("Found match! Your site is " + site.getName());
|
||||
return site;
|
||||
}
|
||||
}
|
||||
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;
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param request
|
||||
|
@ -162,15 +180,34 @@ public class PortalContext {
|
|||
* @throws PortalException
|
||||
* @throws SystemException
|
||||
*/
|
||||
private static String getGroupFriendlyURL(final HttpServletRequest request, final Group currentGroup) throws PortalException, SystemException {
|
||||
private static String getGroupFriendlyURL(HttpServletRequest request, final Group currentGroup) throws PortalException, SystemException {
|
||||
String friendlyURL = GCubePortalConstants.PREFIX_GROUP_URL;
|
||||
StringBundler sb = new StringBundler();
|
||||
sb.append(friendlyURL).append(currentGroup.getFriendlyURL());
|
||||
return sb.toString();
|
||||
}
|
||||
/**
|
||||
* read the infrastructure gateway name from a property file and returns it
|
||||
*
|
||||
* @param request the HttpServletRequest instance of your servlet
|
||||
* @return the current Site Name based on the request
|
||||
*/
|
||||
public String getGatewayName(HttpServletRequest request) {
|
||||
String toReturn = DEFAULT_GATEWAY_NAME;
|
||||
try {
|
||||
Group currSite = getSiteFromServletRequest(request);
|
||||
toReturn = (String) new LiferayGroupManager().readCustomAttr(currSite.getGroupId(), CustomAttributeKeys.GATEWAY_SITE_NAME.getKeyName());
|
||||
} catch (Exception e) {
|
||||
toReturn = DEFAULT_GATEWAY_NAME;
|
||||
_log.error("Could not read Site Custom Attr: " + CustomAttributeKeys.GATEWAY_SITE_NAME.getKeyName() + ", returning default Gateway Name " + toReturn);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* read the infrastructure gateway name from a property file and returns it
|
||||
* @deprecated use getGatewayName(HttpServletRequest request)
|
||||
*/
|
||||
@Deprecated
|
||||
public String getGatewayName() {
|
||||
//get the portles to look for from the property file
|
||||
Properties props = new Properties();
|
||||
|
@ -185,7 +222,7 @@ public class PortalContext {
|
|||
}
|
||||
//catch exception in case properties file does not exist
|
||||
catch(IOException e) {
|
||||
toReturn = "D4science Gateway";
|
||||
toReturn = DEFAULT_GATEWAY_NAME;
|
||||
_log.error("gcube-data.properties file not found under $CATALINA_HOME/conf dir, returning default Portal Name " + toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
@ -193,8 +230,26 @@ public class PortalContext {
|
|||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* read the sender (from) email address for notifications name from a property file and returns it
|
||||
*
|
||||
* @param request the HttpServletRequest instance of your servlet
|
||||
* @return the sender (from) email address for the current Site based on the request
|
||||
*/
|
||||
public String getSenderEmail(HttpServletRequest request) {
|
||||
String toReturn = DEFAULT_GATEWAY_EMAIL;
|
||||
try {
|
||||
Group currSite = getSiteFromServletRequest(request);
|
||||
toReturn = (String) new LiferayGroupManager().readCustomAttr(currSite.getGroupId(), CustomAttributeKeys.GATEWAY_SITE_EMAIL_SENDER.getKeyName());
|
||||
} catch (Exception e) {
|
||||
toReturn = DEFAULT_GATEWAY_EMAIL;
|
||||
_log.error("Could not read Site Custom Attr: " + CustomAttributeKeys.GATEWAY_SITE_EMAIL_SENDER.getKeyName() + ", returning default Gateway Email Sender " + toReturn);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* read the sender (from) email address for notifications name from a property file and returns it
|
||||
* @deprecated use getSenderEmail(HttpServletRequest request)
|
||||
*/
|
||||
@Deprecated
|
||||
public String getSenderEmail() {
|
||||
//get the portles to look for from the property file
|
||||
Properties props = new Properties();
|
||||
|
@ -209,7 +264,7 @@ public class PortalContext {
|
|||
}
|
||||
//catch exception in case properties file does not exist
|
||||
catch(IOException e) {
|
||||
toReturn = "do-not-reply@d4science.org";
|
||||
toReturn = DEFAULT_GATEWAY_EMAIL;
|
||||
_log.error("gcube-data.properties file not found under $CATALINA_HOME/conf dir, returning default Email" + toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue