--- /dev/null
+<?xml version="1.0"?>
+<!-- $Id: config-sru-to-z3950.xml,v 1.1 2006-09-13 10:43:21 marc Exp $ -->
+<yp2 xmlns="http://indexdata.dk/yp2/config/1">
+ <start route="start"/>
+ <filters>
+ <filter id="frontend" type="frontend_net">
+ <threads>10</threads>
+ <port>@:9000</port>
+ </filter>
+ <filter id="backend" type="z3950_client">
+ <timeout>30</timeout>
+ </filter>
+ </filters>
+ <routes>
+ <route id="start">
+ <filter refid="frontend"/>
+ <filter type="log">
+ <message>SRU/W</message>
+ </filter>
+ <filter type="SRUtoZ3950"/>
+ <filter type="log">
+ <message>Z3950</message>
+ </filter>
+ <filter type="virt_db">
+ <virtual>
+ <database>Default</database>
+ <target>localhost:1314/Default</target>
+ </virtual>
+ </filter>
+ <filter refid="backend"/>
+ <filter type="bounce"/>
+ </route>
+ </routes>
+</yp2>
+
$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);
$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");
}
}
-## $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
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 \
-/* $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
#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"
&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,
--- /dev/null
+/* $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 <boost/thread/mutex.hpp>
+
+#include "util.hpp"
+#include "filter_sru_to_z3950.hpp"
+
+#include <yaz/zgdu.h>
+
+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
+ */
--- /dev/null
+/* $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 <boost/scoped_ptr.hpp>
+
+#include "filter.hpp"
+
+namespace metaproxy_1 {
+ namespace filter {
+ class SRUtoZ3950 : public Base {
+ class Rep;
+ boost::scoped_ptr<Rep> 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
+ */