[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Thu Jan 15 20:59:39 UTC 2004


mwilkinson
Thu Jan 15 15:59:38 EST 2004
Update of /home/repository/moby/moby-live/Perl/MOBY/lsid/authority
In directory pub.open-bio.org:/tmp/cvs-serv27404/authority

Modified Files:
	ClassResolver.pm Error.pm NamespaceResolver.pm 
	PredicateResolver.pm RDFConfigure.pm RelationshipResolver.pm 
	ServiceInstanceResolver.pm ServiceResolver.pm 
	lsid_resolver.kpf metadata.pl 
Log Message:
updating all metadata resolvers with correct error codes according to the I3C

moby-live/Perl/MOBY/lsid/authority ClassResolver.pm,1.3,1.4 Error.pm,1.2,1.3 NamespaceResolver.pm,1.3,1.4 PredicateResolver.pm,1.2,1.3 RDFConfigure.pm,1.2,1.3 RelationshipResolver.pm,1.3,1.4 ServiceInstanceResolver.pm,1.2,1.3 ServiceResolver.pm,1.3,1.4 lsid_resolver.kpf,1.1,1.2 metadata.pl,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ClassResolver.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ClassResolver.pm	2004/01/11 03:50:31	1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ClassResolver.pm	2004/01/15 20:59:38	1.4
@@ -19,7 +19,7 @@
     my ($class_db_params, $ls) = @_;
 	my $lsid= LS::ID->new($ls)->canonical;
 	unless ($lsid) {
-		_die('Malformed LSID', 200);
+		_die('MALFORMED_LSID');
 	}
 
 	my $authority= $lsid->authority;
@@ -34,7 +34,7 @@
     $sth->execute($lsid);
     my ($object_type, $description, $authURI, $contact_email) = $sth->fetchrow_array;
     unless ($object_type){
-        _die('LSID Does not exist', 404);
+        _die('UNKNOWN_LSID');
     }
 
     # LSID is now fully validated.  Carry on with metadata.
@@ -74,7 +74,7 @@
     $RDF_SUFFIX?1:1;
 
 	unless ($mdata) {
-		_die ('Metadata not available', 300);
+		_die ('NO_METADATA_AVAILABLE');
 	}
 	return $mdata;
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/Error.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/Error.pm	2004/01/11 02:30:58	1.2
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/Error.pm	2004/01/15 20:59:38	1.3
@@ -1,8 +1,91 @@
 #$Id$
 package MOBY::lsid::authority::Error;
+use base 'Exporter';
+require Exporter;
+my %errors = (
+    200, 'MALFORMED_LSID',
+    #A syntactically invalid LSID provided.
+    201, 'UNKNOWN_LSID',
+    #An unknown LSID provided.
+    202, 'CANNOT_ASSIGN_LSID',
+    #No LSID can be created from the given properties.
+
+    #Error codes dealing with data retrieval
+    ###############################################
+
+    300, 'NO_DATA_AVAILABLE',
+    #No data exists for the given LSID.
+#An exception with this code is raised when there could be data attached
+#to the given LSID but they are not available in the time of the request.
+#The exception should not raised when the LSID identifies an abstract
+#concept in which case there are never any concrete data attached to it.
+
+    301, 'INVALID_RANGE',
+    # The requested starting position of data range is not
+#valid.
+    
+    #Error codes dealing with metadata retrieval
+    ###############################################
+    400, 'NO_METADATA_AVAILABLE',
+    # No metadata exists for the given LSID -
+#at the moment. The same data retrieval service may be successful
+#next time. The exception should not be raised if there are no
+#metadata at all, at any time.
+
+    401, 'NO_METADATA_AVAILABLE_FOR_FORMATS',
+    #No metadata exists this time,
+#or any time for the requested format. The exception cannot be raised
+#if the requested format includes wild-chars.
+
+    402, 'UNKNOWN_SELECTOR_FORMAT',
+    #The format of the metadata selector is
+#not supported by the service.
+    
+    #General error codes
+    ###############################################
+
+    500, 'INTERNAL_PROCESSING_ERROR',
+    #A generic catch-all for
+#errors not specifically mentioned elsewhere in this list.
+
+    501, 'METHOD_NOT_IMPLEMENTED',
+    #A requested method is not implemented.
+#Note that the method in question must exist otherwise it may be
+#caught already by the underlying protocol and reported differently -
+#but it has no implementation.The implementation may extend the set
+#of error codes in order to include implementation-specific codes. If
+#it does so it should use numbers above 20 in each of the groups,
+#or any number above 700. In other words, the free codes are:
+#    221-299, 321-399, 421-499, 521-599, 701-above).
+             );
+
+my %errornames;  # flip it
+while (my ($n, $m) = each %errors){
+    $errornames{$m} = $n;
+}
+
+
+our @EXPORT_OK = qw(
+    _die
+    );
+our @EXPORT = qw(
+    _die
+    );
+our %EXPORT_TAGS =(all => [qw(
+    _die
+    )]);
 
 sub clientFault {}
 
 sub serverFault {}
 
+sub _die {
+    my $m = shift;
+    my $n = $errornames{$m};
+    print header(
+        -status=>"$n $m",
+                );
+    exit 1;
+}
+
 1;
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/NamespaceResolver.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/NamespaceResolver.pm	2004/01/11 03:50:31	1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/NamespaceResolver.pm	2004/01/15 20:59:38	1.4
@@ -20,7 +20,7 @@
     #print STDERR "LSID is $ls\n";
 	my $lsid= LS::ID->new($ls)->canonical;
 	unless ($lsid) {
-		_die('Malformed LSID', 200);
+		_die('MALFORMED_LSID');
 	}
 
 	my $authority= $lsid->authority;
@@ -35,7 +35,7 @@
     $sth->execute($lsid);
     my ($namespace_type, $description, $authURI, $contact_email) = $sth->fetchrow_array;
     unless ($namespace_type){
-        _die('LSID Does not exist', 404);
+        _die('UNKNOWN_LSID');
     }
 
     # LSID is now fully validated.  Carry on with metadata.
@@ -75,7 +75,7 @@
     $RDF_SUFFIX?1:1;
 
 	unless ($mdata) {
-		die Error::clientFault('Metadata not available', 300);
+		_die ('NO_METADATA_AVAILABLE');
 	}
 	return $mdata;
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/PredicateResolver.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/PredicateResolver.pm	2004/01/11 02:30:58	1.2
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/PredicateResolver.pm	2004/01/15 20:59:38	1.3
@@ -22,7 +22,7 @@
     my ($ls) = @_;
 	my $lsid= LS::ID->new($ls)->canonical;
 	unless ($lsid) {
-		_die('Malformed LSID', 200);
+		_die('MALFORMED_LSID');
 	}
 
 	my $authority= $lsid->authority;
@@ -32,7 +32,7 @@
 	# e.g. urn:lsid:biomoby.org:rdfpredicates:mobyOntology
 
     unless ($known_predicates->{$obj}){
-        _die('LSID '.($lsid->as_string).' ($obj) Does not exist', 404);
+        _die('UNKNOWN_LSID');
     }
 
     # LSID is now fully validated.  Carry on with metadata.
@@ -62,7 +62,7 @@
     $RDF_SUFFIX?1:1;
 
 	unless ($mdata) {
-		_die ('Metadata not available', 300);
+		_die ('NO_METADATA_AVAILABLE');
 	}
 	return $mdata;
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/RDFConfigure.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/RDFConfigure.pm	2004/01/11 02:30:58	1.2
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/RDFConfigure.pm	2004/01/15 20:59:38	1.3
@@ -27,42 +27,37 @@
 	my ($subj, $pred, $obj)= @_;
 	return "<rdf:Description rdf:about='$subj'>
 \t<$pred rdf:resource='$obj'/>
-</rdf:Description>";
+</rdf:Description>\n";
 }
 
 sub rdfBnode {
 	my ($subj, $pred, $id)= @_;
 	return "<rdf:Description rdf:about='$subj'>
 \t<$pred rdf:nodeID='$id'/>
-</rdf:Description>";
+</rdf:Description>\n";
 }
 
 sub rdfBnodeResource {
 	my ($subj, $pred, $obj)= @_;
 	return "<rdf:Description rdf:nodeID='$subj'>
 \t<$pred rdf:resource='$obj'/>
-</rdf:Description>";
+</rdf:Description>\n";
 }
 
 sub rdfBnodeLiteral {
 	my ($subj, $pred, $obj)= @_;
 	return "<rdf:Description rdf:nodeID='$subj'>
 \t<$pred>$obj</$pred>
-</rdf:Description>";
+</rdf:Description>\n";
 }
 
 sub rdfBnodeBnode {
 	my ($subj, $pred, $id)= @_;
 	return "<rdf:Description rdf:nodeID='$subj'>
 \t<$pred rdf:nodeID='$id'/>
-</rdf:Description>";
+</rdf:Description>\n";
 }
 
