|
Lines 32-75
GetOptions(
Link Here
|
| 32 |
|
32 |
|
| 33 |
if ( $help || !$config ) { |
33 |
if ( $help || !$config ) { |
| 34 |
print <<EOF |
34 |
print <<EOF |
| 35 |
$0 --config=my.conf |
35 |
OCLC Import Daemon |
| 36 |
Parameters : |
36 |
|
| 37 |
--daemon | -d - go to background; prints pid to stdout |
37 |
This script hosts a server which listens for connections from an OCLC Connexion client or WorldShare Record Manager. |
| 38 |
--config | -c - config file |
38 |
|
| 39 |
--help | -? - this message |
39 |
The records are forwarded to Koha by sending a request to the handler at `/cgi-bin/koha/svc/import_bib` on the |
|
|
40 |
intranet of the configured Koha instance. The request is authenticated using the credentials of a Koha staff user. |
| 41 |
|
| 42 |
See the documentation for the `import_bib` endpoint at |
| 43 |
https://wiki.koha-community.org/wiki/Koha_/svc/_HTTP_API#POST_.2Fsvc.2Fimport_bib . |
| 44 |
The `import_bib` endpoint is being phased out. This script should be rewritten to use the newer REST API instead. |
| 45 |
|
| 46 |
If you have multiple Koha instances, run a separate instance of this script for each one, using a different port and |
| 47 |
different credentials for each one. |
| 48 |
|
| 49 |
Usage: |
| 50 |
$0 --config=my.conf |
| 51 |
|
| 52 |
Command line options: |
| 53 |
--daemon | -d - Run in the background. Prints the process ID to stdout. |
| 54 |
--config | -c - Specify the config file to use. Required. |
| 55 |
--help | -? - Print this message. |
| 40 |
|
56 |
|
| 41 |
Config file format: |
57 |
Config file format: |
| 42 |
Lines of the form: |
58 |
Each line has the form: |
| 43 |
name: value |
59 |
NAME: VALUE |
| 44 |
|
60 |
For example: |
| 45 |
# comments are supported |
61 |
port: 5500 |
| 46 |
No quotes |
62 |
|
| 47 |
|
63 |
Empty parameters look like this: |
| 48 |
Parameter Names: |
64 |
NAME: |
| 49 |
host - ip address or hostname to bind to, defaults all available |
65 |
For example: |
| 50 |
port - port to bind to, mandatory |
66 |
overlay_framework: |
| 51 |
log - log file path, stderr if omitted |
67 |
|
| 52 |
debug - dumps requests to the log file, passwords inclusive |
68 |
Values should not be quoted. |
| 53 |
koha - koha intranet base url, eg http://librarian.koha |
69 |
|
| 54 |
user - koha user, authentication |
70 |
Lines starting with # are treated as comments. |
| 55 |
password - koha user password, authentication |
71 |
|
| 56 |
match - marc_matchers.code: ISBN or ISSN |
72 |
Parameters: |
| 57 |
overlay_action - import_batches.overlay_action: replace, create_new or ignore |
73 |
host |
| 58 |
overlay_framework - if overlaying records - move to a new framework, if blank will use default |
74 |
The IP address or host name to bind to (i.e., listen on). |
| 59 |
if not included it will use the framework of the existing record |
75 |
Defaults to 0.0.0.0, i.e., listen on all interfaces. |
| 60 |
nomatch_action - import_batches.nomatch_action: create_new or ignore |
76 |
|
| 61 |
item_action - import_batches.item_action: always_add, |
77 |
port |
| 62 |
add_only_for_matches, add_only_for_new or ignore |
78 |
The port to bind to (i.e., listen on). |
| 63 |
import_mode - stage or direct |
79 |
Typically 5500. |
| 64 |
framework - to be used if import_mode is direct, if blank, will use default |
80 |
This must be different from the port used by any other service on the same machine. |
| 65 |
connexion_user - User sent from connexion client |
81 |
Required. |
| 66 |
connexion_password - Password sent from connexion client |
82 |
|
| 67 |
|
83 |
log |
| 68 |
Note: If connexion parameters are not defined request authentication will not be checked |
84 |
The path to the log file. |
| 69 |
You should specify a different user for connexion to protect the Koha credentials |
85 |
Logs are written to stderr if omitted. |
| 70 |
|
86 |
|
| 71 |
All process related parameters (all but ip and port) have default values as |
87 |
debug |
| 72 |
per Koha import process. |
88 |
Dumps all incoming requests to the log file. |
|
|
89 |
WARNING: This includes the connexion user's password, if it is part of the request. |
| 90 |
Use 1 for on and 0 for off. |
| 91 |
Defaults to 0 (off). |
| 92 |
|
| 93 |
koha |
| 94 |
The base URL of the intranet of your Koha instance, e.g. http://librarian.koha |
| 95 |
When this script is running on the same machine as the Koha instance, and you have dedicated port for the Koha |
| 96 |
intranet, you can use http://localhost:port here. Otherwise, use the URL you would use when accessing your Koha |
| 97 |
intranet through a browser. |
| 98 |
Required. |
| 99 |
|
| 100 |
user |
| 101 |
The Koha user used for logging in to the intranet of your Koha instance. |
| 102 |
Required. |
| 103 |
|
| 104 |
password |
| 105 |
The password of the Koha user. |
| 106 |
Required. |
| 107 |
|
| 108 |
connexion_user |
| 109 |
The user name expected to be sent by the connexion client with every request. |
| 110 |
If set, also set `connexion_password`. In this case, request authentication will be checked. |
| 111 |
If omitted, also omit `connexion_password`. In this case, request authentication will not be checked, and |
| 112 |
anyone with access to the port opened by this script will be able to send records into your Koha instance. |
| 113 |
|
| 114 |
connexion_password |
| 115 |
The password expected to be sent by the connexion client with every request. |
| 116 |
WARNING: Do NOT use the same password as the Koha user password. |
| 117 |
|
| 118 |
import_mode |
| 119 |
Where the imported records should go. See the explanation below. |
| 120 |
Available values: |
| 121 |
stage |
| 122 |
The records will be imported into the staging area (reservoir) at /cgi-bin/koha/tools/manage-marc-import.pl |
| 123 |
into a batch called `(webservice)`. |
| 124 |
The records will also show up below the catalog results in the staff client when doing a "cataloging search" |
| 125 |
at /cgi-bin/koha/cataloguing/addbooks.pl?q=... |
| 126 |
direct |
| 127 |
The records will be imported directly into the catalog. They will show up in all catalog searches |
| 128 |
as soon as the indexing catches up. |
| 129 |
Defaults to `stage`. |
| 130 |
|
| 131 |
match |
| 132 |
Which code to use for matching MARC records when deciding whether to add or replace a record. |
| 133 |
Corresponds to the "Matching rule applied" field at /cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=... |
| 134 |
Available options: |
| 135 |
ISBN |
| 136 |
Use the International Standard Book Number (MARC 020\$a) |
| 137 |
ISSN |
| 138 |
Use the International Standard Serial Number (MARC 022\$a) |
| 139 |
KohaBiblio |
| 140 |
Use the Koha biblio number (MARC 999\$c) |
| 141 |
See `C4::Matcher`. |
| 142 |
|
| 143 |
overlay_action |
| 144 |
What to do when the incoming record matches a record already in the catalog. |
| 145 |
Corresponds to the "Action if matching record found" field at /cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=... |
| 146 |
Available values: |
| 147 |
replace |
| 148 |
Replace the existing record with the incoming record. |
| 149 |
create_new |
| 150 |
Create a new record alongside the existing record. |
| 151 |
ignore |
| 152 |
Discard the incoming record. |
| 153 |
|
| 154 |
nomatch_action |
| 155 |
What to do when the incoming record does not match any record in the catalog. |
| 156 |
Corresponds to the "Action if no match found" field at /cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=... |
| 157 |
Available values: |
| 158 |
create_new |
| 159 |
Create a new record. |
| 160 |
ignore |
| 161 |
Discard the incoming record. |
| 162 |
|
| 163 |
item_action |
| 164 |
What to do when the incoming MARC record contains one or more items embedded in field 952. |
| 165 |
Corresponds to the "Item processing" field at /cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=... |
| 166 |
Available values: |
| 167 |
always_add |
| 168 |
add_only_for_matches |
| 169 |
add_only_for_new |
| 170 |
replace |
| 171 |
ignore |
| 172 |
|
| 173 |
framework |
| 174 |
The cataloging framework to use when no match was found in the catalog (i.e., when adding a new record). |
| 175 |
Defaults to the default framework configured at /cgi-bin/koha/admin/biblio_framework.pl |
| 176 |
|
| 177 |
overlay_framework |
| 178 |
The cataloging framework to use when a match was found in the catalog (i.e., when replacing an existing record). |
| 179 |
Corresponds to the "Replacement record framework" field at /cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=... |
| 180 |
You have three options here: |
| 181 |
Do not specify this parameter. |
| 182 |
The default framework configured at /cgi-bin/koha/admin/biblio_framework.pl will be used. |
| 183 |
Specify this parameter without a value, i.e., `overlay_framework:`. |
| 184 |
The new record will use the same framework as the record being replaced. |
| 185 |
Specify this parameter with a value, e.g., `overlay_framework: my_framework`. |
| 186 |
The new record will use the specified framework. |
| 187 |
|
| 188 |
Explanation of `import_mode`: |
| 189 |
- When using `direct`, each request will create a new batch and import the batch immediately. |
| 190 |
- When using `stage`, each request will cause records to be added to an existing batch. |
| 191 |
- The batch name is always `(webservice)`. |
| 192 |
- If you change `import_mode` from `stage` to `direct` after some records have already been staged, the next request |
| 193 |
will cause all records in that batch to be imported into the catalog, not just the records from the latest request. |
| 194 |
- These config parameters define the settings of the batch that is created, whether or not it is imported immediately: |
| 195 |
- `match` |
| 196 |
- `overlay_action` |
| 197 |
- `nomatch_action` |
| 198 |
- `item_action` |
| 199 |
- `framework` |
| 200 |
- `overlay_framework` |
| 201 |
- If one or more of these parameters are changed, a new batch is created with the new settings, and any new records |
| 202 |
are added to that batch instead of to the old one. |
| 203 |
- If you stage a record that cannot be imported then all future imports will be stuck until that batch is cleaned |
| 204 |
and deleted. |
| 205 |
|
| 73 |
EOF |
206 |
EOF |
| 74 |
; |
207 |
; |
| 75 |
exit; |
208 |
exit; |
|
Lines 294-300
exit;
Link Here
|
| 294 |
$in =~ m/(.)$/; |
427 |
$in =~ m/(.)$/; |
| 295 |
my $lastchar = $1; |
428 |
my $lastchar = $1; |
| 296 |
my ( $xml, $user, $password, $local_user ); |
429 |
my ( $xml, $user, $password, $local_user ); |
| 297 |
my $data = $in; # copy for diagmostic purposes |
430 |
my $data = $in; # copy for diagnostic purposes |
| 298 |
while () { |
431 |
while () { |
| 299 |
my $first = substr( $data, 0, 1 ); |
432 |
my $first = substr( $data, 0, 1 ); |
| 300 |
if ( !defined $first ) { |
433 |
if ( !defined $first ) { |
| 301 |
- |
|
|