summaryrefslogtreecommitdiffstats
path: root/Bugzilla/WebService
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2014-11-10 17:08:13 +0100
committerDavid Lawrence <dkl@mozilla.com>2014-11-10 17:08:13 +0100
commitb9543e48f33729c4a4560eac2a856af06ed9e9d5 (patch)
tree4db2a797fc4f138a74ad09551b273bcf1b61785b /Bugzilla/WebService
parent41dbccc20f013f0b06959ad587f5fb6ac4813686 (diff)
downloadbugzilla-b9543e48f33729c4a4560eac2a856af06ed9e9d5.tar.gz
bugzilla-b9543e48f33729c4a4560eac2a856af06ed9e9d5.tar.xz
Bug 1094858: Create hook in Bugzilla::WebService::Constants to allow overrriding of standard status codes by extensions
r=gerv,a=glob
Diffstat (limited to 'Bugzilla/WebService')
-rw-r--r--Bugzilla/WebService/Constants.pm48
1 files changed, 28 insertions, 20 deletions
diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm
index db50611cb..2f38c8db1 100644
--- a/Bugzilla/WebService/Constants.pm
+++ b/Bugzilla/WebService/Constants.pm
@@ -239,26 +239,33 @@ use constant STATUS_GONE => 410;
# the related webvservice call. We choose the appropriate
# http status code based on the error code or use the
# default STATUS_BAD_REQUEST.
-use constant REST_STATUS_CODE_MAP => {
- 51 => STATUS_NOT_FOUND,
- 101 => STATUS_NOT_FOUND,
- 102 => STATUS_NOT_AUTHORIZED,
- 106 => STATUS_NOT_AUTHORIZED,
- 109 => STATUS_NOT_AUTHORIZED,
- 110 => STATUS_NOT_AUTHORIZED,
- 113 => STATUS_NOT_AUTHORIZED,
- 115 => STATUS_NOT_AUTHORIZED,
- 120 => STATUS_NOT_AUTHORIZED,
- 300 => STATUS_NOT_AUTHORIZED,
- 301 => STATUS_NOT_AUTHORIZED,
- 302 => STATUS_NOT_AUTHORIZED,
- 303 => STATUS_NOT_AUTHORIZED,
- 304 => STATUS_NOT_AUTHORIZED,
- 410 => STATUS_NOT_AUTHORIZED,
- 504 => STATUS_NOT_AUTHORIZED,
- 505 => STATUS_NOT_AUTHORIZED,
- 32614 => STATUS_NOT_FOUND,
- _default => STATUS_BAD_REQUEST
+sub REST_STATUS_CODE_MAP {
+ my $status_code_map = {
+ 51 => STATUS_NOT_FOUND,
+ 101 => STATUS_NOT_FOUND,
+ 102 => STATUS_NOT_AUTHORIZED,
+ 106 => STATUS_NOT_AUTHORIZED,
+ 109 => STATUS_NOT_AUTHORIZED,
+ 110 => STATUS_NOT_AUTHORIZED,
+ 113 => STATUS_NOT_AUTHORIZED,
+ 115 => STATUS_NOT_AUTHORIZED,
+ 120 => STATUS_NOT_AUTHORIZED,
+ 300 => STATUS_NOT_AUTHORIZED,
+ 301 => STATUS_NOT_AUTHORIZED,
+ 302 => STATUS_NOT_AUTHORIZED,
+ 303 => STATUS_NOT_AUTHORIZED,
+ 304 => STATUS_NOT_AUTHORIZED,
+ 410 => STATUS_NOT_AUTHORIZED,
+ 504 => STATUS_NOT_AUTHORIZED,
+ 505 => STATUS_NOT_AUTHORIZED,
+ 32614 => STATUS_NOT_FOUND,
+ _default => STATUS_BAD_REQUEST
+ };
+
+ Bugzilla::Hook::process('webservice_status_code_map',
+ { status_code_map => $status_code_map });
+
+ return $status_code_map;
};
# These are the fallback defaults for errors not in ERROR_CODE.
@@ -307,6 +314,7 @@ sub WS_DISPATCH {
=over
+=item REST_STATUS_CODE_MAP
=item WS_DISPATCH
=back