This is "as easy as it gets", but the process can be much more complex if needed. This solution requires no modification of the DNS/SRV records, and runs as a simple HTTP GET CGI service for metadata resolution.
Here we go! :-)
*** A HELLO WORLD LSID AUTHORITY ***
*** authority.pl ***
#!/usr/bin/perl
use strict;
use warnings;
use LS::Service::Authority;
use LS::Service::DataService;
use LS::HTTP::Service;
use LS::SOAP::Service transport=> 'HTTP::CGI';
my $location = 'http://';
if($ENV{'HTTP_HOST'} ) {
$location .= $ENV{'HTTP_HOST'};
}
else {
$location .= 'localhost:8080';
}
# FIRST create the authority service
my $authority_service = LS::Service::Authority->new(
name=> 'Hello_World',
authority=> 'bioinfo.icapture.ubc.ca',
location=> $location);
# SECOND create an HTTP GET metadata port
# what comes in here will be:
# $location/authority/metadata?lsid=URN:LSID:blah.blah:nspace:id:version
my $metadata_port =
LS::Authority::WSDL::Simple::MetadataPort->newMetadata(
portName=> 'Hello_there_World',
endpoint=> "$location/authority/metadata",
protocol=> $LS::Authority::WSDL::Constants::Protocols::HTTP,
);
$authority_service->addPort(
serviceName=> 'Hello_World',
port=> $metadata_port);
my $authority_server = LS::SOAP::Service->new();
$authority_server->authorityService($authority_service);
my $http_authority = LS::HTTP::Service->new();
$http_authority->dispatch_authority_to($authority_service);
$authority_server->httpServer($http_authority);
$authority_server->dispatch();
***** HELLO WORLD LSID METADATA SERVER *****
***** metadata.pl ******
#!/usr/bin/perl
use CGI qw/:all/;
my $C = CGI->new;
use strict;
use warnings;
use LS::ID;
use LS::Service::Response;
use LS::Service::Fault;
use LS::RDF::SimpleDocument;
my $lsid = param('lsid');
my $format = param('format') || "text/xml";
print header(-type => $format);
print getMetadata($lsid)->response;
sub getMetadata {
my ($lsid, $format) = @_;
$lsid = LS::ID->new($lsid);
$lsid = $lsid->canonical();
my $id = $lsid->object();
$id .= ':' . $lsid->revision() if($lsid->revision());
return LS::Service::Fault->serverFault(
'Can not do what I cannot do', 500)
unless($id);
# Create a new RDF Document to add triples
my $rdfDoc = LS::RDF::SimpleDocument->new();
return LS::Service::Fault->serverFault(
'Internal error, unable to initialize RDF document', 500)
unless($rdfDoc);
return LS::Service::Fault->fault('Unknown LSID')
unless(1); # whatever conditions you want...
$rdfDoc->addTripleLiteral(
$lsid->as_string(),
'http://purl.org/dc/elements/1.1/#title',
"Hello World");
$rdfDoc->addTripleResource(
$lsid->as_string(),
'urn:lsid:example.com:predicates:another_lsid',
'urn:lsid:biomoby.org:objectclass:DNASequence');
$format = 'application/xml' if(!$format);
return LS::Service::Response->new(
response=> '' .
$rdfDoc->output(),
format=> $format);
}
***** APACHE Server Config ******
***** add these lines to your httpd.conf file ****
ScriptAlias /authority/metadata "/usr/local/apache2/LSID/metadata.pl"
ScriptAlias /authority "/usr/local/apache2/LSID/authority.pl"
<Directory /usr/local/apache2/LSID>
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
*** now put your files in the right place
Create a folder /usr/local/apache2/LSID/
save authority.pl to that folder
save metadata.pl to that folder
(get the permissions right!)
DONE!
You now have an LSID authority and metadata resolver! Enjoy!
No comments:
Post a Comment