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
rpn_cql: allow conversion from RPN to CQL MP-537
[metaproxy-moved-to-github.git]
/
src
/
filter_query_rewrite.cpp
diff --git
a/src/filter_query_rewrite.cpp
b/src/filter_query_rewrite.cpp
index
f979ba4
..
4828781
100644
(file)
--- a/
src/filter_query_rewrite.cpp
+++ b/
src/filter_query_rewrite.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) 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
@@
-85,7
+85,7
@@
void yf::QueryRewrite::process(mp::Package &package) const
void yf::QueryRewrite::Rep::process(mp::Package &package) const
{
Z_GDU *gdu = package.request().get();
void yf::QueryRewrite::Rep::process(mp::Package &package) const
{
Z_GDU *gdu = package.request().get();
-
+
if (gdu && gdu->which == Z_GDU_Z3950)
{
Z_APDU *apdu_req = gdu->u.z3950;
if (gdu && gdu->which == Z_GDU_Z3950)
{
Z_APDU *apdu_req = gdu->u.z3950;
@@
-95,18
+95,13
@@
void yf::QueryRewrite::Rep::process(mp::Package &package) const
const char *addinfo = 0;
mp::odr odr;
Z_SearchRequest *req = apdu_req->u.searchRequest;
const char *addinfo = 0;
mp::odr odr;
Z_SearchRequest *req = apdu_req->u.searchRequest;
-
+
if (m_stylesheet)
{
xmlDocPtr doc_input = 0;
yaz_query2xml(req->query, &doc_input);
if (m_stylesheet)
{
xmlDocPtr doc_input = 0;
yaz_query2xml(req->query, &doc_input);
-
- if (!doc_input)
- {
- error_code = YAZ_BIB1_MALFORMED_QUERY;
- addinfo = "converion from Query to XML failed";
- }
- else
+
+ if (doc_input)
{
xmlDocPtr doc_res = xsltApplyStylesheet(m_stylesheet,
doc_input, 0);
{
xmlDocPtr doc_res = xsltApplyStylesheet(m_stylesheet,
doc_input, 0);
@@
-125,7
+120,7
@@
void yf::QueryRewrite::Rep::process(mp::Package &package) const
xmlFreeDoc(doc_input);
}
}
xmlFreeDoc(doc_input);
}
}
- if (charset_to.length() && charset_from.length() &&
+ if (!error_code && charset_to.length() && charset_from.length() &&
(req->query->which == Z_Query_type_1
|| req->query->which == Z_Query_type_101))
{
(req->query->which == Z_Query_type_1
|| req->query->which == Z_Query_type_101))
{
@@
-145,13
+140,13
@@
void yf::QueryRewrite::Rep::process(mp::Package &package) const
}
if (error_code)
{
}
if (error_code)
{
- Z_APDU *f_apdu =
+ Z_APDU *f_apdu =
odr.create_searchResponse(apdu_req, error_code, addinfo);
package.response() = f_apdu;
return;
}
package.request() = gdu;
odr.create_searchResponse(apdu_req, error_code, addinfo);
package.response() = f_apdu;
return;
}
package.request() = gdu;
- }
+ }
}
package.move();
}
}
package.move();
}
@@
-174,16
+169,16
@@
void mp::filter::QueryRewrite::Rep::configure(const xmlNode *ptr,
std::string fname;
std::string fname;
- for (struct _xmlAttr *attr = ptr->properties;
+ for (struct _xmlAttr *attr = ptr->properties;
attr; attr = attr->next)
{
mp::xml::check_attribute(attr, "", "stylesheet");
attr; attr = attr->next)
{
mp::xml::check_attribute(attr, "", "stylesheet");
- fname = mp::xml::get_text(attr);
+ fname = mp::xml::get_text(attr);
}
if (0 == fname.size())
throw mp::filter::FilterException
}
if (0 == fname.size())
throw mp::filter::FilterException
- ("Attribute <xslt stylesheet=\""
+ ("Attribute <xslt stylesheet=\""
+ fname
+ "\"> needs XSLT stylesheet path content"
+ " in query_rewrite filter");
+ fname
+ "\"> needs XSLT stylesheet path content"
+ " in query_rewrite filter");
@@
-199,14
+194,14
@@
void mp::filter::QueryRewrite::Rep::configure(const xmlNode *ptr,
if (!m_stylesheet)
{
throw mp::filter::FilterException
if (!m_stylesheet)
{
throw mp::filter::FilterException
- ("Failed to read XSLT stylesheet '"
+ ("Failed to read XSLT stylesheet '"
+ fname
+ "' in query_rewrite filter");
}
}
else if (mp::xml::is_element_mp(ptr, "charset"))
{
+ fname
+ "' in query_rewrite filter");
}
}
else if (mp::xml::is_element_mp(ptr, "charset"))
{
- for (struct _xmlAttr *attr = ptr->properties;
+ for (struct _xmlAttr *attr = ptr->properties;
attr; attr = attr->next)
{
if (!strcmp((const char *) attr->name, "from"))
attr; attr = attr->next)
{
if (!strcmp((const char *) attr->name, "from"))
@@
-226,7
+221,7
@@
void mp::filter::QueryRewrite::Rep::configure(const xmlNode *ptr,
else
{
throw mp::filter::FilterException
else
{
throw mp::filter::FilterException
- ("Bad element "
+ ("Bad element "
+ std::string((const char *) ptr->name)
+ " in query_rewrite filter");
}
+ std::string((const char *) ptr->name)
+ " in query_rewrite filter");
}