From 91332b13d81ec4e70f547c8b90eabfb7898ea39c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 27 Sep 2012 15:19:23 +0200 Subject: [PATCH] Make an internal diagnostic for bad CCL map They'll show up via bytarget as diagnostic id = ZOOM_ERROR_CCL_CONFIG = 10013 and additional info as returned by new YAZ function ccl_qual_fitem2. --- src/client.c | 24 +++++++++++++++++++++--- src/session.c | 2 ++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/client.c b/src/client.c index 00d92ad..73bdb49 100644 --- a/src/client.c +++ b/src/client.c @@ -994,15 +994,33 @@ static CCL_bibset prepare_cclmap(struct client *cl, CCL_bibset base_bibset) res = ccl_qual_mk(); for (s = sdb->settings[PZ_CCLMAP]; s; s = s->next) { + const char *addinfo = 0; char *p = strchr(s->name + 3, ':'); if (!p) { - yaz_log(YLOG_WARN, "Malformed cclmap name: %s", s->name); + WRBUF w = wrbuf_alloc(); + wrbuf_printf(w, "Malformed cclmap. name=%s", s->name); + yaz_log(YLOG_WARN, "%s: %s", client_get_id(cl), wrbuf_cstr(w)); + client_set_diagnostic(cl, ZOOM_ERROR_CCL_CONFIG, wrbuf_cstr(w)); + client_set_state_nb(cl, Client_Error); ccl_qual_rm(&res); + wrbuf_destroy(w); return 0; } p++; - ccl_qual_fitem(res, s->value, p); + if (ccl_qual_fitem2(res, s->value, p, &addinfo)) + { + WRBUF w = wrbuf_alloc(); + + wrbuf_printf(w, "Malformed cclmap. name=%s: value=%s (%s)", + s->name, p, addinfo); + yaz_log(YLOG_WARN, "%s: %s", client_get_id(cl), wrbuf_cstr(w)); + client_set_diagnostic(cl, ZOOM_ERROR_CCL_CONFIG, wrbuf_cstr(w)); + client_set_state_nb(cl, Client_Error); + ccl_qual_rm(&res); + wrbuf_destroy(w); + return 0; + } } return res; } @@ -1199,7 +1217,7 @@ int client_parse_query(struct client *cl, const char *query, Z_RPNQuery *zquery; if (!ccl_map) - return -1; + return -3; if (maxrecs && atoi(maxrecs) != cl->maxrecs) { diff --git a/src/session.c b/src/session.c index c5401cf..e2eda61 100644 --- a/src/session.c +++ b/src/session.c @@ -764,6 +764,8 @@ enum pazpar2_error_code session_search(struct session *se, no_failed_query++; else if (parse_ret == -2) no_failed_limit++; + else if (parse_ret) + no_working++; /* other error, such as bad CCL map */ else { int r = -- 1.7.10.4