Annotation of nsdl/lib/perl/Apache/NSDL/ToTheGateway.pm, revision 1.4

1.1       harris41    1: # Apache::NSDL::ToTheGateway
                      2: #
                      3: # ToTheGateway.pm
                      4: # API for passing information from NSDL to the Gateway Server
                      5: #
                      6: # For more documentation, read the POD documentation
                      7: # of this module with the perldoc command:
                      8: #
                      9: #         perldoc ./ToTheGateway.pm
                     10: #
                     11: # Brief description
                     12: # =================
                     13: #
                     14: # This module contains functionality for
                     15: # transferring information from NSDL to the Gateway Server.
                     16: #
                     17: # In terms of the overall data flow, the
                     18: # '=====>' below indicates the role of this
                     19: # module.
                     20: #
                     21: # NSDL =========> Gateway --------> LON-CAPA
                     22: # LON-CAPA -----> Gateway --------> NSDL
                     23: #
                     24: # SUBROUTINES:
                     25: # NSDL->answer_list_records_request
                     26: # NSDL->answer_search_request
                     27: # NSDL->answer_metadata_record_request
                     28: # NSDL->answer_resource_request
                     29: 
                     30: # Year 2002
                     31: # Scott Harrison
                     32: # February-May
                     33: #
                     34: ###
                     35: 
                     36: package Apache::NSDL::ToTheGateway;
                     37: 
                     38: # ================================================================ DEPENDENCIES
                     39: use strict; # enforce handling of variables, references and subroutines
1.3       harris41   40: use Apache::Constants qw(:common);
1.4     ! harris41   41: use Apache::GATEWAY::Common;
        !            42: use Apache::NSDL::FromTheGateway;
1.1       harris41   43: 
                     44: # ============================================================ MODULE VARIABLES
1.4     ! harris41   45: my $VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
1.1       harris41   46: 
                     47: # ================================================================= SUBROUTINES
1.3       harris41   48: 
                     49: # ----------------------------- Handling routine called via Apache and mod_perl
                     50: sub handler {
                     51:     my $r = shift;
1.4     ! harris41   52:     Apache::GATEWAY::Common::readCGI($r);
        !            53:     my $output;
        !            54:     if ($ENV{'form.verb'} eq 'GetRecord') {
        !            55: 	$output=
        !            56:       Apache::NSDL::FromTheGateway::view_LONCAPAgateway_metadata_record(\%ENV);
        !            57:     }
        !            58:     elsif ($ENV{'form.verb'} eq 'Identify') {
        !            59: 	$output=(<<END);
        !            60: <?xml version="1.0" encoding="UTF-8"?>
        !            61:   <Identify 
        !            62:      xmlns="http://www.openarchives.org/OAI/1.1/OAI_Identify"
        !            63:      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        !            64:      xsi:schemaLocation="http://www.openarchives.org/OAI/1.1/OAI_Identify
        !            65:                          http://www.openarchives.org/OAI/1.1/OAI_Identify.xsd">
        !            66:     <responseDate>2001-06-01T19:20:30-04:00</responseDate>
        !            67:     <requestURL>http://nsdl.lon-capa.org/OAI-script?verb=Identify</requestURL>
        !            68:     <repositoryName>The LearningOnline Network with CAPA</repositoryName>
        !            69:     <baseURL>http://nsdl.lon-capa.org/OAI-script</baseURL>
        !            70:     <protocolVersion>1.1</protocolVersion>
        !            71:     <adminEmail>mailto:korte&#x0040;lite.msu.edu</adminEmail>
        !            72:     <description>
        !            73:      <oai-identifier xmlns="http://www.openarchives.org/OAI/1.1/oai-identifier"
        !            74:          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        !            75:          xsi:schemaLocation="http://www.openarchives.org/OAI/1.1/oai-identifier
        !            76:                        http://www.openarchives.org/OAI/1.1/oai-identifier.xsd">
        !            77:         <scheme>oai</scheme>
        !            78:         <repositoryIdentifier>loncapa</repositoryIdentifier>
        !            79:         <delimiter>:</delimiter>
        !            80:         <sampleIdentifier>oai:loncapa:harrison2002-1</sampleIdentifier>
        !            81:       </oai-identifier>
        !            82:     </description>
        !            83:     <description>
        !            84:       <eprints xmlns="http://www.openarchives.org/OAI/1.1/eprints"
        !            85:             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        !            86:             xsi:schemaLocation="http://www.openarchives.org/OAI/1.1/eprints
        !            87:                               http://www.openarchives.org/OAI/1.1/eprints.xsd">
        !            88:         <content>
        !            89:           <URL>http://nsdl.lon-capa.org/info/content.htm</URL>
        !            90:         </content>
        !            91:         <metadataPolicy>
        !            92:           <text>Metadata can be used by authorized users</text>
        !            93:           <URL>http://nsdl.lon-capa.org/metadata_use.htm</URL>
        !            94:         </metadataPolicy>
        !            95:         <dataPolicy>
        !            96:        <text>Full content, i.e. preprints may not be harvested by robots</text>
        !            97:         </dataPolicy>
        !            98:         <submissionPolicy>
        !            99:           <URL>http://nsdl.lon-capa.org/info/submission.htm</URL>
        !           100:         </submissionPolicy>
        !           101:       </eprints>
        !           102:     </description>
        !           103:   </Identify> 
        !           104: END
        !           105:         $output=~s/\>/\&gt;/g;
        !           106: 	$output=~s/\</\&lt;/g;
        !           107:     }
        !           108:     my $cgi;
        !           109:     foreach my $key (keys %ENV) {
        !           110: 	if ($key=~/^form\./) {
        !           111: 	    $cgi.="$key: $ENV{$key}\n";
        !           112: 	}
        !           113:     }
1.3       harris41  114:     $r->content_type('text/html');
                    115:     $r->send_http_header;
                    116:     return(OK) if $r->header_only;
                    117:     $r->print(<<END);
                    118: <html>
                    119: <head><title>Test Output</title></head>
                    120: <body>
1.4     ! harris41  121: <h1>Apache::NSDL::ToTheGateway</h1>
        !           122: <h2>Input</h2>
        !           123: <pre>
        !           124: $cgi
        !           125: </pre>
        !           126: <h2>Output</h2>
        !           127: <pre>
        !           128: $output
        !           129: </pre>
1.3       harris41  130: </body>
                    131: </html>
                    132: END
                    133:     return(OK);
                    134: }
