Search in sources :

Example 11 with IPortalUrlBuilder

use of org.apereo.portal.url.IPortalUrlBuilder 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)

Example 12 with IPortalUrlBuilder

use of org.apereo.portal.url.IPortalUrlBuilder in project uPortal by Jasig.

the class PortletMimeResponseContextImpl method getPortletURLProvider.

/* (non-Javadoc)
     * @see org.apache.pluto.container.PortletMimeResponseContext#getPortletURLProvider(org.apache.pluto.container.PortletURLProvider.TYPE)
     */
@Override
public PortletURLProvider getPortletURLProvider(TYPE type) {
    final IPortletWindowId portletWindowId = this.portletWindow.getPortletWindowId();
    final UrlType urlType = UrlType.fromPortletUrlType(type);
    final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(containerRequest, portletWindowId, urlType);
    final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
    return new PortletURLProviderImpl(portletUrlBuilder);
}
Also used : IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) PortletURLProviderImpl(org.apereo.portal.portlet.url.PortletURLProviderImpl) IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder) UrlType(org.apereo.portal.url.UrlType) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 13 with IPortalUrlBuilder

use of org.apereo.portal.url.IPortalUrlBuilder in project uPortal by Jasig.

the class PortletRegistrySearchService method getSearchResults.

@Override
public SearchResults getSearchResults(PortletRequest request, SearchRequest query) {
    final String queryString = query.getSearchTerms().toLowerCase();
    final List<IPortletDefinition> portlets = portletDefinitionRegistry.getAllPortletDefinitions();
    final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
    final SearchResults results = new SearchResults();
    for (IPortletDefinition portlet : portlets) {
        if (matches(queryString, portlet)) {
            final SearchResult result = new SearchResult();
            result.setTitle(portlet.getTitle());
            result.setSummary(portlet.getDescription());
            result.getType().add(searchResultType);
            final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(httpServletRequest, portlet.getFName());
            // If user does not have browse permission, exclude the portlet.
            if (portletWindow != null && authorizationService.canPrincipalBrowse(authorizationService.newPrincipal(request.getRemoteUser(), EntityEnum.PERSON.getClazz()), portlet)) {
                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"));
                result.setExternalUrl(portalUrlBuilder.getUrlString());
                results.getSearchResult().add(result);
            }
        }
    }
    return results;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) SearchResult(org.apereo.portal.search.SearchResult) SearchResults(org.apereo.portal.search.SearchResults) IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 14 with IPortalUrlBuilder

use of org.apereo.portal.url.IPortalUrlBuilder in project uPortal by Jasig.

the class SearchPortletController method calculateSearchLaunchUrl.

/**
     * Create an actionUrl for the indicated portlet The resource URL is for the ajax typing search
     * results response.
     *
     * @param request render request
     * @param response render response
     */
private String calculateSearchLaunchUrl(RenderRequest request, RenderResponse response) {
    final HttpServletRequest httpRequest = this.portalRequestUtils.getPortletHttpRequest(request);
    final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletFName(httpRequest, "search", UrlType.ACTION);
    return portalUrlBuilder.getUrlString();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder)

Example 15 with IPortalUrlBuilder

use of org.apereo.portal.url.IPortalUrlBuilder in project uPortal by Jasig.

the class SearchPortletController method calculateAutocompleteResourceUrl.

/**
     * Create a resourceUrl for <code>AJAX_RESPONSE_RESOURCE_ID</code>. The resource URL is for the
     * ajax typing search results response.
     *
     * @param request render request
     * @param response render response
     */
private String calculateAutocompleteResourceUrl(RenderRequest request, RenderResponse response) {
    final HttpServletRequest httpRequest = this.portalRequestUtils.getPortletHttpRequest(request);
    final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletFName(httpRequest, "search", UrlType.RESOURCE);
    final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portalUrlBuilder.getTargetPortletWindowId());
    portletUrlBuilder.setResourceId(AJAX_RESPONSE_RESOURCE_ID);
    return portletUrlBuilder.getPortalUrlBuilder().getUrlString();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder)

Aggregations

IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)17 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)11 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)6 UrlType (org.apereo.portal.url.UrlType)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)4 PortletUrlParameter (org.apereo.portal.search.PortletUrlParameter)3 URL (java.net.URL)2 PortletUrl (org.apereo.portal.search.PortletUrl)2 PortletUrlType (org.apereo.portal.search.PortletUrlType)2 SearchResult (org.apereo.portal.search.SearchResult)2 SearchResults (org.apereo.portal.search.SearchResults)2 IPerson (org.apereo.portal.security.IPerson)2 IUserInstance (org.apereo.portal.user.IUserInstance)2 Document (org.w3c.dom.Document)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1