From 1af753738c2bfcdbdcb75dafadb47d762afd71d9 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 13 Dec 2005 14:01:59 +0000 Subject: [PATCH] Description of package API and record update. --- lib/ZOOM.pod | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 4 deletions(-) diff --git a/lib/ZOOM.pod b/lib/ZOOM.pod index 00e5aca..b58fc66 100644 --- a/lib/ZOOM.pod +++ b/lib/ZOOM.pod @@ -1,4 +1,4 @@ -# $Id: ZOOM.pod,v 1.15 2005-12-13 12:32:15 mike Exp $ +# $Id: ZOOM.pod,v 1.16 2005-12-13 14:01:59 mike Exp $ use strict; use warnings; @@ -408,7 +408,7 @@ http://zoom.z3950.org/api/zoom-current.html#3.4 $rs->option(elementSetName => "f"); -Allows options to be set into, and read from a ResultSet, just like +Allows options to be set into, and read from, a ResultSet, just like the Connection class's C method. There is no C method for ResultSet objects. @@ -740,7 +740,7 @@ terms are indexed. print "scan status is ", $ss->option("scanStatus"); -Allows options to be set into, and read from a ScanSet, just like +Allows options to be set into, and read from, a ScanSet, just like the Connection class's C method. There is no C method for ScanSet objects. @@ -757,11 +757,130 @@ reuse a ScanSet that has been Ced. =head2 ZOOM::Package -I<###> + $p = $conn->package(); + $p->option(action => "specialUpdate"); + $p->option(recordIdOpaque => 145); + $p->option(record => content_of("/tmp/record.xml")); + $p->send("update"); + $p->destroy(); + +This class represents an Extended Services Package: an instruction to +the server to do something not covered by the core parts of the Z39.50 +standard (or the equivalent in SRW or SRU). Since the core protocols +are read-only, such requests are often used to make changes to the +database, such as in the record update example above. + +Requesting an extended service is a four-step process: first, create a +package associated with the connection to the relevant database; +second, set options on the package to instruct the server on what to +do; third, send the package (which may result in an exception being +thrown if the server cannot execute the requested operations; and +finally, destroy the package. Package options are listed at http://indexdata.com/yaz/doc/zoom.ext.html +The particular options that have meaning are determined by the +top-level operation string specified as the argument to C. +For example, when the operation is C (the most commonly used +extended service), the C option may be set to any of +C +(add a new record, failing if that record already exists), +C +(delete a record, failing if it is not in the database). +C +(replace a record, failing if an old version is not already present) +or +C +(add a record, replacing any existing version that may be present). + +For update, the C option should be set to the full text of the +XML record to added, deleted or replaced. Depending on how the server +is configured, it may extract the record's unique ID from the text +(i.e. from a known element such as the C<001> field of a MARCXML +record), or it may require the unique ID to passed in explicitly using +the C option. + +Extended services packages are B in the ZOOM +Abstract API at +http://zoom.z3950.org/api/zoom-current.html +They will be added in a forthcoming version, and will function much +as those implemented in this module. + +=head3 Methods + +=head4 option() + + $p->option(recordIdOpaque => "46696f6e61"); + +Allows options to be set into, and read from, a Package, just like +the Connection class's C method. There is no +C method for Package objects. + +Package options are listed at +http://indexdata.com/yaz/doc/zoom.ext.tkl + +=head4 send() + + $p->send("createdb"); + +Sends a package to the server associated with the Connection that +created it. Problems are reported by throwing an exception. The +single parameter indicates the operation that the server is being +requested to perform, and controls the interpretation of the package's +options. Valid operations include: + +=over 4 + +=item itemorder + +Request a copy of a nominated object, e.g. place an ILL request. + +=item create + +Create a new database, the name of which is specified by the +C option. + +=item drop + +Drop an existing database, the name of which is specified by the +C option. + +=item commit + +Commit changes made to the database within a transaction. + +=item update + +Modify the contents of the database by adding, deleting or replacing +records (as described above in the overview of the C +class). + +=item xmlupdate + +I have no idea what this does. + +=back + +Although the module is capable of I all these requests, not +all servers are capable of I them. Refusal is indicated by +throwing an exception. Problems may also be caused by lack of +privileges; so C must be used with caution, and is perhaps +best wrapped in a clause that checks for execptions, like so: + + eval { $p->send("create") }; + if ($@ && $@->isa("ZOOM::Exception")) { + print "Oops! ", $@->message(), "\n"; + return $@->code(); + } + +=head4 destroy() + + $p->destroy() + +Destroys a Package object, freeing its resources. It is an error to +reuse a Package that has been Ced. + =head2 ZOOM::Query I<###> -- 1.7.10.4