[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Wed Nov 7 18:06:38 UTC 2007
kawas
Wed Nov 7 13:06:38 EST 2007
Update of /home/repository/moby/moby-live/Perl/scripts
In directory dev.open-bio.org:/tmp/cvs-serv15066
Modified Files:
authority.pl
Log Message:
added code to allow for the data resolution of service instances
moby-live/Perl/scripts authority.pl,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/authority.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/scripts/authority.pl 2007/08/14 23:28:09 1.2
+++ /home/repository/moby/moby-live/Perl/scripts/authority.pl 2007/11/07 18:06:38 1.3
@@ -1,167 +1,185 @@
-#!/usr/bin/perl -w
-#-----------------------------------------------------------------
-# authority.pl
-# Author: Edward Kawas <edward.kawas at gmail.com>,
-# For copyright and disclaimer see below.
-#
-# $Id$
-#-----------------------------------------------------------------
-
-use strict;
-use warnings;
-
-use MOBY::lsid::authority::MobyMetadataResolver;
-
-use LS::ID;
-
-use LS::Service::Fault;
-use LS::Service::Response;
-use LS::Service::Authority;
-use LS::Service::Namespace;
-use LS::Service::DataService;
-use LS::Service::AdvancedDataService;
-
-use LS::HTTP::Service;
-use LS::RDF::SimpleDocument;
-
-#
-# The SOAP service will travel over HTTP to this mod_perl based
-# authority where all of the SOAP messages are decoded and
-# passed up the SOAP stack until they reach this framework
-#
-# UNTESTED: The package defaults to HTTP:CGI which works in most
-# cases.
-#
-#use LS::SOAP::Service transport=> 'HTTP::Apache';
-use LS::SOAP::Service transport => 'HTTP::CGI';
-
-##############
-
-my $location = 'http://';
-
-# TODO get this from the mobyconfig file
-if ( $ENV{'HTTP_HOST'} ) {
-
- $location .= $ENV{'HTTP_HOST'};
-}
-else {
-
- # Set this to the default hostname for the authority
- $location .= 'localhost:8080';
-}
-
-# Create the authority service
-my $authority = LS::Service::Authority->new(
- name => 'BioMOBY',
- authority => 'biomoby.org',
- location => $location,
- getAvailableServices => \&dynamic_ops
-);
-
-#
-# Add two ports to the authority:
-#
-# 1. A HTTP Location for the metadata
-#
-# 2. A SOAP location for the metadata
-#
-
-my $port;
-
-$port = LS::Authority::WSDL::Simple::MetadataPort->newMetadata(
- portName=> 'BioMOBYSoapPort',
- endpoint=> "$location/authority/metadata",
- protocol=> $LS::Authority::WSDL::Constants::Protocols::SOAP,
- );
-$authority->addPort(serviceName=> 'BioMOBY', port=> $port);
-
-$port = LS::Authority::WSDL::Simple::MetadataPort->newMetadata(
- portName=> 'BioMOBYHttpPort',
- endpoint=> "$location/authority/metadata",
- protocol=> $LS::Authority::WSDL::Constants::Protocols::HTTP,
- );
-$authority->addPort(serviceName=> 'BioMOBY', port=> $port);
-
-
-
-# Add the metadata service with namespaces
-
-# we will handle 4 namespaces ... namespacetype, serviceinstance, servicetype and objectclass.
-#TODO add the other predicates ...
-my $metadata = LS::Service::DataService->new();
-$metadata->addNamespace( MobyNamespaceType->new() );
-$metadata->addNamespace( MobyServiceInstance->new() );
-$metadata->addNamespace( MobyServiceType->new() );
-$metadata->addNamespace( MobyObjectClass->new() );
-
-my $moby_authority_service = LS::SOAP::Service->new();
-
-$moby_authority_service->metadata_service($metadata);
-$moby_authority_service->data_service($metadata);
-$moby_authority_service->authority_service($authority);
-
-#
-# Create a HTTP service and instruct the SOAP service to
-# accept HTTP queries
-#
-my $moby_http_service = LS::HTTP::Service->new();
-$moby_http_service->dispatch_authority_to($authority);
-$moby_http_service->dispatch_metadata_to($metadata);
-
-$moby_authority_service->http_server($moby_http_service);
-
-$moby_authority_service->dispatch();
-
-#
-# This adds a HTTP/CGI metadata port to the returned WSDL for each valid
-# LSID
-#
-sub dynamic_ops {
-
-# if the namespace is serviceinstance, get the signatureURL and add it as a location
- my ( $lsid, $wsdl ) = @_;
- my %valid_namespaces = (
- "namespacetype" => 1,
- "serviceinstance" => 1,
- "objectclass" => 1,
- "servicetype" => 1
- );
- my $namespace = $lsid->namespace();
- my $object = $lsid->object();
-
- return LS::Service::Fault->fault('Unknown LSID')
- unless ( $valid_namespaces{$namespace} );
-
-# need to decide whether or not i should check exisitence here as well as in the MobyMetadataResolver.pm ...
- my $port;
-
- do {
- my $length = length($object);
- # some error conditions
- if ( $length > 0 and index( $object, ',' ) > 0 ) {
- my $servicename =
- substr( $object, index( $object, ',' ) + 1, $length );
- my $authURI = substr( $object, 0, index( $object, ',' ) );
-
- my $moby = MOBY::Client::Central->new();
- my ( $services, $RegObject ) = $moby->findService(
- authURI => $authURI,
- serviceName => $servicename
- );
- foreach my $SI (@$services) {
- #should only be one of them ...
- $port = LS::Authority::WSDL::Simple::MetadataPort->newMetadata(
- portName => 'HTTPMetadata',
- endpoint => $SI->signatureURL,
- protocol => $LS::Authority::WSDL::Constants::Protocols::HTTP,
- );
- $wsdl->addPort(
- serviceName => 'ServiceProviderMetadataHTTPPort',
- port => $port
- );
- }
- }
- } if ( $namespace eq 'serviceinstance' );
- return $wsdl;
-}
-__END__
+#!/usr/bin/perl -w
+#-----------------------------------------------------------------
+# authority.pl
+# Author: Edward Kawas <edward.kawas at gmail.com>,
+# For copyright and disclaimer see below.
+#
+# $Id$
+#-----------------------------------------------------------------
+
+use strict;
+use warnings;
+
+use MOBY::lsid::authority::MobyMetadataResolver;
+
+use LS::ID;
+
+use LS::Service::Fault;
+use LS::Service::Response;
+use LS::Service::Authority;
+use LS::Service::Namespace;
+use LS::Service::DataService;
+use LS::Service::AdvancedDataService;
+
+use LS::HTTP::Service;
+use LS::RDF::SimpleDocument;
+
+#
+# The SOAP service will travel over HTTP to this mod_perl based
+# authority where all of the SOAP messages are decoded and
+# passed up the SOAP stack until they reach this framework
+#
+# UNTESTED: The package defaults to HTTP:CGI which works in most
+# cases.
+#
+#use LS::SOAP::Service transport=> 'HTTP::Apache';
+use LS::SOAP::Service transport => 'HTTP::CGI';
+
+##############
+
+my $location = 'http://';
+
+# TODO get this from the mobyconfig file
+if ( $ENV{'HTTP_HOST'} ) {
+
+ $location .= $ENV{'HTTP_HOST'};
+}
+else {
+
+ # Set this to the default hostname for the authority
+ $location .= 'localhost:8080';
+}
+
+# Create the authority service
+my $authority = LS::Service::Authority->new(
+ name => 'BioMOBY',
+ authority => 'biomoby.org',
+ location => $location,
+ getAvailableServices => \&dynamic_ops
+);
+
+#
+# Add two ports to the authority:
+#
+# 1. A HTTP Location for the metadata
+#
+# 2. A SOAP location for the metadata
+#
+# 3. A HTTP Location for the data
+#
+# 4. A SOAP location for the data
+#
+
+my $port;
+
+$port = LS::Authority::WSDL::Simple::MetadataPort->newMetadata(
+ portName=> 'BioMOBYSoapPort',
+ endpoint=> "$location/authority/metadata",
+ protocol=> $LS::Authority::WSDL::Constants::Protocols::SOAP,
+ );
+$authority->addPort(serviceName=> 'BioMOBY', port=> $port);
+
+$port = LS::Authority::WSDL::Simple::MetadataPort->newMetadata(
+ portName=> 'BioMOBYHttpPort',
+ endpoint=> "$location/authority/metadata",
+ protocol=> $LS::Authority::WSDL::Constants::Protocols::HTTP,
+ );
+$authority->addPort(serviceName=> 'BioMOBY', port=> $port);
+
+#data ports
+$port = LS::Authority::WSDL::Simple::DataPort->newData(
+ portName=> 'BioMOBYHttpPort',
+ endpoint=> "$location/authority/data",
+ protocol=> $LS::Authority::WSDL::Constants::Protocols::HTTP,
+ );
+
+$authority->addPort(serviceName=> 'BioMOBY', port=> $port);
+$port = LS::Authority::WSDL::Simple::DataPort->newData(
+ portName=> 'BioMOBYSoapPort',
+ endpoint=> "$location/authority/data",
+ protocol=> $LS::Authority::WSDL::Constants::Protocols::SOAP,
+ );
+$authority->addPort(serviceName=> 'BioMOBY', port=> $port);
+
+
+# Add the metadata service with namespaces
+
+# we will handle 4 namespaces ... namespacetype, serviceinstance, servicetype and objectclass.
+#TODO add the other predicates ...
+my $metadata = LS::Service::DataService->new();
+$metadata->addNamespace( MobyNamespaceType->new() );
+$metadata->addNamespace( MobyServiceInstance->new() );
+$metadata->addNamespace( MobyServiceType->new() );
+$metadata->addNamespace( MobyObjectClass->new() );
+
+my $moby_authority_service = LS::SOAP::Service->new();
+
+$moby_authority_service->metadata_service($metadata);
+$moby_authority_service->data_service($metadata);
+$moby_authority_service->authority_service($authority);
+
+#
+# Create a HTTP service and instruct the SOAP service to
+# accept HTTP queries
+#
+my $moby_http_service = LS::HTTP::Service->new();
+$moby_http_service->dispatch_authority_to($authority);
+$moby_http_service->dispatch_metadata_to($metadata);
+
+$moby_authority_service->http_server($moby_http_service);
+
+$moby_authority_service->dispatch();
+
+#
+# This adds a HTTP/CGI metadata port to the returned WSDL for each valid
+# LSID
+#
+sub dynamic_ops {
+
+# if the namespace is serviceinstance, get the signatureURL and add it as a location
+ my ( $lsid, $wsdl ) = @_;
+ my %valid_namespaces = (
+ "namespacetype" => 1,
+ "serviceinstance" => 1,
+ "objectclass" => 1,
+ "servicetype" => 1
+ );
+ my $namespace = $lsid->namespace();
+ my $object = $lsid->object();
+
+ return LS::Service::Fault->fault('Unknown LSID')
+ unless ( $valid_namespaces{$namespace} );
+
+# need to decide whether or not i should check exisitence here as well as in the MobyMetadataResolver.pm ...
+ my $port;
+
+ do {
+ my $length = length($object);
+ # some error conditions
+ if ( $length > 0 and index( $object, ',' ) > 0 ) {
+ my $servicename =
+ substr( $object, index( $object, ',' ) + 1, $length );
+ my $authURI = substr( $object, 0, index( $object, ',' ) );
+
+ my $moby = MOBY::Client::Central->new();
+ my ( $services, $RegObject ) = $moby->findService(
+ authURI => $authURI,
+ serviceName => $servicename
+ );
+ foreach my $SI (@$services) {
+ #should only be one of them ...
+ $port = LS::Authority::WSDL::Simple::MetadataPort->newMetadata(
+ portName => 'HTTPMetadata',
+ endpoint => $SI->signatureURL,
+ protocol => $LS::Authority::WSDL::Constants::Protocols::HTTP,
+ );
+ $wsdl->addPort(
+ serviceName => 'ServiceProviderMetadataHTTPPort',
+ port => $port
+ );
+ }
+ }
+ } if ( $namespace eq 'serviceinstance' );
+ return $wsdl;
+}
+__END__
More information about the MOBY-guts
mailing list