[MOBY-l] Potential fix for RFC1863 Commonsubs/was: missing RFC1863 support in perl CommonSubs
Björn Usadel
usadel at mpimp-golm.mpg.de
Tue May 9 15:19:23 UTC 2006
Dear List,
sorry it took me a bit longer to implement the change in responseHeader.
I basically changed the code in responseHeader by adding the following
lines: (some formatting included)
#####################
...
if ($exception) {
$xml .= " <moby:serviceNotes>\n$exception";
if ( $notes ) {
my $encodednotes = HTML::Entities::encode( $notes );
$xml .= " <moby:Notes>$encodednotes</moby:Notes>\n";
}
$xml .=" </moby:serviceNotes>";
}
elsif...
##########################
and adding an additional sub "encodeException", which xmlencodes an
exception. I just figured out, that this is also available via
Java/src/perl/parser/service exception.pm.
Is this supposed to be used in general? In which case one better uses
this approach, since it is far more OO structured than mine. (and I will
make a new diff)
Maybe somebody more insightful than me can comment on this and have a
look/test my code. It generates well-formed xml and seems to be backward
compatible, but that is as much as I can test it.
If encodeException is to be kept, is there any recommendation what the
default behavior for missing errorcode severity etc. should be,
currently it returns ""?
I included a diff against the Common Subs 1.9 (i hope to have brought
mine to the same level by hand from 1.87)
In case these changes are ok, I think I would add an additional example
in the perldoc using errors.
Cheers,
Björn
PS Thanks to Marc for how to post :-)
> Björn,
>
> To my knowledge, nobody has yet checked in any work on integrating the
> new Exception mechanism into the Perl codebase. It appears that the
> Java codebase already has this feature, so we need it in the Perl
> version too, urgently. You should feel free to go ahead - anyone out
> there working on this? perhaps you should get together on it.
>
> -Frank
>
> At 04:50 AM 3/24/2006, you wrote:
>> Dear list,
>>
>> I just learned how to use Biomoby and stumbled over the problem that it
>> is not possible to integrate
>> moby Exceptions (as specified in RFC1863) into the header using the perl
>> method "responseHeader" from CommonSubs (latest cvs). Since everything
>> there which is passed in the parameter notes gets HTMLified and wrapped
>> into notes as well as service notes.
>>
>> Is anybody working on fixing that?
>> Otherwise I could try developing a version here with the additional
>> paramter exception (and post it on this list?)
>>
>>
>> Cheers,
>> Björn
>>
>>
>> _______________________________________________
>> moby-l mailing list
>> moby-l at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/moby-l
>
> PhD, Computational Biologist,
> Harvard Medical School BCMP/SGM-322, 250 Longwood Ave, Boston MA
> 02115, USA.
> Tel: 617-432-3555 Fax: 617-432-3557
> http://llama.med.harvard.edu/~fgibbons
##############################diff
1c1
< #$Id: CommonSubs.pm,v 1.90 2006/05/04 20:30:47 mwilkinson Exp $
---
> #$Id: CommonSubs.pm,v 1.87 2006/04/28 13:10:38 mwilkinson Exp $
230a231
> encodeException
622c623
< B<function:> print the XML string of a MOBY response header +/-
serviceNotes
---
> B<function:> print the XML string of a MOBY response header +/-
serviceNotes +/- Exceptions
630c631,633
< -note => 'here is some data from the service provider')
---
> -note => 'here is some data from the service provider'
> -exception=>'an xml encoded exception string')
>
634c637
< notes.
---
> notes which can include already xml encoded exceptions
648c651
< my ( $auth, $notes ) = _rearrange( [qw[AUTHORITY NOTE]], @_ );
---
> my ( $auth, $notes, $exception ) = _rearrange( [qw[AUTHORITY NOTE
EXCEPTION]], @_ );
650a654
> $exception ||="";
652,655c656,668
< "<?xml version='1.0' encoding='UTF-8'?>"
< . "<moby:MOBY xmlns:moby='http://www.biomoby.org/moby'
xmlns='http://www.biomoby.org/moby'>"
< . "<moby:mobyContent moby:authority='$auth'>";
< if ( $notes ) {
---
> "<?xml version='1.0' encoding='UTF-8'?>\n"
> . " <moby:MOBY xmlns:moby='http://www.biomoby.org/moby'
xmlns='http://www.biomoby.org/moby'>\n"
> . " <moby:mobyContent moby:authority='$auth'>\n";
> if ($exception) {
> $xml .= " <moby:serviceNotes>\n$exception";
> if ( $notes ) {
> my $encodednotes = HTML::Entities::encode( $notes );
> $xml .= " <moby:Notes>$encodednotes</moby:Notes>\n";
> }
> $xml .=" </moby:serviceNotes>";
> }
>
> elsif ( $notes ) {
661a675,716
>
> =head2 encodeException
>
> B<function:> wraps a Biomoby Exception with all its parameters into
the appropiate MobyData structure
>
> B<usage:>
>
> encodeException(
> -element => 'refers to the queryID of the offending
input mobyData',
> -query => 'refers to the articleName of the offending
input Simple or Collection'
> -severity=>'error'
> -code=>'An error code '
> -message=>'a human readable description for the error
code')
>
> B<args:>the different arguments required by the mobyException API
> severity can be either error, warning or information
> valid error codes are decribed on the biomoby website
>
>
> B<notes:> returns everything required to use for the responseHeader:
>
> <moby:mobyException moby:refElement='input1' moby:refQueryID='1'
moby:severity =''>
> <moby:exceptionCode>600</moby:exceptionCode>
> <moby:exceptionMessage>Unable to execute the
service</moby:exceptionMessage>
> </moby:mobyException>
>
> =cut
>
> sub encodeException{
> use HTML::Entities ();
> my ( $refElement, $refQueryID, $severity, $code, $message ) =
_rearrange( [qw[ELEMENT QUERYID SEVERITY CODE MESSAGE]], @_ );
> $refElement ||= "";
> defined($refQueryID) || ($refQueryID= "");
> $severity ||= "";
> defined($code) || ($code = "");
> $message ||= "not provided";
> my $xml=" <moby:mobyException
moby:refElement='$refElement' moby:refQueryID='$refQueryID'
moby:severity ='$severity'>\n".
> "
<moby:exceptionCode>$code</moby:exceptionCode>\n".
> "
<moby:exceptionMessage>".HTML::Entities::encode($message)."</moby:exceptionMessage>\n".
> " </moby:mobyException>\n";
> }
>
More information about the moby-l
mailing list