use of org.eclipse.sw360.datahandler.thrift.search.SearchResult in project sw360portal by sw360.
the class SearchPortlet method doView.
@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
final User user = UserCacheHolder.getUserFromRequest(request);
String searchtext = request.getParameter(KEY_SEARCH_TEXT);
String[] typeMaskArray = request.getParameterValues(TYPE_MASK);
List<String> typeMask;
if (typeMaskArray != null) {
// premature optimization would add && typeMaskArray.length<6
typeMask = Arrays.asList(typeMaskArray);
} else {
typeMask = Collections.emptyList();
log.info("typeMask set to emptyList");
}
String usedsearchtext;
if (isNullOrEmpty(searchtext)) {
usedsearchtext = "";
searchtext = "";
} else {
usedsearchtext = searchtext;
}
List<SearchResult> searchResults;
try {
SearchService.Iface client = thriftClients.makeSearchClient();
searchResults = client.searchFiltered(usedsearchtext, user, typeMask);
} catch (TException e) {
log.error("Search could not be performed!", e);
searchResults = Collections.emptyList();
}
// Set the results
request.setAttribute(KEY_SEARCH_TEXT, searchtext);
request.setAttribute(KEY_SUMMARY, searchResults);
request.setAttribute(TYPE_MASK, typeMask);
// Proceed with page rendering
super.doView(request, response);
}
Aggregations