1.1       harris41  135: 
                    136: # ------------------------------------------- NSDL->answer_list_records_request
                    137: sub answer_list_records_request {
                    138: # Not yet implemented
                    139: # Need to specifically characterize INPUT arguments and OUTPUT data
                    140: }
                    141: 
                    142: # ------------------------------------------------- NSDL->answer_search_request
                    143: sub answer_search_request {
1.4     ! harris41  144:     my ($url)=@_;
        !           145:     return "will have http querying strategy against NSDL servers\n";
1.1       harris41  146: }
                    147: 
                    148: # ---------------------------------------- NSDL->answer_metadata_record_request
                    149: sub answer_metadata_record_request {
1.4     ! harris41  150:     my ($eref)=@_;
        !           151:     return Apache::NSDL::FromTheGateway($eref);
1.1       harris41  152: }
                    153: 
                    154: # ----------------------------------------------- NSDL->answer_resource_request
                    155: sub answer_resource_request {
                    156: # Not yet implemented
                    157: # Need to specifically characterize INPUT arguments and OUTPUT data
                    158: }
                    159: 
                    160: 1;
                    161: 
                    162: __END__
                    163: 
                    164: =pod
                    165: 
                    166: =head1 NAME
                    167: 
                    168: B<Apache::NSDL::ToTheGateway> - API for passing information from NSDL to the Gateway Server
                    169: 
                    170: =head1 SYNOPSIS
                    171: 
                    172:  use Apache::NSDL::ToTheGateway;
                    173: 
                    174:  my $arrayref=
                    175:     Apache::NSDL::ToTheGateway::answer_list_records_request
                    176:       ($OAI_protocol_request);
                    177: 
                    178: =head1 DESCRIPTION
                    179: 
                    180: This module contains functionality for
                    181: transferring information from NSDL to the Gateway Server.
                    182: 
                    183: In terms of the overall data flow, the
                    184: '=====>' below indicates the role of this
                    185: module.
                    186: 
                    187: B<NSDL =========E<gt> Gateway> --------E<gt> LON-CAPA
                    188: 
                    189: LON-CAPA -----E<gt> Gateway --------E<gt> NSDL
                    190: 
                    191: =head2 EXIT CODES
                    192: 
                    193: The subroutines of this module all output an exit code which
                    194: describes the status of function completion.  The exit code
                    195: may be followed by a more descriptive message such as:
                    196: 
                    197:  FORMATERROR:Sun May  5 20:15:16 GMT 2002:missing 'protocol://' pattern
                    198: 
                    199: =over 4
                    200: 
                    201: =item *
                    202: 
                    203: B<'SUCCESS'>, information was found and is being returned
                    204: 
                    205: =item *
                    206: 
                    207: B<'EMPTY'>, everything functioned properly, but no information was present
                    208: 
                    209: =item *
                    210: 
                    211: B<'BADEMPTY'>, everything appeared to function properly, but no information
                    212: was present (which defies expectation); this is useful for detecting phantom
                    213: cases of connectivity when verifying test cases of vertical software partitions
                    214: 
                    215: =item *
                    216: 
                    217: B<'TIMEOUT'>, the request is taking WAY too long
                    218: 
                    219: =item *
                    220: 
                    221: B<'FORMATERROR'>, the input argument is not formatted correctly in a way that
                    222: can be processed by the NSDL server
                    223: 
                    224: =item *
                    225: 
                    226: B<'CONNECTIONFAILURE'>, the NSDL server cannot be contacted
                    227: 
                    228: =back
                    229: 
                    230: =head2 SUBROUTINES
                    231: 
                    232: Note that the subroutines all output an exit code which
                    233: describes the status of function completion.
                    234: 
                    235: In the case of failed function completion, the other
                    236: output argument(s) will typically only be 'NULL' values.
                    237: 
                    238: =over 4
                    239: 
                    240: =item B<Apache::NSDL::answer_list_records_request>
                    241: 
                    242: =over 4
                    243: 
                    244: =item B<Input> - Scalar string
                    245: 
                    246: Take in an OAI-format request for a specific NSDL server.
                    247: 
                    248: =item B<Output> - Scalar string, Scalar array reference
                    249: 
                    250: An exit code is returned as a scalar string.
                    251: 
                    252: A list of records returned via an array reference.
                    253: 
                    254: =item B<Description>
                    255: 
                    256: This lists the records matching a given request.
                    257: The request comes from the Gateway Server, B<and the information
                    258: passes from NSDL I<to the> GATEWAY>.
                    259: 
