[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Wed Nov 7 18:04:56 UTC 2007
kawas
Wed Nov 7 13:04:55 EST 2007
Update of /home/repository/moby/moby-live/Perl/MOBY/lsid/authority
In directory dev.open-bio.org:/tmp/cvs-serv15023
Modified Files:
MobyMetadataResolver.pm
Log Message:
updated this module to include a getData call for service instances. Should probably move it to a different module considering the name of the this module suggests methods for metadata resolution
moby-live/Perl/MOBY/lsid/authority MobyMetadataResolver.pm,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/MobyMetadataResolver.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/MobyMetadataResolver.pm 2007/07/17 17:25:39 1.1
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/MobyMetadataResolver.pm 2007/11/07 18:04:55 1.2
@@ -654,7 +654,8 @@
use LS::ID;
use LS::Service::Response;
use LS::Service::Fault;
-
+use MOBY::Client::Service;
+use MOBY::Client::Central;
use MOBY::Config;
use MOBY::RDF::Ontologies::Services;
@@ -704,6 +705,102 @@
}
#-----------------------------------------------------------------
+# getData
+#-----------------------------------------------------------------
+
+=head2 getData
+
+This subroutine is the handler that actually performs
+the action when getData is called on an LSID under this namespace
+
+This routine has 2 parameters:
+ lsid - the LSID
+ format - output format <optional>
+
+ Example: getData(LS::ID->new('urn:lsid:authority:namespace:object'));
+
+A LS::Service::Response is returned if getData is successful.
+
+=cut
+
+sub getData {
+
+ my ( $self, $lsid, $format ) = @_;
+ $lsid = $lsid->canonical();
+ my $length = length( $lsid->object() );
+
+ # some error conditions
+ return LS::Service::Fault->fault('malformed LSID') unless $length > 0;
+ return LS::Service::Fault->fault('malformed LSID')
+ unless index( $lsid->object(), ',' ) > 0;
+
+ my $servicename =
+ substr( $lsid->object(), index( $lsid->object(), ',' ) + 1, $length );
+ my $authURI = substr( $lsid->object(), 0, index( $lsid->object(), ',' ) );
+
+ return LS::Service::Fault->fault('Unknown LSID')
+ unless (
+ $self->lsidExists(
+ $lsid->namespace, $lsid->object, $lsid->revision
+ )
+ );
+
+ my $latest =
+ $self->isLatest( $lsid->namespace, $lsid->object,
+ $lsid->revision );
+ do {
+ my $data = MOBY::RDF::Ontologies::Services->new;
+ $format = 'application/xml' if ( !$format );
+ my $wsdl = $self->_getServiceWSDL($authURI, $servicename);
+ print STDERR $wsdl;
+ return LS::Service::Response->new(
+ response => $wsdl,
+ format => $format
+ );
+ } unless $latest;
+
+ return LS::Service::Fault->serverFault( 'Unable to load Data', 600 )
+ if ( $latest eq "" );
+
+ $format = 'text/plain';
+ return LS::Service::Response->new(
+ response => "",
+ format => $format
+ );
+
+
+}
+#-----------------------------------------------------------------
+# _getServiceWSDL
+#-----------------------------------------------------------------
+
+=head2 _getServiceWSDL
+
+This subroutine obtains the wsdl for moby services given the name/auth
+combination. It uses the registry that is set in the enviroment.
+TODO - might have to change this behaviour, if we think of a good
+reason!
+
+=cut
+
+sub _getServiceWSDL {
+ my ( $self, $authority, $servicename ) = @_;
+ my $moby = MOBY::Client::Central->new();
+ my ( $services, $RegObject ) = $moby->findService(
+ authURI => $authority,
+ serviceName => $servicename
+ );
+ unless ($services && @{$services}[0] ) {
+ return "";
+ };
+ # should only be one ...
+ foreach my $ServiceInstance ( @{ $services } ) {
+ return $moby->retrieveService($ServiceInstance);
+ }
+ return ""
+}
+
+#-----------------------------------------------------------------
# getMetadata
#-----------------------------------------------------------------
More information about the MOBY-guts
mailing list