X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffilter_sru_to_z3950.cpp;h=51e14fe92b141c927aa21d33c79968c026104cfa;hb=HEAD;hp=204639ec1bd8ecb3471afc9f12a278a3e5e321b3;hpb=8ad47a5541b059938d469e47a539762e031e925f;p=metaproxy-moved-to-github.git diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index 204639e..51e14fe 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -31,9 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include -#if YAZ_VERSIONL >= 0x50000 #include -#endif #include #include @@ -68,11 +66,6 @@ namespace metaproxy_1 { typedef std::map ActiveUrlMap; - boost::mutex m_url_mutex; - boost::condition m_cond_url_ready; - ActiveUrlMap m_active_urls; - - boost::mutex m_mutex_session; boost::condition m_cond_session_ready; std::map m_clients; @@ -441,33 +434,7 @@ void yf::SRUtoZ3950::Impl::process(mp::Package &package) if (zgdu_req && zgdu_req->which == Z_GDU_HTTP_Request) { - if (zgdu_req->u.HTTP_Request->content_len == 0) - { - const char *path = zgdu_req->u.HTTP_Request->path; - boost::mutex::scoped_lock lock(m_url_mutex); - while (1) - { - ActiveUrlMap::iterator it = m_active_urls.find(path); - if (it == m_active_urls.end()) - { - m_active_urls[path] = 1; - break; - } - yaz_log(YLOG_LOG, "Waiting for %s to complete", path); - m_cond_url_ready.wait(lock); - } - } sru(package, zgdu_req); - if (zgdu_req && zgdu_req->u.HTTP_Request->content_len == 0) - { - const char *path = zgdu_req->u.HTTP_Request->path; - boost::mutex::scoped_lock lock(m_url_mutex); - - ActiveUrlMap::iterator it = m_active_urls.find(path); - - m_active_urls.erase(it); - m_cond_url_ready.notify_all(); - } } else { @@ -643,15 +610,11 @@ bool yf::SRUtoZ3950::Impl::z3950_search_request(mp::Package &package, odr_malloc(odr_en, sizeof(char *)); z_searchRequest->databaseNames[0] = odr_strdup(odr_en, db.c_str()); } -#if YAZ_VERSIONL >= 0x50000 - // yaz_oi_set_facetlist not public in YAZ 4.2.66 if (sr_req->facetList) { Z_OtherInformation **oi = &z_searchRequest->additionalSearchInfo; yaz_oi_set_facetlist(oi, odr_en, sr_req->facetList); } -#endif - Z_Query *z_query = (Z_Query *) odr_malloc(odr_en, sizeof(Z_Query)); z_searchRequest->query = z_query; @@ -691,12 +654,10 @@ bool yf::SRUtoZ3950::Impl::z3950_search_request(mp::Package &package, { return false; } -#if YAZ_VERSIONL >= 0x50000 Z_FacetList *fl = yaz_oi_get_facetlist(&sr->additionalSearchInfo); if (!fl) fl = yaz_oi_get_facetlist(&sr->otherInfo); sru_pdu_res->u.response->facetList = fl; -#endif sru_pdu_res->u.response->numberOfRecords = odr_intdup(odr_en, *sr->resultCount); return true; @@ -928,13 +889,7 @@ int yf::SRUtoZ3950::Impl::z3950_build_query( const Z_SRW_searchRetrieveRequest *req ) const { - if ( -#ifdef Z_SRW_query_type_cql - req->query_type == Z_SRW_query_type_cql -#else - !strcmp(req->queryType, "cql") -#endif - ) + if (!strcmp(req->queryType, "cql")) { Z_External *ext = (Z_External *) odr_malloc(odr_en, sizeof(*ext)); @@ -943,39 +898,21 @@ int yf::SRUtoZ3950::Impl::z3950_build_query( ext->indirect_reference = 0; ext->descriptor = 0; ext->which = Z_External_CQL; - ext->u.cql = odr_strdup(odr_en, -#ifdef Z_SRW_query_type_cql - req->query.cql -#else - req->query -#endif - ); + ext->u.cql = odr_strdup(odr_en, req->query); z_query->which = Z_Query_type_104; z_query->u.type_104 = ext; return 0; } - if ( -#ifdef Z_SRW_query_type_pqf - req->query_type == Z_SRW_query_type_pqf -#else - !strcmp(req->queryType, "pqf") -#endif - ) + if (!strcmp(req->queryType, "pqf")) { Z_RPNQuery *RPNquery; YAZ_PQF_Parser pqf_parser; pqf_parser = yaz_pqf_create (); - RPNquery = yaz_pqf_parse (pqf_parser, odr_en, -#ifdef Z_SRW_query_type_pqf - req->query.pqf -#else - req->query -#endif - ); + RPNquery = yaz_pqf_parse (pqf_parser, odr_en, req->query); yaz_pqf_destroy(pqf_parser); if (!RPNquery) @@ -986,6 +923,15 @@ int yf::SRUtoZ3950::Impl::z3950_build_query( return 0; } + + if (!strcmp(req->queryType, "ccl")) + { + z_query->which = Z_Query_type_2; + z_query->u.type_2 = odr_create_Odr_oct(odr_en, req->query, + strlen(req->query)); + return 0; + } + return YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED; }