File:  [LON-CAPA] / nsdl / lib / perl / Apache / LONCAPA / ToTheGateway.pm
Revision 1.3: download - view: text, annotated - select for diffs
Wed May 29 01:09:37 2002 UTC (22 years, 5 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
implement mod_perl handler; respond to OAI GetRecord and Identify requests;
debugging implementation of answer_metadata_record_request

# Apache::LONCAPA::ToTheGateway
#
# ToTheGateway.pm
# API for passing information from LONCAPA to the Gateway Server
#
# For more documentation, read the POD documentation
# of this module with the perldoc command:
#
#         perldoc ./ToTheGateway.pm
#
# Brief description
# =================
#
# This module contains functionality for
# transferring information from LON-CAPA to the Gateway Server.
#
# In terms of the overall data flow, the
# '=====>' below indicates the role of this
# module.
#
# NSDL ---------> Gateway --------> LON-CAPA
# LON-CAPA =====> Gateway --------> NSDL
#
# SUBROUTINES:
# LONCAPA->answer_search_request
# LONCAPA->answer_metadata_record_request
# LONCAPA->answer_resource_request

# Year 2002
# Scott Harrison
# February-May
#
###

package Apache::LONCAPA::ToTheGateway;

# ================================================================ DEPENDENCIES
use strict; # enforce handling of variables, references and subroutines
use Apache::Constants qw(:common);
use Apache::LONCAPA::FromTheGateway;

# ============================================================ MODULE VARIABLES
my $VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\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 'search') {
# NSDL->answer_metadata_record_request
	$output=
  Apache::LONCAPA::FromTheGateway::search_or_browse_against_NSDLgateway(\%ENV);
    }
    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::LONCAPA::ToTheGateway</h1>
<h2>Input</h2>
<pre>
$cgi
</pre>
<h2>Output</h2>
<pre>
$output
</pre>
</body>
</html>
END
    return(OK);
}

# ---------------------------------------------- LONCAPA->answer_search_request
sub answer_search_request {
# Not yet implemented
# Need to specifically characterize INPUT arguments and OUTPUT data
}

# ------------------------------------- LONCAPA->answer_metadata_record_request
sub answer_metadata_record_request {
    my ($url)=@_;
    return "will have multiplexed this and returned from LON-CAPA network\n";
}

# -------------------------------------------- LONCAPA->answer_resource_request
sub answer_resource_request {
# Not yet implemented
# Need to specifically characterize INPUT arguments and OUTPUT data
}

1;

__END__

=pod

=head1 NAME

B<Apache::LONCAPA::ToTheGateway> - API for passing information from LONCAPA to the Gateway Server

=head1 SYNOPSIS

 use Apache::LONCAPA::ToTheGateway;

 my $arrayref=
    Apache::LONCAPA::ToTheGateway::answer_search_request
      ($search_request);

=head1 DESCRIPTION

This module contains functionality for
transferring information to LON-CAPA from the Gateway Server.

In terms of the overall data flow, the
'=====>' below indicates the role of this
module.

NSDL ---------E<gt> Gateway --------E<gt> LON-CAPA

B<LON-CAPA =====E<gt> Gateway> --------E<gt> NSDL

=head2 EXIT CODES

The subroutines of this module all output an exit code which
describes the status of function completion.  The exit code
may be followed by a more descriptive message such as:

 FORMATERROR:Sun May  5 20:15:16 GMT 2002:missing 'protocol://' pattern

=over 4

=item *

B<'SUCCESS'>, information was found and is being returned

=item *

B<'EMPTY'>, everything functioned properly, but no information was present

=item *

B<'BADEMPTY'>, everything appeared to function properly, but no information
was present (which defies expectation); this is useful for detecting phantom
cases of connectivity when verifying test cases of vertical software partitions

=item *

B<'TIMEOUT'>, the request is taking WAY too long

=item *

B<'FORMATERROR'>, the input argument is not formatted correctly in a way that
can be processed by the NSDL server

=item *

B<'CONNECTIONFAILURE'>, the NSDL server cannot be contacted

=back

=head2 SUBROUTINES

Note that the subroutines all output an exit code which
describes the status of function completion.

In the case of failed function completion, the other
output argument(s) will typically only be 'NULL' values.

=over 4

=item B<Apache::LONCAPA::answer_search_request>

=over 4

=item B<Input> - Scalar string

Memory location of Gateway Server results.

=item B<Output> - Scalar string, Scalar string reference

An exit code is returned as a scalar string.

View the Gateway Server results.

=item B<Description>

This facilitates the passing of LON-CAPA search results
B<This relates to information that has passed
from LON-CAPA I<to the> GATEWAY>.

=item B<Status of Implementation>

n/a

=back

=item B<Apache::LONCAPA::answer_metadata_record_request>

=over 4

=item B<Input> - Scalar string

Identifier for a specific LON-CAPA metadata record.

=item B<Output> - Scalar string, Scalar string reference

An exit code is returned as a scalar string.

A pointer to the metadata.

=item B<Description>

This provides the metadata of the resource matching a given identifier.
B<The information has passed from LONCAPA I<to the> GATEWAY>.

=item B<Status of Implementation>

n/a

=back

=item B<Apache::LONCAPA::answer_resource_request>

=over 4

=item B<Input> - Scalar string

Identifier for LON-CAPA resource.

=item B<Output> - Scalar string, Scalar string reference.

An exit code is returned as a scalar string.

Pointer to information about accessing LON-CAPA resource.

=item B<Description>

This gives access to a LON-CAPA resource.
B<The information has passed from LON-CAPA I<to the> GATEWAY>.

=item B<Status of Implementation>

n/a

=back

=back

=head1 README

B<Apache::LONCAPA::ToTheGateway>
is part of the NSDL-LONCAPA Gateway Server system.
Please see http://nsdl.lon-capa.org/ for more information.

=head1 AUTHOR

Scott Harrison, 2002

=head1 PREREQUISITES

This module requires the C<strict> module.

=head1 COREQUISITES

Apache::NSDL::FromTheGateway
Apache::NSDL::ToTheGateway
Apache::GATEWAY::ToNSDL
Apache::GATEWAY::FromNSDL
Apache::GATEWAY::ToLONCAPA
Apache::GATEWAY::FromLONCAPA
Apache::LONCAPA::FromTheGateway

=head1 SEE ALSO

http://www.lon-capa.org/

http://www.smete.org/

Also visit the other Apache::NSDL::*, Apache::LONCAPA::*,
and Apache::GATEWAY::* manpages.

=head1 OSNAMES

linux

=cut


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