mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-15 15:02:20 +00:00
Merged searchbcr (5.2.1) to 5.2.N (5.2.1)
135428 gjames: Using a @FunctionalInterface git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@136074 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,16 +23,17 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Processes Json returned from Solr
|
||||
*
|
||||
* @author Gethin James
|
||||
*/
|
||||
public interface SolrJsonProcessor<T extends JSONResult>
|
||||
{
|
||||
public T getResult(JSONObject json);
|
||||
}
|
||||
package org.alfresco.repo.search.impl.lucene;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Processes Json returned from Solr
|
||||
*
|
||||
* @author Gethin James
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface SolrJsonProcessor<T extends JSONResult>
|
||||
{
|
||||
public T getResult(JSONObject json);
|
||||
}
|
||||
|
@@ -275,7 +275,7 @@ public class SolrQueryHTTPClient implements BeanFactoryAware, InitializingBean
|
||||
|
||||
Pair<HttpClient, String> httpClientAndBaseUrl = mapping.getHttpClientAndBaseUrl();
|
||||
HttpClient httpClient = httpClientAndBaseUrl.getFirst();
|
||||
String url = buildStatsUrl(searchParameters, httpClientAndBaseUrl.getSecond(), locale, mapping);
|
||||
String url = buildStatsUrl(searchParameters, httpClientAndBaseUrl.getSecond(), locale, mapping);
|
||||
JSONObject body = buildStatsBody(searchParameters, tenantService.getCurrentUserDomain(), locale);
|
||||
|
||||
if(httpClient == null)
|
||||
@@ -283,14 +283,9 @@ public class SolrQueryHTTPClient implements BeanFactoryAware, InitializingBean
|
||||
throw new AlfrescoRuntimeException("No http client for store " + store.toString());
|
||||
}
|
||||
|
||||
return (SolrStatsResult) postSolrQuery(httpClient, url, body, new SolrJsonProcessor<SolrStatsResult>() {
|
||||
|
||||
@Override
|
||||
public SolrStatsResult getResult(JSONObject json)
|
||||
{
|
||||
return new SolrStatsResult(json, searchParameters.isDateSearch());
|
||||
}
|
||||
|
||||
return (SolrStatsResult) postSolrQuery(httpClient, url, body, json ->
|
||||
{
|
||||
return new SolrStatsResult(json, searchParameters.isDateSearch());
|
||||
});
|
||||
|
||||
}
|
||||
@@ -312,7 +307,7 @@ public class SolrQueryHTTPClient implements BeanFactoryAware, InitializingBean
|
||||
}
|
||||
}
|
||||
|
||||
protected String buildStatsUrl(StatsParameters searchParameters, String baseUrl, Locale locale, SolrStoreMappingWrapper mapping) throws UnsupportedEncodingException
|
||||
protected String buildStatsUrl(StatsParameters searchParameters, String baseUrl, Locale locale, SolrStoreMappingWrapper mapping) throws UnsupportedEncodingException
|
||||
{
|
||||
URLCodec encoder = new URLCodec();
|
||||
StringBuilder url = new StringBuilder();
|
||||
@@ -337,28 +332,28 @@ public class SolrQueryHTTPClient implements BeanFactoryAware, InitializingBean
|
||||
url.append("&stats.").append(entry.getKey()).append("=").append(encoder.encode(entry.getValue(), "UTF-8"));
|
||||
}
|
||||
|
||||
if((mapping != null) && ((searchParameters.getStores().size() > 1) || (mapping.isSharded())))
|
||||
{
|
||||
boolean requiresSeparator = false;
|
||||
url.append("&shards=");
|
||||
for(StoreRef storeRef : searchParameters.getStores())
|
||||
{
|
||||
SolrStoreMappingWrapper storeMapping = extractMapping(storeRef);
|
||||
|
||||
if(requiresSeparator)
|
||||
{
|
||||
url.append(',');
|
||||
}
|
||||
else
|
||||
{
|
||||
requiresSeparator = true;
|
||||
}
|
||||
|
||||
url.append(storeMapping.getShards());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if((mapping != null) && ((searchParameters.getStores().size() > 1) || (mapping.isSharded())))
|
||||
{
|
||||
boolean requiresSeparator = false;
|
||||
url.append("&shards=");
|
||||
for(StoreRef storeRef : searchParameters.getStores())
|
||||
{
|
||||
SolrStoreMappingWrapper storeMapping = extractMapping(storeRef);
|
||||
|
||||
if(requiresSeparator)
|
||||
{
|
||||
url.append(',');
|
||||
}
|
||||
else
|
||||
{
|
||||
requiresSeparator = true;
|
||||
}
|
||||
|
||||
url.append(storeMapping.getShards());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
@@ -546,16 +541,9 @@ public class SolrQueryHTTPClient implements BeanFactoryAware, InitializingBean
|
||||
|
||||
final int maximumResults = maxResults; //just needed for the final parameter
|
||||
|
||||
|
||||
|
||||
return (ResultSet) postSolrQuery(httpClient, url.toString(), body, new SolrJsonProcessor<SolrJSONResultSet>() {
|
||||
|
||||
@Override
|
||||
public SolrJSONResultSet getResult(JSONObject json)
|
||||
{
|
||||
return new SolrJSONResultSet(json, searchParameters, nodeService, nodeDAO, limitBy, maximumResults);
|
||||
}
|
||||
|
||||
return (ResultSet) postSolrQuery(httpClient, url.toString(), body, json ->
|
||||
{
|
||||
return new SolrJSONResultSet(json, searchParameters, nodeService, nodeDAO, limitBy, maximumResults);
|
||||
}, spellCheckQueryStr);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
|
Reference in New Issue
Block a user