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

harris41 lon-capa-cvs@mail.lon-capa.org
Sun, 14 Jul 2002 07:37:20 -0000


This is a MIME encoded message

--harris411026632240
Content-Type: text/plain

harris41		Sun Jul 14 03:37:20 2002 EDT

  Modified files:              
    /nsdl/lib/perl/Apache/NSDL	ToTheGateway.pm 
  Log:
  BUG 398; hesitant to implement set hierarchy functions yet
  
  
--harris411026632240
Content-Type: text/plain
Content-Disposition: attachment; filename="harris41-20020714033720.txt"

Index: nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm
diff -u nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm:1.5 nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm:1.6
--- nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm:1.5	Thu May 30 13:07:38 2002
+++ nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm	Sun Jul 14 03:37:20 2002
@@ -42,7 +42,8 @@
 use Apache::NSDL::FromTheGateway;
 
 # ============================================================ MODULE VARIABLES
-my $VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/);
+my $VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/);
+my $hostname='nsdl.lon-capa.org';
 
 # ================================================================= SUBROUTINES
 
@@ -52,29 +53,83 @@
     Apache::GATEWAY::Common::readCGI($r);
     my $output;
     if ($ENV{'form.verb'} eq 'GetRecord') {
-	$output=
+	# arguments: identifier, metadataPrefix
+	if(!defined($ENV{'form.identifier'})) {
+	    my $responseDate=Apache::GATEWAY::Common::responseDate();
+	    my $requestURL=Apache::GATEWAY::Common::requestURL();
+	    $output=(<<END);
+<?xml version="1.0" encoding="UTF-8"?>
+ <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" 
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
+          http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
+   <responseDate>$responseDate</responseDate>
+   <request>$requestURL</request>
+   <error code="badArgument">Missing identifier argument</error>
+ </OAI-PMH>
+END
+	}
+	elsif(!defined($ENV{'form.metadataPrefix'})) {
+	    my $responseDate=Apache::GATEWAY::Common::responseDate();
+	    my $requestURL=Apache::GATEWAY::Common::requestURL();
+	    $output=(<<END);
+<?xml version="1.0" encoding="UTF-8"?>
+ <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" 
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
+          http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
+   <responseDate>$responseDate</responseDate>
+   <request>$requestURL</request>
+   <error code="badArgument">Missing metadataPrefix argument</error>
+ </OAI-PMH>
+END
+	}
+	elsif ($ENV{'form.metadataPrefix'} ne 'oai_dc' and
+	       $ENV{'form.metadataPrefix'} ne 'loncapa_ieeelom') {
+	    my $responseDate=Apache::GATEWAY::Common::responseDate();
+	    my $requestURL=Apache::GATEWAY::Common::requestURL();
+	    $output=(<<END);
+<?xml version="1.0" encoding="UTF-8"?>
+ <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" 
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
+          http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
+   <responseDate>$responseDate</responseDate>
+   <request>$requestURL</request>
+   <error code="cannotDisseminateFormat">Cannot disseminate the requested
+metadata format</error>
+ </OAI-PMH>
+END
+	}
+	else {
+	    my $status;
+	    ($status,$output)=
       Apache::NSDL::FromTheGateway::view_LONCAPAgateway_metadata_record(\%ENV);
+	}
     }
     elsif ($ENV{'form.verb'} eq 'Identify') {
+	# arguments: none
 	my $responseDate=Apache::GATEWAY::Common::responseDate();
+	my $requestURL=Apache::GATEWAY::Common::requestURL();
 	$output=(<<END);
 <?xml version="1.0" encoding="UTF-8"?>
-  <Identify 
-     xmlns="http://www.openarchives.org/OAI/1.1/OAI_Identify"
+  <OAI-PMH
+     xmlns="http://www.openarchives.org/OAI/2.0/"
      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">
+     xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
+                         http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
     <responseDate>$responseDate</responseDate>
-    <requestURL>http://nsdl.lon-capa.org/OAI-script?verb=Identify</requestURL>
+    <requestURL>$requestURL</requestURL>
+  <Identify >
     <repositoryName>The LearningOnline Network with CAPA</repositoryName>
-    <baseURL>http://nsdl.lon-capa.org/OAI-script</baseURL>
+    <baseURL>http://$hostname/OAI-script</baseURL>
     <protocolVersion>1.1</protocolVersion>
-    <adminEmail>mailto:korte&#x0040;lite.msu.edu</adminEmail>
+    <adminEmail>mailto:korte\@lite.msu.edu</adminEmail>
     <description>
-     <oai-identifier xmlns="http://www.openarchives.org/OAI/1.1/oai-identifier"
+     <oai-identifier xmlns="http://www.openarchives.org/OAI/2.0/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">
+         xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai-identifier
+                       http://www.openarchives.org/OAI/2.0/oai-identifier.xsd">
         <scheme>oai</scheme>
         <repositoryIdentifier>loncapa</repositoryIdentifier>
         <delimiter>:</delimiter>
@@ -82,66 +137,161 @@
       </oai-identifier>
     </description>
     <description>
-      <eprints xmlns="http://www.openarchives.org/OAI/1.1/eprints"
+      <eprints xmlns="http://www.openarchives.org/OAI/2.0/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">
+            xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/eprints
+                              http://www.openarchives.org/OAI/2.0/eprints.xsd">
         <content>
-          <URL>http://nsdl.lon-capa.org/info/content.htm</URL>
+          <URL>http://$hostname/info/content.html</URL>
+          <text>Educational materials from the LearningOnline Network</text>
         </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>
+          <text>Submissions can be made by institutions with installed
+LON-CAPA servers.</text>
         </submissionPolicy>
       </eprints>
     </description>
   </Identify> 
+ </OAI-PMH>
 END
     }
     elsif ($ENV{'form.verb'} eq 'ListIdentifiers') {
-	$output='not yet implemented';
+	# arguments: until, from, set, resumptionToken
+#	$output=
+#      Apache::NSDL::FromTheGateway::search_against_LONCAPAgateway(\%ENV);
+	# no full implementation scheme yet so...
+	    my $responseDate=Apache::GATEWAY::Common::responseDate();
+	    my $requestURL=Apache::GATEWAY::Common::requestURL();
+	    $output=(<<END);
+<?xml version="1.0" encoding="UTF-8"?>
+ <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" 
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
+          http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
+   <responseDate>$responseDate</responseDate>
+   <request>$requestURL</request>
+   <error code="noSetHierarchy">No set hierarchy available yet for this
+gateway.</error>
+ </OAI-PMH>
+END
     }
     elsif ($ENV{'form.verb'} eq 'ListMetadataFormats') {
-	$output='not yet implemented';
+	# arguments: identifier
+	my $responseDate=Apache::GATEWAY::Common::responseDate();
+	my $requestURL=Apache::GATEWAY::Common::requestURL();
+	$output=(<<END);
+<?xml version="1.0" encoding="UTF-8"?>
+  <ListMetadataFormats 
+      xmlns="http://www.openarchives.org/OAI/1.1/OAI_ListMetadataFormats"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://www.openarchives.org/OAI/1.1/OAI_ListMetadataFormats
+              http://www.openarchives.org/OAI/1.1/OAI_ListMetadataFormats.xsd">
+    <responseDate>$responseDate</responseDate> 
+    <requestURL>$requestURL</requestURL>
+    <metadataFormat>
+      <metadataPrefix>oai_dc</metadataPrefix>
+      <schema>http://www.openarchives.org/OAI/1.1/dc.xsd</schema>
+      <metadataNamespace>http://purl.org/dc/elements/1.1/</metadataNamespace>
+    </metadataFormat>
+    <metadataFormat>
+      <metadataPrefix>loncapa_ieeelom</metadataPrefix>
+      <schema>http://nsdl.lon-capa.org/lom/6.4/ieeelom.xsd</schema>
+      <metadataNamespace>http://nsdl.lon-capa.org/lom/6.4/</metadataNamespace>
+    </metadataFormat>
+</ListMetadataFormats>
+END
     }
     elsif ($ENV{'form.verb'} eq 'ListRecords') {
-	$output='not yet implemented';
+	# arguments: until, from, set, resumptionToken
+#	$output=
+#      Apache::NSDL::FromTheGateway::search_against_LONCAPAgateway(\%ENV);
+	    my $responseDate=Apache::GATEWAY::Common::responseDate();
+	    my $requestURL=Apache::GATEWAY::Common::requestURL();
+	    $output=(<<END);
+<?xml version="1.0" encoding="UTF-8"?>
+ <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" 
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
+          http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
+   <responseDate>$responseDate</responseDate>
+   <request>$requestURL</request>
+   <error code="noSetHierarchy">No set hierarchy available yet for this
+gateway.</error>
+ </OAI-PMH>
+END
     }
     elsif ($ENV{'form.verb'} eq 'ListSets') {
-	$output='not yet implemented';
+	# arguments: resumptionToken
+#	$output='not yet implemented';
+	    my $responseDate=Apache::GATEWAY::Common::responseDate();
+	    my $requestURL=Apache::GATEWAY::Common::requestURL();
+	    $output=(<<END);
+<?xml version="1.0" encoding="UTF-8"?>
+ <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" 
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
+          http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
+   <responseDate>$responseDate</responseDate>
+   <request>$requestURL</request>
+   <error code="noSetHierarchy">No set hierarchy available yet for this
+gateway.</error>
+ </OAI-PMH>
+END
     }
