Pazpar2 honors pz:url setting
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 5 Oct 2011 13:18:35 +0000 (15:18 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 5 Oct 2011 13:18:35 +0000 (15:18 +0200)
13 files changed:
doc/pazpar2_conf.xml
src/database.c
src/database.h
src/session.c
src/settings.c
src/settings.h
test/Makefile.am
test/test_url.cfg [new file with mode: 0644]
test/test_url.sh [new file with mode: 0755]
test/test_url.urls [new file with mode: 0644]
test/test_url_1.res [new file with mode: 0644]
test/test_url_2.res [new file with mode: 0644]
test/test_url_3.res [new file with mode: 0644]

index ef4cdb9..1120185 100644 (file)
        multiple overlapping settings with the same name and target
        value, the 'precedence' attribute determines what happens.
       </para>
+      <para>
+       For Pazpar2 1.6.4 or later, the target ID may be user-defined, in
+       which case, the actual host, port, etc is given by setting
+       <xref linkend="pzurl"/>.
+      </para>
      </listitem>
     </varlistentry>
     <varlistentry>
       </note>
      </listitem>
     </varlistentry>
+
+    <varlistentry id="pzurl">
+     <term>pz:url</term>
+     <listitem>
+      <para>
+       Specifies URL for the target and overrides the target ID.
+      </para>
+      <note>
+       <para>
+       <literal>pz:url</literal> is only recognized for
+       Pazpar2 1.6.4 and later.
+       </para>
+      </note>
+     </listitem>
+    </varlistentry>
     
    </variablelist>
 
index 873c7eb..ef3ae25 100644 (file)
@@ -101,12 +101,13 @@ static struct host *find_host(database_hosts_t hosts,
     return p;
 }
 
-int resolve_database(struct conf_service *service, struct database *db)
+int resolve_database(struct conf_service *service, struct database *db,
+                     const char *hostport)
 {
     if (db->host == 0)
     {
         struct host *host;
-        if (!(host = find_host(service->server->database_hosts, db->url)))
+        if (!(host = find_host(service->server->database_hosts, hostport)))
             return -1;
         db->host = host;
     }
index 4b27826..3d9bfbf 100644 (file)
@@ -30,7 +30,8 @@ int session_grep_databases(struct session *se, const char *filter,
 int predef_grep_databases(void *context, struct conf_service *service,
                          void (*fun)(void *context, struct database *db));
 int match_zurl(const char *zurl, const char *pattern);
-int resolve_database(struct conf_service *service, struct database *db);
+int resolve_database(struct conf_service *service, struct database *db,
+                    const char *hostport);
 struct database *new_database(const char *id, NMEM nmem);
 
 database_hosts_t database_hosts_create(void);
index 06e49e8..3567ab6 100644 (file)
@@ -526,8 +526,12 @@ static void select_targets_callback(struct session *se,
 {
     struct client *cl = client_create();
     struct client_list *l;
+    const char *url = session_setting_oneval(db, PZ_URL);
+    
+    if (!url || !*url)
+        url = db->database->url;
 
-    resolve_database(se->service, db->database);
+    resolve_database(se->service, db->database, url);
 
     client_set_database(cl, db);
 
index 4d68651..fe1b8c4 100644 (file)
@@ -76,6 +76,7 @@ static char *hard_settings[] = {
     "pz:query_syntax",
     "pz:facetmap:",
     "pz:limitmap:",
+    "pz:url",
     0
 };
 
index a71eea2..5a56750 100644 (file)
@@ -49,7 +49,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define PZ_QUERY_SYNTAX         26
 #define PZ_FACETMAP             27
 #define PZ_LIMITMAP             28
-#define PZ_MAX_EOF              29
+#define PZ_URL                  29
+#define PZ_MAX_EOF              30
 
 struct setting
 {
index e2121e8..e6521da 100644 (file)
@@ -1,7 +1,7 @@
 # This file is part of Pazpar2.
 check_SCRIPTS = test_http.sh test_icu.sh test_post.sh \
  test_settings.sh test_turbomarcxml.sh test_facets.sh \
- test_solr.sh
+ test_solr.sh test_url.sh
 
 EXTRA_DIST = run_pazpar2.sh marc21_test.xsl tmarc.xsl solr-pz2.xsl \
        z3950_indexdata_com_marc.xml \
@@ -13,6 +13,7 @@ EXTRA_DIST = run_pazpar2.sh marc21_test.xsl tmarc.xsl solr-pz2.xsl \
        test_settings.cfg test_settings.urls \
        test_solr.cfg test_solr.urls \
        test_turbomarcxml.cfg test_turbomarcxml.urls \
+       test_url.cfg test_url.urls \
        $(check_SCRIPTS)
 
 TESTS = $(check_SCRIPTS)
diff --git a/test/test_url.cfg b/test/test_url.cfg
new file mode 100644 (file)
index 0000000..881ee65
--- /dev/null
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pazpar2 xmlns="http://www.indexdata.com/pazpar2/1.0">
+  <!-- Used by test_url.sh -->
+  <threads number="0"/> <!-- non-zero to enable threaded operation -->
+  <server>
+    <listen port="9763"/>
+    
+    <service>
+      <icu_chain id="relevance" locale="en">
+       <transform rule="[:Control:] Any-Remove"/>
+       <tokenize rule="l"/>
+       <transform rule="[[:WhiteSpace:][:Punctuation:]`] Remove"/>
+       <casemap rule="l"/>
+      </icu_chain>
+      
+      <icu_chain id="sort" locale="en">
+       <transform rule="[[:Control:][:WhiteSpace:][:Punctuation:]`] Remove"/>
+       <casemap rule="l"/>
+      </icu_chain>
+      
+      <icu_chain id="mergekey" locale="en">
+       <tokenize rule="l"/>
+       <transform rule="[[:Control:][:WhiteSpace:][:Punctuation:]`] Remove"/>
+       <casemap rule="l"/>
+      </icu_chain>
+      
+      <icu_chain id="facet" locale="en">
+       <display/>
+       <transform rule="Title"/>
+      </icu_chain>
+      
+      <metadata name="url" merge="unique"/>
+      <metadata name="title" brief="yes" sortkey="skiparticle" merge="longest" rank="6" mergekey="required" />
+      <metadata name="title-remainder" brief="yes" merge="longest" rank="5"/>
+      <metadata name="isbn"/>
+      <metadata name="date" brief="yes" sortkey="numeric" type="year" merge="range"
+                termlist="yes"/>
+      <metadata name="author" brief="yes" termlist="yes" merge="longest" rank="2" mergekey="optional" />
+      <metadata name="subject" merge="unique" termlist="yes" rank="3"/>
+      <metadata name="id"/>
+      <metadata name="lccn" merge="unique"/>
+      <metadata name="description" brief="yes" merge="longest" rank="3"/>
+    </service>
+    
+  </server>
+  
+</pazpar2>
+<!-- Keep this comment at the end of the file
+     Local variables:
+     mode: nxml
+     End:
+-->
+
diff --git a/test/test_url.sh b/test/test_url.sh
new file mode 100755 (executable)
index 0000000..dd6b88f
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+#
+
+# srcdir might be set by make
+srcdir=${srcdir:-"."}
+
+# Test using test_http.cfg
+exec ${srcdir}/run_pazpar2.sh test_url
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation: 2
+# sh-basic-offset: 4
+# End:
diff --git a/test/test_url.urls b/test/test_url.urls
new file mode 100644 (file)
index 0000000..e2874fd
--- /dev/null
@@ -0,0 +1,3 @@
+http://localhost:9763/search.pz2?command=init&clear=1&pz:elements%5Bmy%5D=F&pz:requestsyntax%5Bmy%5D=usmarc&pz:nativesyntax%5Bmy%5D=iso2709&pz:xslt%5Bmy%5D=marc21_test.xsl&pz:name%5Bmy%5D=marcserver&pz:url%5Bmy%5D=z3950.indexdata.com%2Fmarc
+http://localhost:9763/search.pz2?session=1&command=search&query=computer
+2 http://localhost:9763/search.pz2?session=1&command=show&block=1
diff --git a/test/test_url_1.res b/test/test_url_1.res
new file mode 100644 (file)
index 0000000..81ff9ff
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<init><status>OK</status><session>1</session><protocol>1</protocol></init>
\ No newline at end of file
diff --git a/test/test_url_2.res b/test/test_url_2.res
new file mode 100644 (file)
index 0000000..ab63fe6
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<search><status>OK</status></search>
\ No newline at end of file
diff --git a/test/test_url_3.res b/test/test_url_3.res
new file mode 100644 (file)
index 0000000..ca6ceb2
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<show><status>OK</status>
+<activeclients>0</activeclients>
+<merged>9</merged>
+<total>10</total>
+<start>0</start>
+<num>9</num>
+<hit>
+
+<md-title>How to program a computer</md-title>
+<md-author>Jack Collins</md-author><location id="my" name="marcserver">
+<md-title>How to program a computer</md-title>
+<md-author>Jack Collins</md-author></location>
+<location id="my" name="marcserver">
+<md-title>How to program a computer</md-title>
+<md-author>Jack Collins</md-author></location>
+<count>2</count>
+<relevance>25286</relevance>
+<recid>title how to program a computer author jack collins medium book</recid>
+</hit>
+<hit>
+
+<md-title>The Computer Bible</md-title>
+<md-date>1973-1980</md-date>
+<md-description>Vols. 2, 8: Missoula, Mont. : Published by Scholars Press for Biblical Research Associates</md-description><location id="my" name="marcserver">
+<md-title>The Computer Bible</md-title>
+<md-date>1973-1980</md-date>
+<md-description tag="500">Hebrew and Greek; introductions in English</md-description>
+<md-description tag="500">Vols. 2, 8: Missoula, Mont. : Published by Scholars Press for Biblical Research Associates</md-description></location>
+<relevance>21072</relevance>
+<recid>title the computer bible author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Computer science &amp; technology</md-title>
+<md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
+<md-date>1977</md-date><location id="my" name="marcserver">
+<md-title>Computer science &amp; technology</md-title>
+<md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
+<md-date>1977</md-date></location>
+<relevance>15804</relevance>
+<recid>title computer science technology author medium book</recid>
+</hit>
+<hit>
+
+<md-title>A plan for community college computer development</md-title>
+<md-date>1971</md-date>
+<md-description>Cover title</md-description><location id="my" name="marcserver">
+<md-title>A plan for community college computer development</md-title>
+<md-date>1971</md-date>
+<md-description tag="500">Cover title</md-description></location>
+<relevance>9030</relevance>
+<recid>title a plan for community college computer development author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Washington metropolitan area rail computer feasibility study;</md-title>
+<md-title-remainder>final report</md-title-remainder>
+<md-date>1971</md-date>
+<md-author>Englund, Carl R</md-author>
+<md-description>&quot;Contract DOT-UT-10003.&quot;</md-description><location id="my" name="marcserver">
+<md-title>Washington metropolitan area rail computer feasibility study;</md-title>
+<md-title-remainder>final report</md-title-remainder>
+<md-date>1971</md-date>
+<md-author>Englund, Carl R</md-author>
+<md-description tag="500">&quot;Contract DOT-UT-10003.&quot;</md-description></location>
+<relevance>9030</relevance>
+<recid>title washington metropolitan area rail computer feasibility study author englund carl r medium book</recid>
+</hit>
+<hit>
+
+<md-title>The Puget Sound Region</md-title>
+<md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
+<md-date>1974</md-date>
+<md-author>Mairs, John W</md-author>
+<md-description>Scale of maps ca. 1:1,000,000</md-description><location id="my" name="marcserver">
+<md-title>The Puget Sound Region</md-title>
+<md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
+<md-date>1974</md-date>
+<md-author>Mairs, John W</md-author>
+<md-description tag="500">Scale of maps ca. 1:1,000,000</md-description>
+<md-description tag="504">Bibliography: p. 4</md-description></location>
+<relevance>8780</relevance>
+<recid>title the puget sound region author mairs john w medium book</recid>
+</hit>
+<hit>
+
+<md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
+<md-title-remainder>the proceedings of a workshop</md-title-remainder>
+<md-date>1974</md-date>
+<md-description>Includes bibliographical references and index</md-description><location id="my" name="marcserver">
+<md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
+<md-title-remainder>the proceedings of a workshop</md-title-remainder>
+<md-date>1974</md-date>
+<md-description tag="504">Includes bibliographical references and index</md-description></location>
+<relevance>6321</relevance>
+<recid>title computer processing of dynamic images from an anger scintillation camera author medium book</recid>
+</hit>
+<hit>
+
+<md-title>The use of passwords for controlled access to computer resources</md-title>
+<md-date>1977</md-date>
+<md-author>Wood, Helen M</md-author><location id="my" name="marcserver">
+<md-title>The use of passwords for controlled access to computer resources</md-title>
+<md-date>1977</md-date>
+<md-author>Wood, Helen M</md-author></location>
+<relevance>6321</relevance>
+<recid>title the use of passwords for controlled access to computer resources author wood helen m medium book</recid>
+</hit>
+<hit>
+
+<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
+<md-title-remainder>proceedings of the workshop</md-title-remainder>
+<md-date>1977</md-date>
+<md-description>Includes bibliographical references and index</md-description><location id="my" name="marcserver">
+<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
+<md-title-remainder>proceedings of the workshop</md-title-remainder>
+<md-date>1977</md-date>
+<md-description tag="504">Includes bibliographical references and index</md-description></location>
+<relevance>0</relevance>
+<recid>title reconstruction tomography in diagnostic radiology and nuclear medicine author medium book</recid>
+</hit>
+</show>
\ No newline at end of file