From 4eb9ec58eb14d82b0532b4a4dab56c98ccdcea11 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 25 Jul 2011 16:40:35 +0200 Subject: [PATCH] Start work on contentProxy support New setting in Torus/record contentConnector specifies a connector to be used for contentProxy. If this is defined (non-zero length) then content proxy rewrite is performed on generated-url from urlRecipe. The rewritten server is specified by attribute 'server' in element contentProxy in zoom filter configureation. --- etc/config-zoom.xml | 2 ++ src/filter_zoom.cpp | 34 ++++++++++++++++++++++++++++++++++ xml/schema/filter_zoom.rnc | 7 ++++++- xml/schema/filter_zoom.rng | 12 ++++++++++++ xml/schema/filter_zoom.xsd | 8 ++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/etc/config-zoom.xml b/etc/config-zoom.xml index 659fa94..531963f 100644 --- a/etc/config-zoom.xml +++ b/etc/config-zoom.xml @@ -24,6 +24,7 @@ tmarc.xsl http://sever.com?title=${md-title[\s+/+/g]} localhost:9999/db01 + connectorfile 1 @@ -73,6 +74,7 @@ + diff --git a/src/filter_zoom.cpp b/src/filter_zoom.cpp index e9fd0db..7476417 100644 --- a/src/filter_zoom.cpp +++ b/src/filter_zoom.cpp @@ -63,6 +63,7 @@ namespace metaproxy_1 { std::string record_encoding; std::string transform_xsl_fname; std::string urlRecipe; + std::string contentConnector; bool use_turbomarc; bool piggyback; CCL_bibset ccl_bibset; @@ -140,6 +141,7 @@ namespace metaproxy_1 { std::map fieldmap; std::string xsldir; std::string file_path; + std::string content_proxy_server; CCL_bibset bibset; std::string element_transform; std::string element_raw; @@ -387,6 +389,11 @@ yf::Zoom::SearchablePtr yf::Zoom::Impl::parse_torus_record(const xmlNode *ptr) { s->cfSubDb = mp::xml::get_text(ptr); } + else if (!strcmp((const char *) ptr->name, + "contentConnector")) + { + s->contentConnector = mp::xml::get_text(ptr); + } else if (!strcmp((const char *) ptr->name, "udb")) { s->udb = mp::xml::get_text(ptr); @@ -553,6 +560,19 @@ void yf::Zoom::Impl::configure(const xmlNode *ptr, bool test_only, if (cql_field.length()) fieldmap[cql_field] = ccl_field; } + else if (!strcmp((const char *) ptr->name, "contentProxy")) + { + const struct _xmlAttr *attr; + for (attr = ptr->properties; attr; attr = attr->next) + { + if (!strcmp((const char *) attr->name, "server")) + content_proxy_server = mp::xml::get_text(attr->children); + else + throw mp::filter::FilterException( + "Bad attribute " + std::string((const char *) + attr->name)); + } + } else { throw mp::filter::FilterException @@ -936,6 +956,20 @@ Z_Records *yf::Zoom::Frontend::get_records(Odr_int start, xmlDoc *doc = xmlParseMemory(rec_buf, rec_len); std::string res = mp::xml::url_recipe_handle(doc, b->sptr->urlRecipe); + if (res.length() && b->sptr->contentConnector.length()) + { + yaz_log(YLOG_LOG, "contentConnector: %s", + b->sptr->contentConnector.c_str()); + size_t off = res.find_first_of("://"); + if (off != std::string::npos) + { + char tmp[1024]; + long id = 12345; + sprintf(tmp, "%ld.%s/", + id, m_p->content_proxy_server.c_str()); + res.insert(off + 3, tmp); + } + } if (res.length()) { xmlNode *ptr = xmlDocGetRootElement(doc); diff --git a/xml/schema/filter_zoom.rnc b/xml/schema/filter_zoom.rnc index 75494bb..ab03ddc 100644 --- a/xml/schema/filter_zoom.rnc +++ b/xml/schema/filter_zoom.rnc @@ -32,7 +32,8 @@ filter_zoom = element mp:zurl { xsd:string }, element mp:cfAuth { xsd:string }?, element mp:cfProxy { xsd:string }?, - element mp:cfSubDb { xsd:string }? + element mp:cfSubDb { xsd:string }?, + element mp:contentConnector { xsd:string }? }* }? }?, @@ -48,6 +49,10 @@ filter_zoom = attribute value { xsd:string } }+ }* + }?, + element mp:contentProxy { + attribute server { xsd:string } }? + diff --git a/xml/schema/filter_zoom.rng b/xml/schema/filter_zoom.rng index 16f04d1..981f5b9 100644 --- a/xml/schema/filter_zoom.rng +++ b/xml/schema/filter_zoom.rng @@ -135,6 +135,11 @@ + + + + + @@ -174,5 +179,12 @@ + + + + + + + diff --git a/xml/schema/filter_zoom.xsd b/xml/schema/filter_zoom.xsd index fe9c5a6..17ea392 100644 --- a/xml/schema/filter_zoom.xsd +++ b/xml/schema/filter_zoom.xsd @@ -8,6 +8,7 @@ + @@ -51,6 +52,7 @@ + @@ -74,6 +76,7 @@ + @@ -101,6 +104,11 @@ + + + + + -- 1.7.10.4