3 #===============================================================================
12 # AUTHOR: Chris Cormack (rangi), chrisc@catalyst.net.nz
13 # ORGANIZATION: Koha Development Team
15 # CREATED: 19/09/13 10:43:14
17 #===============================================================================
19 # Copyright 2014 Catalyst IT <chrisc@catalyst.net.nz>
21 # This file is part of NCIPServer
23 # NCIPServer is free software; you can redistribute it and/or modify it under the
24 # terms of the GNU General Public License as published by the Free Software
25 # Foundation; either version 2 of the License, or (at your option) any later
28 # NCIPServer is distributed in the hope that it will be useful, but WITHOUT ANY
29 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
30 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
32 # You should have received a copy of the GNU General Public License along
33 # with NCIPServer; if not, write to the Free Software Foundation, Inc.,
34 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
43 my $handler = NCIP::Handler->new( { namespace => $namespace,
44 type => $request_type,
46 template_dir => $templates
53 use Object::Tiny qw{ type namespace ils templates };
59 Set up a new handler object, this will actually create one of the request type
60 eg NCIP::Handler::LookupUser
67 my $subclass = __PACKAGE__ . "::" . $params->{type};
68 load $subclass || die "Can't load module $subclass";
70 type => $params->{type},
71 namespace => $params->{namespace},
72 ils => $params->{ils},
73 templates => $params->{template_dir}
78 =head2 get_user_elements($xml)
80 When passed an xml dom, this will find the user elements and pass convert them into an arrayref
84 sub get_user_elements {
87 my $xpc = XML::LibXML::XPathContext->new;
88 $xpc->registerNs( 'ns', $self->namespace() );
90 my $root = $xmldoc->documentElement();
92 $xpc->findnodes( '//ns:LookupUser/UserElementType/Value', $root );
93 unless ( $elements[0] ) {
94 @elements = $xpc->findnodes( '//ns:UserElementType', $root );
102 my $xpc = XML::LibXML::XPathContext->new;
103 $xpc->registerNs( 'ns', $self->namespace() );
105 my $root = $xmldoc->documentElement();
108 $xpc->find( '//ns:FromAgencyId', $root );
110 $xpc->find( '//ns:ToAgencyId', $root );
111 return ( $from, $to );
116 my $templatename = shift;
119 my $template = Template->new(
121 INCLUDE_PATH => $self->templates,
126 $template->process( $templatename, $vars, \$output );