Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/pazpar2
authorDennis Schafroth <dennis@indexdata.com>
Thu, 15 Dec 2011 13:16:56 +0000 (14:16 +0100)
committerDennis Schafroth <dennis@indexdata.com>
Thu, 15 Dec 2011 13:16:56 +0000 (14:16 +0100)
17 files changed:
debian/changelog
doc/pazpar2_protocol.xml
src/client.c
src/client.h
src/http_command.c
src/session.c
test/test_facets.urls
test/test_facets_11.res
test/test_facets_14.res
test/test_facets_17.res
test/test_facets_18.res
test/test_facets_24.res
test/test_facets_6.res
test/test_http.urls
test/test_http_46.res
www/mobile/UiUIKit/stylesheets/iphone.css
www/mobile/index.html

index e84ecc1..5735676 100644 (file)
@@ -1,3 +1,9 @@
+pazpar2 (1.6.6-2indexdata) unstable; urgency=low
+
+  * Testing
+
+ -- Adam Dickmeiss <adam@indexdata.dk>  Tue, 13 Dec 2011 14:39:42 +0100
+
 pazpar2 (1.6.6-1indexdata) unstable; urgency=low
 
   * Upstream 
index 47314ac..e898566 100644 (file)
@@ -428,15 +428,16 @@ search.pz2?session=2044502273&command=show&start=0&num=2&sort=title:1
       <listitem>
        <para>
        This optional parameter is an integer which, when given, makes
-       Pazpar2 return the raw record for a target. The raw record
-       from first target is numbered 0, second numbered 1, etc.
-       When a raw record is returned Pazpar2 will XSLT transform the
-       record but an XML version is returned. All ISO2709 records are
-       returned as MARCXML. OPAC records are returned as YAZ'
-       OPAC with an MARCXML sibling.
+       Pazpar2 return the original record for a specific target.
+       The record set from first target is numbered 0,
+       second record set is numbered 1, etc.
+       The nativesyntax setting, as usual, is used to determine how to
+       create XML from the original record - unless parameter
+       <literal>binary</literal> is given in which the record is
+       fetched as "raw" from ZOOM C (raw, original record).
        </para>
        <para>
-       When offset is not given the Pazpar2 metadata for the record
+       When offset is not given, the Pazpar2 metadata for the record
        is returned and with metadata for each targets' data specified
        in a 'location' list.
        </para>
@@ -444,6 +445,17 @@ search.pz2?session=2044502273&command=show&start=0&num=2&sort=title:1
      </varlistentry>
 
      <varlistentry>
+      <term>nativesyntax</term>
+      <listitem>
+       <para>
+       This optional parameter can be used to override pz:nativesyntax
+       as given for the target. This allow an alternative nativesyntax
+       to be used for original records (see parameteroffset above).
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term>syntax</term>
       <listitem>
        <para>
@@ -471,9 +483,9 @@ search.pz2?session=2044502273&command=show&start=0&num=2&sort=title:1
       <listitem>
        <para>
        This optional parameter enables "binary" response for retrieval
-       of a raw record (i.e. when offset is specified). For binary
-       responses the record is <emphasis>not</emphasis> converted to
-       XML and the HTTP content type is application/octet-stream.
+       of a original record (i.e. when offset is specified). For binary
+       response the record by default is fetched from ZOOM C using
+       the "raw" option or by parameter nativesyntax if given.
        </para>
       </listitem>
      </varlistentry>
index 8890060..7dc07d8 100644 (file)
@@ -139,6 +139,7 @@ struct show_raw {
     int binary;
     char *syntax;
     char *esn;
+    char *nativesyntax;
     void (*error_handler)(void *data, const char *addinfo);
     void (*record_handler)(void *data, const char *buf, size_t sz);
     void *data;
@@ -216,15 +217,15 @@ const char *client_get_pquery(struct client *cl)
 }
 
 static void client_send_raw_present(struct client *cl);