-    $output=~s/\>/\&gt;/g;
-    $output=~s/\</\&lt;/g;
-    my $cgi;
-    foreach my $key (keys %ENV) {
-	if ($key=~/^form\./) {
-	    $cgi.="$key: $ENV{$key}\n";
-	}
+    else {
+	my $responseDate=Apache::GATEWAY::Common::responseDate();
+	my $requestURL=Apache::GATEWAY::Common::requestURL();
+	$output=(<<END);
+<?xml version="1.0" encoding="UTF-8"?>
+ <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" 
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
+          http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
+   <responseDate>$responseDate</responseDate>
+   <request>$requestURL</request>
+   <error code="badVerb">Illegal OAI verb</error>
+ </OAI-PMH>
+END
     }
-    $r->content_type('text/html');
+    $r->content_type('text/xml');
     $r->send_http_header;
     return(OK) if $r->header_only;
     $r->print(<<END);
-<html>
-<head><title>Test Output</title></head>
-<body>
-<h1>Apache::NSDL::ToTheGateway</h1>
-<h2>Input</h2>
-<pre>
-$cgi
-</pre>
-<h2>Output</h2>
-<pre>
 $output
-</pre>
-</body>
-</html>
+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;
+#    $r->print(<<END);
+#<html>
+#<head><title>Test Output</title></head>
+#<body>
+#<h1>Apache::NSDL::ToTheGateway</h1>
+#<h2>Input</h2>
+#<pre>
+#$cgi
+#</pre>
+#<h2>Output</h2>
+#<pre>
+#$output
+#</pre>
+#</body>
+#</html>
 END
     return(OK);
 }
@@ -166,8 +316,8 @@
 
 # ----------------------------------------------- NSDL->answer_resource_request
 sub answer_resource_request {
-# Not yet implemented
-# Need to specifically characterize INPUT arguments and OUTPUT data
+    my ($eref)=@_;
+    return Apache::NSDL::FromTheGateway($eref);
 }
 
 1;

--harris411026632240--