Search in sources :

Example 1 with SolrSQLJSONResultSet

use of org.alfresco.repo.search.impl.solr.SolrSQLJSONResultSet in project alfresco-remote-api by Alfresco.

the class SearchSQLApiWebscript method execute.

@Override
public void execute(WebScriptRequest webScriptRequest, WebScriptResponse res) throws IOException {
    try {
        // Turn JSON into a Java object representation
        SearchSQLQuery searchQuery = extractJsonContent(webScriptRequest, assistant.getJsonHelper(), SearchSQLQuery.class);
        SearchParameters sparams = buildSearchParameters(searchQuery);
        ResultSet results = searchService.query(sparams);
        FilteringResultSet frs = (FilteringResultSet) results;
        SolrSQLJSONResultSet ssjr = (SolrSQLJSONResultSet) frs.getUnFilteredResultSet();
        // When solr format is requested pass the solr output directly.
        if (searchQuery.getFormat().equalsIgnoreCase("solr")) {
            res.getWriter().write(ssjr.getSolrResponse());
        } else {
            CollectionWithPagingInfo<TupleList> nodes = resultMapper.toCollectionWithPagingInfo(ssjr.getDocs(), searchQuery);
            renderJsonResponse(res, nodes, assistant.getJsonHelper());
        }
        setResponse(res, DEFAULT_SUCCESS);
    } catch (Exception exception) {
        renderException(exception, res, assistant);
    }
}
Also used : FilteringResultSet(org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet) TupleList(org.alfresco.rest.api.search.model.TupleList) SearchParameters(org.alfresco.service.cmr.search.SearchParameters) SolrSQLJSONResultSet(org.alfresco.repo.search.impl.solr.SolrSQLJSONResultSet) ResultSet(org.alfresco.service.cmr.search.ResultSet) FilteringResultSet(org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet) SolrSQLJSONResultSet(org.alfresco.repo.search.impl.solr.SolrSQLJSONResultSet) SearchSQLQuery(org.alfresco.rest.api.search.model.SearchSQLQuery) IOException(java.io.IOException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Aggregations

IOException (java.io.IOException)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 SolrSQLJSONResultSet (org.alfresco.repo.search.impl.solr.SolrSQLJSONResultSet)1 FilteringResultSet (org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet)1 SearchSQLQuery (org.alfresco.rest.api.search.model.SearchSQLQuery)1 TupleList (org.alfresco.rest.api.search.model.TupleList)1 ResultSet (org.alfresco.service.cmr.search.ResultSet)1 SearchParameters (org.alfresco.service.cmr.search.SearchParameters)1