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