record_transform: remove some dead code
[metaproxy-moved-to-github.git] / src / filter_record_transform.cpp
index cf7af72..2883b4d 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of Metaproxy.
-   Copyright (C) 2005-2010 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
@@ -17,19 +17,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
 #include "config.hpp"
-#include "filter.hpp"
 #include "filter_record_transform.hpp"
-#include "package.hpp"
-#include "util.hpp"
+#include <metaproxy/package.hpp>
+#include <metaproxy/util.hpp>
 #include "gduutil.hpp"
-#include "xmlutil.hpp"
 
 #include <yaz/diagbib1.h>
 #include <yaz/zgdu.h>
 #include <yaz/retrieval.h>
 
-//#include <boost/thread/mutex.hpp>
-
 #include <iostream>
 
 namespace mp = metaproxy_1;
@@ -43,7 +39,7 @@ namespace metaproxy_1 {
             Impl();
             ~Impl();
             void process(metaproxy_1::Package & package) const;
-            void configure(const xmlNode * xml_node);
+            void configure(const xmlNode * xml_node, const char *path);
         private:
             yaz_retrieval_t m_retrieval;
         };
@@ -60,9 +56,10 @@ yf::RecordTransform::~RecordTransform()
 {  // must have a destructor because of boost::scoped_ptr
 }
 
-void yf::RecordTransform::configure(const xmlNode *xmlnode, bool test_only)
+void yf::RecordTransform::configure(const xmlNode *xmlnode, bool test_only,
+                                    const char *path)
 {
-    m_p->configure(xmlnode);
+    m_p->configure(xmlnode, path);
 }
 
 void yf::RecordTransform::process(mp::Package &package) const
@@ -87,11 +84,10 @@ yf::RecordTransform::Impl::~Impl()
         yaz_retrieval_destroy(m_retrieval);
 }
 
-void yf::RecordTransform::Impl::configure(const xmlNode *xml_node)
+void yf::RecordTransform::Impl::configure(const xmlNode *xml_node,
+                                          const char *path)
 {
-    //const char *srcdir = getenv("srcdir");
-    //if (srcdir)
-    //    yaz_retrieval_set_path(m_retrieval, srcdir);
+    yaz_retrieval_set_path(m_retrieval, path);
 
     if (!xml_node)
         throw mp::XMLError("RecordTransform filter config: empty XML DOM");
@@ -109,7 +105,8 @@ void yf::RecordTransform::Impl::configure(const xmlNode *xml_node)
     }
 
     // read configuration
-    if ( 0 != yaz_retrieval_configure(m_retrieval, retrieval_node)){
+    if (0 != yaz_retrieval_configure(m_retrieval, retrieval_node))
+    {
         std::string msg("RecordTransform filter config: ");
         msg += yaz_retrieval_get_error(m_retrieval);
         throw mp::XMLError(msg);
@@ -139,16 +136,17 @@ void yf::RecordTransform::Impl::process(mp::Package &package) const
 
     // setting up variables for conversion state
     yaz_record_conv_t rc = 0;
-    int ret_code;
 
     const char *input_schema = 0;
     Odr_oid *input_syntax = 0;
 
-    if(pr_req->recordComposition){
+    if (pr_req->recordComposition)
+    {
         input_schema 
             = mp_util::record_composition_to_esn(pr_req->recordComposition);
     }
-    if(pr_req->preferredRecordSyntax){
+    if (pr_req->preferredRecordSyntax)
+    {
         input_syntax = pr_req->preferredRecordSyntax;
     }
     
@@ -158,7 +156,7 @@ void yf::RecordTransform::Impl::process(mp::Package &package) const
     const char *backend_schema = 0;
     Odr_oid *backend_syntax = 0;
 
-    ret_code 
+    int ret_code 
         = yaz_retrieval_request(m_retrieval,
                                 input_schema, input_syntax,
                                 &match_schema, &match_syntax,
@@ -202,13 +200,11 @@ void yf::RecordTransform::Impl::process(mp::Package &package) const
     }
 
     // now re-coding the z3950 backend present request
-     
     if (backend_syntax) 
         pr_req->preferredRecordSyntax = odr_oiddup(odr_en, backend_syntax);
     else
         pr_req->preferredRecordSyntax = 0;
     
-
     // z3950'fy record schema
     if (backend_schema)
     {
@@ -237,31 +233,12 @@ void yf::RecordTransform::Impl::process(mp::Package &package) const
         || !gdu_res->u.z3950->u.presentResponse)
 
     {
-        std::cout << "record-transform: error back present\n";
         package.session().close();
         return;
     }
     
-
-    // everything fine, continuing
-    // std::cout << "z3950_present_request OK\n";
-    // std::cout << "back z3950 " << *gdu_res << "\n";
-
     Z_PresentResponse * pr_res = gdu_res->u.z3950->u.presentResponse;
 
-    // let non surrogate dioagnostics in Z3950 present response package
-    // pass to frontend - just return
-    if (pr_res->records 
-        && pr_res->records->which == Z_Records_NSD
-        && pr_res->records->u.nonSurrogateDiagnostic)
-    {
-        // we might do more clever tricks to "reverse"
-        // these error(s).
-
-        //*pr_res->records->u.nonSurrogateDiagnostic->condition = 
-        // YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS;
-    }
-
     // record transformation must take place 
     if (rc && pr_res 
         && pr_res->numberOfRecordsReturned 
@@ -270,7 +247,7 @@ void yf::RecordTransform::Impl::process(mp::Package &package) const
         && pr_res->records->which == Z_Records_DBOSD
         && pr_res->records->u.databaseOrSurDiagnostics->num_records)
     {
-         //transform all records
+         // transform all records
          for (int i = 0; 
               i < pr_res->records->u.databaseOrSurDiagnostics->num_records; 
               i++)
@@ -284,13 +261,9 @@ void yf::RecordTransform::Impl::process(mp::Package &package) const
                  int ret_trans = 0;
                  if (r->which == Z_External_OPAC)
                  {
-#if YAZ_VERSIONL >= 0x030011
                      ret_trans = 
                          yaz_record_conv_opac_record(rc, r->u.opac,
                                                      output_record);
-#else
-                     ;
-#endif
                  }
                  else if (r->which == Z_External_octet) 
                  {