Net-Z3950-SimpleServer

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	* Tests now work on platforms (such as MacOS 12.7.5) where the
	  program is hardened and will not accept dynamic libraries
	  from relative paths. Fixes ZOOM-31.

1.26  Mon Oct  8 13:47:43 CEST 2018
        * SIM-29: Handle extended service XML-ES response

1.25  Wed Sep 26 15:19:30 CEST 2018
        * SIM-28: Handle extended service XML-ES (pass XML_ILL document)

1.24  Tue Mar  7 11:05:56 CET 2017
	* Extended Service: no fake targetReference in Task Package
	* Few doc updates; bump copyright year
	* Use thread-safe notation for callbacks

1.23  Mon Nov 14 15:54:36 UTC 2016
	* GROUP passed to init handler

1.22  Tue Nov  1 11:23:56 UTC 2016
	* Extended service Item Order with XML body
	* SCHEMA_OID to fetch+present handler

Changes  view on Meta::CPAN

	* Fix some typos in documentation and change-log.
	* README file converted to README.md (Markdown).
	* Many other improvements and clarifications to
	  documentation.
	* Update which distributions we build for.
	  
1.20  Thu Jan 29 07:53:46 UTC 2015
	- Add support for Type-1's proximity operator. Patch from
	  Simon Jacob of the National Library of Australia.

1.19  Fri Nov 22 12:31:24 CET 2013
       -  ESTIMATED_HIT_COUNT = 1 from search_handler signal.
       -  fetch handler: partial present response for undef RECORD
          The old behavior was to return empty record (if RECORD was
          not modified by handler). RECORD is now undefined upon entry
          to fetch handler and handler must set it to return a record
	  or just leave it undefined to signal "no record".

1.18  Mon Oct 14 11:23:17 CEST 2013
       -  Debian/RPM packages now built with YAZ 5.

1.17  Tue Feb 12 13:30:52 CET 2013
	- Scan and Search handler gets EXTRA_ARGS . It's represented as
	  a hash. It holds the extra arguments for SRU (URL).
	- Scan and Search handler may return extra response data in
	  EXTRA_RESPONSE_DATA. That's an XML fragment for SRU extra
	  response data.
	- Scan Term may include a DISPLAY_TERM (Z39.50 / SRU display term).
	  Thanks to Simon Jacob for patch.
	  
1.16  Thu Jan 10 13:22:01 CET 2013
        - Create packages for Ubuntu quantal precise oneiric.
        - Add support for GFS start handler (START) to allow handling
          of GFS config file (-c).
        - Handler search now gets PRESENT_NUMBER - a hint for how many
          records are to be fetched following search (piggyback).

1.15  Fri Oct 14 14:01:18 CEST 2011
        - Fix decoding of OUTPUTFACETS (optinal) ; crashed on some Perl
          versions

1.14  Thu Aug 18 08:47:13 UTC 2011
	- Support for facets in search handler
	- Corrections to manual, kindly supplied by Ben Webb
	  <bjwebb67@googlemail.com>
	- Resolve contradictory licence terms: SimpleServer is now
	  definitely distributed under the Revised BSD licence, whereas
	  earlier versions claimed in the source code to be Revised
	  BSD but in the README to be under the same terms as Perl.

Changes  view on Meta::CPAN

	  functions.  This allows global state to be eliminated from
	  SimpleServer applications ... finally!
	- Search handler now deals correctly with undefined addinfo:
	  previously a (harmless) error message was emitted.
	- Add Perl API to yaz_diag_srw_to_bib1(), which SimpleServer
	  applications will need if they access SRU/SRW back-end
	  databases and need to report errors.
	- Add Perl API to yaz_diag_bib1_to_srw(), because it would
	  seem churlish not to.

1.05  Wed Dec 27 13:19:13 CET 2006
        - Taking new naming convention for YAZ constants into account.

1.04  Fri Dec  1 10:48:32 CET 2006
        - Build such that SimpleServer links to new yaz shared object.

1.03  Tue Aug  8 17:27:16 BST 2006
	- Rely on version 2.1.14 or later of YAZ; this is the first
	  version that reliably passes through the additional
	  information associated with errors generated while serving
	  SRU/W requests.  No functional differences since 1.02.

1.02  Wed Jul 26 12:09:50 BST 2006
	- Better support for Open and User/Password authentication.

SimpleServer.pm  view on Meta::CPAN

    SETNAME             =>  "id",    # ID of the result set
    REPL_SET            =>  0,       # Replace set if already existing?
    DATABASES           =>  ["xxx"], # Reference to a list of databases to search
    QUERY               =>  "query", # The query expression as a PQF string
    RPN                 =>  $obj,    # Reference to a Net::Z3950::APDU::Query
    CQL                 =>  $x,      # A CQL query, if this is provided instead of Type-1
    SRW_SORTKEYS        =>  $x,      # XXX to be described
    PID                 =>  $x,      # XXX to be described
    PRESENT_NUMBER      =>  $x,      # XXX to be described
    EXTRA_ARGS          =>  $x,      # XXX to be described
    INPUTFACETS         =>  $x,      # Specification of facets required: see below.

                                     ## Response parameters:

    ERR_CODE            =>  0,       # Error code (0=Successful search)
    ERR_STR             =>  "",      # Error string
    HITS                =>  0,       # Number of matches
    ESTIMATED_HIT_COUNT =>  $x,      # XXX to be described
    EXTRA_RESPONSE_DATA =>  $x,      # XXX to be described
    OUTPUTFACETS        =>  $x       # Facets returned: see below.
  };

