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

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


harris41		Tue May 28 21:17:55 2002 EDT

  Modified files:              
    /nsdl/lib/perl/Apache/NSDL	ToTheGateway.pm 
  Log:
  debugging implementation of answer_search_request; implementing OAI GetRecord
  and Identify; mod_perl handler
  
  
Index: nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm
diff -u nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm:1.3 nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm:1.4
--- nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm:1.3	Thu May 23 15:54:28 2002
+++ nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm	Tue May 28 21:17:55 2002
@@ -38,15 +38,79 @@
 # ================================================================ DEPENDENCIES
 use strict; # enforce handling of variables, references and subroutines
 use Apache::Constants qw(:common);
+use Apache::GATEWAY::Common;
+use Apache::NSDL::FromTheGateway;
 
 # ============================================================ MODULE VARIABLES
-my $VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
+my $VERSION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\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 'GetRecord') {
+	$output=
+      Apache::NSDL::FromTheGateway::view_LONCAPAgateway_metadata_record(\%ENV);
+    }
+    elsif ($ENV{'form.verb'} eq 'Identify') {
+	$output=(<<END);
+<?xml version="1.0" encoding="UTF-8"?>
+  <Identify 
+     xmlns="http://www.openarchives.org/OAI/1.1/OAI_Identify"
+     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+     xsi:schemaLocation="http://www.openarchives.org/OAI/1.1/OAI_Identify
+                         http://www.openarchives.org/OAI/1.1/OAI_Identify.xsd">
+    <responseDate>2001-06-01T19:20:30-04:00</responseDate>
+    <requestURL>http://nsdl.lon-capa.org/OAI-script?verb=Identify</requestURL>
+    <repositoryName>The LearningOnline Network with CAPA</repositoryName>
+    <baseURL>http://nsdl.lon-capa.org/OAI-script</baseURL>
+    <protocolVersion>1.1</protocolVersion>
+    <adminEmail>mailto:korte&#x0040;lite.msu.edu</adminEmail>
+    <description>
+     <oai-identifier xmlns="http://www.openarchives.org/OAI/1.1/oai-identifier"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://www.openarchives.org/OAI/1.1/oai-identifier
+                       http://www.openarchives.org/OAI/1.1/oai-identifier.xsd">
+        <scheme>oai</scheme>
+        <repositoryIdentifier>loncapa</repositoryIdentifier>
+        <delimiter>:</delimiter>
+        <sampleIdentifier>oai:loncapa:harrison2002-1</sampleIdentifier>
+      </oai-identifier>
+    </description>
+    <description>
+      <eprints xmlns="http://www.openarchives.org/OAI/1.1/eprints"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.openarchives.org/OAI/1.1/eprints
+                              http://www.openarchives.org/OAI/1.1/eprints.xsd">
+        <content>
+          <URL>http://nsdl.lon-capa.org/info/content.htm</URL>
+        </content>
+        <metadataPolicy>
+          <text>Metadata can be used by authorized users</text>
+          <URL>http://nsdl.lon-capa.org/metadata_use.htm</URL>
+        </metadataPolicy>
+        <dataPolicy>
+       <text>Full content, i.e. preprints may not be harvested by robots</text>
+        </dataPolicy>
+        <submissionPolicy>
+          <URL>http://nsdl.lon-capa.org/info/submission.htm</URL>
+        </submissionPolicy>
+      </eprints>
+    </description>
+  </Identify> 
+END
+        $output=~s/\>/\&gt;/g;
+	$output=~s/\</\&lt;/g;
+    }
+    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;
@@ -54,7 +118,15 @@
 <html>
 <head><title>Test Output</title></head>
 <body>
-Apache::NSDL::ToTheGateway
+<h1>Apache::NSDL::ToTheGateway</h1>
+<h2>Input</h2>
+<pre>
+$cgi
+</pre>
+<h2>Output</h2>
+<pre>
+$output
+</pre>
 </body>
 </html>
 END
@@ -69,14 +141,14 @@
 
 # ------------------------------------------------- NSDL->answer_search_request
 sub answer_search_request {
-# Not yet implemented
-# Need to specifically characterize INPUT arguments and OUTPUT data
+    my ($url)=@_;
+    return "will have http querying strategy against NSDL servers\n";
 }
 
 # ---------------------------------------- NSDL->answer_metadata_record_request
 sub answer_metadata_record_request {
-# Not yet implemented
-# Need to specifically characterize INPUT arguments and OUTPUT data
+    my ($eref)=@_;
+    return Apache::NSDL::FromTheGateway($eref);
 }
 
 # ----------------------------------------------- NSDL->answer_resource_request
@@ -314,4 +386,3 @@
 linux
 
 =cut
-