Enabled passing settings values to normalization stylesheet.
[pazpar2-moved-to-github.git] / src / http_command.c
index 9c56046..087f53d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: http_command.c,v 1.54 2007-06-15 19:35:17 adam Exp $
+/* $Id: http_command.c,v 1.57 2007-07-16 17:01:46 adam Exp $
    Copyright (c) 2006-2007, Index Data.
 
 This file is part of Pazpar2.
@@ -20,7 +20,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  */
 
 /*
- * $Id: http_command.c,v 1.54 2007-06-15 19:35:17 adam Exp $
+ * $Id: http_command.c,v 1.57 2007-07-16 17:01:46 adam Exp $
  */
 
 #include <stdio.h>
@@ -243,10 +243,15 @@ static void cmd_init(struct http_channel *c)
 {
     unsigned int sesid;
     char buf[1024];
+    const char *clear = http_argbyname(c->request, "clear");
     struct http_session *s = http_session_create();
     struct http_response *rs = c->response;
 
     yaz_log(YLOG_DEBUG, "HTTP Session init");
+    if (!clear || *clear == '0')
+        session_init_databases(s->psession);
+    else
+        yaz_log(YLOG_LOG, "No databases preloaded");
     sesid = make_sessionid();
     s->session_id = sesid;
     if (process_settings(s->psession, c->request, c->response) < 0)
@@ -495,7 +500,7 @@ static void show_raw_record_error(void *data, const char *addinfo)
 
     http_remove_observer(obs);
 
-    error(rs, PAZPAR2_NOT_IMPLEMENTED, addinfo);
+    error(rs, PAZPAR2_RECORD_FAIL, addinfo);
 }
 
 static void show_raw_record_ok(void *data, const char *buf, size_t sz)
@@ -528,8 +533,6 @@ static void cmd_record(struct http_channel *c)
     const char *idstr = http_argbyname(rq, "id");
     const char *offsetstr = http_argbyname(rq, "offset");
     
-    int id;
-
     if (!s)
         return;
     if (!idstr)
@@ -538,8 +541,7 @@ static void cmd_record(struct http_channel *c)
         return;
     }
     wrbuf_rewind(c->wrbuf);
-    id = atoi(idstr);
-    if (!(rec = show_single(s->psession, id)))
+    if (!(rec = show_single(s->psession, idstr)))
     {
         error(rs, PAZPAR2_RECORD_MISSING, idstr);
         return;
@@ -577,7 +579,7 @@ static void cmd_record(struct http_channel *c)
     else
     {
         wrbuf_puts(c->wrbuf, "<record>\n");
-        wrbuf_printf(c->wrbuf, "<recid>%d</recid>\n", rec->recid);
+        wrbuf_printf(c->wrbuf, "<recid>%s</recid>\n", rec->recid);
         write_metadata(c->wrbuf, service, rec->metadata, 1);
         for (r = rec->records; r; r = r->next)
             write_subrecord(r, c->wrbuf, service, 1);
@@ -645,7 +647,7 @@ static void show_records(struct http_channel *c, int active)
             write_subrecord(p, c->wrbuf, service, 0); // subrecs w/o details
         if (ccount > 1)
             wrbuf_printf(c->wrbuf, "<count>%d</count>\n", ccount);
-        wrbuf_printf(c->wrbuf, "<recid>%d</recid>\n", rec->recid);
+        wrbuf_printf(c->wrbuf, "<recid>%s</recid>\n", rec->recid);
         wrbuf_puts(c->wrbuf, "</hit>\n");
     }