Rubber-stamped by Brady Eidson.
[webbrowser.git] / BugsSite / xmlrpc.cgi
blobf24f91b0cfa15d3de95c1e5e1a5081bd371d659b
1 #!/usr/bin/env perl -wT
2 # -*- Mode: perl; indent-tabs-mode: nil -*-
4 # The contents of this file are subject to the Mozilla Public
5 # License Version 1.1 (the "License"); you may not use this file
6 # except in compliance with the License. You may obtain a copy of
7 # the License at http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS
10 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11 # implied. See the License for the specific language governing
12 # rights and limitations under the License.
14 # The Original Code is the Bugzilla Bug Tracking System.
16 # Contributor(s): Marc Schumann <wurblzap@gmail.com>
18 use strict;
19 use lib qw(. lib);
21 use Bugzilla;
22 use Bugzilla::Constants;
23 use Bugzilla::Error;
24 use Bugzilla::Hook;
25 use Bugzilla::WebService::Constants;
27 # Use an eval here so that runtests.pl accepts this script even if SOAP-Lite
28 # is not installed.
29 eval 'use XMLRPC::Transport::HTTP;
30 use Bugzilla::WebService;';
31 $@ && ThrowCodeError('soap_not_installed');
33 Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_WEBSERVICE);
34 local $SOAP::Constants::FAULT_SERVER;
35 $SOAP::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL;
36 # The line above is used, this one is ignored, but SOAP::Lite
37 # might start using this constant (the correct one) for XML-RPC someday.
38 local $XMLRPC::Constants::FAULT_SERVER;
39 $XMLRPC::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL;
41 my %hook_dispatch;
42 Bugzilla::Hook::process('webservice', { dispatch => \%hook_dispatch });
43 local @INC = (bz_locations()->{extensionsdir}, @INC);
45 my $dispatch = {
46 'Bugzilla' => 'Bugzilla::WebService::Bugzilla',
47 'Bug' => 'Bugzilla::WebService::Bug',
48 'User' => 'Bugzilla::WebService::User',
49 'Product' => 'Bugzilla::WebService::Product',
50 %hook_dispatch
53 # The on_action sub needs to be wrapped so that we can work out which
54 # class to use; when the XMLRPC module calls it theres no indication
55 # of which dispatch class will be handling it.
56 # Note that using this to get code thats called before the actual routine
57 # is a bit of a hack; its meant to be for modifying the SOAPAction
58 # headers, which XMLRPC doesn't use; it relies on the XMLRPC modules
59 # using SOAP::Lite internally....
61 my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI
62 ->dispatch_with($dispatch)
63 ->on_action(sub { Bugzilla::WebService::handle_login($dispatch, @_) } )
64 ->handle;