projects
/
metaproxy-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
session_shared: remove log msg about backend classes
[metaproxy-moved-to-github.git]
/
src
/
filter_cql_to_rpn.cpp
diff --git
a/src/filter_cql_to_rpn.cpp
b/src/filter_cql_to_rpn.cpp
index
225ee82
..
322eb46
100644
(file)
--- a/
src/filter_cql_to_rpn.cpp
+++ b/
src/filter_cql_to_rpn.cpp
@@
-1,5
+1,5
@@
/* This file is part of Metaproxy.
/* This file is part of Metaproxy.
- Copyright (C) 2005-2012 Index Data
+ Copyright (C) 2005-2013 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
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
@@
-30,7
+30,7
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <yaz/zgdu.h>
#include <yaz/diagbib1.h>
#include <yaz/srw.h>
#include <yaz/zgdu.h>
#include <yaz/diagbib1.h>
#include <yaz/srw.h>
-
+#include <yaz/tpath.h>
namespace mp = metaproxy_1;
namespace yf = metaproxy_1::filter;
namespace mp = metaproxy_1;
namespace yf = metaproxy_1::filter;
@@
-42,7
+42,7
@@
namespace metaproxy_1 {
Impl();
~Impl();
void process(metaproxy_1::Package & package);
Impl();
~Impl();
void process(metaproxy_1::Package & package);
- void configure(const xmlNode * ptr);
+ void configure(const xmlNode *ptr, const char *path);
private:
yazpp_1::Yaz_cql2rpn m_cql2rpn;
};
private:
yazpp_1::Yaz_cql2rpn m_cql2rpn;
};
@@
-51,7
+51,7
@@
namespace metaproxy_1 {
// define Pimpl wrapper forwarding to Impl
// define Pimpl wrapper forwarding to Impl
-
+
yf::CQLtoRPN::CQLtoRPN() : m_p(new Impl)
{
}
yf::CQLtoRPN::CQLtoRPN() : m_p(new Impl)
{
}
@@
-63,7
+63,7
@@
yf::CQLtoRPN::~CQLtoRPN()
void yf::CQLtoRPN::configure(const xmlNode *xmlnode, bool test_only,
const char *path)
{
void yf::CQLtoRPN::configure(const xmlNode *xmlnode, bool test_only,
const char *path)
{
- m_p->configure(xmlnode);
+ m_p->configure(xmlnode, path);
}
void yf::CQLtoRPN::process(mp::Package &package) const
}
void yf::CQLtoRPN::process(mp::Package &package) const
@@
-79,10
+79,10
@@
yf::CQLtoRPN::Impl::Impl()
}
yf::CQLtoRPN::Impl::~Impl()
}
yf::CQLtoRPN::Impl::~Impl()
-{
+{
}
}
-void yf::CQLtoRPN::Impl::configure(const xmlNode *xmlnode)
+void yf::CQLtoRPN::Impl::configure(const xmlNode *xmlnode, const char *path)
{
/*
{
/*
@@
-90,7
+90,7
@@
void yf::CQLtoRPN::Impl::configure(const xmlNode *xmlnode)
<conversion file="pqf.properties"/>
</filter>
*/
<conversion file="pqf.properties"/>
</filter>
*/
-
+
std::string fname;
for (xmlnode = xmlnode->children; xmlnode; xmlnode = xmlnode->next)
{
std::string fname;
for (xmlnode = xmlnode->children; xmlnode; xmlnode = xmlnode->next)
{
@@
-111,7
+111,7
@@
void yf::CQLtoRPN::Impl::configure(const xmlNode *xmlnode)
}
else
{
}
else
{
- throw mp::filter::FilterException("Bad element "
+ throw mp::filter::FilterException("Bad element "
+ std::string((const char *)
xmlnode->name));
}
+ std::string((const char *)
xmlnode->name));
}
@@
-122,8
+122,14
@@
void yf::CQLtoRPN::Impl::configure(const xmlNode *xmlnode)
"for filter cql_rpn");
}
"for filter cql_rpn");
}
+
+ char fullpath[1024];
+ if (!yaz_filepath_resolve(fname.c_str(), path, 0, fullpath))
+ {
+ throw mp::filter::FilterException("Could not open " + fname);
+ }
int error = 0;
int error = 0;
- if (!m_cql2rpn.parse_spec_file(fname.c_str(), &error))
+ if (!m_cql2rpn.parse_spec_file(fullpath, &error))
{
throw mp::filter::FilterException("Bad or missing "
"CQL to RPN configuration "
{
throw mp::filter::FilterException("Bad or missing "
"CQL to RPN configuration "
@@
-146,17
+152,17
@@
void yf::CQLtoRPN::Impl::process(mp::Package &package)
char *addinfo = 0;
Z_RPNQuery *rpnquery = 0;
mp::odr odr;
char *addinfo = 0;
Z_RPNQuery *rpnquery = 0;
mp::odr odr;
-
+
int r = m_cql2rpn.query_transform(sr->query->u.type_104->u.cql,
&rpnquery, odr,
&addinfo);
if (r == -3)
{
int r = m_cql2rpn.query_transform(sr->query->u.type_104->u.cql,
&rpnquery, odr,
&addinfo);
if (r == -3)
{
- Z_APDU *f_apdu =
+ Z_APDU *f_apdu =
odr.create_searchResponse(
odr.create_searchResponse(
- apdu_req,
- YAZ_BIB1_TEMPORARY_SYSTEM_ERROR,
- "Missing CQL to RPN configuration");
+ apdu_req,
+ YAZ_BIB1_PERMANENT_SYSTEM_ERROR,
+ "cql_rpn: missing CQL to RPN configuration");
package.response() = f_apdu;
return;
}
package.response() = f_apdu;
return;
}
@@
-164,14
+170,14
@@
void yf::CQLtoRPN::Impl::process(mp::Package &package)
{
int error_code = yaz_diag_srw_to_bib1(r);
{
int error_code = yaz_diag_srw_to_bib1(r);
- Z_APDU *f_apdu =
+ Z_APDU *f_apdu =
odr.create_searchResponse(apdu_req, error_code, addinfo);
package.response() = f_apdu;
return;
}
else
{ // conversion OK
odr.create_searchResponse(apdu_req, error_code, addinfo);
package.response() = f_apdu;
return;
}
else
{ // conversion OK
-
+
sr->query->which = Z_Query_type_1;
sr->query->u.type_1 = rpnquery;
package.request() = gdu;
sr->query->which = Z_Query_type_1;
sr->query->u.type_1 = rpnquery;
package.request() = gdu;
@@
-188,7
+194,7
@@
static mp::filter::Base* filter_creator()
}
extern "C" {
}
extern "C" {
- struct metaproxy_1_filter_struct metaproxy_1_filter_cql_to_rpn = {
+ struct metaproxy_1_filter_struct metaproxy_1_filter_cql_rpn = {
0,
"cql_rpn",
filter_creator
0,
"cql_rpn",
filter_creator