-/* $Id: pazpar2.c,v 1.73 2007-04-11 18:42:25 quinn Exp $
+/* $Id: pazpar2.c,v 1.77 2007-04-12 13:46:28 adam Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
#include <yaz/otherinfo.h>
#include <yaz/yaz-util.h>
#include <yaz/nmem.h>
+#include <yaz/querytowrbuf.h>
+#if YAZ_VERSIONL >= 0x020163
+#include <yaz/oid_db.h>
+#endif
#if HAVE_CONFIG_H
#include "cconfig.h"
if (0 < strlen(global_parameters.zproxy_override)
&& 0 < strlen(cl->database->database->url))
- yaz_oi_set_string_oidval(&a->u.initRequest->otherInfo,
+ {
+#if YAZ_VERSIONL >= 0x020163
+ const int *oid_proxy = yaz_string_to_oid(yaz_oid_std(),
+ CLASS_USERINFO, OID_STR_PROXY);
+ yaz_oi_set_string_oid(&a->u.initRequest->otherInfo,
+ global_parameters.odr_out, oid_proxy,
+ 1, cl->database->database->url);
+#else
+ yaz_oi_set_string_oidval(&a->u.initRequest->otherInfo,
global_parameters.odr_out, VAL_PROXY,
1, cl->database->database->url);
+#endif
+ }
if (send_apdu(cl, a) >= 0)
{
char *recsyn;
char *piggyback;
- yaz_log(YLOG_DEBUG, "Sending search");
+ yaz_log(YLOG_DEBUG, "Sending search to %s", cl->database->database->url);
cn = ccl_find_str(sdb->database->ccl_map, se->query, &cerror, &cpos);
if (!cn)
if (!(piggyback = session_setting_oneval(sdb, PZ_PIGGYBACK)) || *piggyback == '1')
{
if ((recsyn = session_setting_oneval(sdb, PZ_REQUESTSYNTAX)))
+ {
+#if YAZ_VERSIONL >= 0x020163
a->u.searchRequest->preferredRecordSyntax =
- yaz_str_to_z3950oid(global_parameters.odr_out,
- CLASS_RECSYN, recsyn);
+ yaz_string_to_oid_odr(yaz_oid_std(),
+ CLASS_RECSYN, recsyn,
+ global_parameters.odr_out);
+#else
+ a->u.searchRequest->preferredRecordSyntax =
+ yaz_str_to_z3950oid(global_parameters.odr_out,
+ CLASS_RECSYN, recsyn);
+#endif
+ }
a->u.searchRequest->smallSetUpperBound = &ssub;
a->u.searchRequest->largeSetLowerBound = &lslb;
a->u.searchRequest->mediumSetPresentNumber = &mspn;
a->u.searchRequest->databaseNames = databaselist;
a->u.searchRequest->num_databaseNames = ndb;
- if (send_apdu(cl, a) >= 0)
- {
- iochan_setflags(i, EVENT_INPUT);
- cl->state = Client_Searching;
- cl->requestid = se->requestid;
- }
- else
- cl->state = Client_Error;
+
+ { //scope for sending and logging queries
+ WRBUF wbquery = wrbuf_alloc();
+ yaz_query_to_wrbuf(wbquery, zquery);
+
+ if (send_apdu(cl, a) >= 0)
+ {
+ iochan_setflags(i, EVENT_INPUT);
+ cl->state = Client_Searching;
+ cl->requestid = se->requestid;
+ yaz_log(YLOG_LOG, "SearchRequest %s %s",
+ cl->database->database->url, wrbuf_cstr(wbquery));
+ }
+ else {
+ cl->state = Client_Error;
+ yaz_log(YLOG_WARN, "Failed SearchRequest %s %s",
+ cl->database->database->url, wrbuf_cstr(wbquery));
+ }
+
+ wrbuf_destroy(wbquery);
+ }
odr_reset(global_parameters.odr_out);
}
a->u.presentRequest->resultSetId = "Default";
if ((recsyn = session_setting_oneval(sdb, PZ_REQUESTSYNTAX)))
+ {
+#if YAZ_VERSIONL >= 0x020163
a->u.presentRequest->preferredRecordSyntax =
- yaz_str_to_z3950oid(global_parameters.odr_out,
- CLASS_RECSYN, recsyn);
+ yaz_string_to_oid_odr(yaz_oid_std(),
+ CLASS_RECSYN, recsyn,
+ global_parameters.odr_out);
+#else
+ a->u.presentRequest->preferredRecordSyntax =
+ yaz_str_to_z3950oid(global_parameters.odr_out,
+ CLASS_RECSYN, recsyn);
+#endif
+ }
if (send_apdu(cl, a) >= 0)
{
cl->database->database->url);
return 0;
}
+
+ yaz_marc_write_using_libxml2(db->yaz_marc, 1);
if (yaz_marc_write_xml(db->yaz_marc, &res,
"http://www.loc.gov/MARC21/slim", 0, 0) < 0)
{
}
rdoc = xmlNewDoc((xmlChar *) "1.0");
xmlDocSetRootElement(rdoc, res);
+
}
else
{
- yaz_log(YLOG_FATAL, "Unknown native_syntax in normalize_record");
+ yaz_log(YLOG_FATAL,
+ "Unknown native_syntax in normalize_record from %s",
+ cl->database->database->url);
exit(1);
}
- if (global_parameters.dump_records)
- {
- fprintf(stderr, "Input Record (normalized):\n----------------\n");
+ if (global_parameters.dump_records){
+ fprintf(stderr,
+ "Input Record (normalized) from %s\n----------------\n",
+ cl->database->database->url);
#if LIBXML_VERSION >= 20600
xmlDocFormatDump(stderr, rdoc, 1);
#else
#endif
}
- for (m = db->map; m; m = m->next)
- {
- xmlDoc *new;
- if (!(new = xsltApplyStylesheet(m->stylesheet, rdoc, 0)))
+ for (m = db->map; m; m = m->next){
+ xmlDoc *new = 0;
+
+#if 1
+ {
+ xmlNodePtr root = 0;
+ new = xsltApplyStylesheet(m->stylesheet, rdoc, 0);
+ root= xmlDocGetRootElement(new);
+ if (!new || !root || !(root->children))
{
- yaz_log(YLOG_WARN, "XSLT transformation failed");
+ yaz_log(YLOG_WARN, "XSLT transformation failed from %s",
+ cl->database->database->url);
+ xmlFreeDoc(new);
+ xmlFreeDoc(rdoc);
return 0;
}
+ }
+#endif
+
+#if 0
+ // do it another way to detect transformation errors right now
+ // but does not seem to work either!
+ {
+ xsltTransformContextPtr ctxt;
+ ctxt = xsltNewTransformContext(m->stylesheet, rdoc);
+ new = xsltApplyStylesheetUser(m->stylesheet, rdoc, 0, 0, 0, ctxt);
+ if ((ctxt->state == XSLT_STATE_ERROR) ||
+ (ctxt->state == XSLT_STATE_STOPPED)){
+ yaz_log(YLOG_WARN, "XSLT transformation failed from %s",
+ cl->database->database->url);
+ xmlFreeDoc(new);
+ xmlFreeDoc(rdoc);
+ return 0;
+ }
+ }
+#endif
+
xmlFreeDoc(rdoc);
rdoc = new;
}
if (global_parameters.dump_records)
{
- fprintf(stderr, "Record:\n----------------\n");
+ fprintf(stderr, "Record from %s\n----------------\n",
+ cl->database->database->url);
#if LIBXML_VERSION >= 20600
xmlDocFormatDump(stderr, rdoc, 1);
#else
new->target = dbname;
new->name = setting;
new->value = value;
- new->user = "";
new->next = sdb->settings[offset];
sdb->settings[offset] = new;
break;