@ 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 ( ) ) ; // portletWindow is null if user does not have access to portlet. // 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 ; }
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