[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at dev.open-bio.org
Mon Nov 26 23:00:36 UTC 2007


mwilkinson
Mon Nov 26 18:00:35 EST 2007
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory dev.open-bio.org:/tmp/cvs-serv18260/MOBY/Client

Modified Files:
	Central.pm OntologyServer.pm 
Log Message:
Perl code now scraping current location of default MOBY Central from the 301 Redirect headers from biomoby.org
moby-live/Perl/MOBY/Client Central.pm,1.152,1.153 OntologyServer.pm,1.17,1.18
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -r1.152 -r1.153
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2007/09/14 17:23:47	1.152
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2007/11/26 23:00:35	1.153
@@ -143,12 +143,8 @@
 	  (
 		Connections             => [ undef,         'read/write' ],
 		default_MOBY_servername => [ 'mobycentral', 'read/write' ],
-		default_MOBY_server     => [			
-'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl',
-			'read/write'
-		],
-		default_MOBY_uri =>
-		  [ 'http://mobycentral.icapture.ubc.ca/MOBY/Central', 'read/write' ],
+		default_MOBY_server     => [ '',		'read/write'],
+		default_MOBY_uri 	=> [ 'http://biomoby.org/MOBY/Central', 'read/write' ],
 		default_MOBY_proxy  => [ undef,  'read/write' ],
 		default_MOBY_type   => [ 'soap', 'read/write' ],
 		Registries          => [ undef,  'read/write' ],
@@ -263,7 +259,11 @@
   }
   $self->Connections( [] );    # initialize;
   
+  my ($central, $ontologyserver) = _getDefaultCentral();
+  $self->default_MOBY_server($central) if $central;
+
   # if user has set up preferred servers, then use those by default
+
   $self->default_MOBY_server( $ENV{MOBY_SERVER} ) if $ENV{MOBY_SERVER};
   $self->default_MOBY_uri( $ENV{MOBY_URI} )       if $ENV{MOBY_URI};
   $self->default_MOBY_type( $ENV{MOBY_TYPE} )     if $ENV{MOBY_TYPE};
@@ -358,6 +358,23 @@
   return $self;
 }
 
+
+sub _getDefaultCentral {
+
+	use LWP::UserAgent;
+	use HTTP::Request::Common qw(HEAD);
+ 
+	my $ua = LWP::UserAgent->new;
+	my $req = HEAD 'http://biomoby.org/mobycentral';
+	my $res = $ua->simple_request($req);
+	my $mobycentral = $res->header('location');
+ 
+	$req = HEAD 'http://biomoby.org/ontologyserver';
+	$res = $ua->simple_request($req);
+	my $ontologyserver = $res->header('location');
+	return ($mobycentral, $ontologyserver);
+}
+
 =head2 registerObject  a.k.a registerObjectClass
 
  Usage     :	$REG = $MOBY->registerObject(%args)

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm	2007/01/25 17:15:13	1.17
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm	2007/11/26 23:00:35	1.18
@@ -85,10 +85,7 @@
 	#ATTRIBUTES
 	my %_attr_data =    #     				DEFAULT    	ACCESSIBILITY
 	  (
-		host => [
-				  "http://mobycentral.icapture.ubc.ca/cgi-bin/OntologyServer.cgi",
-				  'read/write'
-		],
+		host => ['' ,'read/write'],
 		proxy => [ undef, 'read/write' ],
 	  );
 
@@ -126,11 +123,24 @@
 			$self->{$attrname} = $self->_default_for( $attrname );
 		}
 	}
-	$self->host($ENV{MOBY_ONTOLOGYSERVER}) if ($ENV{MOBY_ONTOLOGYSERVER});
+	my ($ontologyserver) = _getOntologyServer();  # get default from moby central
+        $self->host($ontologyserver) if $ontologyserver;
+	$self->host($ENV{MOBY_ONTOLOGYSERVER}) if ($ENV{MOBY_ONTOLOGYSERVER});  # override with user preference if set in their environment
 	return undef unless $self->host;
 	return $self;
 }
 
+
+sub _getOntologyServer {
+	use LWP::UserAgent;
+	use HTTP::Request::Common qw(HEAD);
+ 	my $ua = LWP::UserAgent->new;
+	my $req = HEAD 'http://biomoby.org/ontologyserver';
+	my $res = $ua->simple_request($req);
+	my $ontologyserver = $res->header('location');
+	return $ontologyserver;
+}
+
 =head2 objectExists
 
 =cut




More information about the MOBY-guts mailing list