use of org.alfresco.repo.search.impl.lucene.SolrCommandBackupResult in project alfresco-repository by Alfresco.
the class SOLRAdminClient method executeCommand.
/* (non-Javadoc)
* @see org.alfresco.repo.search.impl.solr.SolrAdminClient#executeCommand(java.lang.String, org.alfresco.repo.search.impl.solr.SolrAdminClient.HANDLER, org.alfresco.repo.search.impl.solr.SolrAdminClient.COMMAND, java.util.Map)
*/
@Override
public JSONAPIResult executeCommand(String core, JSONAPIResultFactory.HANDLER handler, JSONAPIResultFactory.COMMAND command, Map<String, String> parameters) {
StoreRef store = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
SolrStoreMappingWrapper mapping = SolrClientUtil.extractMapping(store, mappingLookup, shardRegistry, useDynamicShardRegistration, beanFactory);
HttpClient httpClient = mapping.getHttpClientAndBaseUrl().getFirst();
StringBuilder url = new StringBuilder();
url.append(baseUrl);
if (!url.toString().endsWith("/")) {
url.append("/");
}
url.append(core + "/" + handler.toString().toLowerCase());
URLCodec encoder = new URLCodec();
url.append("?command=" + command.toString().toLowerCase());
parameters.forEach((key, value) -> {
try {
url.append("&" + key + "=" + encoder.encode(value));
} catch (EncoderException e) {
throw new RuntimeException(e);
}
});
url.append("&alfresco.shards=");
if (mapping.isSharded()) {
url.append(mapping.getShards());
} else {
String solrurl = httpClient.getHostConfiguration().getHostURL() + mapping.getHttpClientAndBaseUrl().getSecond();
url.append(solrurl);
}
try {
JSONAPIResult response = new SolrCommandBackupResult(getOperation(httpClient, url.toString()));
if (response.getStatus() != 0) {
solrTracker.setSolrActive(false);
}
return response;
} catch (IOException e) {
throw new LuceneQueryParserException("action", e);
}
}
Aggregations