-static int nativesyntax_to_type(struct session_database *sdb, char *type,
-                                ZOOM_record rec);
+static int nativesyntax_to_type(const char *s, char *type, ZOOM_record rec);
 
 static void client_show_immediate(
     ZOOM_resultset resultset, struct session_database *sdb, int position,
     void *data,
     void (*error_handler)(void *data, const char *addinfo),
     void (*record_handler)(void *data, const char *buf, size_t sz),
-    int binary)
+    int binary,
+    const char *nativesyntax)
 {
     ZOOM_record rec = 0;
     char type[80];
@@ -242,10 +243,7 @@ static void client_show_immediate(
         error_handler(data, "no record");
         return;
     }
-    if (binary)
-        strcpy(type, "raw");
-    else
-        nativesyntax_to_type(sdb, type, rec);
+    nativesyntax_to_type(nativesyntax, type, rec);
     buf = ZOOM_record_get(rec, type, &len);
     if (!buf)
     {
@@ -262,13 +260,25 @@ int client_show_raw_begin(struct client *cl, int position,
                           void (*error_handler)(void *data, const char *addinfo),
                           void (*record_handler)(void *data, const char *buf,
                                                  size_t sz),
-                          int binary)
+                          int binary,
+                          const char *nativesyntax)
 {
+    if (!nativesyntax)
+    {
+        if (binary)
+            nativesyntax = "raw";
+        else
+        {
+            struct session_database *sdb = client_get_database(cl);
+            nativesyntax = session_setting_oneval(sdb, PZ_NATIVESYNTAX);
+        }
+    }
+
     if (syntax == 0 && esn == 0)
         client_show_immediate(cl->resultset, client_get_database(cl),
                               position, data,
                               error_handler, record_handler,
-                              binary);
+                              binary, nativesyntax);
     else
     {
         struct show_raw *rr, **rrp;
@@ -292,6 +302,10 @@ int client_show_raw_begin(struct client *cl, int position,
             rr->esn = xstrdup(esn);
         else
             rr->esn = 0;
+
+        assert(nativesyntax);
+        rr->nativesyntax = xstrdup(nativesyntax);
+            
         rr->next = 0;
         
         for (rrp = &cl->show_raw; *rrp; rrp = &(*rrp)->next)
@@ -318,6 +332,7 @@ static void client_show_raw_delete(struct show_raw *r)
 {
     xfree(r->syntax);
     xfree(r->esn);
+    xfree(r->nativesyntax);
     xfree(r);
 }
 
@@ -386,11 +401,9 @@ static void client_send_raw_present(struct client *cl)
     connection_continue(co);
 }
 
-static int nativesyntax_to_type(struct session_database *sdb, char *type,
+static int nativesyntax_to_type(const char *s, char *type,
                                 ZOOM_record rec)
 {
-    const char *s = session_setting_oneval(sdb, PZ_NATIVESYNTAX);
-
     if (s && *s)
     {
         if (!strncmp(s, "iso2709", 7))
@@ -408,7 +421,7 @@ static int nativesyntax_to_type(struct session_database *sdb, char *type,
             yaz_snprintf(type, 80, "txml; charset=%s", cp ? cp+1 : "marc-8s");
         }
         else
-            return -1;
+            strcpy(type, s);
         return 0;
     }
     else  /* attempt to deduce structure */
@@ -486,14 +499,7 @@ static void ingest_raw_record(struct client *cl, ZOOM_record rec)
     int len;
     char type[80];
 
-    if (cl->show_raw->binary)
-        strcpy(type, "raw");
-    else
-    {
-        struct session_database *sdb = client_get_database(cl);
-        nativesyntax_to_type(sdb, type, rec);
-    }
-
+    nativesyntax_to_type(cl->show_raw->nativesyntax, type, rec);
     buf = ZOOM_record_get(rec, type, &len);
     cl->show_raw->record_handler(cl->show_raw->data,  buf, len);
     client_show_raw_dequeue(cl);
@@ -592,7 +598,8 @@ static void client_record_ingest(struct client *cl)
             const char *xmlrec;
             char type[80];
             
-            if (nativesyntax_to_type(sdb, type, rec))
+            const char *s = session_setting_oneval(sdb, PZ_NATIVESYNTAX);
+            if (nativesyntax_to_type(s, type, rec))
                 yaz_log(YLOG_WARN, "Failed to determine record type");
             xmlrec = ZOOM_record_get(rec, type, NULL);
             if (!xmlrec)
index 8697ba0..16f9b78 100644 (file)
@@ -45,7 +45,8 @@ int client_show_raw_begin(struct client *cl, int position,
                           void (*error_handler)(void *data, const char *addinfo),
                           void (*record_handler)(void *data, const char *buf,
                                                  size_t sz),
-                          int binary);
+                          int binary,
+                          const char *nativesyntax);
 
 void client_show_raw_remove(struct client *cl, void *rr);
 
index e0921e8..edaad36 100644 (file)
@@ -888,7 +888,8 @@ static void cmd_record(struct http_channel *c)
         int i;
         struct record*r = rec->records;
         int binary = 0;
-
+        const char *nativesyntax = http_argbyname(rq, "nativesyntax");
+        
         if (binarystr && *binarystr != '0')
             binary = 1;
 
@@ -903,13 +904,14 @@ static void cmd_record(struct http_channel *c)
             http_channel_observer_t obs =
                 http_add_observer(c, r->client, show_raw_reset);
             int ret = client_show_raw_begin(r->client, r->position,
-                                        syntax, esn, 
-                                        obs /* data */,
-                                        show_raw_record_error,
-                                        (binary ? 
-                                         show_raw_record_ok_binary : 
-                                         show_raw_record_ok),
-                                        (binary ? 1 : 0));
+                                            syntax, esn,
+                                            obs /* data */,
+                                            show_raw_record_error,
+                                            (binary ? 
+                                             show_raw_record_ok_binary : 
+                                             show_raw_record_ok),
+                                            (binary ? 1 : 0),
+                                            nativesyntax);
             if (ret == -1)
             {
                 http_remove_observer(obs);
index 9706e0e..d388016 100644 (file)
@@ -1058,8 +1058,10 @@ void perform_termlist(struct http_channel *c, struct session *se,
     char **names;
     int num_names = 0;
 
-    if (name)
-        nmem_strsplit(nmem_tmp, ",", name, &names, &num_names);
+    if (!name)
+        name = "*";
+
+    nmem_strsplit(nmem_tmp, ",", name, &names, &num_names);
 
     session_enter(se);
 
@@ -1067,17 +1069,18 @@ void perform_termlist(struct http_channel *c, struct session *se,
     {
         const char *tname;
         
-        wrbuf_puts(c->wrbuf, "<list name=\"");
-        wrbuf_xmlputs(c->wrbuf, names[j]);
-        wrbuf_puts(c->wrbuf, "\">\n");
-
         for (i = 0; i < se->num_termlists; i++)
         {
             tname = se->termlists[i].name;
-            if (num_names > 0 && !strcmp(names[j], tname))
+            if (!strcmp(names[j], tname) || !strcmp(names[j], "*"))
             {
                 struct termlist_score **p = 0;
                 int len;
+
+                wrbuf_puts(c->wrbuf, "<list name=\"");
+                wrbuf_xmlputs(c->wrbuf, tname);
+                wrbuf_puts(c->wrbuf, "\">\n");
+
                 p = termlist_highscore(se->termlists[i].termlist, &len);
                 if (p)
                 {
@@ -1099,14 +1102,19 @@ void perform_termlist(struct http_channel *c, struct session *se,
                         wrbuf_puts(c->wrbuf, "</term>\n");
                     }
                 }
+                wrbuf_puts(c->wrbuf, "</list>\n");
             }
         }
         tname = "xtargets";
-        if (num_names > 0 && !strcmp(names[j], tname))
+        if (!strcmp(names[j], tname) || !strcmp(names[j], "*"))
         {
+            wrbuf_puts(c->wrbuf, "<list name=\"");
+            wrbuf_xmlputs(c->wrbuf, tname);
+            wrbuf_puts(c->wrbuf, "\">\n");
+
             targets_termlist_nb(c->wrbuf, se, num, c->nmem);
+            wrbuf_puts(c->wrbuf, "</list>\n");
         }
-        wrbuf_puts(c->wrbuf, "</list>\n");
     }
     session_leave(se);
     nmem_destroy(nmem_tmp);
index af9d74a..805ab95 100644 (file)
@@ -11,7 +11,7 @@ http://localhost:9763/search.pz2?session=1&command=bytarget
 http://localhost:9763/search.pz2?session=1&command=termlist&name=xtargets%2Cauthor%2Csubject%2Cdate%2Cmedium
 http://localhost:9763/search.pz2?session=1&command=search&query=8+and+computer
 http://localhost:9763/search.pz2?session=1&command=show&block=1
-http://localhost:9763/search.pz2?session=1&command=termlist&name=xtargets%2Cauthor%2Csubject%2Cdate%2Cmedium
+http://localhost:9763/search.pz2?session=1&command=termlist
 http://localhost:9763/search.pz2?session=1&command=search&query=6+and+computer
 http://localhost:9763/search.pz2?session=1&command=show
 http://localhost:9763/search.pz2?session=1&command=termlist&name=xtargets%2Cauthor%2Csubject%2Cdate%2Cmedium
index aaf0155..6045d02 100644 (file)
@@ -45,6 +45,4 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
-<list name="medium">
-</list>
 </termlist>
\ No newline at end of file
index 37b5a75..1f06ee1 100644 (file)
@@ -1,14 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <termlist><activeclients>0</activeclients>
-<list name="xtargets">
-<term>
-<id>localhost:9999/db1</id>
-<name>db1</name>
-<frequency>8</frequency>
-<state>Client_Idle</state>
-<diagnostic>0</diagnostic>
-</term>
-</list>
 <list name="author">
 <term><name>author0</name><frequency>100</frequency></term>
 <term><name>author1</name><frequency>90</frequency></term>
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
-<list name="medium">
+<list name="xtargets">
+<term>
+<id>localhost:9999/db1</id>
+<name>db1</name>
+<frequency>8</frequency>
+<state>Client_Idle</state>
+<diagnostic>0</diagnostic>
+</term>
 </list>
 </termlist>
\ No newline at end of file
index 00e11f8..7765713 100644 (file)
@@ -45,6 +45,4 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
-<list name="medium">
-</list>
 </termlist>
\ No newline at end of file
index 00e11f8..7765713 100644 (file)
@@ -45,6 +45,4 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
-<list name="medium">
-</list>
 </termlist>
\ No newline at end of file
index 598b204..512b81f 100644 (file)
@@ -40,6 +40,4 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
-<list name="medium">
-</list>
 </termlist>
\ No newline at end of file
index ebb8bb4..f78c7dc 100644 (file)
@@ -30,6 +30,4 @@
 <term><name>1973</name><frequency>1</frequency></term>
 <term><name>1980</name><frequency>1</frequency></term>
 </list>
-<list name="medium">
-</list>
 </termlist>
\ No newline at end of file
index de45220..18a454b 100644 (file)
@@ -43,7 +43,7 @@ http://localhost:9763/search.pz2?session=5&command=show&block=1
 http://localhost:9763/search.pz2?command=init&pz:elements%5Bz3950.indexdata.com%2Fmarc%5D=F
 1 http://localhost:9763/search.pz2?session=6&command=search&query=louis
 1 http://localhost:9763/search.pz2?session=6&command=show&block=1
-http://localhost:9763/search.pz2?session=6&command=record&id=content%3A+title+computer+processing+of+dynamic+images+from+an+anger+scintillation+camera+author+medium+book&offset=0
+http://localhost:9763/search.pz2?session=6&command=record&id=content%3A+title+computer+processing+of+dynamic+images+from+an+anger+scintillation+camera+author+medium+book&offset=0&nativesyntax=txml%3Bcharset%3Dmarc-8
 http://localhost:9763/search.pz2?command=init&pz:elements%5Bz3950.indexdata.com%2Fmarc%5D=F
 http://localhost:9763/search.pz2?session=7&command=search&query=greece
 1 http://localhost:9763/search.pz2?session=7&command=show&block=1
index 986955f..13c7f18 100644 (file)
@@ -1,73 +1,73 @@
-<record xmlns="http://www.loc.gov/MARC21/slim">
-  <leader>01369nam a2200265 i 4504</leader>
-  <controlfield tag="001">   73090924 //r82</controlfield>
-  <controlfield tag="003">DLC</controlfield>
-  <controlfield tag="005">19820524000000.0</controlfield>
-  <controlfield tag="008">760609s1974    nyua     b    10110 eng  </controlfield>
-  <datafield tag="010" ind1=" " ind2=" ">
-    <subfield code="a">   73090924 //r82</subfield>
-  </datafield>
-  <datafield tag="040" ind1=" " ind2=" ">
-    <subfield code="a">DLC</subfield>
-    <subfield code="c">DLC</subfield>
-    <subfield code="d">DLC</subfield>
-  </datafield>
-  <datafield tag="050" ind1="0" ind2="0">
-    <subfield code="a">RC71.3</subfield>
-    <subfield code="b">.W67 1971</subfield>
-  </datafield>
-  <datafield tag="082" ind1="0" ind2="0">
-    <subfield code="a">616.07/575/02854</subfield>
-  </datafield>
-  <datafield tag="111" ind1="2" ind2="0">
-    <subfield code="a">Workshop on Computer Processing of Dynamic Images from an Anger Scintillation Camera,</subfield>
-    <subfield code="c">Washington University,</subfield>
-    <subfield code="d">1971.</subfield>
-  </datafield>
-  <datafield tag="245" ind1="1" ind2="0">
-    <subfield code="a">Computer processing of dynamic images from an Anger scintillation camera :</subfield>
-    <subfield code="b">the proceedings of a workshop /</subfield>
-    <subfield code="c">cosponsored by the Biomedical Computer Laboratory and the Nuclear Medicine Division, Department of Radiology, School of Medicine, Washington University, St. Louis, January 18-22, 1971 ; edited by Kenneth B. Larson, Jerome R. Cox, Jr.</subfield>
-  </datafield>
-  <datafield tag="260" ind1="0" ind2=" ">
-    <subfield code="a">New York :</subfield>
-    <subfield code="b">Society of Nuclear Medicine,</subfield>
-    <subfield code="c">[c1974]</subfield>
-  </datafield>
-  <datafield tag="300" ind1=" " ind2=" ">
-    <subfield code="a">xiv, p. :</subfield>
-    <subfield code="b">ill. ;</subfield>
-    <subfield code="c">24 cm.</subfield>
-  </datafield>
-  <datafield tag="504" ind1=" " ind2=" ">
-    <subfield code="a">Includes bibliographical references and index.</subfield>
-  </datafield>
-  <datafield tag="650" ind1=" " ind2="0">
-    <subfield code="a">Radioisotope scanning</subfield>
-    <subfield code="x">Data processing</subfield>
-    <subfield code="x">Congresses.</subfield>
-  </datafield>
-  <datafield tag="650" ind1=" " ind2="0">
-    <subfield code="a">Scintillation cameras</subfield>
-    <subfield code="x">Congresses.</subfield>
-  </datafield>
-  <datafield tag="650" ind1=" " ind2="0">
-    <subfield code="a">Imaging systems in medicine</subfield>
-    <subfield code="x">Data processing</subfield>
-    <subfield code="x">Congresses.</subfield>
-  </datafield>
-  <datafield tag="700" ind1="1" ind2="0">
-    <subfield code="a">Larson, Kenneth B.</subfield>
-  </datafield>
-  <datafield tag="700" ind1="1" ind2="0">
-    <subfield code="a">Cox, Jerome R. </subfield>
-  </datafield>
-  <datafield tag="710" ind1="2" ind2="0">
-    <subfield code="a">Washington University, St. Louis.</subfield>
-    <subfield code="b">Biomedical Computer Laboratory.</subfield>
-  </datafield>
-  <datafield tag="710" ind1="2" ind2="0">
-    <subfield code="a">Washington University, St. Louis.</subfield>
-    <subfield code="b">Nuclear Medicine Division.</subfield>
-  </datafield>
-</record>
+<r xmlns="http://www.indexdata.com/turbomarc">
+  <l>01369nam a2200265 i 4504</l>
+  <c001>   73090924 //r82</c001>
+  <c003>DLC</c003>
+  <c005>19820524000000.0</c005>
+  <c008>760609s1974    nyua     b    10110 eng  </c008>
+  <d010 i1=" " i2=" ">
+    <sa>   73090924 //r82</sa>
+  </d010>
+  <d040 i1=" " i2=" ">
+    <sa>DLC</sa>
+    <sc>DLC</sc>
+    <sd>DLC</sd>
+  </d040>
+  <d050 i1="0" i2="0">
+    <sa>RC71.3</sa>
+    <sb>.W67 1971</sb>
+  </d050>
+  <d082 i1="0" i2="0">
+    <sa>616.07/575/02854</sa>
+  </d082>
+  <d111 i1="2" i2="0">
+    <sa>Workshop on Computer Processing of Dynamic Images from an Anger Scintillation Camera,</sa>
+    <sc>Washington University,</sc>
+    <sd>1971.</sd>
+  </d111>
+  <d245 i1="1" i2="0">
+    <sa>Computer processing of dynamic images from an Anger scintillation camera :</sa>
+    <sb>the proceedings of a workshop /</sb>
+    <sc>cosponsored by the Biomedical Computer Laboratory and the Nuclear Medicine Division, Department of Radiology, School of Medicine, Washington University, St. Louis, January 18-22, 1971 ; edited by Kenneth B. Larson, Jerome R. Cox, Jr.</sc>
+  </d245>
+  <d260 i1="0" i2=" ">
+    <sa>New York :</sa>
+    <sb>Society of Nuclear Medicine,</sb>
+    <sc>[c1974]</sc>
+  </d260>
+  <d300 i1=" " i2=" ">
+    <sa>xiv, p. :</sa>
+    <sb>ill. ;</sb>
+    <sc>24 cm.</sc>
+  </d300>
+  <d504 i1=" " i2=" ">
+    <sa>Includes bibliographical references and index.</sa>
+  </d504>
+  <d650 i1=" " i2="0">
+    <sa>Radioisotope scanning</sa>
+    <sx>Data processing</sx>
+    <sx>Congresses.</sx>
+  </d650>
+  <d650 i1=" " i2="0">
+    <sa>Scintillation cameras</sa>
+    <sx>Congresses.</sx>
+  </d650>
+  <d650 i1=" " i2="0">
+    <sa>Imaging systems in medicine</sa>
+    <sx>Data processing</sx>
+    <sx>Congresses.</sx>
+  </d650>
+  <d700 i1="1" i2="0">
+    <sa>Larson, Kenneth B.</sa>
+  </d700>
+  <d700 i1="1" i2="0">
+    <sa>Cox, Jerome R. </sa>
+  </d700>
+  <d710 i1="2" i2="0">
+    <sa>Washington University, St. Louis.</sa>
+    <sb>Biomedical Computer Laboratory.</sb>
+  </d710>
+  <d710 i1="2" i2="0">
+    <sa>Washington University, St. Louis.</sa>
+    <sb>Nuclear Medicine Division.</sb>
+  </d710>
+</r>
index b4194d6..a247266 100644 (file)
                                padding: 10px 10px 10px 10px;
                                border: 1px solid #B4B4B4;
                                font-weight: bold;
-                               -webkit-tap-highlight-color:rgba(0,0,0,0);
+                font-size: 16px;
+                -webkit-tap-highlight-color:rgba(0,0,0,0);
                                }
                                
 
index 9d811b7..a29606b 100644 (file)
         </select>
         and show 
         <select name="perpage" id="perpage">
+         <option value="50" selected="selected">select</option>
          <option value="5">5</option>
-         <option value="5" selected="selected">10</option>
+         <option value="10">10</option>
          <option value="20">20</option>
          <option value="30">30</option>
          <option value="50">50</option>
   </div>
   <div id="detailview" style="display:none">
       <h4>Detailed view</h4>
-    <div id="detailrecord">meh</div> 
+    <div id="detailrecord"></div> 
   </div>
   <div id="targetview" style="display: none">
    <div id="bytarget">