[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Sat Nov 1 06:17:24 EST 2003


mwilkinson
Sat Nov  1 06:17:24 EST 2003
Update of /home/repository/moby/moby-live/Perl/lsid/authority
In directory pub.open-bio.org:/tmp/cvs-serv21514/lsid/authority

Modified Files:
	Error.pm RDFConfigure.pm authority.pl dbConfigure.pm.template 
	metadata.pl 
Log Message:
shuffling stuff around to make it available to various modules

moby-live/Perl/lsid/authority Error.pm,1.1,1.2 RDFConfigure.pm,1.1,1.2 authority.pl,1.1,1.2 dbConfigure.pm.template,1.1,1.2 metadata.pl,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/lsid/authority/Error.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/lsid/authority/Error.pm	2003/11/01 10:37:41	1.1
+++ /home/repository/moby/moby-live/Perl/lsid/authority/Error.pm	2003/11/01 11:17:24	1.2
@@ -1,3 +1,4 @@
+#$Id$
 package Error;
 
 sub clientFault {}

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/lsid/authority/RDFConfigure.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/lsid/authority/RDFConfigure.pm	2003/11/01 09:40:58	1.1
+++ /home/repository/moby/moby-live/Perl/lsid/authority/RDFConfigure.pm	2003/11/01 11:17:24	1.2
@@ -1,3 +1,4 @@
+#$Id$
 
 package RDFConfigure;
 use strict;
@@ -8,11 +9,16 @@
     $SERVICE_CGI
     $RDF_PREFIX
     $RDF_SUFFIX
+    rdfLiteral
+    rdfResource
     );
-#our %EXPORT_TAGS =(all => [qw($SERVICE_CGI
-#    $RDF_PREFIX
-#    $RDF_SUFFIX
-#    )]);
+our %EXPORT_TAGS =(all => [qw(
+    $SERVICE_CGI
+    $RDF_PREFIX
+    $RDF_SUFFIX
+    rdfLiteral
+    rdfResource
+    )]);
 
 
 our $SERVICE_CGI= 'http://localhost:80/cgi-bin/authority/metadata.pl';
@@ -23,4 +29,20 @@
 xmlns:i3cp='urn:lsid:i3c.org:predicates:'
 xmlns:mobyp='urn:lsid:biomoby.org:rdfpredicates:'>\n\n";
 our $RDF_SUFFIX= "</rdf:RDF>";
+
+
+sub rdfLiteral {
+	my ($subj, $pred, $obj)= @_;
+	return "<rdf:Description rdf:about='$subj'>
+\t<$pred>$obj</$pred>
+</rdf:Description>\n";
+}
+
+sub rdfResource {
+	my ($subj, $pred, $obj)= @_;
+	return "<rdf:Description rdf:about='$subj'>
+\t<$pred rdf:resource='$obj'/>
+</rdf:Description>";
+}
+
 1;

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/lsid/authority/authority.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/lsid/authority/authority.pl	2003/11/01 09:40:58	1.1
+++ /home/repository/moby/moby-live/Perl/lsid/authority/authority.pl	2003/11/01 11:17:24	1.2
@@ -1,12 +1,5 @@
 #!/usr/bin/perl -w
-# =====================================================================
-# Copyright (c) 2002,2003 IBM Corporation 
-# All rights reserved.   This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.opensource.org/licenses/cpl.php
-# 
-# =====================================================================
+#$Id$
 
 use LS::Authority::WSDL::Simple;
 

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/lsid/authority/dbConfigure.pm.template,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/lsid/authority/dbConfigure.pm.template	2003/11/01 09:40:58	1.1
+++ /home/repository/moby/moby-live/Perl/lsid/authority/dbConfigure.pm.template	2003/11/01 11:17:24	1.2
@@ -14,22 +14,22 @@
 
 =cut
 
-
+#$Id$
 package dbConfigure;
 use strict;
 use base 'Exporter';
 require Exporter;
 
 our @EXPORT_OK = qw(
-	$central
-	$namespace
-	$object
-	$service
-	$relationship
+	$centraldb
+	$namespacedb
+	$objectdb
+	$servicedb
+	$relationshipdb
 	);
 
 # parameters for the mobycentral database
