Add a LookupVersion handler.
authorJason Stephenson <jason@sigio.com>
Fri, 27 Jun 2014 18:55:40 +0000 (14:55 -0400)
committerJason Stephenson <jason@sigio.com>
Sat, 19 Jul 2014 15:21:04 +0000 (11:21 -0400)
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 <jason@sigio.com>
lib/NCIP/Const.pm [new file with mode: 0644]
lib/NCIP/Handler/LookupVersion.pm [new file with mode: 0644]
templates/includes/LookupVersionResponse.inc [new file with mode: 0644]

diff --git a/lib/NCIP/Const.pm b/lib/NCIP/Const.pm
new file mode 100644 (file)
index 0000000..950eb45
--- /dev/null
@@ -0,0 +1,28 @@
+# ---------------------------------------------------------------
+# Copyright © 2014 Jason J.A. Stephenson <jason@sigio.com>
+#
+# 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 (file)
index 0000000..4fa63e7
--- /dev/null
@@ -0,0 +1,51 @@
+# ---------------------------------------------------------------
+# Copyright © 2014 Jason J.A. Stephenson <jason@sigio.com>
+#
+# 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 (file)
index 0000000..7e9e888
--- /dev/null
@@ -0,0 +1,5 @@
+[% FOREACH version IN versions %]
+<VersionSupported>
+[% version %]
+</VersionSupported>
+[% END %]