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