From: Marc Cromme Date: Wed, 13 Sep 2006 10:43:21 +0000 (+0000) Subject: added first files for SRU to Z3950 filter module, much more work needed X-Git-Tag: METAPROXY.1.0.7~69 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=3825178e4cb10dda3de93336cad102f1459e48c6;p=metaproxy-moved-to-github.git added first files for SRU to Z3950 filter module, much more work needed --- diff --git a/etc/config-sru-to-z3950.xml b/etc/config-sru-to-z3950.xml new file mode 100644 index 0000000..3f4ff34 --- /dev/null +++ b/etc/config-sru-to-z3950.xml @@ -0,0 +1,35 @@ + + + + + + + 10 + @:9000 + + + 30 + + + + + + + SRU/W + + + + Z3950 + + + + Default + localhost:1314/Default + + + + + + + + diff --git a/etc/experiment-query-config-translate.php b/etc/experiment-query-config-translate.php index 57fec67..38e764e 100755 --- a/etc/experiment-query-config-translate.php +++ b/etc/experiment-query-config-translate.php @@ -9,6 +9,13 @@ print_r($command->command()); $config = new Config; $config->load($command->config()); $config->parse(); +$config->cql_check_boolean("and"); +$config->cql_check_boolean("notexist"); +$config->cql_check_apt("cql", "all", "="); +$config->cql_check_apt("cql", "all", "notexist"); +$config->cql_check_apt("cql", "notexist", "="); +$config->cql_check_apt("notexist", "all", "<>"); + print("DONE\n"); exit(0); @@ -122,15 +129,44 @@ class Config { $namespaces = $this->xml_conf->getNamespaces(true); foreach ($namespaces as $ns){ print("namespace '" . $ns . "'\n"); - } - + } foreach ($this->xml_conf->xpath('//iq:syntax') as $syntax){ print("syntax '" . $syntax['name'] . "'\n"); - } - + } + } + + public function cql_check_boolean($boolean){ + foreach ($this->xml_conf->xpath("//iq:syntax[@name='cql']//iq:boolean") + as $b){ + if ($b['name'] == $boolean ){ + print("CQL boolean '" . $boolean . "' exists\n"); + return; + } + } + print("CQL boolean '" . $boolean . "' error\n"); + } + + public function cql_check_apt($set, $index, $relation){ + print("CQL APT set'" . $set . "' index '" . $index + . "' relation '" . $relation . "' check\n"); + foreach ($this->xml_conf->xpath("//iq:syntax[@name='cql']//iq:set") + as $s){ + if ($s['name'] == $set ){ + print("CQL APT set'" . $set . "' OK\n"); + foreach ($set->xpath("//iq:index") as $i){ + + print("CQL APT set'" . $set . "' OK index '" . $index . "' ERROR\n"); + return; + } + + print("CQL APT set'" . $set . "' OK index '" . $index . "' ERROR\n"); + return; + } + } + print("CQL APT set'" . $set . "' ERROR\n"); } } diff --git a/src/Makefile.am b/src/Makefile.am index f16e172..22e0736 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.53 2006-08-31 13:01:09 marc Exp $ +## $Id: Makefile.am,v 1.54 2006-09-13 10:43:24 marc Exp $ MAINTAINERCLEANFILES = Makefile.in config.in config.hpp @@ -24,6 +24,7 @@ libmetaproxy_la_SOURCES = \ filter_multi.cpp filter_multi.hpp \ filter_query_rewrite.cpp filter_query_rewrite.hpp \ filter_session_shared.cpp filter_session_shared.hpp \ + filter_sru_to_z3950.cpp filter_sru_to_z3950.hpp \ filter_template.cpp filter_template.hpp \ filter_virt_db.cpp filter_virt_db.hpp \ filter_z3950_client.cpp filter_z3950_client.hpp \ diff --git a/src/factory_static.cpp b/src/factory_static.cpp index 378a742..38466f1 100644 --- a/src/factory_static.cpp +++ b/src/factory_static.cpp @@ -1,4 +1,4 @@ -/* $Id: factory_static.cpp,v 1.11 2006-08-31 13:01:09 marc Exp $ +/* $Id: factory_static.cpp,v 1.12 2006-09-13 10:43:24 marc Exp $ Copyright (c) 2005-2006, Index Data. See the LICENSE file for details @@ -24,6 +24,7 @@ #include "filter_multi.hpp" #include "filter_query_rewrite.hpp" #include "filter_session_shared.hpp" +#include "filter_sru_to_z3950.hpp" #include "filter_template.hpp" #include "filter_virt_db.hpp" #include "filter_z3950_client.hpp" @@ -42,6 +43,7 @@ mp::FactoryStatic::FactoryStatic() &metaproxy_1_filter_multi, &metaproxy_1_filter_query_rewrite, &metaproxy_1_filter_session_shared, + &metaproxy_1_filter_sru_to_z3950, &metaproxy_1_filter_template, &metaproxy_1_filter_virt_db, &metaproxy_1_filter_z3950_client, diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp new file mode 100644 index 0000000..260efeb --- /dev/null +++ b/src/filter_sru_to_z3950.cpp @@ -0,0 +1,103 @@ +/* $Id: filter_sru_to_z3950.cpp,v 1.1 2006-09-13 10:43:24 marc Exp $ + Copyright (c) 2005-2006, Index Data. + + See the LICENSE file for details + */ + +#include "config.hpp" + +#include "filter.hpp" +#include "package.hpp" + +#include + +#include "util.hpp" +#include "filter_sru_to_z3950.hpp" + +#include + +namespace mp = metaproxy_1; +namespace yf = mp::filter; + +namespace metaproxy_1 { + namespace filter { + class SRUtoZ3950::Rep { + friend class SRUtoZ3950; + //int dummy; + }; + } +} + +yf::SRUtoZ3950::SRUtoZ3950() : m_p(new Rep) +{ + //m_p->dummy = 1; +} + +yf::SRUtoZ3950::~SRUtoZ3950() +{ // must have a destructor because of boost::scoped_ptr +} + +void yf::SRUtoZ3950::process(mp::Package &package) const +{ + Z_GDU *zgdu_req = package.request().get(); + + // ignoring all non HTTP_Request packages + if (!zgdu_req || !(zgdu_req->which == Z_GDU_HTTP_Request)){ + package.move(); + return; + } + + // only working on HTTP_Request packages now + Z_HTTP_Request* http_req = zgdu_req->u.HTTP_Request; + + // TODO: SRU package checking and translation to Z3950 package + + // sending Z3950 package through pipeline + package.move(); + + + // TODO: Z3950 response parsing and translation to SRU package + //Z_HTTP_Response* http_res = 0; + + + Z_GDU *zgdu_res = 0; + metaproxy_1::odr odr; + zgdu_res + = odr.create_HTTP_Response(package.session(), + zgdu_req->u.HTTP_Request, 200); + + //zgdu_res->u.HTTP_Response->content_len = message.str().size(); + //zgdu_res->u.HTTP_Response->content_buf + // = (char*) odr_malloc(odr, zgdu_res->u.HTTP_Response->content_len); + + //strncpy(zgdu_res->u.HTTP_Response->content_buf, + // message.str().c_str(), zgdu_res->u.HTTP_Response->content_len); + + // z_HTTP_header_add(o, &hres->headers, + // "Content-Type", content_type.c_str()); + package.response() = zgdu_res; + +} + +static mp::filter::Base* filter_creator() +{ + return new mp::filter::SRUtoZ3950; +} + +extern "C" { + struct metaproxy_1_filter_struct metaproxy_1_filter_sru_to_z3950 = { + 0, + "SRUtoZ3950", + filter_creator + }; +} + + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * c-file-style: "stroustrup" + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ diff --git a/src/filter_sru_to_z3950.hpp b/src/filter_sru_to_z3950.hpp new file mode 100644 index 0000000..334601b --- /dev/null +++ b/src/filter_sru_to_z3950.hpp @@ -0,0 +1,40 @@ +/* $Id: filter_sru_to_z3950.hpp,v 1.1 2006-09-13 10:43:24 marc Exp $ + Copyright (c) 2005-2006, Index Data. + + See the LICENSE file for details + */ + +// Filter that does nothing. Use as sru_to_z3950 for new filters +#ifndef FILTER_SRU_TO_Z3950_HPP +#define FILTER_SRU_TO_Z3950_HPP + +#include + +#include "filter.hpp" + +namespace metaproxy_1 { + namespace filter { + class SRUtoZ3950 : public Base { + class Rep; + boost::scoped_ptr m_p; + public: + SRUtoZ3950(); + ~SRUtoZ3950(); + void process(metaproxy_1::Package & package) const; + }; + } +} + +extern "C" { + extern struct metaproxy_1_filter_struct metaproxy_1_filter_sru_to_z3950; +} + +#endif +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * c-file-style: "stroustrup" + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */