virt_db: remove query-encoding facility
[metaproxy-moved-to-github.git] / src / filter_virt_db.cpp
index 64ac19a..b583757 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of Metaproxy.
-   Copyright (C) 2005-2011 Index Data
+   Copyright (C) 2005-2012 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,7 +26,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <boost/shared_ptr.hpp>
 
 #include <metaproxy/util.hpp>
-#include "torus.hpp"
 
 #include <yaz/zgdu.h>
 #include <yaz/otherinfo.h>
@@ -59,8 +58,6 @@ namespace metaproxy_1 {
             std::string m_dbpattern;
             std::list<std::string> m_targets;
             std::string m_route;
-        public:
-            std::string m_query_encoding;
         };
         struct VirtualDB::Backend {
             mp::Session m_backend_session;
@@ -120,7 +117,6 @@ namespace metaproxy_1 {
             boost::condition m_cond_session_ready;
             std::map<mp::Session, FrontendPtr> m_clients;
             bool pass_vhosts;
-            mp::Torus torus;
         };
     }
 }
@@ -181,7 +177,7 @@ yf::VirtualDB::BackendPtr yf::VirtualDB::Frontend::create_backend_from_databases
         // see if we have a route conflict.
         if (!first_route && b->m_route != map_it->m_route)
         {
-            // we have a conflict.. 
+            // we have a conflict.. routing must be same for all
             error_code =  YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
             BackendPtr ptr;
             return ptr;
@@ -239,8 +235,7 @@ yf::VirtualDB::BackendPtr yf::VirtualDB::Frontend::init_backend(
     // we hope to get an init response
     error_code = YAZ_BIB1_DATABASE_UNAVAILABLE;
     if (gdu && gdu->which == Z_GDU_Z3950
-        && gdu->u.z3950->which == Z_APDU_initResponse
-        && *gdu->u.z3950->u.initResponse->result)
+        && gdu->u.z3950->which == Z_APDU_initResponse)
     {
         Z_InitResponse *res = gdu->u.z3950->u.initResponse;
         if (ODR_MASK_GET(res->options, Z_Options_namedResultSets))
@@ -443,71 +438,6 @@ void yf::VirtualDB::Rep::release_frontend(mp::Package &package)
     }
 }
 
-void yf::VirtualDB::Rep::refresh_torus(void)
-{
-    xmlDoc *doc = torus.get_doc();
-    if (!doc)
-        return;
-
-    xmlNode *ptr1 = xmlDocGetRootElement(doc);
-    if (!ptr1)
-        return ;
-
-    for (ptr1 = ptr1->children; ptr1; ptr1 = ptr1->next)
-    {
-        if (ptr1->type != XML_ELEMENT_NODE)
-            continue;
-        if (!strcmp((const char *) ptr1->name, "record"))
-        {
-            xmlNode *ptr2 = ptr1;
-            for (ptr2 = ptr2->children; ptr2; ptr2 = ptr2->next)
-            {
-                if (ptr2->type != XML_ELEMENT_NODE)
-                    continue;
-                if (!strcmp((const char *) ptr2->name, "layer"))
-                {
-                    std::string database;
-                    std::string target;
-                    std::string route;
-                    std::string solr;
-                    std::string query_encoding;
-                    xmlNode *ptr3 = ptr2;
-                    for (ptr3 = ptr3->children; ptr3; ptr3 = ptr3->next)
-                    {
-                        if (ptr3->type != XML_ELEMENT_NODE)
-                            continue;
-                        if (!strcmp((const char *) ptr3->name, "id"))
-                        {
-                            database = mp::xml::get_text(ptr3);
-                        }
-                        else if (!strcmp((const char *) ptr3->name, "zurl"))
-                        {
-                            target = mp::xml::get_text(ptr3);
-                        }
-                        else if (!strcmp((const char *) ptr3->name, "sru"))
-                        {
-                            solr = mp::xml::get_text(ptr3);
-                        }
-                        else if (!strcmp((const char *) ptr3->name,
-                                         "queryEncoding"))
-                        {
-                            query_encoding = mp::xml::get_text(ptr3);
-                        }
-                    }
-                    if (solr.length() == 0 && 
-                        database.length() && target.length())
-                    {
-                        VirtualDB::Map vmap(
-                            mp::util::database_name_normalize(database),
-                            target, route);
-                        vmap.m_query_encoding = query_encoding;
-                        m_maps.push_back(vmap);
-                    }
-                }
-            }
-        }
-    }
-}
 
 yf::VirtualDB::Set::Set(BackendPtr b, std::string setname)
     :  m_backend(b), m_setname(setname)
@@ -757,6 +687,7 @@ void yf::VirtualDB::Frontend::scan(mp::Package &package, Z_APDU *apdu_req)
                                                 &req->num_databaseNames,
                                                 &req->databaseNames);
     }
+
     scan_package.request() = yazpp_1::GDU(apdu_req);
     
     scan_package.move(b->m_route);
@@ -900,7 +831,8 @@ void yf::VirtualDB::process(mp::Package &package) const
     m_p->release_frontend(package);
 }
 
-void mp::filter::VirtualDB::configure(const xmlNode * ptr, bool test_only)
+void mp::filter::VirtualDB::configure(const xmlNode * ptr, bool test_only,
+                                      const char *path)
 {
     for (ptr = ptr->children; ptr; ptr = ptr->next)
     {
@@ -908,11 +840,10 @@ void mp::filter::VirtualDB::configure(const xmlNode * ptr, bool test_only)
             continue;
         if (!strcmp((const char *) ptr->name, "pass-vhosts"))
         {
-            m_p->pass_vhosts = mp::xml::get_bool(ptr->children, false);
+            m_p->pass_vhosts = mp::xml::get_bool(ptr, false);
         }
         else if (!strcmp((const char *) ptr->name, "virtual"))
         {
-            std::string query_encoding;
             std::string database;
             std::list<std::string> targets;
             xmlNode *v_node = ptr->children;
@@ -925,8 +856,6 @@ void mp::filter::VirtualDB::configure(const xmlNode * ptr, bool test_only)
                     database = mp::xml::get_text(v_node);
                 else if (mp::xml::is_element_mp(v_node, "target"))
                     targets.push_back(mp::xml::get_text(v_node));
-                else if (mp::xml::is_element_mp(v_node, "query-encoding"))
-                    targets.push_back(mp::xml::get_text(v_node));
                 else
                     throw mp::filter::FilterException
                         ("Bad element " 
@@ -938,25 +867,8 @@ void mp::filter::VirtualDB::configure(const xmlNode * ptr, bool test_only)
 
             VirtualDB::Map vmap(mp::util::database_name_normalize(database),
                                 targets, route);
-            vmap.m_query_encoding = query_encoding;
             m_p->m_maps.push_back(vmap);
         }
-        else if (!strcmp((const char *) ptr->name, "torus"))
-        {
-            std::string url;
-            const struct _xmlAttr *attr;
-            for (attr = ptr->properties; attr; attr = attr->next)
-            {
-                if (!strcmp((const char *) attr->name, "url"))
-                    url = mp::xml::get_text(attr->children);
-                else
-                    throw mp::filter::FilterException(
-                        "Bad attribute " + std::string((const char *)
-                                                       attr->name));
-            }
-            m_p->torus.read_searchables(url);
-            m_p->refresh_torus();
-        }
         else
         {
             throw mp::filter::FilterException