public static String addParam(String url, String name, Object value) { try { return UrlUtils.addParam(url, name, value.toString(), "UTF-8"); } catch (UnsupportedEncodingException e) { // Shouldn't happen, UTF-8 is a valid encoding throw new IllegalStateException(e); } }
protected String createBaseUrl(String serviceUrl) { return UrlUtils.concat(serverUrl, URL_ROOT, serviceUrl); }
@Override @SuppressWarnings("unchecked") public Map<String, Object> search(String indexId, SolrQuery query) throws SearchException { String searchUrl = createBaseUrl(URL_SEARCH, indexId); searchUrl = UrlUtils.addQueryStringFragment(searchUrl, query.toUrlQueryString()); try { return restTemplate.getForObject(new URI(searchUrl), Map.class); } catch (URISyntaxException e) { throw new SearchException(indexId, "Invalid URI: " + searchUrl, e); } catch (HttpStatusCodeException e) { throw new SearchException(indexId, "Search for query " + query + " failed: [" + e.getStatusText() + "] " + e.getResponseBodyAsString()); } catch (Exception e) { throw new SearchException(indexId, "Search for query " + query + " failed: " + e.getMessage(), e); } }
@Override @SuppressWarnings("unchecked") public Map<String, Object> search(String indexId, SolrQuery query) throws SearchException { String searchUrl = createBaseUrl(URL_SEARCH, indexId); searchUrl = UrlUtils.addQueryStringFragment(searchUrl, query.toUrlQueryString()); try { return restTemplate.getForObject(new URI(searchUrl), Map.class); } catch (URISyntaxException e) { throw new SearchException(indexId, "Invalid URI: " + searchUrl, e); } catch (HttpStatusCodeException e) { throw getSearchException(indexId, "Search for query " + query + " failed: [" + e.getStatusText() + "] " + e.getResponseBodyAsString(), e); } catch (Exception e) { throw new SearchException(indexId, "Search for query " + query + " failed: " + e.getMessage(), e); } }
protected String createBaseUrl(String serviceUrl) { return UrlUtils.concat(serverUrl, URL_ROOT, serviceUrl); }