From: Mike Taylor Date: Wed, 20 Jul 2011 16:17:16 +0000 (+0100) Subject: Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/metaproxy X-Git-Tag: v1.3.14~10 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=0884c5b06c5d6878c2b2fbfdc7e528bf6877d888;hp=96f11822e640c404d9bbd8508b40c8a76996580a;p=metaproxy-moved-to-github.git Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/metaproxy --- diff --git a/etc/config-zoom.xml b/etc/config-zoom.xml index 20246c1..659fa94 100644 --- a/etc/config-zoom.xml +++ b/etc/config-zoom.xml @@ -38,6 +38,16 @@ 1 UTF-8 + jstor-local + s=al + 1=title s=pw t=l,r + get + dc.xsl + dfr.jstor.org/sru + + + 1 + UTF-8 cf-local 1=1016 s=al 1=4 s=pw t=l,r @@ -57,27 +67,7 @@ - - - - - - - - - - - - - - @@ -92,18 +82,6 @@ F - - - - - - - - - - - - B diff --git a/src/filter_zoom.cpp b/src/filter_zoom.cpp index eb9f64b..76992fa 100644 --- a/src/filter_zoom.cpp +++ b/src/filter_zoom.cpp @@ -537,6 +537,7 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases( if (m_backend && m_backend->m_frontend_database == database) return m_backend; + const char *sru_proxy = 0; std::string db_args; std::string torus_db; size_t db_arg_pos = database.find(','); @@ -635,19 +636,34 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases( { // A CF target b->set_option("user", sptr->cfAuth.c_str()); - if (authentication.length() && db_args.length() == 0) + if (db_args.length() == 0) { - // no database (auth) args specified already.. and the - // Torus authentication has it.. Generate the args that CF - // understands.. - size_t found = authentication.find('/'); - if (found != std::string::npos) + if (authentication.length()) + { + // no database (auth) args specified already.. and the + // Torus authentication has it.. Generate the args that CF + // understands.. + size_t found = authentication.find('/'); + if (found != std::string::npos) + { + db_args += "user=" + mp::util::uri_encode(authentication.substr(0, found)) + + "&password=" + mp::util::uri_encode(authentication.substr(found+1)); + } + else + db_args += "user=" + mp::util::uri_encode(authentication); + } + if (sptr->cfProxy.length()) { - db_args += "user=" + mp::util::uri_encode(authentication.substr(0, found)) - + "&password=" + mp::util::uri_encode(authentication.substr(found+1)); + if (db_args.length()) + db_args += "&"; + db_args += "proxy=" + mp::util::uri_encode(sptr->cfProxy); } - else - db_args += "user=" + mp::util::uri_encode(authentication); + } + if (sptr->cfSubDb.length()) + { + if (db_args.length()) + db_args += "&"; + db_args += "subdatabase=" + mp::util::uri_encode(sptr->cfSubDb); } } else @@ -671,6 +687,8 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases( param_user = value; else if (!strcmp(name, "password")) param_password = value; + else if (!strcmp(name, "proxy")) + sru_proxy = value; else { BackendPtr notfound; @@ -699,18 +717,9 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases( b->set_option("user", authentication.c_str()); } } - if (sptr->cfProxy.length()) - { - if (db_args.length()) - db_args += "&"; - db_args += "proxy=" + mp::util::uri_encode(sptr->cfProxy); - } - if (sptr->cfSubDb.length()) - { - if (db_args.length()) - db_args += "&"; - db_args += "subdatabase=" + mp::util::uri_encode(sptr->cfSubDb); - } + + if (sru_proxy) + b->set_option("proxy", sru_proxy); std::string url; if (sptr->sru.length()) diff --git a/src/router_flexml.cpp b/src/router_flexml.cpp index 0a019eb..7aca757 100644 --- a/src/router_flexml.cpp +++ b/src/router_flexml.cpp @@ -67,9 +67,9 @@ namespace metaproxy_1 { const char *file_include_path); void parse_xml_filters(xmlDocPtr doc, const xmlNode *node, - bool test_only); + bool test_only, const char *file_include_path); void parse_xml_routes(xmlDocPtr doc, const xmlNode *node, - bool test_only); + bool test_only, const char *file_include_path); bool m_xinclude; private: @@ -91,7 +91,8 @@ namespace metaproxy_1 { void mp::RouterFleXML::Rep::parse_xml_filters(xmlDocPtr doc, const xmlNode *node, - bool test_only) + bool test_only, + const char *file_include_path) { unsigned int filter_nr = 0; while(node && mp::xml::check_element_mp(node, "filter")) @@ -140,7 +141,8 @@ void mp::RouterFleXML::Rep::parse_xml_filters(xmlDocPtr doc, void mp::RouterFleXML::Rep::parse_xml_routes(xmlDocPtr doc, const xmlNode *node, - bool test_only) + bool test_only, + const char *file_include_path) { mp::xml::check_element_mp(node, "route"); @@ -288,7 +290,7 @@ void mp::RouterFleXML::Rep::parse_xml_config_dom(xmlDocPtr doc, { parse_xml_filters(doc, mp::xml::jump_to_children(node, XML_ELEMENT_NODE), - test_only); + test_only, file_include_path); node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE); } @@ -296,7 +298,7 @@ void mp::RouterFleXML::Rep::parse_xml_config_dom(xmlDocPtr doc, mp::xml::check_element_mp(node, "routes"); parse_xml_routes(doc, mp::xml::jump_to_children(node, XML_ELEMENT_NODE), - test_only); + test_only, file_include_path); node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE); if (node) diff --git a/src/test_xmlutil.cpp b/src/test_xmlutil.cpp index 13065a1..ae9b571 100644 --- a/src/test_xmlutil.cpp +++ b/src/test_xmlutil.cpp @@ -99,8 +99,13 @@ BOOST_AUTO_TEST_CASE( url_recipe ) xmlFreeDoc(doc); } } + catch ( std::runtime_error &e) { + std::cout << "std::runtime error: " << e.what() << std::endl; + BOOST_CHECK(false); + } catch ( ... ) { - BOOST_CHECK (false); + std::cout << "unknown exception" << std::endl; + BOOST_CHECK(false); } } diff --git a/src/url_recipe.cpp b/src/url_recipe.cpp index 8076928..7a8f28f 100644 --- a/src/url_recipe.cpp +++ b/src/url_recipe.cpp @@ -117,15 +117,19 @@ std::string mp_xml::url_recipe_handle(xmlDoc *doc, std::string recipe) break; } } - boost::regex::flag_type b_mode = boost::regex::perl; - if (mode.find_first_of('i') != std::string::npos) - b_mode |= boost::regex::icase; - boost::regex e(pattern, b_mode); - - boost::match_flag_type match_mode = boost::format_first_only; - if (mode.find_first_of('g') != std::string::npos) - match_mode = boost::format_all; - result += regex_replace(text, e, replacement, match_mode); + if (pattern.length() == 0) + result += text; + else + { + boost::regex::flag_type b_mode = boost::regex::perl; + if (mode.find_first_of('i') != std::string::npos) + b_mode |= boost::regex::icase; + boost::regex e(pattern, b_mode); + boost::match_flag_type match_mode = boost::format_first_only; + if (mode.find_first_of('g') != std::string::npos) + match_mode = boost::format_all; + result += regex_replace(text, e, replacement, match_mode); + } } } return result;