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>" +
                    "</D:searchrequest>";

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>";

Shen

________________________________
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

Hello

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?

Code:
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);
                  connectionManager.setParams(params);

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

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

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

Best regards

Shen


Mime
View raw message