Search in sources :

Example 1 with SearchInfo

use of org.apache.jackrabbit.webdav.search.SearchInfo in project jackrabbit by apache.

the class RepositoryServiceImpl method executeQuery.

@Override
public QueryInfo executeQuery(SessionInfo sessionInfo, String statement, String language, Map<String, String> namespaces, long limit, long offset, Map<String, QValue> values) throws RepositoryException {
    HttpSearch request = null;
    try {
        String uri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
        SearchInfo sInfo = new SearchInfo(language, ItemResourceConstants.NAMESPACE, statement, namespaces);
        if (limit != -1) {
            sInfo.setNumberResults(limit);
        }
        if (offset != -1) {
            sInfo.setOffset(offset);
        }
        if (!(values == null || values.isEmpty())) {
            throw new UnsupportedOperationException("Implementation missing:  JCR-2107");
        }
        request = new HttpSearch(uri, sInfo);
        HttpResponse response = executeRequest(sessionInfo, request);
        request.checkSuccess(response);
        MultiStatus ms = request.getResponseBodyAsMultiStatus(response);
        NamePathResolver resolver = getNamePathResolver(sessionInfo);
        return new QueryInfoImpl(ms, idFactory, resolver, valueFactory, getQValueFactory());
    } catch (IOException e) {
        throw new RepositoryException(e);
    } catch (DavException e) {
        throw ExceptionConverter.generate(e);
    } finally {
        if (request != null) {
            request.releaseConnection();
        }
    }
}
Also used : NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) SearchInfo(org.apache.jackrabbit.webdav.search.SearchInfo) DavException(org.apache.jackrabbit.webdav.DavException) HttpResponse(org.apache.http.HttpResponse) MultiStatus(org.apache.jackrabbit.webdav.MultiStatus) RepositoryException(javax.jcr.RepositoryException) HttpSearch(org.apache.jackrabbit.webdav.client.methods.HttpSearch) IOException(java.io.IOException)

Example 2 with SearchInfo

use of org.apache.jackrabbit.webdav.search.SearchInfo in project jackrabbit by apache.

the class AbstractWebdavServlet method doSearch.

/**
     * The SEARCH method
     *
     * @param request
     * @param response
     * @param resource
     * @throws DavException
     * @throws IOException
     */
protected void doSearch(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException {
    if (!(resource instanceof SearchResource)) {
        response.sendError(DavServletResponse.SC_METHOD_NOT_ALLOWED);
        return;
    }
    Document doc = request.getRequestDocument();
    if (doc != null) {
        SearchInfo sR = SearchInfo.createFromXml(doc.getDocumentElement());
        response.sendMultiStatus(((SearchResource) resource).search(sR));
    } else {
        // request without request body is valid if requested resource
        // is a 'query' resource.
        response.sendMultiStatus(((SearchResource) resource).search(null));
    }
}
Also used : SearchInfo(org.apache.jackrabbit.webdav.search.SearchInfo) Document(org.w3c.dom.Document) SearchResource(org.apache.jackrabbit.webdav.search.SearchResource)

Aggregations

SearchInfo (org.apache.jackrabbit.webdav.search.SearchInfo)2 IOException (java.io.IOException)1 RepositoryException (javax.jcr.RepositoryException)1 HttpResponse (org.apache.http.HttpResponse)1 NamePathResolver (org.apache.jackrabbit.spi.commons.conversion.NamePathResolver)1 DavException (org.apache.jackrabbit.webdav.DavException)1 MultiStatus (org.apache.jackrabbit.webdav.MultiStatus)1 HttpSearch (org.apache.jackrabbit.webdav.client.methods.HttpSearch)1 SearchResource (org.apache.jackrabbit.webdav.search.SearchResource)1 Document (org.w3c.dom.Document)1