-sub _die {
-    my $m = shift;
-    my $e = shift;
-    die ($e, $m);
-}
 
 
 our @EXPORT_OK = qw(
@@ -75,7 +70,6 @@
     rdfBnodeResource
     rdfBnodeLiteral
     rdfBnodeBnode
-    _die
     );
 our %EXPORT_TAGS =(all => [qw(
     $SERVICE_CGI
@@ -87,7 +81,6 @@
     rdfBnodeResource
     rdfBnodeLiteral
     rdfBnodeBnode
-    _die
     )]);
 
 1;

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/RelationshipResolver.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/RelationshipResolver.pm	2004/01/11 03:50:31	1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/RelationshipResolver.pm	2004/01/15 20:59:38	1.4
@@ -19,7 +19,7 @@
     my ($class_db_params, $ls) = @_;
 	my $lsid= LS::ID->new($ls)->canonical;
 	unless ($lsid) {
-		_die('Malformed LSID', 200);
+		_die('MALFORMED_LSID');
 	}
 
 	my $authority= $lsid->authority;
@@ -34,7 +34,7 @@
     $sth->execute($lsid);
     my ($relationship_type, $description, $authURI, $contact_email, $ontology) = $sth->fetchrow_array;
     unless ($relationship_type){
-        _die('LSID Does not exist', 404);
+        _die('UNKNOWN_LSID');
     }
 
     # LSID is now fully validated.  Carry on with metadata.
