virt_db: return other diagnostic if init is rejected
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 30 Apr 2012 10:14:06 +0000 (12:14 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 30 Apr 2012 10:15:38 +0000 (12:15 +0200)
Diagnostic 236: "Access to specified database denied" is returned,
but only if init response from backend does not carry diagnostics
aleady.

etc/config3.xml
src/filter_virt_db.cpp

index 3ae07fd..1f73053 100644 (file)
           <target>bagel.indexdata.dk:80</target>
         </virtual>
         <virtual>
+          <database>cf</database>
+          <target>connect.indexdata.com</target>
+        </virtual>
+        <virtual>
           <database>gils</database>
-          <target>indexdata.dk/gils</target>
+          <target>z3950.indexdata.dk/gils</target>
         </virtual>
         <virtual>
           <database>marc</database>
-          <target>indexdata.dk/marc</target>
+          <target>z3950.indexdata.dk/marc1</target>
         </virtual>
         <virtual>
           <database>loc</database>
index b583757..f2420bf 100644 (file)
@@ -233,7 +233,7 @@ yf::VirtualDB::BackendPtr yf::VirtualDB::Frontend::init_backend(
 
     Z_GDU *gdu = init_package.response().get();
     // we hope to get an init response
-    error_code = YAZ_BIB1_DATABASE_UNAVAILABLE;
+    error_code = 0;
     if (gdu && gdu->which == Z_GDU_Z3950
         && gdu->u.z3950->which == Z_APDU_initResponse)
     {
@@ -249,6 +249,13 @@ yf::VirtualDB::BackendPtr yf::VirtualDB::Frontend::init_backend(
         }
         mp::util::get_init_diagnostics(res, error_code, addinfo);
     }
+    if (error_code == 0)
+    {
+        std::list<std::string>::const_iterator db_it = databases.begin();
+        error_code = YAZ_BIB1_ACCESS_TO_SPECIFIED_DATABASE_DENIED;
+        if (db_it != databases.end())
+            addinfo = *db_it;
+    }
     if (!init_package.session().is_closed())
     {
         Package close_package(b->m_backend_session, package.origin());