Difference between revisions of "Portal Context"
From Gcube Wiki
(Created page with "=== 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 o...") |
(→Example) |
||
Line 18: | Line 18: | ||
=== Example === | === Example === | ||
+ | A new instance of the manager can be retrieved by invoking | ||
+ | |||
+ | <source lang="java"> | ||
+ | PortalContext instance = PortalContext.getConfiguration(); | ||
+ | </source> | ||
+ | |||
+ | A part this information, the new version allows to retrieve: | ||
+ | |||
+ | * The name of the gateway and its URL | ||
+ | |||
+ | <source lang="java"> | ||
+ | // get the gateway name given the HttpServletRequest | ||
+ | instance.getGatewayName(request); | ||
+ | |||
+ | // get the gateway url given the HttpServletRequest | ||
+ | instance.getGatewayUrl(request); | ||
+ | </source> | ||
+ | |||
+ | * mail sender for the current site | ||
+ | <source lang="java"> | ||
+ | // get the current site email's sender (used when notifications are sent, for example), given the HttpServletRequest | ||
+ | instance.getSenderEmail(request); | ||
+ | </source> | ||
+ | |||
+ | * the name of the current infrastructure in which the client is running | ||
+ | |||
+ | <source lang="java"> | ||
+ | // get the current infrastructure name | ||
+ | instance.getInfrastructureName(); | ||
+ | </source> |
Revision as of 11:49, 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 instance.getGatewayName(request); // get the gateway url given the HttpServletRequest 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 instance.getSenderEmail(request);
- the name of the current infrastructure in which the client is running
// get the current infrastructure name instance.getInfrastructureName();