Search in sources :

Example 6 with SearchResults

use of org.apereo.portal.search.SearchResults in project uPortal by Jasig.

the class GsaSearchService method search.

protected SearchResults search(String query) {
    Map<String, String> vars = new HashMap<>();
    vars.put("query", query);
    vars.put("baseUrl", gsaBaseUrl);
    vars.put("site", gsaSite);
    GsaResults gsaResults = restTemplate.getForObject(urlTemplate, GsaResults.class, vars);
    SearchResults results = new SearchResults();
    for (GsaSearchResult gsaResult : gsaResults.getSearchResults()) {
        SearchResult result = new SearchResult();
        result.setTitle(gsaResult.getTitle());
        result.setExternalUrl(gsaResult.getLink());
        result.setSummary(gsaResult.getSnippet());
        result.getType().add(this.resultType);
        results.getSearchResult().add(result);
    }
    return results;
}
Also used : HashMap(java.util.HashMap) SearchResult(org.apereo.portal.search.SearchResult) SearchResults(org.apereo.portal.search.SearchResults)

Example 7 with SearchResults

use of org.apereo.portal.search.SearchResults 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 8 with SearchResults

use of org.apereo.portal.search.SearchResults in project uPortal by Jasig.

the class GsaSearchService method getSearchResults.

@Override
public SearchResults getSearchResults(PortletRequest request, SearchRequest query) {
    final SearchResults results = search(query.getSearchTerms());
    results.setQueryId(query.getQueryId());
    results.setWindowId(request.getWindowID());
    return results;
}
Also used : SearchResults(org.apereo.portal.search.SearchResults)

Example 9 with SearchResults

use of org.apereo.portal.search.SearchResults in project uPortal by Jasig.

the class MarketplaceSearchService method getSearchResults.

/**
     * Returns a list of search results that pertain to the marketplace query is the query to search
     * will search name, title, description, fname, and captions
     */
@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 (this.matches(queryString, new MarketplacePortletDefinition(portlet, this.marketplaceService, this.portletCategoryRegistry))) {
            final SearchResult result = new SearchResult();
            result.setTitle(portlet.getTitle());
            result.setSummary(portlet.getDescription());
            result.getType().add("marketplace");
            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());
                PortletUrl url = new PortletUrl();
                url.setType(PortletUrlType.RENDER);
                url.setPortletMode("VIEW");
                url.setWindowState("maximized");
                PortletUrlParameter actionParam = new PortletUrlParameter();
                actionParam.setName("action");
                actionParam.getValue().add("view");
                url.getParam().add(actionParam);
                PortletUrlParameter fNameParam = new PortletUrlParameter();
                fNameParam.setName("fName");
                fNameParam.getValue().add(portlet.getFName());
                url.getParam().add(fNameParam);
                result.setPortletUrl(url);
                //Add the result to list to return
                results.getSearchResult().add(result);
            }
        }
    }
    return results;
}
Also used : 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) HttpServletRequest(javax.servlet.http.HttpServletRequest) PortletUrlParameter(org.apereo.portal.search.PortletUrlParameter) PortletUrl(org.apereo.portal.search.PortletUrl) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

SearchResults (org.apereo.portal.search.SearchResults)9 SearchResult (org.apereo.portal.search.SearchResult)6 Event (javax.portlet.Event)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)3 SearchRequest (org.apereo.portal.search.SearchRequest)3 EventMapping (org.springframework.web.portlet.bind.annotation.EventMapping)3 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)2 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)2 PortletUrl (org.apereo.portal.search.PortletUrl)2 PortletUrlParameter (org.apereo.portal.search.PortletUrlParameter)2 IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)2 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 PortletSession (javax.portlet.PortletSession)1