Merge Alan's NCIP.pm and NCIPResponder.pm.
authorAlan Rykhus <alan.rykhus@mnsu.edu>
Tue, 3 Sep 2013 14:53:50 +0000 (10:53 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Tue, 3 Sep 2013 14:53:50 +0000 (10:53 -0400)
He had no copyright headers on those files.

We could not merge his other files because the copyright header
specified GPL version 2.  We want GPL version 2 or later.

This branch is not going into master.  It is for review purposes
only.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
1  2 
lib/NCIP.pm
lib/NCIPResponder.pm

diff --cc lib/NCIP.pm
index 0000000,0000000..d1f1521
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,26 @@@
++package NCIP;
++use NCIP::Configuration;
++use Modern::Perl;
++
++
++use FileHandle;
++
++sub new {
++    my $self = shift;
++    my $config_file = shift;
++
++    my $config = NCIP::Configuration->new($config_file);
++    return bless $config, $self;
++
++}
++
++sub process_request {
++    my $self = shift;
++    my $xml = shift;
++
++    my $response = "<HTML> <HEAD> <TITLE>Hello There</TITLE> </HEAD> <BODY> <H1>Hello You Big JERK!</H1> Who would take this book seriously if the first eaxample didn't say \"hello world\"?  </BODY> </HTML>";
++
++    return $response;
++}
++
++1;
index 0000000,0000000..21714e5
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,43 @@@
++package NCIPResponder;
++use Modern::Perl;
++use NCIP;
++
++use FileHandle;
++
++use Apache2::Const -compile => qw(OK :log :http :methods :cmd_how :override);
++use Apache2::RequestRec ();
++use Apache2::RequestIO ();
++use NCIPServer::NCIP;
++
++sub handler {
++    my $r = shift;
++
++    return Apache2::Const::HTTP_METHOD_NOT_ALLOWED unless $r->method_number eq Apache2::Const::M_POST;
++
++    my $NCIPConfigFile = $r->dir_config('NCIPConfigFile');
++
++    if (!defined($NCIPConfigFile)) {
++        die sprintf "error: There is no NCIPConfigFile defined\n";
++    } else {
++        if (! (-r $NCIPConfigFile)) {
++            die sprintf "error: NCIPConfigFile %s does not exist or is not readable\n", $NCIPConfigFile;
++        }
++    }
++
++    my $ncip = NCIP->new($NCIPConfigFile);
++
++    $r->content_type('text/html');
++    my $tmp_buf;
++    my $input_xml;
++
++    while ($r->read($tmp_buf, 1024)) {
++        $input_xml .= $tmp_buf;
++    }
++
++    my $response_xml = $ncip->process_request($input_xml);
++
++    $r->print($response_xml);
++    return Apache2::Const::OK;
++}
++
++1;