//--------------------------------------------------------------------------
public Element exec(Element params, ServiceContext context) throws Exception
{
// build result data
UserSession session = context.getUserSession();
MetaSearcher searcher = (MetaSearcher) session.getProperty(Geonet.Session.SEARCH_RESULT);
String fast = _config.getValue("fast","");
if (StringUtils.isNotEmpty(fast)) {
params.addContent(new Element("fast").setText(fast));
}
String range = _config.getValue("range");
if (range != null)
if (range.equals("all"))
{
params.addContent(new Element("from").setText("1"));
params.addContent(new Element("to").setText(searcher.getSize() +""));
} else {
params.addContent(new Element("from").setText("1"));
params.addContent(new Element("to").setText(range));
}
Element result = searcher.present(context, params, _config);
// Update result elements to present
SelectionManager.updateMDResult(context.getUserSession(), result);
// Restore last search if set
String restoreLastSearch = params.getChildText(Geonet.SearchResult.RESTORELASTSEARCH);
if (restoreLastSearch != null && restoreLastSearch.equals("yes")) {
Object oldSearcher = session.getProperty(Geonet.Session.LAST_SEARCH_RESULT);
if (oldSearcher != null) {
context.info("Restoring last search");
if (oldSearcher instanceof LuceneSearcher) ((LuceneSearcher)searcher).close();
session.setProperty(Geonet.Session.SEARCH_RESULT, oldSearcher);
}
}
return result;
}