Search API
The Search API uses the Events API that is part of JSR-286. Below is a summary of the approach used to implement the new Search API included in uPortal 4
How To Integrate with the uPortal Search API
Step 1. Add the uportal-search-api jar to your portlet
Step 2. Add the portlet-app level event-definitions and .....
Add the portlet-app level event-definitions and the portlet level supported-publishing-event and supported-processing-event elements. These declare to the portal the events your portlet app knows about and which events your portlet wants to be notified of and which events it will be publishing.
Step 3. Add @EventMapping...
Add @EventMapping(SearchConstants.SEARCH_REQUEST_QNAME_STRING) to a method in a @Controller
- See the searchContent method in https://github.com/Jasig/SimpleContentPortlet/tree/master/src/main/java/org/jasig/portlet/cms/mvc/portlet/SearchContentController.java
- Here is where the work happens, EventRequest.getEvent() returns a SearchRequest
- SearchRequest specified the search terms that were specified, your portlet should use these to do its searching
- If there is a hit create a SearchResults object, copy over the queryId, set the windowId, for each result create a SearchResult and set title/summary. Set the type to a string relevant to your portlet. The type is used to determine which tab to display the results on (as determined by map "searchTabs" in bean https://github.com/Jasig/uPortal/blob/master/uportal-war/src/main/resources/properties/contexts/servicesContext.xml)
- Call EventResponse.setEvent to send the results back to the search portlet
- This example is Spring 3.x specific but it can be doing using the plain-old portlet 2 APIs as well
Â
List of Apereo Portlets Already Integrated with the uPortal Search API
Portlet | Search Results Type value |
---|---|
Calendar | v2.1.3-M3: Calendar, pre v2.1.3-M3: null |
Simple Content Management Portlet | v1.0.8: Portlet Content, pre v1.0.8: null |
Contacts Portlet | contact |
Add Feedback content box here.....