Blame | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.services;import java.util.Map;import org.apache.http.conn.HttpHostConnectException;import org.json.JSONArray;import org.json.JSONObject;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Value;import org.springframework.stereotype.Component;import com.spice.profitmandi.common.enumuration.SchemeType;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.web.client.RestClient;import com.spice.profitmandi.service.catalog.BrandsService;/*** Executes partner-facing queries against the solr demo core, always applying* the partner's restricted-brand (blocked + LOI-ineligible) exclusion at query time.*/@Componentpublic class PartnerSolrClient {@Value("${new.solr.url}")private String solrUrl;@Autowiredprivate BrandsService brandsService;@Autowiredprivate RestClient restClient;public JSONArray selectDocs(Map<String, String> params, int fofoId) throws ProfitMandiBusinessException {brandsService.applyRestrictedSolrExclusion(params, fofoId);String response;try {response = restClient.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);} catch (HttpHostConnectException e) {throw new ProfitMandiBusinessException("", "", "Could not connect to host");}return new JSONObject(response).getJSONObject("response").getJSONArray("docs");}}