* @param config
* @param indexReference
* @throws YardException
*/
private IndexReference checkManagedSolrIndex(ManagedSolrServer managedSolrServer, SolrYardConfig config) throws YardException {
IndexReference indexReference = IndexReference.parse(config.getSolrServerLocation());
if(indexReference.isName()){
if(managedSolrServer == null){
log.warn("Unable to init SolrIndex '{}' because ManagedSolrServer service is not available",
config.getSolrServerLocation());
return null; //indicate that the server is not yet active
} else if(indexReference.getServer() == null ||
indexReference.getServer().equals(managedSolrServer.getServerName())){
//check if the referenced Index is Managed
IndexMetadata indexMetadata = managedSolrServer.getIndexMetadata(indexReference.getIndex());
if(indexMetadata == null){
// not managed -> try to create
IndexReference createdIndexRef = createSolrIndex(managedSolrServer,config, indexReference.getIndex());
if(context == null){
//in that case we need to replace the parse SolrServerLocation
//with the name of the created solr index
config.setSolrServerLocation(createdIndexRef.getIndex());
}
//return the created IndexReference
return createdIndexRef;
} else if(!indexMetadata.isActive()){ //already managed, but not active
//try to activate