use of org.springframework.expression.spel.SpelParseException in project uPortal by Jasig.
the class SearchPortletController method modifySearchResultLinkTitle.
/**
* Since portlets don't have access to the portlet definition to create a useful search results
* link using something like the portlet definition's title, post-process the link text and for
* those portlets whose type is present in the substitution set, replace the title with the
* portlet definition's title.
*
* @param result Search results object (may be modified)
* @param httpServletRequest HttpServletRequest
* @param portletWindowId Portlet Window ID
*/
protected void modifySearchResultLinkTitle(SearchResult result, final HttpServletRequest httpServletRequest, final IPortletWindowId portletWindowId) {
// If the title contains a SpEL expression, parse it with the portlet definition in the evaluation context.
if (result.getType().size() > 0 && result.getTitle().contains("${")) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(httpServletRequest, portletWindowId);
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
final SpELEnvironmentRoot spelEnvironment = new SpELEnvironmentRoot(portletDefinition);
try {
result.setTitle(spELService.getValue(result.getTitle(), spelEnvironment));
} catch (SpelParseException | SpelEvaluationException e) {
result.setTitle("(Invalid portlet title) - see details in log file");
logger.error("Invalid Spring EL expression {} in search result portlet title", result.getTitle(), e);
}
}
}
Aggregations