use of org.jasig.portal.search.SearchResults in project SimpleContentPortlet by Jasig.
the class SearchContentController method searchContent.
@EventMapping(SearchConstants.SEARCH_REQUEST_QNAME_STRING)
public void searchContent(EventRequest request, EventResponse response) {
final Event event = request.getEvent();
final SearchRequest searchQuery = (SearchRequest) event.getValue();
final String textContent = getTextContent(request);
final String[] searchTerms = searchQuery.getSearchTerms().split(" ");
for (final String term : searchTerms) {
if (StringUtils.containsIgnoreCase(textContent, term)) {
// matched, create results object and copy over the query id
final SearchResults searchResults = new SearchResults();
searchResults.setQueryId(searchQuery.getQueryId());
searchResults.setWindowId(request.getWindowID());
// Build the result object for the match
final SearchResult searchResult = new SearchResult();
String title = request.getPreferences().getValue("searchResultsTitle", "${portlet.title}");
searchResult.setTitle(title);
searchResult.setSummary(getContentSummary(textContent));
searchResult.getType().add("Portlet Content");
// Add the result to the results and send the event
searchResults.getSearchResult().add(searchResult);
response.setEvent(SearchConstants.SEARCH_RESULTS_QNAME, searchResults);
// Stop processing
return;
}
}
}
Aggregations