From d0fef3a0b9afaee590e748341c073594f62d01b8 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 31 Aug 2009 14:39:35 +0200 Subject: [PATCH] Extend record response with more info. The record command now has activeclients (as in show), nextrecid (if such record exist), prevrecid (if such record exist). This allows navigation on single records and check for whether the system is idle (activeclients == 0). Bug #3012. --- src/http_command.c | 18 ++++++++++++++++-- src/logic.c | 12 +++++++++++- src/pazpar2.h | 4 +++- test/test_http_23.res | 2 ++ test/test_http_6.res | 2 ++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/http_command.c b/src/http_command.c index 340e7c0..ff35fdd 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -550,7 +550,7 @@ static void cmd_record(struct http_channel *c) struct http_response *rs = c->response; struct http_request *rq = c->request; struct http_session *s = locate_session(rq, rs); - struct record_cluster *rec; + struct record_cluster *rec, *prev_r, *next_r; struct record *r; struct conf_service *service = global_parameters.server->service; const char *idstr = http_argbyname(rq, "id"); @@ -565,7 +565,7 @@ static void cmd_record(struct http_channel *c) return; } wrbuf_rewind(c->wrbuf); - if (!(rec = show_single(s->psession, idstr))) + if (!(rec = show_single(s->psession, idstr, &prev_r, &next_r))) { if (session_set_watch(s->psession, SESSION_WATCH_RECORD, cmd_record_ready, c, c) != 0) @@ -618,6 +618,20 @@ static void cmd_record(struct http_channel *c) wrbuf_puts(c->wrbuf, ""); wrbuf_xmlputs(c->wrbuf, rec->recid); wrbuf_puts(c->wrbuf, "\n"); + if (prev_r) + { + wrbuf_puts(c->wrbuf, ""); + wrbuf_xmlputs(c->wrbuf, prev_r->recid); + wrbuf_puts(c->wrbuf, "\n"); + } + if (next_r) + { + wrbuf_puts(c->wrbuf, ""); + wrbuf_xmlputs(c->wrbuf, next_r->recid); + wrbuf_puts(c->wrbuf, "\n"); + } + wrbuf_printf(c->wrbuf, "%d\n", + session_active_clients(s->psession)); write_metadata(c->wrbuf, service, rec->metadata, 1); for (r = rec->records; r; r = r->next) write_subrecord(r, c->wrbuf, service, 1); diff --git a/src/logic.c b/src/logic.c index 02a133d..f565706 100644 --- a/src/logic.c +++ b/src/logic.c @@ -765,14 +765,24 @@ void report_nmem_stats(void) } #endif -struct record_cluster *show_single(struct session *s, const char *id) +struct record_cluster *show_single(struct session *s, const char *id, + struct record_cluster **prev_r, + struct record_cluster **next_r) { struct record_cluster *r; reclist_rewind(s->reclist); + *prev_r = 0; + *next_r = 0; while ((r = reclist_read_record(s->reclist))) + { if (!strcmp(r->recid, id)) + { + *next_r = reclist_read_record(s->reclist); return r; + } + *prev_r = r; + } return 0; } diff --git a/src/pazpar2.h b/src/pazpar2.h index 243745c..2a1f65c 100644 --- a/src/pazpar2.h +++ b/src/pazpar2.h @@ -172,7 +172,9 @@ enum pazpar2_error_code search(struct session *s, char *query, char *filter, const char **addinfo); struct record_cluster **show(struct session *s, struct reclist_sortparms *sp, int start, int *num, int *total, int *sumhits, NMEM nmem_show); -struct record_cluster *show_single(struct session *s, const char *id); +struct record_cluster *show_single(struct session *s, const char *id, + struct record_cluster **prev_r, + struct record_cluster **next_r); struct termlist_score **termlist(struct session *s, const char *name, int *num); int session_set_watch(struct session *s, int what, session_watchfun fun, void *data, struct http_channel *c); int session_active_clients(struct session *s); diff --git a/test/test_http_23.res b/test/test_http_23.res index 6701271..348843c 100644 --- a/test/test_http_23.res +++ b/test/test_http_23.res @@ -1,5 +1,7 @@ title how to program a computer author jack collins medium book +title computer processing of dynamic images from an anger scintillation camera author medium book +0 How to program a computer Jack Collins diff --git a/test/test_http_6.res b/test/test_http_6.res index 6701271..cd94513 100644 --- a/test/test_http_6.res +++ b/test/test_http_6.res @@ -1,5 +1,7 @@ title how to program a computer author jack collins medium book +title the use of passwords for controlled access to computer resources author wood helen m medium book +0 How to program a computer Jack Collins -- 1.7.10.4