Reputation: 141
I'm trying to execute import via java using ModifiableSolrParams:
Can you please point me on the right direction or reference on how to add security credentials (username / password) to trigger the import.
Current code
SolrServer server = new HttpSolrServer(baseurl);
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("command", "full-import");
params.set("clean", "true");
params.set("commit", "true");
QueryRequest request = new QueryRequest(params);
request.setPath("/dataimport");
server.request(request);
Upvotes: 0
Views: 190
Reputation: 141
I veered away from Solrj and went with this approach instead.
HttpClient Client = new DefaultHttpClient();
String userpass = usr + ":" + pwd;
HttpPost httpGet = new HttpPost(dataimport_cmd);
String encoding =
DatatypeConverter.printBase64Binary(userpass.getBytes("UTF-8"));
httpGet.setHeader("Authorization", "Basic " + encoding);
Client.execute(httpGet);
Upvotes: 1
Reputation: 197
You need to add HttpRequestInterceptor to you HttpServer. This interceptor will be able to add authorization header to every your request.
For cloud Solr the util class that allow to do this is HttpClientUtil. You can start from this class, or check where in HttpSolrServer is actually HttpClient present.
Upvotes: 1