Search in sources :

Example 16 with IPortletUrlBuilder

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();
}
Also used : IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 17 with IPortletUrlBuilder

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);
    }
}
Also used : Locale(java.util.Locale) MalformedURLException(java.net.MalformedURLException) IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder) URL(java.net.URL)

Aggregations

IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)17 IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)11 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)9 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 UrlType (org.apereo.portal.url.UrlType)4 PortletUrlParameter (org.apereo.portal.search.PortletUrlParameter)3 IPortalActionUrlBuilder (org.apereo.portal.url.IPortalActionUrlBuilder)3 WindowState (javax.portlet.WindowState)2 MockPortletWindowId (org.apereo.portal.mock.portlet.om.MockPortletWindowId)2 PortletUrl (org.apereo.portal.search.PortletUrl)2 PortletUrlType (org.apereo.portal.search.PortletUrlType)2 Test (org.junit.Test)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 StringWriter (java.io.StringWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Locale (java.util.Locale)1 Map (java.util.Map)1