Hello,

I'm trying to use the SEARCH method of WebDAV, which is supported
according to the documentation:

http://jackrabbit.apache.org/jcr/components/jackrabbit-webdav-library.html

However, when I try performing a SEARCH on the standalone server, I get
a "Method not allowed" (405) error (the code used is below). Other
methods work, however.

How do I enable the search method for a jackrabbit WebDAV repository?
Is there anything else I'm missing?

I'm using the latest stable version of Jackrabbit (2.12.2).

Any help would be greatly appreciated.

Regards, and thanks,

        Mario S. Mommer

P.S: Here is the code I'm using to perform the tests:

import java.io.IOException;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.jackrabbit.webdav.client.methods.SearchMethod;

public class TestDav {
        static void testSearch(HttpClient client) throws IOException {
                String query = "<D:searchrequest xmlns:D =\"DAV:\">" + "  
<D:sql>"
                                + "SELECT * FROM [nt:base]" + "  </D:sql>"
                                + "</D:searchrequest>";
                SearchMethod searchMethod = new 
SearchMethod("/repository/default/",
                                query, "SQL");
                client.executeMethod(searchMethod);
                byte[] resp = searchMethod.getResponseBody();
                System.out.println("response: " + resp);

                int statuscode = searchMethod.getStatusCode();
                System.out.println("statusCode: " + statuscode);
                String statustext = searchMethod.getStatusText();
                System.out.println("text: " + statustext);

        }

        static void testGet(HttpClient client) throws IOException {
                GetMethod gm = new GetMethod("/repository/default/receta.txt");

                client.executeMethod(gm);
                byte[] resp = gm.getResponseBody();
                System.out.println("response: " + resp);

                int statuscode = gm.getStatusCode();
                System.out.println("statusCode: " + statuscode);
                String statustext = gm.getStatusText();
                System.out.println("text: " + statustext);
        }

        public static void main(String[] args) throws IOException {
                HostConfiguration hostConfig = new HostConfiguration();
                hostConfig.setHost("localhost", 5007);
                HttpConnectionManager connectionManager = new 
MultiThreadedHttpConnectionManager();
                HttpConnectionManagerParams params = new 
HttpConnectionManagerParams();
                int maxHostConnections = 20;
                params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
                connectionManager.setParams(params);

                HttpClient client = new HttpClient(connectionManager);
                Credentials creds = new UsernamePasswordCredentials("admin", 
"admin");
                client.getState().setCredentials(AuthScope.ANY, creds);
                client.setHostConfiguration(hostConfig);

                System.out.println("Testing GET:");
                testGet(client);

                System.out.println();
                System.out.println("Testing SEARCH:");
                testSearch(client);
        }

}


Reply via email to