Difference between revisions of "Portal Context"
From Gcube Wiki
(→Example) |
(→Example) |
||
Line 30: | Line 30: | ||
<source lang="java"> | <source lang="java"> | ||
// get the gateway name given the HttpServletRequest | // get the gateway name given the HttpServletRequest | ||
− | instance.getGatewayName(request); | + | String gatewayName = instance.getGatewayName(request); |
// get the gateway url given the HttpServletRequest | // get the gateway url given the HttpServletRequest | ||
− | instance.getGatewayUrl(request); | + | String gatewayUrl = instance.getGatewayUrl(request); |
</source> | </source> | ||
Line 39: | Line 39: | ||
<source lang="java"> | <source lang="java"> | ||
// get the current site email's sender (used when notifications are sent, for example), given the HttpServletRequest | // get the current site email's sender (used when notifications are sent, for example), given the HttpServletRequest | ||
− | instance.getSenderEmail(request); | + | String sender = instance.getSenderEmail(request); |
</source> | </source> | ||
Line 46: | Line 46: | ||
<source lang="java"> | <source lang="java"> | ||
// get the current infrastructure name | // get the current infrastructure name | ||
− | instance.getInfrastructureName(); | + | String infrastructureName = instance.getInfrastructureName(); |
</source> | </source> |
Revision as of 11:50, 3 May 2016
Introduction
The gCube Portal Manager is a component all portlets need to use to get the context where they are running into. Moreover, passing an HttpServletRequest object to its methods, you can also:
- retrieve the list of Virtual Organizations available on a given portal;
- retrieve the configured senders of emails sent by the portal;
- retrieve the gateway of the portal.
Maven Dependency
In order to use it in your project, add the following dependency to the project's pom.xml file
<dependency> <groupId>org.gcube.common.portal</groupId> <artifactId>portal-manager</artifactId> <scope>provided</scope> </dependency>
Example
A new instance of the manager can be retrieved by invoking
PortalContext instance = PortalContext.getConfiguration();
A part this information, the new version allows to retrieve:
- The name of the gateway and its URL
// get the gateway name given the HttpServletRequest String gatewayName = instance.getGatewayName(request); // get the gateway url given the HttpServletRequest String gatewayUrl = instance.getGatewayUrl(request);
- mail sender for the current site
// get the current site email's sender (used when notifications are sent, for example), given the HttpServletRequest String sender = instance.getSenderEmail(request);
- the name of the current infrastructure in which the client is running
// get the current infrastructure name String infrastructureName = instance.getInfrastructureName();