/* This file is part of Metaproxy.
- Copyright (C) 2005-2011 Index Data
+ 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
SearchablePtr sptr;
xsltStylesheetPtr xsp;
std::string content_session_id;
+ bool enable_cproxy;
public:
Backend(SearchablePtr sptr);
~Backend();
char **addinfo,
ODR odr,
std::string authentication,
- std::string proxy);
+ std::string proxy,
+ std::string realm);
void prepare_elements(BackendPtr b,
Odr_oid *preferredRecordSyntax,
ZOOM_connection_save_apdu_wrbuf(m_connection, m_apdu_wrbuf);
m_resultset = 0;
xsp = 0;
+ enable_cproxy = true;
}
yf::Zoom::Backend::~Backend()
xsltFreeStylesheet(xsp);
ZOOM_connection_destroy(m_connection);
ZOOM_resultset_destroy(m_resultset);
+ wrbuf_destroy(m_apdu_wrbuf);
}
void yf::Zoom::Backend::search(ZOOM_query q, Odr_int *hits,
int *error, char **addinfo, ODR odr)
{
+ ZOOM_resultset_destroy(m_resultset);
m_resultset = ZOOM_connection_search(m_connection, q);
get_zoom_error(error, addinfo, odr);
if (*error == 0)
int *error, char **addinfo,
ODR odr,
std::string authentication,
- std::string proxy)
+ std::string proxy,
+ std::string realm)
{
if (b->sptr->contentConnector.length())
{
wrbuf_printf(w, "auth: %s\n", authentication.c_str());
if (proxy.length())
wrbuf_printf(w, "proxy: %s\n", proxy.c_str());
+ if (realm.length())
+ wrbuf_printf(w, "realm: %s\n", realm.c_str());
fwrite(wrbuf_buf(w), 1, wrbuf_len(w), file);
fclose(file);
package.log("zoom", YLOG_LOG, "content file: %s", fname);
xfree(fname);
+ wrbuf_destroy(w);
}
return true;
}
const char *param_password = 0;
const char *param_content_user = 0;
const char *param_content_password = 0;
+ const char *param_nocproxy = 0;
int no_parms = 0;
char **names;
param_content_password = value;
else if (!strcmp(name, "content-proxy"))
content_proxy = value;
+ else if (!strcmp(name, "nocproxy"))
+ param_nocproxy = value;
else if (!strcmp(name, "proxy"))
{
char **dstr;
b->xsp = xsp;
b->m_frontend_database = database;
+ b->enable_cproxy = param_nocproxy ? false : true;
if (sptr->query_encoding.length())
b->set_option("rpnCharset", sptr->query_encoding);
out_names[no_out_args] = "subdatabase";
out_values[no_out_args++] = odr_strdup(odr, sptr->cfSubDB.c_str());
}
+ if (param_nocproxy)
+ {
+ out_names[no_out_args] = "nocproxy";
+ out_values[no_out_args++] = odr_strdup(odr, param_nocproxy);
+ }
}
else
{
}
package.log("zoom", YLOG_LOG, "url: %s", url.c_str());
b->connect(url, error, addinfo, odr);
- if (*error == 0)
+ if (*error == 0 && b->enable_cproxy)
create_content_session(package, b, error, addinfo, odr,
content_authentication.length() ?
content_authentication : authentication,
- content_proxy.length() ? content_proxy : proxy);
+ content_proxy.length() ? content_proxy : proxy,
+ realm);
if (*error == 0)
m_backend = b;
return b;
Z_NamePlusRecord *npr = 0;
const char *addinfo;
- package.log("zoom", YLOG_LOG, "Inspecting record at position %d",
- start + i);
int sur_error = ZOOM_record_error(recs[i], 0 /* msg */,
&addinfo, 0 /* diagset */);
}
}
- if (rec_buf)
+ if (rec_buf && b->enable_cproxy)
{
xmlDoc *doc = xmlParseMemory(rec_buf, rec_len);
std::string res =
log_diagnostic(package, error, addinfo);
apdu_res = odr.create_searchResponse(apdu_req, error, addinfo);
package.response() = apdu_res;
+ cql_parser_destroy(cp);
return;
}
char ccl_buf[1024];
-
r = cql_to_ccl_buf(cn, ccl_buf, sizeof(ccl_buf));
- if (r == 0)
- {
- ccl_wrbuf = wrbuf_alloc();
- wrbuf_puts(ccl_wrbuf, ccl_buf);
-
- WRBUF sru_sortkeys_wrbuf = wrbuf_alloc();
-
- cql_sortby_to_sortkeys(cn, wrbuf_vp_puts, sru_sortkeys_wrbuf);
- WRBUF sort_spec_wrbuf = wrbuf_alloc();
- yaz_srw_sortkeys_to_sort_spec(wrbuf_cstr(sru_sortkeys_wrbuf),
- sort_spec_wrbuf);
- wrbuf_destroy(sru_sortkeys_wrbuf);
-
- yaz_tok_cfg_t tc = yaz_tok_cfg_create();
- yaz_tok_parse_t tp =
- yaz_tok_parse_buf(tc, wrbuf_cstr(sort_spec_wrbuf));
- yaz_tok_cfg_destroy(tc);
-
- /* go through sortspec and map fields */
- int token = yaz_tok_move(tp);
- while (token != YAZ_TOK_EOF)
- {
- if (token == YAZ_TOK_STRING)
- {
- const char *field = yaz_tok_parse_string(tp);
- std::map<std::string,std::string>::iterator it;
- it = b->sptr->sortmap.find(field);
- if (it != b->sptr->sortmap.end())
- sortkeys += it->second;
- else
- sortkeys += field;
- }
- sortkeys += " ";
- token = yaz_tok_move(tp);
- if (token == YAZ_TOK_STRING)
- {
- sortkeys += yaz_tok_parse_string(tp);
- }
- if (token != YAZ_TOK_EOF)
- {
- sortkeys += " ";
- token = yaz_tok_move(tp);
- }
- }
- yaz_tok_parse_destroy(tp);
- wrbuf_destroy(sort_spec_wrbuf);
- }
- cql_parser_destroy(cp);
if (r)
{
error = YAZ_BIB1_MALFORMED_QUERY;
log_diagnostic(package, error, addinfo);
apdu_res = odr.create_searchResponse(apdu_req, error, addinfo);
package.response() = apdu_res;
+ cql_parser_destroy(cp);
return;
}
+
+ WRBUF sru_sortkeys_wrbuf = wrbuf_alloc();
+ if (cql_sortby_to_sortkeys(cn, wrbuf_vp_puts, sru_sortkeys_wrbuf))
+ {
+ error = YAZ_BIB1_ILLEGAL_SORT_RELATION;
+ const char *addinfo = "CQL to CCL sortby conversion";
+
+ log_diagnostic(package, error, addinfo);
+ apdu_res = odr.create_searchResponse(apdu_req, error, addinfo);
+ package.response() = apdu_res;
+ wrbuf_destroy(sru_sortkeys_wrbuf);
+ cql_parser_destroy(cp);
+ return;
+ }
+ WRBUF sort_spec_wrbuf = wrbuf_alloc();
+ yaz_srw_sortkeys_to_sort_spec(wrbuf_cstr(sru_sortkeys_wrbuf),
+ sort_spec_wrbuf);
+ wrbuf_destroy(sru_sortkeys_wrbuf);
+
+ ccl_wrbuf = wrbuf_alloc();
+ wrbuf_puts(ccl_wrbuf, ccl_buf);
+
+ yaz_tok_cfg_t tc = yaz_tok_cfg_create();
+ yaz_tok_parse_t tp =
+ yaz_tok_parse_buf(tc, wrbuf_cstr(sort_spec_wrbuf));
+ yaz_tok_cfg_destroy(tc);
+
+ /* go through sortspec and map fields */
+ int token = yaz_tok_move(tp);
+ while (token != YAZ_TOK_EOF)
+ {
+ if (token == YAZ_TOK_STRING)
+ {
+ const char *field = yaz_tok_parse_string(tp);
+ std::map<std::string,std::string>::iterator it;
+ it = b->sptr->sortmap.find(field);
+ if (it != b->sptr->sortmap.end())
+ sortkeys += it->second;
+ else
+ sortkeys += field;
+ }
+ sortkeys += " ";
+ token = yaz_tok_move(tp);
+ if (token == YAZ_TOK_STRING)
+ {
+ sortkeys += yaz_tok_parse_string(tp);
+ }
+ if (token != YAZ_TOK_EOF)
+ {
+ sortkeys += " ";
+ token = yaz_tok_move(tp);
+ }
+ }
+ yaz_tok_parse_destroy(tp);
+ wrbuf_destroy(sort_spec_wrbuf);
+
+ cql_parser_destroy(cp);
}
else
{