jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xiaojie Shen <Xiaojie.S...@cybercomgroup.com>
Subject RE: jackrabbit searchMethod - error 405 Method Not Allowed
Date Wed, 23 Jun 2010 13:21:30 GMT
SearchMethod is not allowed for repository. Should be "/jackrabbit-webapp_default/server/default".

From: Xiaojie Shen
Sent: den 22 juni 2010 18:37
To: 'dev@jackrabbit.apache.org'
Subject: RE: jackrabbit searchMethod - error 405 Method Not Allowed

Well, I answer myself. Problem is the "/" in search path. Slide webdav uses "/", but it doesn't
work in Jackrabbit.

SearchMethod searchMethod = new SearchMethod("/jackrabbit-webapp_default/repository/default",query,"sql");
should be
SearchMethod searchMethod = new SearchMethod("jackrabbit-webapp_default/repository/default",query,"sql");

Now I get error 400 Bad Request because of invalid query body. I tried the following sql/xpath
queries with or without sql/xpath tags, but none of them succeeds. Can someone give a query
example that's working against the Jackrabbit standalone server?

String query = "<D:searchrequest xmlns:D =\"DAV:\">" +
                    "  <D:sql>" +
                    " select * from nt:base" +
                    "  </D:sql>" +

String query = "<d:searchrequest xmlns:d=\"DAV:\" dcr:=\"http://www.day.com/jcr/webdav/1.0\">"
                  " <dcr:xpath>//sv:node[@sv:name='jcr:root']</dcr:xpath>" +
                  " </d:searchrequest>";


From: Xiaojie Shen [mailto:Xiaojie.Shen@cybercomgroup.com]
Sent: den 21 juni 2010 10:13
To: dev@jackrabbit.apache.org
Subject: jackrabbit searchMethod - error 405 Method Not Allowed
Importance: High


We're trying to do Webdav Search by Jackrabbit searchMethod against our Jackrabbit server,
but always get error 405 Method Not Allowed and there's none error logged in Jackrabbit log.
Then I'm trying to do Search against the Jackrabbit default server, but same error is given.
So far, I haven't found any successful example of SearchMethod on Jackrabbit's wiki or other
resource. Can anybody please give some suggestion?

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.params.HttpConnectionManagerParams;
import org.apache.jackrabbit.webdav.client.methods.SearchMethod;

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

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

                  String query = "<D:searchrequest xmlns:D =\"DAV:\">" +
                    "  <D:sql>" +
                    " SELECT *" +
                    "  </D:sql>" +
                  SearchMethod searchMethod = new SearchMethod("/jackrabbit-webapp_default/repository/default",query,"sql");
                  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);

Run result:
response: [B@c44b88
statusCode 405
text Method Not Allowed

Best regards


View raw message