X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ffilter_sru_to_z3950.cpp;h=5704479e70877fc2ffd53aeb35632cbd504b5073;hb=8ced8e7b5de3ecba12ac68ce5c5e8cddf40d800f;hp=6590d4d13cf37ab0fd717c595329b0fafa1721ba;hpb=73f37c91c144b070020df2f27472c09b62367acf;p=metaproxy-moved-to-github.git diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index 6590d4d..5704479 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -1,5 +1,5 @@ /* This file is part of Metaproxy. - Copyright (C) 2005-2012 Index Data + Copyright (C) 2005-2013 Index Data Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -26,8 +26,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "sru_util.hpp" #include "filter_sru_to_z3950.hpp" -#include -#include #include #include #include @@ -39,7 +37,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include -/* #include */ #include namespace mp = metaproxy_1; @@ -492,28 +489,43 @@ yf::SRUtoZ3950::Impl::z3950_init_request(mp::Package &package, // send Z3950 package z3950_package.move(); - // dead Z3950 backend detection - if (z3950_package.session().is_closed()) - { - yaz_add_srw_diagnostic(odr_en, - &(sru_pdu_res->u.response->diagnostics), - &(sru_pdu_res->u.response->num_diagnostics), - YAZ_SRW_SYSTEM_TEMPORARILY_UNAVAILABLE, 0); - return false; - } - // check successful initResponse Z_GDU *z3950_gdu = z3950_package.response().get(); + int error = YAZ_SRW_SYSTEM_TEMPORARILY_UNAVAILABLE; + const char *addinfo = 0; if (z3950_gdu && z3950_gdu->which == Z_GDU_Z3950 - && z3950_gdu->u.z3950->which == Z_APDU_initResponse - && *z3950_gdu->u.z3950->u.initResponse->result) - return true; + && z3950_gdu->u.z3950->which == Z_APDU_initResponse) + { + Z_InitResponse *initrs = z3950_gdu->u.z3950->u.initResponse; + if (*initrs->result) + return true; + int no = 0; + while (1) + { + Z_DefaultDiagFormat *df = yaz_decode_init_diag(no, initrs); + if (!df) + break; + yaz_add_srw_diagnostic(odr_en, + &(sru_pdu_res->u.response->diagnostics), + &(sru_pdu_res->u.response->num_diagnostics), + yaz_diag_bib1_to_srw(*df->condition), + df->u.v2Addinfo); + no++; + } + if (no) + return false; // got least one diagnostic from init + + // we just have result=false. + error = YAZ_SRW_AUTHENTICATION_ERROR; + } + else + addinfo = "sru_z3950: expected initResponse"; yaz_add_srw_diagnostic(odr_en, &(sru_pdu_res->u.response->diagnostics), &(sru_pdu_res->u.response->num_diagnostics), - YAZ_SRW_SYSTEM_TEMPORARILY_UNAVAILABLE, 0); + error, addinfo); return false; }