Search in sources :

Example 1 with SearchResource

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

the class AbstractWebdavServlet method doOptions.

/**
     * The OPTION method
     *
     * @param request
     * @param response
     * @param resource
     */
protected void doOptions(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException {
    response.addHeader(DavConstants.HEADER_DAV, resource.getComplianceClass());
    response.addHeader("Allow", resource.getSupportedMethods());
    response.addHeader("MS-Author-Via", DavConstants.HEADER_DAV);
    if (resource instanceof SearchResource) {
        String[] langs = ((SearchResource) resource).getQueryGrammerSet().getQueryLanguages();
        for (String lang : langs) {
            response.addHeader(SearchConstants.HEADER_DASL, "<" + lang + ">");
        }
    }
    // with DeltaV the OPTIONS request may contain a Xml body.
    OptionsResponse oR = null;
    OptionsInfo oInfo = request.getOptionsInfo();
    if (oInfo != null && resource instanceof DeltaVResource) {
        oR = ((DeltaVResource) resource).getOptionResponse(oInfo);
    }
    if (oR == null) {
        response.setStatus(DavServletResponse.SC_OK);
    } else {
        response.sendXmlResponse(oR, DavServletResponse.SC_OK);
    }
}
Also used : DeltaVResource(org.apache.jackrabbit.webdav.version.DeltaVResource) SearchResource(org.apache.jackrabbit.webdav.search.SearchResource) OptionsResponse(org.apache.jackrabbit.webdav.version.OptionsResponse) OptionsInfo(org.apache.jackrabbit.webdav.version.OptionsInfo)

Example 2 with SearchResource

use of org.apache.jackrabbit.webdav.search.SearchResource 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

SearchResource (org.apache.jackrabbit.webdav.search.SearchResource)2 SearchInfo (org.apache.jackrabbit.webdav.search.SearchInfo)1 DeltaVResource (org.apache.jackrabbit.webdav.version.DeltaVResource)1 OptionsInfo (org.apache.jackrabbit.webdav.version.OptionsInfo)1 OptionsResponse (org.apache.jackrabbit.webdav.version.OptionsResponse)1 Document (org.w3c.dom.Document)1