[LON-CAPA-cvs] cvs: nsdl /lib/perl/Apache/LONCAPA ToTheGateway.pm

harris41 lon-capa-cvs@mail.lon-capa.org
Wed, 29 May 2002 01:09:37 -0000


harris41		Tue May 28 21:09:37 2002 EDT

  Modified files:              
    /nsdl/lib/perl/Apache/LONCAPA	ToTheGateway.pm 
  Log:
  implement mod_perl handler; respond to OAI GetRecord and Identify requests;
  debugging implementation of answer_metadata_record_request
  
  
Index: nsdl/lib/perl/Apache/LONCAPA/ToTheGateway.pm
diff -u nsdl/lib/perl/Apache/LONCAPA/ToTheGateway.pm:1.2 nsdl/lib/perl/Apache/LONCAPA/ToTheGateway.pm:1.3
--- nsdl/lib/perl/Apache/LONCAPA/ToTheGateway.pm:1.2	Tue May  7 10:04:07 2002
+++ nsdl/lib/perl/Apache/LONCAPA/ToTheGateway.pm	Tue May 28 21:09:37 2002
@@ -36,12 +36,52 @@
 
 # ================================================================ DEPENDENCIES
 use strict; # enforce handling of variables, references and subroutines
+use Apache::Constants qw(:common);
+use Apache::LONCAPA::FromTheGateway;
 
 # ============================================================ MODULE VARIABLES
-my $VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/);
+my $VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
 
 # ================================================================= SUBROUTINES
  
+# ----------------------------- Handling routine called via Apache and mod_perl
+sub handler {
+    my $r = shift;
+    Apache::GATEWAY::Common::readCGI($r);
+    my $output;
+    if ($ENV{'form.verb'} eq 'search') {
+# NSDL->answer_metadata_record_request
+	$output=
+  Apache::LONCAPA::FromTheGateway::search_or_browse_against_NSDLgateway(\%ENV);
+    }
+    my $cgi;
+    foreach my $key (keys %ENV) {
+	if ($key=~/^form\./) {
+	    $cgi.="$key: $ENV{$key}\n";
+	}
+    }
+    $r->content_type('text/html');
+    $r->send_http_header;
+    return(OK) if $r->header_only;
+    $r->print(<<END);
+<html>
+<head><title>Test Output</title></head>
+<body>
+<h1>Apache::LONCAPA::ToTheGateway</h1>
+<h2>Input</h2>
+<pre>
+$cgi
+</pre>
+<h2>Output</h2>
+<pre>
+$output
+</pre>
+</body>
+</html>
+END
+    return(OK);
+}
+
 # ---------------------------------------------- LONCAPA->answer_search_request
 sub answer_search_request {
 # Not yet implemented
@@ -50,8 +90,8 @@
 
 # ------------------------------------- LONCAPA->answer_metadata_record_request
 sub answer_metadata_record_request {
-# Not yet implemented
-# Need to specifically characterize INPUT arguments and OUTPUT data
+    my ($url)=@_;
+    return "will have multiplexed this and returned from LON-CAPA network\n";
 }
 
 # -------------------------------------------- LONCAPA->answer_resource_request