Note that a search which finds 0 hits is considered successful in
Z39.50 terms - you should only set the ERR_CODE to a non-zero value
if there was a problem processing the request. The Z39.50 standard
provides a comprehensive list of standard diagnostic codes, and you
should use these whenever possible.

=head3 Query structures

SimpleServer.pm  view on Meta::CPAN

In SRU, facets may be requested by the C<facetLimit> parameter,
L<as documented in the OASIS standard that formalises the SRU specification|http://docs.oasis-open.org/search-ws/searchRetrieve/v1.0/os/part3-sru2.0/searchRetrieve-v1.0-os-part3-sru2.0.html#_Toc324162453>.
Its value is a string consisting of a comma-separated list of facet
specifications. Each facet specification consists of of a count, a
colon and a fieldname. For example, C<facetLimit=10:title,5:author>
asks for ten title facets and five author facets.

=head4 Request format

The facet request is passed to the search-handler function in the
INPUTFACETS parameter. Its value is rather complex, due to backwards
compatibility with Z39.50:

=over 4

=item *

The top-level value is a C<Net::Z3950::FacetList> array.

=item *

SimpleServer.pm  view on Meta::CPAN

=item *

Each of these is an object with two members, C<term> and C<count>. The
first of these is an integer, the second a string.

=back

=head4 Response format

Having generated facets corresponding to the request, the search
handler should return them in the C<OUTPUTFACETS> argument. The
structure of this response is similar to that of the request:

=over 4

=item *

The top-level value is a C<Net::Z3950::FacetList> array.

=item *

SimpleServer.pm  view on Meta::CPAN

=item *

Each of these is an object with two members, C<term> and C<count>. The
first of these is a string containing one of the facet terms, and the
second is an integer indicating how many times it occurs in the
records that were found by the search.

=back

The example SimpleServer applicaation server C<ztest.pl> includes code
that shows how to examine the INPUTFACETS data structure and create
the OUTPUTFACETS structure.

=head2 Present handler

The presence of a present handler in a SimpleServer front-end is optional.
Each time a client wishes to retrieve records, the present service is
called. The present service allows the origin to request a certain number
of records retrieved from a given result set.
When the present handler is called, the front-end server should prepare a
result set for fetching. In practice, this means to get access to the
data from the backend database and store the data in a temporary fashion

SimpleServer.xs  view on Meta::CPAN

	hv_store(href, "HANDLE", 6, zhandle->handle, 0);
	hv_store(href, "PID", 3, newSViv(getpid()), 0);
	hv_store(href, "PRESENT_NUMBER", 14, newSViv(rr->present_number), 0);
	hv_store(href, "EXTRA_ARGS", 10,
		newRV( (SV*) parse_extra_args(rr->extra_args)), 0);
	if ((rpnSV = zquery2perl(rr->query)) != 0) {
	    hv_store(href, "RPN", 3, rpnSV, 0);
	}
	facetSV = f_FacetList_to_SV(yaz_oi_get_facetlist(&rr->search_input));
	if (facetSV) {
	    hv_store(href, "INPUTFACETS", 11, facetSV, 0);
	}

	query = zquery2pquery(rr->query);
	if (query)
	{
		hv_store(href, "QUERY", 5, newSVpv((char *)query->buf, query->pos), 0);
	}
	else if (rr->query->which == Z_Query_type_104 &&
		 rr->query->u.type_104->which == Z_External_CQL) {
	    hv_store(href, "CQL", 3,

SimpleServer.xs  view on Meta::CPAN


	temp = hv_fetch(href, "ERR_CODE", 8, 1);
	rr->errcode = SvIV(*temp);

	temp = hv_fetch(href, "ERR_STR", 7, 1);
	rr->errstring = string_or_undef(temp, rr->stream);

	temp = hv_fetch(href, "HANDLE", 6, 1);
	point = newSVsv(*temp);

	temp = hv_fetch(href, "OUTPUTFACETS", 12, 1);
        if (SvTYPE(*temp) != SVt_NULL)
	    f_SV_to_FacetList(*temp, &rr->search_info, rr->stream);

	temp = hv_fetch(href, "EXTRA_RESPONSE_DATA", 19, 0);
	if (temp)
	{
		ptr = SvPV(*temp, len);
		rr->extra_response_data = odr_strdupn(rr->stream, ptr, len);
	}

ztest.pl  view on Meta::CPAN

			name		=>	"Alain Blondel",
			title		=>	"Head of coll.",
			collaboration	=>	"ALEPH"
	   	    }];

	my $session = $args->{HANDLE};
	my $set_id = $args->{SETNAME};
	my $rpn = $args->{RPN};
	my @database_list = @{ $args->{DATABASES} };
	my $query = $args->{QUERY};
	my $facets = my_facets_response($args->{INPUTFACETS});
	my $hits = 3;

	print "------------------------------------------------------------\n";
	print "Processing query : $query\n";
	printf("Database set     : %s\n", join(" ", @database_list));
	print "Setname          : $set_id\n";
	print " inputfacets:\n";
	print Dumper($facets);
        print " extra args:\n";
        print Dumper($args->{EXTRA_ARGS});
	print "------------------------------------------------------------\n";

	$args->{OUTPUTFACETS} = $facets;

	$args->{EXTRA_RESPONSE_DATA} = '<searchextra>b</searchextra>';
	$args->{HITS} = $hits;
	$session->{$set_id} = $data;
	$session->{__HITS} = $hits;
	if ($_fail_frequency != 0 && ++$_counter % $_fail_frequency == 0) {
	    print "Exiting to be nasty to client\n";
	    exit(1);
	}
}



( run in 0.547 second using v1.01-cache-2.11-cpan-49f99fa48dc )