private void deployCore(FulltextIndexSchema schema, String url, String path, boolean replica) throws SolrServerException, IOException {
HttpSolrServer server = new HttpSolrServer(url);
CoreAdminResponse response = CoreAdminRequest.getStatus(coreName, server);
NamedList<Object> status = response.getCoreStatus(coreName);
if (status.size() != 0) {
response = CoreAdminRequest.unloadCore(coreName, server);
if (response.getStatus() != ErrorCode.UNKNOWN.code) {
throw new GeneralServiceException("Unloading core {} resulted in error code {}", coreName, response.getStatus());
}
}
final EmbeddedConfig embeddedConfig = new EmbeddedConfig(coreName, coreName, path, coreName);
translator.createSolrFileStructure(embeddedConfig, schema, solrConfigResource, true, new HashMap<String, String>());
if (replica) {
File replicaDirectory = new File(path + "/" + coreName + "/conf");
File srcFile = new File(replicaDirectory, REPLICA_PROPERTIES_FILENAME);
File destFile = new File(replicaDirectory, PROPERTIES_FILENAME);
if(destFile.exists()){
destFile.delete();
}
FileUtils.moveFile(srcFile, destFile);
}
response = CoreAdminRequest.createCore(coreName, path + "/" + coreName, server);
if (response.getStatus() != ErrorCode.UNKNOWN.code) {
throw new GeneralServiceException("Creating core {} resulted in error code {}", coreName, response.getStatus());
}
}