[MOBY-guts] biomoby commit
Jason Stewart
jstewart at pub.open-bio.org
Thu May 8 18:58:58 UTC 2003
jstewart
Thu May 8 14:58:58 EDT 2003
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv3012/MOBY
Modified Files:
Central.pm
Log Message:
added better error output
moby-live/Perl/MOBY Central.pm,1.34,1.35
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2003/05/08 18:38:58 1.34
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2003/05/08 18:58:58 1.35
@@ -1057,33 +1057,33 @@
$debug && &_LOG("new service instance created\n");
foreach my $IN(@IN){
- my ($success) = &_registerArticles($SVC, "input", $IN, undef);
+ my ($success,$msg) = &_registerArticles($SVC, "input", $IN, undef);
unless ($success==1) {
my $reg = &Registration({
success => 0,
- error_message => "Registration Failed During INPUT Article Registration",
+ error_message => "Registration Failed During INPUT Article Registration: $msg",
registration_id => "",
});
return $reg;
}# and return it.
}
foreach my $OUT(@OUT){
- my ($success) = &_registerArticles($SVC, "output", $OUT, undef);
+f my ($success,$msg) = &_registerArticles($SVC, "output", $OUT, undef);
unless ($success==1) {
my $reg = &Registration({
success => 0,
- error_message => "Registration Failed During OUTPUT Article Registration",
+ error_message => "Registration Failed During OUTPUT Article Registration: $msg",
registration_id => $SVC->service_instance_id,
});
return $reg;
}# and return it.
}
foreach my $SEC(@SECS){
- my ($success) = &_registerArticles($SVC, "secondary", $SEC, undef);
+ my ($success,$msg) = &_registerArticles($SVC, "secondary", $SEC, undef);
unless ($success==1) {
my $reg = &Registration({
success => 1,
- error_message => "Registration Failed During SECONDARY Article Registration",
+ error_message => "Registration Failed During SECONDARY Article Registration: $msg",
registration_id => $SVC->service_instance_id,
});
return $reg;
@@ -1100,7 +1100,7 @@
sub _registerArticles {
my ($SVC, $inout, $node,$collid) = @_;
my $dbh = $SVC->dbh;
- return unless $node->getNodeType == ELEMENT_NODE;
+ return (-1,'Bad node') unless $node->getNodeType == ELEMENT_NODE;
# this is a Simple or a Complex object
my $simp_coll = $node->getTagName;
$debug && &_LOG("TAGNAME in _registerArticle is $simp_coll");
@@ -1125,50 +1125,55 @@
} elsif ($simp_coll eq "Simple") {
-
-
- my $article = $node->getAttributeNode("articleName");
- $article = $article->getValue() if $article;
- # get object type and its URI from the ontoogy server
- my $types = $node->getElementsByTagName('objectType');
- my $OE = MOBY::OntologyServer->new(ontology => "object");
- foreach ($types->item(0)->getChildNodes){ # should only ever be one!
- ($_->getNodeType == TEXT_NODE) && ($object_type = $_->toString);
- }
- my ($success, $message, $typeURI) = $OE->objectExists(term => $object_type);
- unless ($success){$SVC->DELETE_THYSELF; return "-1"} # kill it all unless this was successful!
+ my $article = $node->getAttributeNode("articleName");
+ $article = $article->getValue() if $article;
- my $namespace_string;
- my $namespaces = $node->getElementsByTagName('Namespace');
- my $num_ns = $namespaces->getLength;
- $OE = MOBY::OntologyServer->new(ontology => "namespace");
- for (my $n = 0; $n<$num_ns;++$n){
- foreach my $name($namespaces->item($n)->getChildNodes){
- if ($name->getNodeType == TEXT_NODE){
- my ($success, $message, $URI) = $OE->namespaceExists(term => $name->toString);
- unless ($success){$SVC->DELETE_THYSELF; return "-1"}
- $namespace_string .=$URI.",";
- }
- }
- }
- chop($namespace_string); # remove trailing comma
- my $dbh = $SVC->dbh;
- my $service_instance_id;
- unless ($collid){$service_instance_id = $SVC->service_instance_id} # one or the other, but not both
- $dbh->do("insert into simple_".$inout."
+ # get object type and its URI from the ontoogy server
+ my $types = $node->getElementsByTagName('objectType');
+ my $OE = MOBY::OntologyServer->new(ontology => "object");
+ foreach ($types->item(0)->getChildNodes) { # should only ever be one!
+ ($_->getNodeType == TEXT_NODE) && ($object_type = $_->toString);
+ }
+ my ($success, $message, $typeURI) = $OE->objectExists(term => $object_type);
+ unless ($success) {
+ $SVC->DELETE_THYSELF; return (-1,"object: $object_type does not exist");
+ } # kill it all unless this was successful!
+
+ my $namespace_string;
+ my $namespaces = $node->getElementsByTagName('Namespace');
+ my $num_ns = $namespaces->getLength;
+ $OE = MOBY::OntologyServer->new(ontology => "namespace");
+ for (my $n = 0; $n<$num_ns;++$n) {
+ foreach my $name ($namespaces->item($n)->getChildNodes) {
+ if ($name->getNodeType == TEXT_NODE) {
+ my ($success, $message, $URI) = $OE->namespaceExists(term => $name->toString);
+ unless ($success) {
+ $SVC->DELETE_THYSELF; return (-1,"namespace: " . $name->toString . " doesn't exist";
+ }
+ $namespace_string .=$URI.",";
+ }
+ }
+ }
+ chop($namespace_string); # remove trailing comma
+ my $dbh = $SVC->dbh;
+ my $service_instance_id;
+ unless ($collid) {
+ $service_instance_id = $SVC->service_instance_id;
+ } # one or the other, but not both
+ $dbh->do("insert into simple_".$inout."
(object_type_uri,
namespace_type_uris,
article_name,
service_instance_id,
collection_".$inout."_id)
values (?,?,?,?,?)",
- undef,
- ($typeURI,
- $namespace_string,
- $article,
- $service_instance_id,
- $collid));
-
+ undef,
+ ($typeURI,
+ $namespace_string,
+ $article,
+ $service_instance_id,
+ $collid));
+
} elsif ($simp_coll eq "Parameter"){
my $article = $node->getAttributeNode("articleName");
$article = $article->getValue() if $article;
@@ -1207,7 +1212,7 @@
undef,
($def, $max, $min, $enum_string, $datatype, $article, $SVC->service_instance_id));
}
- return 1;
+ return 1;
}
sub _registerServicePayload {
my ($payload) = @_;
More information about the MOBY-guts
mailing list