[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Wed Mar 22 21:38:58 UTC 2006
mwilkinson
Wed Mar 22 16:38:58 EST 2006
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv7408/Perl/MOBY
Modified Files:
service_instance.pm
Log Message:
dueling code with Eddie. This version validates the structure of an incoming LSID prior to creating the service instance, rather than imposing our structure on the LSID. The only part that is imposed is the timestamp, which we have promised in our RFC will have a particular format. Services that attempt to register with an LSID that is incorrectly formatted will fail - service_instance returns undef, MOBY::Central returns failure registration object. Unfortunately, at the moment service_instance.pm has no way of passing back the REASON for the failure, so it may be a bit cryptic to the person trying to register the service....
moby-live/Perl/MOBY service_instance.pm,1.38,1.39
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2006/03/22 02:51:30 1.38
+++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2006/03/22 21:38:58 1.39
@@ -182,7 +182,10 @@
}
return undef unless $self->authority_uri;
return undef unless $self->servicename;
-
+ if( $self->lsid){
+ my $l = $self->lsid; # but is LSID valid format?
+ return undef unless $l =~ m'urn\:lsid\:[^:/?#\.]+(\.[^:/?#\.]+)+\:[^:/?#\.]+\:[^:/?#\.]+\:\d\d\-\d\d\-\d\dT\d\d\-\d\d\-\d\d';
+ }
if ( $self->test ) { return $self->service_instance_exists } # returns boolean
$self->authority( $self->_get_authority() ); # as MOBY::authority object
@@ -230,32 +233,16 @@
#create LSID for service and register it in the DB
my $_config ||= MOBY::Config->new;
- if ($self->lsid){
- # we were passed in an LSID, so lets construct a correct one and append the revision
- use LS::ID;
- my $LSID_Auth = $_config->{mobycentral}->{lsid_authority};
- my $LSID_NS = $_config->{mobycentral}->{lsid_namespace};
- $LSID_Auth ||="biomoby.org";
- $LSID_NS ||="serviceinstance";
- my $rev = "";
- my $service_lsid = "urn:lsid:$LSID_Auth:$LSID_NS:"
- . $self->authority_uri . ","
- . $self->servicename.":";
- # create a new lsid
- my $lsid = LS::ID->new($self->lsid);
- # ensure that the lsid was valid syntacticly
- return undef unless $lsid;
- $rev = $lsid->_revision;
- return undef unless $rev;
- $self->lsid($service_lsid . $rev);
- } else {
+ unless ($self->lsid){
# create an LSID if one wasnt passed in
my $LSID_Auth = $_config->{mobycentral}->{lsid_authority};
my $LSID_NS = $_config->{mobycentral}->{lsid_namespace};
$LSID_Auth ||="biomoby.org";
$LSID_NS ||="serviceinstance";
+
+# TODO - # MOBY Central should validate the format of authority uri and servicename when it starts up, sice we are using them to construct LSID's
my $service_lsid = "urn:lsid:$LSID_Auth:$LSID_NS:"
- . $self->authority_uri . ","
+ . $self->authority_uri . ","
. $self->servicename.":"."$date"; # LSID with timestamp
$self->lsid($service_lsid);
}
More information about the MOBY-guts
mailing list