Merged 5.1.0 (5.1.0.9) to 5.1.N (5.1.2)

128469 ahind: MNT-16445: Inconsistent behavior of Site File Type Breakdown dashlet in a sharded environment


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@128736 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2016-07-12 14:04:44 +00:00
parent cc6549f253
commit 15c4fb0f57
2 changed files with 25 additions and 3 deletions

View File

@@ -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);
String url = buildStatsUrl(searchParameters, httpClientAndBaseUrl.getSecond(), locale, mapping);
JSONObject body = buildStatsBody(searchParameters, tenantService.getCurrentUserDomain(), locale);
if(httpClient == null)
@@ -312,7 +312,7 @@ public class SolrQueryHTTPClient implements BeanFactoryAware, InitializingBean
}
}
protected String buildStatsUrl(StatsParameters searchParameters, String baseUrl, Locale locale) throws UnsupportedEncodingException
protected String buildStatsUrl(StatsParameters searchParameters, String baseUrl, Locale locale, SolrStoreMappingWrapper mapping) throws UnsupportedEncodingException
{
URLCodec encoder = new URLCodec();
StringBuilder url = new StringBuilder();
@@ -337,6 +337,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());
}
}
return url.toString();
}