- b->m_route = map_it->second.m_route;
- b->m_vhost = map_it->second.m_vhost;
- const char *sep = strchr(b->m_vhost.c_str(), '/');
- std::string backend_database;
- if (sep)
- b->m_backend_database = std::string(sep+1);
- else
- b->m_backend_database = database;
+
+ bool first_route = true;
+
+ std::map<std::string,bool> targets_dedup;
+ for (; db_it != databases.end(); db_it++)
+ {
+ std::map<std::string, VirtualDB::Map>::iterator map_it;
+ map_it = m_p->m_maps.find(mp::util::database_name_normalize(*db_it));
+ if (map_it == m_p->m_maps.end()) // database not found
+ {
+ error_code = YAZ_BIB1_DATABASE_DOES_NOT_EXIST;
+ addinfo = *db_it;
+ BackendPtr ptr;
+ return ptr;
+ }
+ std::list<std::string>::const_iterator t_it =
+ map_it->second.m_targets.begin();
+ for (; t_it != map_it->second.m_targets.end(); t_it++)
+ targets_dedup[*t_it] = true;
+
+ // see if we have a route conflict.
+ if (!first_route && b->m_route != map_it->second.m_route)
+ {
+ // we have a conflict..
+ error_code = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
+ BackendPtr ptr;
+ return ptr;
+ }
+ b->m_route = map_it->second.m_route;
+ first_route = false;
+ }
+ std::map<std::string,bool>::const_iterator tm_it = targets_dedup.begin();
+ for (; tm_it != targets_dedup.end(); tm_it++)
+ b->m_targets.push_back(tm_it->first);