[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Tue Jun 15 00:09:37 UTC 2004
mwilkinson
Mon Jun 14 20:09:36 EDT 2004
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv11678
Modified Files:
Central.pm Central.html
Log Message:
modified the way Central gets its configuration. Also fixed a bug that allowed object names to be registered with spaces
moby-live/Perl/MOBY Central.pm,1.127,1.128 Central.html,1.13,1.14
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2004/04/20 23:24:25 1.127
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2004/06/15 00:09:36 1.128
@@ -18,6 +18,7 @@
use MOBY::authority;
use MOBY::service_instance;
use MOBY::central_db_connection;
+use MOBY::Config;
my $debug = 0;
@@ -72,6 +73,43 @@
Servers/Services, or queryiong for available services given certain input/output
or service type constraints.
+=cut
+
+
+=head1 CONFIGURATION
+
+This depends on a config file to get its database connection information. At a minimum
+this config file must have the following clause:
+
+ [mobycentral]
+ url = some.url
+ username = foo
+ password = bar
+ port = portnumber
+ dbname = mobycentral
+
+
+The space before and after the '=' is critical.
+
+The end of a clause is indicated by a blank line.
+
+Additional identically formatted clauses may be added for each of:
+
+ [mobyobject]
+ [mobynamespace]
+ [mobyservice]
+ [mobyrelationship]
+
+if these ontologies are being served from a local database (via the
+OntologyServer module). These clauses will be read by the OntologyServer
+module if they are present, otherwise default connections will be made
+to the MOBY Central ontology server.
+
+The config file must be readable by the webserver, and the webserver
+environment should include the following ENV variable:
+
+$ENV{MOBY_CENTRAL_CONFIG} = /path/to/config/file.name
+
=head1 AUTHORS
@@ -141,21 +179,20 @@
}
sub _dbAccess {
-
-# this configuration system was stoopid and is now defunkt.
-
-# my $filename = "./MOBY/central.cfg";# $self->config;
-# $debug && &_LOG("trying to open file $filename\n");
-# open (IN, $filename) || die "can't open configuration file $filename: $!";
-# my $url = <IN>; chomp $url;
-# my $dbname = <IN>; chomp $dbname;
-# my $username = <IN>; chomp $username;
-# my $password = <IN>; chomp $password;
- my $url = $ENV{MOBY_CENTRAL_URL}; chomp $url;
- my $dbname = $ENV{MOBY_CENTRAL_DBNAME}; chomp $dbname;
- my $username = $ENV{MOBY_CENTRAL_DBUSER}; chomp $username;
- my $password = $ENV{MOBY_CENTRAL_DBPASS}; chomp $password;
- my $port = $ENV{MOBY_CENTRAL_DBPORT}; chomp $port;
+
+ my $conf = MOBY::Config->new;
+
+ $username = $conf->{mobycentral}->{username};
+ $password = $conf->{mobycentral}->{password};
+ $port = $conf->{mobycentral}->{port};
+ $dbname = $conf->{mobycentral}->{dbname};
+ $url = $conf->{mobycentral}->{url};
+
+ #my $url = $ENV{MOBY_CENTRAL_URL}; chomp $url;
+ #my $dbname = $ENV{MOBY_CENTRAL_DBNAME}; chomp $dbname;
+ #my $username = $ENV{MOBY_CENTRAL_DBUSER}; chomp $username;
+ #my $password = $ENV{MOBY_CENTRAL_DBPASS}; chomp $password;
+ #my $port = $ENV{MOBY_CENTRAL_DBPORT}; chomp $port;
my ($dsn) = "DBI:mysql:$dbname:$url:$port";
my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database";
@@ -237,6 +274,10 @@
return &_error("Malformed authURI - must not have an http:// prefix","") if $auth =~ '[/:]';
return &_error("Malformed authURI - must take the form NNN.NNN.NNN","") unless $auth =~ /\./;
return &_error("Malformed email - must be a valid email address of the form name\@organization.foo","") unless $email =~ /\S\@\S+\.\S+/;
+ return &_error("Object name may not contain spaces or other characters invalid in a URN","") if $term =~ /\s\"\&\<\>\[\]\^\`\{\|\}\~/;
+ if ($term =~ m"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?"){ # matches a URI
+ return &_error("Object name may not be an URN or URI","") if $1;
+ }
# validate that the final ontology will be valid by testing against existing relationships and such
while (my ($reltype, $obj) = each %{$relationships}){
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.html,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- /home/repository/moby/moby-live/Perl/MOBY/Central.html 2004/04/15 14:38:22 1.13
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.html 2004/06/15 00:09:36 1.14
@@ -15,6 +15,7 @@
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
+ <li><a href="#configuration">CONFIGURATION</a></li>
<li><a href="#authors">AUTHORS</a></li>
<li><a href="#registration_xml_object">Registration XML Object</a></li>
<li><a href="#methods">METHODS</a></li>
@@ -107,6 +108,34 @@
<p>
</p>
<hr />
+<h1><a name="configuration">CONFIGURATION</a></h1>
+<p>This depends on a config file to get its database connection information. At a minimum
+this config file must have the following clause:</p>
+<pre>
+ [mobycentral]
+ url = some.url
+ username = foo
+ password = bar
+ port = portnumber
+ dbname = mobycentral</pre>
+<p>The space before and after the '=' is critical.</p>
+<p>The end of a clause is indicated by a blank line.</p>
+<p>Additional identically formatted clauses may be added for each of:</p>
+<pre>
+ [mobyobject]
+ [mobynamespace]
+ [mobyservice]
+ [mobyrelationship]</pre>
+<p>if these ontologies are being served from a local database (via the
+OntologyServer module). These clauses will be read by the OntologyServer
+module if they are present, otherwise default connections will be made
+to the MOBY Central ontology server.</p>
+<p>The config file must be readable by the webserver, and the webserver
+environment should include the following ENV variable:</p>
+<p>$ENV{MOBY_CENTRAL_CONFIG} = /path/to/config/file.name</p>
+<p>
+</p>
+<hr />
<h1><a name="authors">AUTHORS</a></h1>
<p>Mark Wilkinson (<a href="mailto:markw at illuminae.com">markw at illuminae.com</a>)</p>
<p>BioMOBY Project: <a href="http://www.biomoby.org">http://www.biomoby.org</a></p>
More information about the MOBY-guts
mailing list