| 37144 |
amit |
1 |
package com.spice.profitmandi.web.services;
|
|
|
2 |
|
|
|
3 |
import java.util.Map;
|
|
|
4 |
|
|
|
5 |
import org.apache.http.conn.HttpHostConnectException;
|
|
|
6 |
import org.json.JSONArray;
|
|
|
7 |
import org.json.JSONObject;
|
|
|
8 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
9 |
import org.springframework.beans.factory.annotation.Value;
|
|
|
10 |
import org.springframework.stereotype.Component;
|
|
|
11 |
|
|
|
12 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
|
|
13 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
14 |
import com.spice.profitmandi.common.web.client.RestClient;
|
|
|
15 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Executes partner-facing queries against the solr demo core, always applying
|
|
|
19 |
* the partner's restricted-brand (blocked + LOI-ineligible) exclusion at query time.
|
|
|
20 |
*/
|
|
|
21 |
@Component
|
|
|
22 |
public class PartnerSolrClient {
|
|
|
23 |
|
|
|
24 |
@Value("${new.solr.url}")
|
|
|
25 |
private String solrUrl;
|
|
|
26 |
|
|
|
27 |
@Autowired
|
|
|
28 |
private BrandsService brandsService;
|
|
|
29 |
|
|
|
30 |
@Autowired
|
|
|
31 |
private RestClient restClient;
|
|
|
32 |
|
|
|
33 |
public JSONArray selectDocs(Map<String, String> params, int fofoId) throws ProfitMandiBusinessException {
|
|
|
34 |
brandsService.applyRestrictedSolrExclusion(params, fofoId);
|
|
|
35 |
String response;
|
|
|
36 |
try {
|
|
|
37 |
response = restClient.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
|
|
|
38 |
} catch (HttpHostConnectException e) {
|
|
|
39 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
|
|
40 |
}
|
|
|
41 |
return new JSONObject(response).getJSONObject("response").getJSONArray("docs");
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
}
|