[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Thu Nov 29 21:47:00 UTC 2007


kawas
Thu Nov 29 16:47:00 EST 2007
Update of /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies/Cache
In directory dev.open-bio.org:/tmp/cvs-serv32147/RDF/Ontologies/Cache

Modified Files:
	ServiceCache.pm 
Log Message:
added code that removes cached file segments when they no longer are deemed necessary
moby-live/Perl/MOBY/RDF/Ontologies/Cache ServiceCache.pm,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies/Cache/ServiceCache.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies/Cache/ServiceCache.pm	2007/11/29 18:03:05	1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies/Cache/ServiceCache.pm	2007/11/29 21:47:00	1.4
@@ -377,7 +377,9 @@
 		# check if we need to re-merge the RDF
 		my $isStale = $self->update_service_cache;
 		if ( $isStale or !( -e $file ) ) {
-
+			
+			my $providers = $self->_get_service_providers;
+			
 			# re-merge rdf
 			my $parser = XML::LibXML->new();
 			my $doc    = undef;
@@ -391,6 +393,8 @@
 				  if $RDF eq $self->{utils}->RDF_FILE
 				  or $RDF eq $self->{utils}->LIST_FILE
 				  or $RDF eq $self->{utils}->UPDATE_FILE;
+				#remove those authorities that dont have any services
+				unlink(File::Spec->catfile( $dir, $RDF )) unless $providers->{$RDF};  
 				do {
 					eval {
 						$doc =
@@ -435,6 +439,37 @@
 	return $xml;
 }
 
+sub _get_service_providers {
+	my ($self) = @_;
+	my $soap =    
+	  SOAP::Lite->uri( $self->{utils}->_namespace )
+	  ->proxy( $self->{utils}->_endpoint )->on_fault(
+		sub {
+			my $soap = shift;
+			my $res  = shift;
+			die(   "There was a problem calling the registry: "
+				 . $self->{utils}->_endpoint . "\@ "
+				 #. $self->{utils}->_namespace . ".\n"
+				 . $res );
+		}
+	  );
+
+	my $xml = $soap->retrieveServiceNames()->result;
+	my %providers = ();
+	
+	my $parser                = XML::LibXML->new();
+	my $doc                   = $parser->parse_string($xml);
+	my $nodes = $doc->documentElement()->getChildrenByTagName('serviceName');
+	for ( 1 .. $nodes->size() ) {
+		my $name = $nodes->get_node($_)->getAttribute('authURI');
+		next if $providers{$name};
+		$providers{$name} = 1;
+	}
+	
+	return \%providers;
+	
+}
+
 # creates the list file and returns it as a string
 sub _create_list_file {
 	my ($self) = @_;




More information about the MOBY-guts mailing list