From a49a25aec989530075c4e5b63a48435a146c5023 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 27 Jun 2014 14:55:40 -0400 Subject: [PATCH] Add a LookupVersion handler. We also create a NCIP::Const module to hold the SUPPORTED_VERSIONS list and other constants that we may need in the future. Signed-off-by: Jason Stephenson --- lib/NCIP/Const.pm | 28 +++++++++++ lib/NCIP/Handler/LookupVersion.pm | 51 ++++++++++++++++++++ templates/includes/LookupVersionResponse.inc | 5 ++ 3 files changed, 84 insertions(+) create mode 100644 lib/NCIP/Const.pm create mode 100644 lib/NCIP/Handler/LookupVersion.pm create mode 100644 templates/includes/LookupVersionResponse.inc diff --git a/lib/NCIP/Const.pm b/lib/NCIP/Const.pm new file mode 100644 index 0000000..950eb45 --- /dev/null +++ b/lib/NCIP/Const.pm @@ -0,0 +1,28 @@ +# --------------------------------------------------------------- +# Copyright © 2014 Jason J.A. Stephenson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# --------------------------------------------------------------- +package NCIP::Const; + +# Constants for NCIP.pm and family. + +# We don't use Exporter, so we must refer to these with NCIP::Const:: +# prefix. + +# Versions of NCIP that we support as indicated by a list of schema +# URIs. +use constant SUPPORTED_VERSIONS => ( + 'http://www.niso.org/schemas/ncip/v2_02/ncip_v2_02.xsd' +); + + +1; diff --git a/lib/NCIP/Handler/LookupVersion.pm b/lib/NCIP/Handler/LookupVersion.pm new file mode 100644 index 0000000..4fa63e7 --- /dev/null +++ b/lib/NCIP/Handler/LookupVersion.pm @@ -0,0 +1,51 @@ +# --------------------------------------------------------------- +# Copyright © 2014 Jason J.A. Stephenson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# --------------------------------------------------------------- +package NCIP::Handler::LookupVersion; + +=head1 + + NCIP::Handler::LookupVersion + +=head1 SYNOPSIS + + Not to be called directly, NCIP::Handler will pick the appropriate Handler + object, given a message type + +=head1 FUNCTIONS + +=cut + +use Modern::Perl; + +use NCIP::Handler; +use NCIP::Const; + +our @ISA = qw(NCIP::Handler); + +sub handle { + my $self = shift; + my $xmldoc = shift; + if ($xmldoc) { + my $vars; + my ($from,$to) = $self->get_agencies($xmldoc); + $vars->{'fromagency'} = $to; + $vars->{'toagency'} = $from; + $vars->{'messagetype'} = 'LookupVersionResponse'; + $vars->{'versions'} = [ NCIP::Const::SUPPORTED_VERSIONS ]; + my $output = $self->render_output('response.tt', $vars); + return $output; + } +} + +1; diff --git a/templates/includes/LookupVersionResponse.inc b/templates/includes/LookupVersionResponse.inc new file mode 100644 index 0000000..7e9e888 --- /dev/null +++ b/templates/includes/LookupVersionResponse.inc @@ -0,0 +1,5 @@ +[% FOREACH version IN versions %] + +[% version %] + +[% END %] -- 2.43.2