Diff for /nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm between versions 1.1 and 1.7

version 1.1, 2002/05/05 20:52:58 version 1.7, 2002/07/14 08:12:13
Line 37  package Apache::NSDL::ToTheGateway; Line 37  package Apache::NSDL::ToTheGateway;
   
 # ================================================================ DEPENDENCIES  # ================================================================ DEPENDENCIES
 use strict; # enforce handling of variables, references and subroutines  use strict; # enforce handling of variables, references and subroutines
   use Apache::Constants qw(:common);
   use Apache::GATEWAY::Common;
   use Apache::NSDL::FromTheGateway;
   
 # ============================================================ MODULE VARIABLES  # ============================================================ MODULE VARIABLES
 my $VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/);  my $VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/);
   my $hostname='nsdl.lon-capa.org';
   
 # ================================================================= SUBROUTINES  # ================================================================= 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') {
    # 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"?>
     <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>
       <requestURL>$requestURL</requestURL>
     <Identify >
       <repositoryName>The LearningOnline Network with CAPA</repositoryName>
       <baseURL>http://$hostname/OAI-script</baseURL>
       <protocolVersion>1.1</protocolVersion>
       <adminEmail>mailto:korte\@lite.msu.edu</adminEmail>
       <description>
        <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/2.0/oai-identifier
                          http://www.openarchives.org/OAI/2.0/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/2.0/eprints"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/eprints
                                 http://www.openarchives.org/OAI/2.0/eprints.xsd">
           <content>
             <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>
           </metadataPolicy>
           <dataPolicy>
          <text>Full content, i.e. preprints may not be harvested by robots</text>
           </dataPolicy>
           <submissionPolicy>
             <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') {
    # 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') {
    # 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') {
    # 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') {
    # 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
       }
       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/xml');
       $r->send_http_header;
       return(OK) if $r->header_only;
       $r->print(<<END);
   $output
   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);
   }
   
 # ------------------------------------------- NSDL->answer_list_records_request  # ------------------------------------------- NSDL->answer_list_records_request
 sub answer_list_records_request {  sub answer_list_records_request {
 # Not yet implemented  # Not yet implemented
Line 51  sub answer_list_records_request { Line 304  sub answer_list_records_request {
   
 # ------------------------------------------------- NSDL->answer_search_request  # ------------------------------------------------- NSDL->answer_search_request
 sub answer_search_request {  sub answer_search_request {
 # Not yet implemented      my ($url)=@_;
 # Need to specifically characterize INPUT arguments and OUTPUT data      return "will have http querying strategy against NSDL servers\n";
 }  }
   
 # ---------------------------------------- NSDL->answer_metadata_record_request  # ---------------------------------------- NSDL->answer_metadata_record_request
 sub answer_metadata_record_request {  sub answer_metadata_record_request {
 # Not yet implemented      my ($eref)=@_;
 # Need to specifically characterize INPUT arguments and OUTPUT data      return Apache::NSDL::FromTheGateway($eref);
 }  }
   
 # ----------------------------------------------- NSDL->answer_resource_request  # ----------------------------------------------- NSDL->answer_resource_request
 sub answer_resource_request {  sub answer_resource_request {
 # Not yet implemented      my ($eref)=@_;
 # Need to specifically characterize INPUT arguments and OUTPUT data      return Apache::NSDL::FromTheGateway($eref);
 }  }
   
 1;  1;
Line 167  This lists the records matching a given Line 420  This lists the records matching a given
 The request comes from the Gateway Server, B<and the information  The request comes from the Gateway Server, B<and the information
 passes from NSDL I<to the> GATEWAY>.  passes from NSDL I<to the> GATEWAY>.
   
   =item B<Status of Implementation>
   
   n/a
   
 =back  =back
   
 =item B<Apache::NSDL::answer_search_request>  =item B<Apache::NSDL::answer_search_request>
Line 191  This lists the records matching a given Line 448  This lists the records matching a given
 The request comes from the Gateway Server, B<and the information  The request comes from the Gateway Server, B<and the information
 passes from NSDL I<to the> GATEWAY>.  passes from NSDL I<to the> GATEWAY>.
   
   =item B<Status of Implementation>
   
   n/a
   
 =back  =back
   
 =item B<Apache::NSDL::answer_metadata_record_request>  =item B<Apache::NSDL::answer_metadata_record_request>
Line 214  This lists the records matching a given Line 475  This lists the records matching a given
 The request comes from the Gateway Server, B<and the information  The request comes from the Gateway Server, B<and the information
 passes from NSDL I<to the> GATEWAY>.  passes from NSDL I<to the> GATEWAY>.
   
   =item B<Status of Implementation>
   
   n/a
   
 =back  =back
   
 =item B<Apache::NSDL::answer_resource_request>  =item B<Apache::NSDL::answer_resource_request>
Line 238  This provides the content of the resourc Line 503  This provides the content of the resourc
 The request comes from the Gateway Server, B<and the information  The request comes from the Gateway Server, B<and the information
 passes from NSDL I<to the> GATEWAY>.  passes from NSDL I<to the> GATEWAY>.
   
   =item B<Status of Implementation>
   
   n/a
   
 =back  =back
   
 =back  =back
Line 280  and Apache::GATEWAY::* manpages. Line 549  and Apache::GATEWAY::* manpages.
 linux  linux
   
 =cut  =cut
   

Removed from v.1.1  
changed lines
  Added in v.1.7


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>