View | Details | Raw Unified | Return to bug 21210
Collapse All | Expand All

(-)a/Makefile.PL (+1 lines)
Lines 630-635 push @{ $pl_files->{'rewrite-config.PL'} }, ( Link Here
630
    'blib/SCRIPT_DIR/koha-zebra-ctl.sh',
630
    'blib/SCRIPT_DIR/koha-zebra-ctl.sh',
631
    'blib/SCRIPT_DIR/koha-pazpar2-ctl.sh',
631
    'blib/SCRIPT_DIR/koha-pazpar2-ctl.sh',
632
    'blib/SCRIPT_DIR/koha-index-daemon-ctl.sh',
632
    'blib/SCRIPT_DIR/koha-index-daemon-ctl.sh',
633
    'blib/SCRIPT_DIR/koha-sru-server.sh',
633
);
634
);
634
if ($config{'INSTALL_PAZPAR2'} eq 'yes') {
635
if ($config{'INSTALL_PAZPAR2'} eq 'yes') {
635
    push @{ $pl_files->{'rewrite-config.PL'} }, (
636
    push @{ $pl_files->{'rewrite-config.PL'} }, (
(-)a/etc/sru_server/catmandu.yml (+208 lines)
Line 0 Link Here
1
---
2
store:
3
  sru:
4
    package: ElasticSearch
5
    options:
6
      bags:
7
        data:
8
          cql_mapping:
9
            # Make sure to keep all index names lowercase
10
            default_index: cql.serverchoice
11
            indexes:
12
              rec.id:
13
                op:
14
                  '=': true
15
                  'exact': true
16
                field: 'Local-number'
17
              dc.identifier:
18
                op:
19
                  '=': true
20
                  'exact': true
21
                field: 'control-number'
22
              dc.title:
23
                op:
24
                  'any': true
25
                  'all': true
26
                  '=': true
27
                  'exact': true
28
                field: 'title'
29
              dc.subject:
30
                op:
31
                  'any': true
32
                  'all': true
33
                  '=': true
34
                  'exact': true
35
                field: 'subject'
36
              dc.creator:
37
                op:
38
                  'any': true
39
                  'all': true
40
                  '=': true
41
                  'exact': true
42
                field: 'author'
43
              dc.author:
44
                op:
45
                  'any': true
46
                  'all': true
47
                  '=': true
48
                  'exact': true
49
                field: 'author'
50
              dc.itemtype:
51
                op:
52
                  'any': true
53
                  'all': true
54
                  '=': true
55
                  'exact': true
56
                field: 'itype'
57
              dc.branch:
58
                op:
59
                  'any': true
60
                  'all': true
61
                  '=': true
62
                  'exact': true
63
                field: ['homebranch', 'holdingbranch']
64
              dc.isbn:
65
                op:
66
                  'any': true
67
                  'all': true
68
                  '=': true
69
                  'exact': true
70
                field: 'isbn'
71
              dc.issn:
72
                op:
73
                  'any': true
74
                  'all': true
75
                  '=': true
76
                  'exact': true
77
                field: 'issn'
78
              dc.any:
79
                op:
80
                  'any': true
81
                  'all': true
82
                  '=': true
83
                  'exact': true
84
                field: '_all'
85
              dc.pname:
86
                op:
87
                  'any': true
88
                  'all': true
89
                  '=': true
90
                  'exact': true
91
                field: 'Personal-name'
92
              dc.publisher:
93
                op:
94
                  'any': true
95
                  'all': true
96
                  '=': true
97
                  'exact': true
98
                field: 'publisher'
99
              dc.date:
100
                op:
101
                  'any': true
102
                  'all': true
103
                  '=': true
104
                  'exact': true
105
                field: 'copydate'
106
              dc.format:
107
                op:
108
                  'any': true
109
                  'all': true
110
                  '=': true
111
                  'exact': true
112
                field: 'material-type'
113
              dc.resourceidentifier:
114
                op:
115
                  '=': true
116
                  'exact': true
117
                field: 'Local-number'
118
              bath.keytitle:
119
                op:
120
                  'any': true
121
                  'all': true
122
                  '=': true
123
                  'exact': true
124
                field: 'title'
125
              bath.possessinginstitution:
126
                op:
127
                  'any': true
128
                  'all': true
129
                  '=': true
130
                  'exact': true
131
                field: ['homebranch', 'holdingbranch']
132
              bath.name:
133
                op:
134
                  'any': true
135
                  'all': true
136
                  '=': true
137
                  'exact': true
138
                field: 'author'
139
              bath.personalname:
140
                op:
141
                  'any': true
142
                  'all': true
143
                  '=': true
144
                  'exact': true
145
                field: 'Personal-name'
146
              bath.corporatename:
147
                op:
148
                  'any': true
149
                  'all': true
150
                  '=': true
151
                  'exact': true
152
                field: 'author'
153
              bath.conferencename:
154
                op:
155
                  'any': true
156
                  'all': true
157
                  '=': true
158
                  'exact': true
159
                field: 'Meeting-name'
160
              bath.isbn:
161
                op:
162
                  'any': true
163
                  'all': true
164
                  '=': true
165
                  'exact': true
166
                field: 'isbn'
167
              bath.issn:
168
                op:
169
                  'any': true
170
                  'all': true
171
                  '=': true
172
                  'exact': true
173
                field: 'issn'
174
              bath.geographicname:
175
                op:
176
                  'any': true
177
                  'all': true
178
                  '=': true
179
                  'exact': true
180
                field: 'su-geo'
181
              bath.topicalsubject:
182
                op:
183
                  'any': true
184
                  'all': true
185
                  '=': true
186
                  'exact': true
187
                field: 'subject'
188
              cql.serverchoice:
189
                op:
190
                  'any': true
191
                  'all': true
192
                  '=': true
193
                  'exact': true
194
                field: '_all'
195
              koha.titlemain:
196
                op:
197
                  'any': true
198
                  'all': true
199
                  '=': true
200
                  'exact': true
201
                field: 'title-main'
202
              koha.biblevel:
203
                op:
204
                  'any': true
205
                  'all': true
206
                  '=': true
207
                  'exact': true
208
                field: 'bib-level'
(-)a/etc/sru_server/config.yml (+15 lines)
Line 0 Link Here
1
charset: "UTF-8"
2
content_type: "text/xml"
3
logger: console
4
plugins:
5
    'Catmandu::SRU':
6
        store: sru
7
        bag: data
8
        default_record_schema: marcxml
9
        limit: 20
10
        maximum_limit: 1000
11
        record_schemas:
12
            -
13
                identifier: "info:srw/schema/1/marcxml-v1.1"
14
                name: marcxml
15
                template: marcxml.tt
(-)a/etc/sru_server/marcxml.tt (+19 lines)
Line 0 Link Here
1
2
<record xmlns="http://www.loc.gov/MARC21/slim">
3
[%- FOREACH field IN record %]
4
  [%- IF field.0 == 'LDR' %]
5
  <leader>[% field.4 | xml %]</leader>
6
  [%- ELSIF field.0 < 10 %]
7
  <controlfield tag="[% field.0 | xml %]">[% field.4 | xml %]</controlfield>
8
  [%- ELSE %]
9
  <datafield tag="[% field.0 | xml %]" ind1="[% field.1 | xml %]" ind2="[% field.2 | xml %]">
10
    [%- c = 3 %]
11
    [%- WHILE c < field.size %]
12
      [%- di = c + 1 %]
13
    <subfield code="[% field.$c | xml %]">[% field.$di | xml %]</subfield>
14
      [%- c = c + 2 %]
15
    [%- END %]
16
    </datafield>
17
  [%- END %]
18
[%- END %]
19
</record>
(-)a/misc/bin/koha-sru-server.sh (+90 lines)
Line 0 Link Here
1
#!/bin/sh
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
### BEGIN INIT INFO
19
# Provides:          koha-sru-server-$DBNAME
20
# Required-Start:    $local_fs $syslog
21
# Required-Stop:     $local_fs $syslog
22
# Default-Start:     2 3 4 5
23
# Default-Stop:      0 1 6
24
# X-Interactive:     false
25
# Short-Description: Start/stop koha-sru-server for $DBNAME
26
### END INIT INFO
27
28
. /lib/lsb/init-functions
29
30
USER=__KOHA_USER__
31
GROUP=__KOHA_GROUP__
32
DBNAME=__DB_NAME__
33
NAME=koha-sru-server-$DBNAME
34
PORT=9998
35
LOGDIR=__LOG_DIR__
36
PERL5LIB=__PERL_MODULE_DIR__
37
KOHA_CONFDIR=__KOHA_CONF_DIR__
38
KOHA_CONF=$KOHA_CONFDIR/koha-conf.xml
39
SRU_CONFDIR=$KOHA_CONFDIR/sru_server
40
DANCER_CONFDIR=$SRU_CONFDIR
41
ERRLOG=$LOGDIR/koha-sru-server.err
42
STDOUT=$LOGDIR/koha-sru-server.log
43
OUTPUT=$LOGDIR/koha-sru-server-output.log
44
45
export KOHA_CONF
46
export PERL5LIB
47
export DANCER_CONFDIR
48
49
SRUSERVER="/usr/bin/plackup --server Starman --port $PORT $PERL5LIB/misc/sru_server.pl"
50
SRUSERVER_OPTS=""
51
52
DAEMONOPTS="--name=$NAME \
53
            --errlog=$ERRLOG \
54
            --stdout=$STDOUT \
55
            --output=$OUTPUT \
56
            --verbose=1 --respawn --delay=30"
57
58
USER="--user=$USER.$GROUP"
59
60
61
case "$1" in
62
    start)
63
      log_daemon_msg "Starting Koha SRU server ($DBNAME)"
64
      if daemon $DAEMONOPTS $USER -- $SRUSERVER $SRUSERVER_OPTS; then
65
        log_end_msg 0
66
      else
67
        log_end_msg 1
68
      fi
69
      ;;
70
    stop)
71
      log_daemon_msg "Stopping Koha SRU server ($DBNAME)"
72
      if daemon $DAEMONOPTS $USER --stop -- $SRUSERVER $SRUSERVER_OPTS; then
73
        log_end_msg 0
74
      else
75
        log_end_msg 1
76
      fi
77
      ;;
78
    restart)
79
      log_daemon_msg "Restarting the Koha SRU server ($DBNAME)"
80
      if daemon $DAEMONOPTS $USER --restart -- $SRUSERVER $SRUSERVER_OPTS; then
81
        log_end_msg 0
82
      else
83
        log_end_msg 1
84
      fi
85
      ;;
86
    *)
87
      log_success_msg "Usage: /etc/init.d/$NAME {start|stop|restart}"
88
      exit 1
89
      ;;
90
esac
(-)a/misc/sru_server.pl (-1 / +39 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/env perl
2
#
3
# Copyright University of Helsinki 2017
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Dancer;
21
use Dancer::Config;
22
use Catmandu;
23
use Dancer::Plugin::Catmandu::SRU;
24
use Koha::Logger;
25
use Koha::SearchEngine::Elasticsearch;
26
27
Koha::Logger->get;
28
29
Catmandu->load( Dancer::Config::setting('confdir') );
30
31
my $catmanduConfig = Catmandu->config;
32
my $es = Koha::SearchEngine::Elasticsearch->new({index => 'biblios'});
33
34
$catmanduConfig->{store}{sru}{options}{nodes} = $es->get_elasticsearch_params()->{nodes};
35
$catmanduConfig->{store}{sru}{options}{index_name} = $es->get_elasticsearch_params()->{index_name};
36
37
sru_provider '/sru';
38
39
dance;

Return to bug 21210