[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Thu May 8 15:08:04 UTC 2003


mwilkinson
Thu May  8 11:08:03 EDT 2003
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv996/Perl/MOBY

Modified Files:
	Central.pm service_instance.pm 
Log Message:
fixed deregistration of services - they were being createdif they didn't exist... bonehead
moby-live/Perl/MOBY Central.pm,1.22,1.23 service_instance.pm,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm	2003/05/08 14:10:28	1.22
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm	2003/05/08 15:08:03	1.23
@@ -1487,18 +1487,15 @@
 									  });
 	}
 
-	my $SERVICE = MOBY::service_instance->new(
-		servicename => $serviceName,
-		authority_uri => $authURI);
-	
-	unless (defined $SERVICE){
+
+	unless (MOBY::service_instance->new(servicename => $serviceName, authority_uri => $authURI, test => 1)){
 		return &Registration({
 				success => 0,
 				error_message => "The service specified by authority=$authURI servicename=$serviceName does not exist in the registry",
 				registration_id => 0,
 							   });
 	}	
-
+	my $SERVICE = MOBY::service_instance->new(servicename => $serviceName, authority_uri => $authURI);
 	my $result = $SERVICE->DELETE_THYSELF;
 	
 	if ($result){

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm	2003/05/07 19:20:27	1.1
+++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm	2003/05/08 15:08:03	1.2
@@ -73,6 +73,7 @@
                     authoritative => [0,      'read/write'],
                     description   => [undef,      'read/write'],
                     registry		=> ['MOBY_Central', 		'read/write'],
+                    test      => [0,      'read/write'],  # toggles create or test_existence behaviour
                     
                     username => ["mobycentral",         'read/write'],
                     password => ["mobycentral",         'read/write'],        
@@ -182,12 +183,15 @@
 #		authoritative => $authoritativeService,
 #		description => $desc,
 #
-    return 0 unless $self->authority_uri;
-    return 0 unless $self->servicename;
+    return undef unless $self->authority_uri;
+    return undef unless $self->servicename;
     
     $self->_dbh();
-    return 0 unless $self->dbh;
+    return undef unless $self->dbh;
     my $dbh = $self->dbh;
+
+    if ($self->test){ return $self->service_instance_exists}
+
     $self->authority($self->_get_authority());
     
     if ($self->service_type){
@@ -278,11 +282,23 @@
     return 1;    
 }
 
+
 sub authority_id {
     my ($self) = @_;
     return $self->authority->authority_id;
 }
 
+sub service_instance_exists {
+    my ($self) = @_;
+    my $dbh = $self->dbh;
+    my $authority;
+    my ($id) = $dbh->selectrow_array(q{select authority_id from authority where authority_uri = ?},undef,$self->authority_uri);
+    return undef unless $id;
+    my ($svc) = $dbh->selectrow_array(q{select service_instance_id from service_instance where authority_id = ? and servicename = ?}, undef, ($id, $self->servicename));
+    return $svc;
+}
+    
+    
 sub _get_authority {
     my ($self) = @_;
     my $dbh = $self->dbh;




More information about the MOBY-guts mailing list