use of org.apereo.portal.url.IPortletUrlBuilder in project uPortal by Jasig.
the class PortletRegistryUtil method buildPortletUrl.
/**
* Builds a portal URL to the specific portlet definition {@link IPortletDefinition}, if the
* remote user in the request has browse permissions to the portlet.
*
* @param httpServletRequest Web request with requester as remote user
* @param portlet Definition of portlet to build a maximized portal URL
* @return URL string if user has access; otherwise, return null
*/
public String buildPortletUrl(HttpServletRequest httpServletRequest, IPortletDefinition portlet) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(httpServletRequest, portlet.getFName());
// portletWindow is null if user does not have access to portlet.
if (portletWindow == null) {
return null;
}
// If user does not have browse permission, exclude the portlet.
if (!this.authorizationService.canPrincipalBrowse(this.authorizationService.newPrincipal(httpServletRequest.getRemoteUser(), EntityEnum.PERSON.getClazz()), portlet)) {
return null;
}
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletFName(httpServletRequest, portlet.getFName(), UrlType.RENDER);
final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
portletUrlBuilder.setWindowState(PortletUtils.getWindowState("maximized"));
return portalUrlBuilder.getUrlString();
}
use of org.apereo.portal.url.IPortletUrlBuilder in project uPortal by Jasig.
the class UserAccountHelper method sendLoginToken.
public void sendLoginToken(HttpServletRequest request, ILocalAccountPerson account, IPasswordResetNotification notification) {
Locale locale = getCurrentUserLocale(request);
IPortalUrlBuilder builder = urlProvider.getPortalUrlBuilderByPortletFName(request, PORTLET_FNAME_LOGIN, UrlType.RENDER);
IPortletUrlBuilder portletUrlBuilder = builder.getTargetedPortletUrlBuilder();
portletUrlBuilder.addParameter("username", account.getName());
portletUrlBuilder.addParameter("loginToken", (String) account.getAttributeValue("loginToken"));
portletUrlBuilder.setPortletMode(PortletMode.VIEW);
portletUrlBuilder.setWindowState(WindowState.MAXIMIZED);
try {
String path = fixPortletPath(request, builder);
URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), path);
notification.sendNotification(url, account, locale);
} catch (MalformedURLException e) {
log.error(e);
}
}
Aggregations