Bug 427914

Summary: XMLRPC function addAttachment
Product: [Community] Bugzilla Reporter: Noura El hawary <nelhawar>
Component: WebServiceAssignee: David Lawrence <dkl>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: high    
Version: 3.2   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-09-22 14:48:12 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 406131, 427053    
Attachments:
Description Flags
Patch to add bugzilla.addAttachment functionality to bz 3.2 (v1) nelhawar: review+

Description Noura El hawary 2008-01-08 02:03:55 UTC
write xmlrpc function addAttachment that is to be contributed to the upstream.
Please refer to the following url for details on Bugzilla::RPC 2.18 functions mapped to upstream Bugzilla::WebService and for 2.18 xmlrpc functions sorted by percentage of calls: https://engineering.redhat.com/trac/bugzilla-3.0-rh/wiki/XmlrpcCrossComparison#a2.18xmlrpcfunctionssortedbypercentageofcalls

Comment 1 David Lawrence 2008-09-19 19:13:30 UTC
Created attachment 317227 [details]
Patch to add bugzilla.addAttachment functionality to bz 3.2 (v1)

Patch attached that ports bugzilla.addAttachment() from 2.18 to 3.2.

Please review
Thanks
Dave

Comment 2 Noura El hawary 2008-09-21 15:45:30 UTC
Comment on attachment 317227 [details]
Patch to add bugzilla.addAttachment functionality to bz 3.2 (v1)

Hi Dave,

The function looks good to me and works nicely only 2 points listed below:

>Index: extensions/compat_xmlrpc/code/webservice.pl
>===================================================================

>+sub addAttachment {
>+    my ($self, $bug_id, $data, $username, $password) = @_;
>+    my $dbh  = Bugzilla->dbh;
>+    my $user = Bugzilla->user;
>+
>+    # Try to login if $username and $password provided.
>+    xmlrpc_client_login($username, $password, LOGIN_REQUIRED);
>+    

my $user = Bugzilla->user;  ==> this should be here or otherwise if the user uses the function parameters to login the function will fail.


>+
>+    # Set the content type to text/plain if the attachment is a patch.
>+    my $contenttype = $ispatch ? "text/plain" : $data->{'contenttype'};
>+    $contenttype || ThrowUserError("missing_content_type");
>+


also shall we throw an error in the case of invalid contenttype just as how the webui does as the following from Bugzilla/Attachment.pm:

    if ( $contenttype !~
           /^(application|audio|image|message|model|multipart|text|video)\/.+$/ ) {
            ThrowUserError("invalid_content_type",
                           { contenttype => $contenttype });
    }


Thanks,
Noura

Comment 3 David Lawrence 2008-09-22 14:48:12 UTC
Thanks Noura. Made the changes you suggested and checked in.

Dave