X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffilter_record_transform.cpp;h=221a609e59c3c3b0a11fc8c0f898c2ac5237c738;hb=a83814901948c8dc8d6d3da35e413dad5bf03400;hp=23c45241ead4dbe4d55c8b5992c503bc1e0e6086;hpb=637a685d61a9ff0e3f398a59da426979815c4d68;p=metaproxy-moved-to-github.git diff --git a/src/filter_record_transform.cpp b/src/filter_record_transform.cpp index 23c4524..221a609 100644 --- a/src/filter_record_transform.cpp +++ b/src/filter_record_transform.cpp @@ -1,7 +1,5 @@ -/* $Id: filter_record_transform.cpp,v 1.12 2007-05-09 21:23:09 adam Exp $ - Copyright (c) 2005-2007, Index Data. - -This file is part of Metaproxy. +/* This file is part of Metaproxy. + 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 @@ -14,25 +12,20 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Metaproxy; see the file LICENSE. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - */ +along with this program; if not, write to the Free Software +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 +#include #include "gduutil.hpp" -#include "xmlutil.hpp" #include #include #include -//#include - #include namespace mp = metaproxy_1; @@ -46,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; }; @@ -63,9 +56,10 @@ yf::RecordTransform::~RecordTransform() { // must have a destructor because of boost::scoped_ptr } -void yf::RecordTransform::configure(const xmlNode *xmlnode) +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 @@ -90,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"); @@ -240,7 +233,6 @@ 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; } @@ -282,35 +274,44 @@ void yf::RecordTransform::Impl::process(mp::Package &package) const = pr_res->records->u.databaseOrSurDiagnostics->records[i]; if (npr->which == Z_NamePlusRecord_databaseRecord) { + WRBUF output_record = wrbuf_alloc(); Z_External *r = npr->u.databaseRecord; - //oident *ent = oid_getentbyoid(r->direct_reference); - if (r->which == Z_External_octet) + 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) { - WRBUF output_record = wrbuf_alloc(); - int ret_trans - = yaz_record_conv_record(rc, - (const char *) - r->u.octet_aligned->buf, - r->u.octet_aligned->len, - output_record); - if (ret_trans == 0) - { - npr->u.databaseRecord = - z_ext_record_oid(odr_en, match_syntax, + ret_trans = + yaz_record_conv_record(rc, (const char *) + r->u.octet_aligned->buf, + r->u.octet_aligned->len, + output_record); + } + if (ret_trans == 0) + { + npr->u.databaseRecord = + z_ext_record_oid(odr_en, match_syntax, wrbuf_buf(output_record), wrbuf_len(output_record)); - } - else - { - pr_res->records-> - u.databaseOrSurDiagnostics->records[i] - = zget_surrogateDiagRec( - odr_en, npr->databaseName, - YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS, - yaz_record_conv_get_error(rc)); - } - wrbuf_destroy(output_record); } + else + { + pr_res->records-> + u.databaseOrSurDiagnostics->records[i] + = zget_surrogateDiagRec( + odr_en, npr->databaseName, + YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS, + yaz_record_conv_get_error(rc)); + } + wrbuf_destroy(output_record); } } } @@ -336,8 +337,9 @@ extern "C" { /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil - * c-file-style: "stroustrup" * End: * vim: shiftwidth=4 tabstop=8 expandtab */ +