-our $central = {'host' => '',
+our $centraldb = {'host' => '',
 		'dbname' => '',
 		'user' => '',
 		'pass' => '',
@@ -37,7 +37,7 @@
 	};
 
 # parameters for the namespace database
-our $namespace = {'host' => '',
+our $namespacedb = {'host' => '',
 		'dbname' => '',
 		'user' => '',
 		'pass' => '',
@@ -45,7 +45,7 @@
 	};
 
 # parameters for the object database
-our $object = {	'host' => '',
+our $objectdb = {	'host' => '',
 		'dbname' => '',
 		'user' => '',
 		'pass' => '',
@@ -53,7 +53,7 @@
 	};
 
 # parameters for the service database
-our $service = {'host' => '',
+our $servicedb = {'host' => '',
 		'dbname' => '',
 		'user' => '',
 		'pass' => '',
@@ -62,7 +62,7 @@
 
 
 # parameters for the relationship database
-our $relationship = {'host' => '',
+our $relationshipdb = {'host' => '',
 		'dbname' => '',
 		'user' => '',
 		'pass' => '',

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/lsid/authority/metadata.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/lsid/authority/metadata.pl	2003/11/01 10:35:20	1.2
+++ /home/repository/moby/moby-live/Perl/lsid/authority/metadata.pl	2003/11/01 11:17:24	1.3
@@ -1,4 +1,6 @@
-#!/usr/bin/perl -w 
+#!/usr/bin/perl -w
+#$Id$
+
 use CGI qw/:standard/;
 use lib "/usr/local/apache/cgi-bin/lsid/authority";
 use strict;
@@ -8,19 +10,17 @@
 use LS::Authority::WSDL::Simple;
 use Error;
 
-use RDFConfigure qw(
-    $SERVICE_CGI
-    $RDF_PREFIX
-    $RDF_SUFFIX);
+use RDFConfigure qw(:all);
 
 use dbConfigure qw(
-	$service
-	$namespace
-	$object
-	$central
-	$relationship
+	$servicedb
+	$namespacedb
+	$objectdb
+	$centraldb
+	$relationshipdb
 	);
 
+use NamespaceResolver qw(:all);
 
 my %known_types = (  # switch on/off various LSID resolvers.
     'namespacetype' => 1,
@@ -37,15 +37,8 @@
     my $lsid = param('lsid');
     
     print header(-type => 'x-application/rdf+xml', -expires => 'now');  # both tags are required by the spec
-
-    #my $rdfheader = "<?xml version='1.0'?>\n".
-    #"<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' \n" .
-    #"xmlns:dc='http://purl.org/dc/elements/1.1/' \n" .
-    #"xmlns:mobyp='urn:lsid:biomoby.org:predicates:'>\n";
     my $rdf = validate_lsid($lsid);
-    #my $rdffooter = '</rdf:RDF>';
     _die("RDF creation failed") unless ($rdf);
-#    print $rdfheader.$rdf.$rdffooter;
     print $rdf;
     exit 1;
 }
@@ -71,7 +64,7 @@
 		_die("unknown LSID namespace $1 : $known_types{$1}; known types are ".(keys %known_types)."\n", 404);
 	}
     
-    return resolve_namespacetype($lsid) if $1 eq "namespacetype";
+    return resolve_namespacetype($namespacedb,$lsid) if $1 eq "namespacetype";
     
 }
 
@@ -81,98 +74,3 @@
     die ($e, $m);
 }
 
-sub resolve_namespacetype {
-    my $ls = shift;
-    print STDERR "LSID is $ls\n";
-	my $lsid= LS::ID->new($ls)->canonical;
-	unless ($lsid) {
-		_die('Malformed LSID', 200);
-	}
-
-	my $authority= $lsid->authority;
-	my $ns= $lsid->namespace;
-	my $obj= $lsid->object;
-	my $rev= $lsid->revision;
-	
-	my $mdata;
-    my $dbh = _dbAccess($namespace);
-
-    my $sth = $dbh->prepare("select namespace_type, description, authority, contact_email from namespace where namespace_lsid = ?");
-    $sth->execute($lsid);
-    my ($namespace_type, $description, $authURI, $contact_email) = $sth->fetchrow_array;
-    unless ($namespace_type){
-        _die('LSID Does not exist', 404);
-    }
-
-    # SID is now fully validated.  Carry on with metadata.
-    $RDF_PREFIX?1:1;
-    $mdata= $RDF_PREFIX;
-    $mdata.= rdfLiteral(
-        $lsid->as_string,
-        'dc:title',
-        $namespace_type
-    );
-    $mdata.= rdfLiteral(
-        $lsid->as_string,
-        'rdfs:label',
-        $namespace_type
-    );
-    $mdata.= rdfLiteral(
-        $lsid->as_string,
-        'dc:description',
-        $description
-    );
-    $mdata.= rdfLiteral(
-        $lsid->as_string,
-        'dc:contributor',
-        $authURI
-    );
-    $mdata.= rdfLiteral(
-        $lsid->as_string,
-        'dc:type',
-        "bioMoby namespace identifier"
-    );
-    $mdata.= rdfResource(
-        $contact_email,
-        'dc:label',
-        $contact_email
-    );
-    $mdata.= $RDF_SUFFIX;
-    $RDF_SUFFIX?1:1;
-
-	unless ($mdata) {
-		die Error::clientFault('Metadata not available', 300);
-	}
-	return $mdata;
-}
-
-sub rdfLiteral {
-	my ($subj, $pred, $obj)= @_;
-	return "<rdf:Description rdf:about='$subj'>
-\t<$pred>$obj</$pred>
-</rdf:Description>\n";
-}
-
-sub rdfResource {
-	my ($subj, $pred, $obj)= @_;
-	return "<rdf:Description rdf:about='$subj'>
-\t<$pred rdf:resource='$obj'/>
-</rdf:Description>";
-}
-
-
-sub _dbAccess {
-	use DBI;
-	use DBD::mysql;
-	my ($db) = @_;
-	my $pass = $db->{pass};
-	my $user = $db->{user};
-	my $host = $db->{host};
-	my $dbname = $db->{dbname};
-	my $port = $db->{port};
-	my ($dsn) = "DBI:mysql:$dbname:$host:$port";
-	my $dbh = DBI->connect($dsn, $user, $pass, {RaiseError => 1}) or die "can't connect to database";
-	
-	return ($dbh);
-}
-



More information about the MOBY-guts mailing list