1.2       harris41  260: =item B<Status of Implementation>
                    261: 
                    262: n/a
                    263: 
1.1       harris41  264: =back
                    265: 
                    266: =item B<Apache::NSDL::answer_search_request>
                    267: 
                    268: =over 4
                    269: 
                    270: =item B<Input> - Scalar string
                    271: 
                    272: Take in an OAI-format request for a specific NSDL server (a search expression
                    273: is passed).
                    274: 
                    275: =item B<Output> - Scalar string, Scalar array reference
                    276: 
                    277: An exit code is returned as a scalar string.
                    278: 
                    279: A list of relevant records (matching the search request) returned via an
                    280: array reference.
                    281: 
                    282: =item B<Description>
                    283: 
                    284: This lists the records matching a given search request.
                    285: The request comes from the Gateway Server, B<and the information
                    286: passes from NSDL I<to the> GATEWAY>.
                    287: 
1.2       harris41  288: =item B<Status of Implementation>
                    289: 
                    290: n/a
                    291: 
1.1       harris41  292: =back
                    293: 
                    294: =item B<Apache::NSDL::answer_metadata_record_request>
                    295: 
                    296: =over 4
                    297: 
                    298: =item B<Input> - Scalar string
                    299: 
                    300: Take in an OAI-format request for a specific NSDL server resource's
                    301: metadata.
                    302: 
                    303: =item B<Output> - Scalar string, Scalar string reference
                    304: 
                    305: An exit code is returned as a scalar string.
                    306: 
                    307: The metadata entries for the resource; returned via a scalar reference.
                    308: 
                    309: =item B<Description>
                    310: 
                    311: This lists the records matching a given request.
                    312: The request comes from the Gateway Server, B<and the information
                    313: passes from NSDL I<to the> GATEWAY>.
                    314: 
1.2       harris41  315: =item B<Status of Implementation>
                    316: 
                    317: n/a
                    318: 
1.1       harris41  319: =back
                    320: 
                    321: =item B<Apache::NSDL::answer_resource_request>
                    322: 
                    323: =over 4
                    324: 
                    325: =item B<Input> - Scalar string
                    326: 
                    327: Take in an OAI-format request for a specific NSDL server's
                    328: resource content.
                    329: 
                    330: =item B<Output> - Scalar string, Scalar string reference
                    331: 
                    332: An exit code is returned as a scalar string.
                    333: 
                    334: A reference to the resource content (now physically present in computer
                    335: memory).
                    336: 
                    337: =item B<Description>
                    338: 
                    339: This provides the content of the resource matching a given request.
                    340: The request comes from the Gateway Server, B<and the information
                    341: passes from NSDL I<to the> GATEWAY>.
1.2       harris41  342: 
                    343: =item B<Status of Implementation>
                    344: 
                    345: n/a
1.1       harris41  346: 
                    347: =back
                    348: 
                    349: =back
                    350: 
                    351: =head1 README
                    352: 
                    353: B<Apache::NSDL::ToTheGateway>
                    354: is part of the NSDL-LONCAPA Gateway Server system.
                    355: Please see http://nsdl.lon-capa.org/ for more information.
                    356: 
                    357: =head1 AUTHOR
                    358: 
                    359: Scott Harrison, 2002
                    360: 
                    361: =head1 PREREQUISITES
                    362: 
                    363: This module requires the C<strict> module.
                    364: 
                    365: =head1 COREQUISITES
                    366: 
                    367: Apache::NSDL::FromTheGateway
                    368: Apache::GATEWAY::ToNSDL
                    369: Apache::GATEWAY::FromNSDL
                    370: Apache::GATEWAY::ToLONCAPA
                    371: Apache::GATEWAY::FromLONCAPA
                    372: Apache::LONCAPA::FromTheGateway
                    373: Apache::LONCAPA::ToTheGateway
                    374: 
                    375: =head1 SEE ALSO
                    376: 
                    377: http://www.lon-capa.org/
                    378: 
                    379: http://www.smete.org/
                    380: 
                    381: Also visit the other Apache::NSDL::*, Apache::LONCAPA::*,
                    382: and Apache::GATEWAY::* manpages.
                    383: 
                    384: =head1 OSNAMES
                    385: 
                    386: linux
                    387: 
                    388: =cut

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