@@ -79,7 +79,7 @@
     $RDF_SUFFIX?1:1;
 
 	unless ($mdata) {
-		_die ('Metadata not available', 300);
+		_die ('NO_METADATA_AVAILABLE');
 	}
 	return $mdata;
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ServiceInstanceResolver.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ServiceInstanceResolver.pm	2004/01/11 02:30:58	1.2
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ServiceInstanceResolver.pm	2004/01/15 20:59:38	1.3
@@ -19,7 +19,7 @@
     my ($ls) = @_;
 	my $lsid= LS::ID->new($ls)->canonical;
 	unless ($lsid) {
-		_die('Malformed LSID', 200);
+		_die('MALFORMED_LSID');
 	}
 
 	my $authority= $lsid->authority;
@@ -28,14 +28,14 @@
 	my $rev= $lsid->revision;
 	# e.g. urn:lsid:biomoby.org:serviceinstance:www.illuminae.com,genbankcompletesequenceretrieve
     unless ($obj =~ /(.*)\,(.*):?/){
-        _die('Malformed service instance LSID; should be of form urn:lsid:biomoby.org:serviceinstance:authURI,serviceName',500);
+        _die('MALFORMED_LSID');
     }
     my $auth = $1; my $sname = $2;
     my $M = MOBY::Client::Central->new;
     my ($si, $reg) = $M->findService(authURI => $auth, serviceName => $sname);
     
     unless ($si && ${$si}[0]){
-        _die('LSID '.($lsid->as_string).' ($obj) Does not exist as a MOBY service instance', 404);
+        _die('UNKNOWN_LSID');
     }
     my $service = shift(@{$si});
     # LSID is now fully validated.  Carry on with metadata.
@@ -205,7 +205,7 @@
     $RDF_SUFFIX?1:1;
 
 	unless ($mdata) {
-		_die ('Metadata not available', 300);
+		_die ('NO_METADATA_AVAILABLE');
 	}
 	return $mdata;
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ServiceResolver.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ServiceResolver.pm	2004/01/11 03:50:31	1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ServiceResolver.pm	2004/01/15 20:59:38	1.4
@@ -19,7 +19,7 @@
     my ($class_db_params, $ls) = @_;
 	my $lsid= LS::ID->new($ls)->canonical;
 	unless ($lsid) {
-		_die('Malformed LSID', 200);
+		_die('MALFORMED_LSID');
 	}
 
 	my $authority= $lsid->authority;
@@ -34,7 +34,7 @@
     $sth->execute($lsid);
     my ($service_type, $description, $authURI, $contact_email) = $sth->fetchrow_array;
     unless ($service_type){
-        _die('LSID Does not exist', 404);
+        _die('UNKNOWN_LSID');
     }
 
     # LSID is now fully validated.  Carry on with metadata.
@@ -74,7 +74,7 @@
     $RDF_SUFFIX?1:1;
 
 	unless ($mdata) {
-		_die ('Metadata not available', 300);
+		_die ('NO_METADATA_AVAILABLE');
 	}
 	return $mdata;
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/lsid_resolver.kpf,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/lsid_resolver.kpf	2004/01/10 22:15:21	1.1
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/lsid_resolver.kpf	2004/01/15 20:59:38	1.2
@@ -20,7 +20,7 @@
  </file>
  <file url="dbConfigure.pm.template">
  </file>
- <file url="file:///home/markw/BIO/moby-live/Perl/lsid/authority/ServiceInstanceResolver.pm">
+ <file url="ServiceInstanceResolver.pm">
  </file>
 </files>
 </project>

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/metadata.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/metadata.pl	2004/01/11 03:50:31	1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/metadata.pl	2004/01/15 20:59:38	1.4
@@ -53,22 +53,19 @@
 sub validate_lsid {
     my $lsid = shift;
     unless ($lsid) {
-		_die('No LSID', 200);
+		_die('MALFORMED_LSID');
 	}
     unless ($lsid =~ /biomoby.org/){
-		_die('Not biomoby LSID', 200);
+		_die('UNKNOWN_LSID');
 	}
     unless ($lsid =~ /^urn:lsid/i){
-		_die('Malformed LSID', 200);
-	}
-    unless ($lsid =~ /biomoby.org/){
-		_die('Not biomoby LSID', 200);
+		_die('MALFORMED_LSID');
 	}
     unless ($lsid =~ /biomoby.org\:(\S+?)\:/){
-		_die('Malformed LSID', 200);
+		_die('MALFORMED_LSID');
 	}
     unless ($known_types{$1}){
-		_die("unknown LSID namespace $1; known types are ".(join ",", (keys %known_types))."\n", 404);
+		_die("UNKNOWN_LSID");
 	}
     
     return resolve_namespacetype($namespacedb,$lsid) if $1 eq "namespacetype";




More information about the MOBY-guts mailing list