--- nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm 2002/05/06 19:51:21 1.2 +++ nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm 2002/07/14 07:37:20 1.6 @@ -37,12 +37,265 @@ package Apache::NSDL::ToTheGateway; # ================================================================ 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.2 $ =~ /(\d+)\.(\d+)/); +my $VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/); +my $hostname='nsdl.lon-capa.org'; # ================================================================= 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=(< + + $responseDate + $requestURL + Missing identifier argument + +END + } + elsif(!defined($ENV{'form.metadataPrefix'})) { + my $responseDate=Apache::GATEWAY::Common::responseDate(); + my $requestURL=Apache::GATEWAY::Common::requestURL(); + $output=(< + + $responseDate + $requestURL + Missing metadataPrefix argument + +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=(< + + $responseDate + $requestURL + Cannot disseminate the requested +metadata format + +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=(< + + $responseDate + $requestURL + + The LearningOnline Network with CAPA + http://$hostname/OAI-script + 1.1 + mailto:korte\@lite.msu.edu + + + oai + loncapa + : + oai:loncapa:harrison2002-1 + + + + + + http://$hostname/info/content.html + Educational materials from the LearningOnline Network + + + Metadata can be used by authorized users + + + Full content, i.e. preprints may not be harvested by robots + + + Submissions can be made by institutions with installed +LON-CAPA servers. + + + + + +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=(< + + $responseDate + $requestURL + No set hierarchy available yet for this +gateway. + +END + } + elsif ($ENV{'form.verb'} eq 'ListMetadataFormats') { + # arguments: identifier + my $responseDate=Apache::GATEWAY::Common::responseDate(); + my $requestURL=Apache::GATEWAY::Common::requestURL(); + $output=(< + + $responseDate + $requestURL + + oai_dc + http://www.openarchives.org/OAI/1.1/dc.xsd + http://purl.org/dc/elements/1.1/ + + + loncapa_ieeelom + http://nsdl.lon-capa.org/lom/6.4/ieeelom.xsd + http://nsdl.lon-capa.org/lom/6.4/ + + +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=(< + + $responseDate + $requestURL + No set hierarchy available yet for this +gateway. + +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=(< + + $responseDate + $requestURL + No set hierarchy available yet for this +gateway. + +END + } + else { + my $responseDate=Apache::GATEWAY::Common::responseDate(); + my $requestURL=Apache::GATEWAY::Common::requestURL(); + $output=(< + + $responseDate + $requestURL + Illegal OAI verb + +END + } + $r->content_type('text/xml'); + $r->send_http_header; + return(OK) if $r->header_only; + $r->print(</\>/g; +# $output=~s/\content_type('text/html'); +# $r->send_http_header; +# return(OK) if $r->header_only; +# $r->print(< +#Test Output +# +#

Apache::NSDL::ToTheGateway

+#

Input

+#
+#$cgi
+#
+#

Output

+#
+#$output
+#
+# +# +END + return(OK); +} + # ------------------------------------------- NSDL->answer_list_records_request sub answer_list_records_request { # Not yet implemented @@ -51,20 +304,20 @@ sub answer_list_records_request { # ------------------------------------------------- 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 sub answer_resource_request { -# Not yet implemented -# Need to specifically characterize INPUT arguments and OUTPUT data + my ($eref)=@_; + return Apache::NSDL::FromTheGateway($eref); } 1; @@ -296,4 +549,3 @@ and Apache::GATEWAY::* manpages. linux =cut -