use of org.olat.search.SearchResults in project OpenOLAT by OpenOLAT.
the class JmsSearchProvider method onSearchMessage.
void onSearchMessage(SearchRequest searchRequest, String correlationID, Destination replyTo) {
if (log_.isDebug()) {
log_.debug("onSearchMessage, correlationID=" + correlationID + " , replyTo=" + replyTo + " , searchRequest=" + searchRequest);
}
Session session = null;
try {
Identity identity = BaseSecurityManager.getInstance().loadIdentityByKey(searchRequest.getIdentityId());
SearchResults searchResults = this.doSearch(searchRequest.getQueryString(), searchRequest.getCondQueries(), identity, searchRequest.getRoles(), searchRequest.getFirstResult(), searchRequest.getMaxResults(), searchRequest.isDoHighlighting());
if (log_.isDebug()) {
log_.debug("searchResults: " + searchResults.size());
}
if (searchResults != null) {
session = acquireSession();
Message responseMessage = session.createObjectMessage(searchResults);
responseMessage.setJMSCorrelationID(correlationID);
responseMessage.setStringProperty(SearchClientProxy.JMS_RESPONSE_STATUS_PROPERTY_NAME, SearchClientProxy.JMS_RESPONSE_STATUS_OK);
MessageProducer producer = session.createProducer(replyTo);
if (log_.isDebug()) {
log_.debug("onSearchMessage, send ResponseMessage=" + responseMessage + " to replyTo=" + replyTo);
}
producer.send(responseMessage);
producer.close();
return;
} else {
log_.info("onSearchMessage, no searchResults (searchResults=null)");
}
} catch (JMSException e) {
log_.error("error when receiving jms messages", e);
// signal search not available
return;
// do not throw exceptions here throw new OLATRuntimeException();
} catch (ServiceNotAvailableException sex) {
sendErrorResponse(SearchClientProxy.JMS_RESPONSE_STATUS_SERVICE_NOT_AVAILABLE_EXCEPTION, correlationID, replyTo);
} catch (ParseException pex) {
sendErrorResponse(SearchClientProxy.JMS_RESPONSE_STATUS_PARSE_EXCEPTION, correlationID, replyTo);
} catch (QueryException qex) {
sendErrorResponse(SearchClientProxy.JMS_RESPONSE_STATUS_QUERY_EXCEPTION, correlationID, replyTo);
} catch (Throwable th) {
log_.error("error at ClusteredSearchProvider.receive()", th);
// signal search not available
return;
// do not throw exceptions throw new OLATRuntimeException();
} finally {
releaseSession(session);
DBFactory.getInstance().commitAndCloseSession();
}
}
use of org.olat.search.SearchResults in project openolat by klemens.
the class JmsSearchProvider method onSearchMessage.
void onSearchMessage(SearchRequest searchRequest, String correlationID, Destination replyTo) {
if (log_.isDebug()) {
log_.debug("onSearchMessage, correlationID=" + correlationID + " , replyTo=" + replyTo + " , searchRequest=" + searchRequest);
}
Session session = null;
try {
Identity identity = BaseSecurityManager.getInstance().loadIdentityByKey(searchRequest.getIdentityId());
SearchResults searchResults = this.doSearch(searchRequest.getQueryString(), searchRequest.getCondQueries(), identity, searchRequest.getRoles(), searchRequest.getFirstResult(), searchRequest.getMaxResults(), searchRequest.isDoHighlighting());
if (log_.isDebug()) {
log_.debug("searchResults: " + searchResults.size());
}
if (searchResults != null) {
session = acquireSession();
Message responseMessage = session.createObjectMessage(searchResults);
responseMessage.setJMSCorrelationID(correlationID);
responseMessage.setStringProperty(SearchClientProxy.JMS_RESPONSE_STATUS_PROPERTY_NAME, SearchClientProxy.JMS_RESPONSE_STATUS_OK);
MessageProducer producer = session.createProducer(replyTo);
if (log_.isDebug()) {
log_.debug("onSearchMessage, send ResponseMessage=" + responseMessage + " to replyTo=" + replyTo);
}
producer.send(responseMessage);
producer.close();
return;
} else {
log_.info("onSearchMessage, no searchResults (searchResults=null)");
}
} catch (JMSException e) {
log_.error("error when receiving jms messages", e);
// signal search not available
return;
// do not throw exceptions here throw new OLATRuntimeException();
} catch (ServiceNotAvailableException sex) {
sendErrorResponse(SearchClientProxy.JMS_RESPONSE_STATUS_SERVICE_NOT_AVAILABLE_EXCEPTION, correlationID, replyTo);
} catch (ParseException pex) {
sendErrorResponse(SearchClientProxy.JMS_RESPONSE_STATUS_PARSE_EXCEPTION, correlationID, replyTo);
} catch (QueryException qex) {
sendErrorResponse(SearchClientProxy.JMS_RESPONSE_STATUS_QUERY_EXCEPTION, correlationID, replyTo);
} catch (Throwable th) {
log_.error("error at ClusteredSearchProvider.receive()", th);
// signal search not available
return;
// do not throw exceptions throw new OLATRuntimeException();
} finally {
releaseSession(session);
DBFactory.getInstance().commitAndCloseSession();
}
}
Aggregations