use of org.olat.search.QueryException 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.QueryException in project openolat by klemens.
the class FileDocumentFactory method getDocumentFromCurrentIndex.
private Document getDocumentFromCurrentIndex(SearchResourceContext leafResourceContext, VFSLeaf leaf) {
try {
String resourceUrl = leafResourceContext.getResourceUrl();
SearchService searchService = CoreSpringFactory.getImpl(SearchServiceImpl.class);
Document indexedDoc = searchService.doSearch(resourceUrl);
if (indexedDoc != null) {
String timestamp = indexedDoc.get(AbstractOlatDocument.TIME_STAMP_NAME);
if (timestamp != null) {
Date indexLastModification = DateTools.stringToDate(timestamp);
Date docLastModificationDate = new Date(leaf.getLastModified());
if (leaf instanceof MetaTagged) {
MetaInfo metaInfo = ((MetaTagged) leaf).getMetaInfo();
Date metaDate = metaInfo.getMetaLastModified();
if (metaDate != null && metaDate.after(docLastModificationDate)) {
docLastModificationDate = metaDate;
}
}
if (docLastModificationDate.compareTo(indexLastModification) < 0) {
OlatDocument olatDoc = new OlatDocument(indexedDoc);
return olatDoc.getLuceneDocument();
}
}
}
} catch (ServiceNotAvailableException | ParseException | QueryException | java.text.ParseException e) {
log.error("", e);
}
return null;
}
use of org.olat.search.QueryException 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