Filter virt_db returns first unsvailable database as addinfo
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 16 Jan 2006 16:05:50 +0000 (16:05 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 16 Jan 2006 16:05:50 +0000 (16:05 +0000)
src/filter_virt_db.cpp

index 1ad040c..b35ed7c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter_virt_db.cpp,v 1.26 2006-01-16 15:51:56 adam Exp $
+/* $Id: filter_virt_db.cpp,v 1.27 2006-01-16 16:05:50 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -72,7 +72,8 @@ namespace yp2 {
             BackendPtr lookup_backend_from_databases(
                 std::list<std::string> databases);
             BackendPtr create_backend_from_databases(
-                std::list<std::string> databases);
+                std::list<std::string> databases,
+                std::string &failing_database);
             
             BackendPtr init_backend(std::list<std::string> database,
                                     Package &package,
@@ -113,7 +114,7 @@ yf::Virt_db::BackendPtr yf::Virt_db::Frontend::lookup_backend_from_databases(
 }
 
 yf::Virt_db::BackendPtr yf::Virt_db::Frontend::create_backend_from_databases(
-    std::list<std::string> databases)
+    std::list<std::string> databases, std::string &failing_database)
 {
     BackendPtr b(new Backend);
     std::list<std::string>::const_iterator db_it = databases.begin();
@@ -129,6 +130,7 @@ yf::Virt_db::BackendPtr yf::Virt_db::Frontend::create_backend_from_databases(
         map_it = m_p->m_maps.find(*db_it);
         if (map_it == m_p->m_maps.end())  // database not found
         {
+            failing_database = *db_it;
             BackendPtr ptr;
             return ptr;
         }
@@ -156,11 +158,12 @@ yf::Virt_db::BackendPtr yf::Virt_db::Frontend::init_backend(
     std::list<std::string> databases, Package &package,
     int &error_code, std::string &addinfo)
 {
-    BackendPtr b = create_backend_from_databases(databases);
+    std::string failing_database;
+    BackendPtr b = create_backend_from_databases(databases, failing_database);
     if (!b)
     {
         error_code = YAZ_BIB1_DATABASE_UNAVAILABLE;
-        // addinfo = database;
+        addinfo = failing_database;
         return b;
     }
     Package init_package(b->m_backend_session, package.origin());