Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
44e26f06
Commit
44e26f06
authored
Dec 31, 2013
by
Dave Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 756048 - Add and update bug and attachment flags using the WebService API
r=sgreen,a=justdave
parent
4fa178ae
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
1 deletion
+121
-1
Bug.pm
Bugzilla/WebService/Bug.pm
+0
-0
Constants.pm
Bugzilla/WebService/Constants.pm
+7
-0
Bug.pm
Bugzilla/WebService/Server/REST/Resources/Bug.pm
+17
-1
Util.pm
Bugzilla/WebService/Util.pm
+87
-0
user-error.html.tmpl
template/en/default/global/user-error.html.tmpl
+10
-0
No files found.
Bugzilla/WebService/Bug.pm
View file @
44e26f06
This diff is collapsed.
Click to expand it.
Bugzilla/WebService/Constants.pm
View file @
44e26f06
...
...
@@ -126,6 +126,13 @@ use constant WS_ERROR_CODE => {
missing_resolution
=>
121
,
resolution_not_allowed
=>
122
,
illegal_bug_status_transition
=>
123
,
# Flag errors
flag_status_invalid
=>
129
,
flag_update_denied
=>
130
,
flag_type_requestee_disabled
=>
131
,
flag_not_unique
=>
132
,
flag_type_not_unique
=>
133
,
flag_type_inactive
=>
134
,
# Authentication errors are usually 300-400.
invalid_login_or_password
=>
300
,
...
...
Bugzilla/WebService/Server/REST/Resources/Bug.pm
View file @
44e26f06
...
...
@@ -151,7 +151,23 @@ sub _rest_resources {
}
}
},
qr{^/flag_types/([^/]+)/([^/]+)$}
,
{
GET
=>
{
method
=>
'flag_types'
,
params
=>
sub
{
return
{
product
=>
$_
[
0
],
component
=>
$_
[
1
]
};
}
}
},
qr{^/flag_types/([^/]+)$}
,
{
GET
=>
{
method
=>
'flag_types'
,
params
=>
sub
{
return
{
product
=>
$_
[
0
]
};
}
}
}
];
return
$rest_resources
;
}
...
...
Bugzilla/WebService/Util.pm
View file @
44e26f06
...
...
@@ -10,6 +10,12 @@ package Bugzilla::WebService::Util;
use
5.10.1
;
use
strict
;
use
Bugzilla::
Flag
;
use
Bugzilla::
FlagType
;
use
Bugzilla::
Error
;
use
Storable
qw(dclone)
;
use
parent
qw(Exporter)
;
# We have to "require", not "use" this, because otherwise it tries to
...
...
@@ -17,6 +23,7 @@ use parent qw(Exporter);
require
Test::
Taint
;
our
@EXPORT_OK
=
qw(
extract_flags
filter
filter_wants
taint_data
...
...
@@ -26,6 +33,80 @@ our @EXPORT_OK = qw(
fix_credentials
)
;
sub
extract_flags
{
my
(
$flags
,
$bug
,
$attachment
)
=
@_
;
my
(
@new_flags
,
@old_flags
);
my
$flag_types
=
$attachment
?
$attachment
->
flag_types
:
$bug
->
flag_types
;
my
$current_flags
=
$attachment
?
$attachment
->
flags
:
$bug
->
flags
;
# Copy the user provided $flags as we may call extract_flags more than
# once when editing multiple bugs or attachments.
my
$flags_copy
=
dclone
(
$flags
);
foreach
my
$flag
(
@$flags_copy
)
{
my
$id
=
$flag
->
{
id
};
my
$type_id
=
$flag
->
{
type_id
};
my
$new
=
delete
$flag
->
{
new
};
my
$name
=
delete
$flag
->
{
name
};
if
(
$id
)
{
my
$flag_obj
=
grep
(
$id
==
$_
->
id
,
@$current_flags
);
$flag_obj
||
ThrowUserError
(
'object_does_not_exist'
,
{
class
=>
'Bugzilla::Flag'
,
id
=>
$id
});
}
elsif
(
$type_id
)
{
my
$type_obj
=
grep
(
$type_id
==
$_
->
id
,
@$flag_types
);
$type_obj
||
ThrowUserError
(
'object_does_not_exist'
,
{
class
=>
'Bugzilla::FlagType'
,
id
=>
$type_id
});
if
(
!
$new
)
{
my
@flag_matches
=
grep
(
$type_id
==
$_
->
type
->
id
,
@$current_flags
);
@flag_matches
>
1
&&
ThrowUserError
(
'flag_not_unique'
,
{
value
=>
$type_id
});
if
(
!
@flag_matches
)
{
delete
$flag
->
{
id
};
}
else
{
delete
$flag
->
{
type_id
};
$flag
->
{
id
}
=
$flag_matches
[
0
]
->
id
;
}
}
}
elsif
(
$name
)
{
my
@type_matches
=
grep
(
$name
eq
$_
->
name
,
@$flag_types
);
@type_matches
>
1
&&
ThrowUserError
(
'flag_type_not_unique'
,
{
value
=>
$name
});
@type_matches
||
ThrowUserError
(
'object_does_not_exist'
,
{
class
=>
'Bugzilla::FlagType'
,
name
=>
$name
});
if
(
$new
)
{
delete
$flag
->
{
id
};
$flag
->
{
type_id
}
=
$type_matches
[
0
]
->
id
;
}
else
{
my
@flag_matches
=
grep
(
$name
eq
$_
->
type
->
name
,
@$current_flags
);
@flag_matches
>
1
&&
ThrowUserError
(
'flag_not_unique'
,
{
value
=>
$name
});
if
(
@flag_matches
)
{
$flag
->
{
id
}
=
$flag_matches
[
0
]
->
id
;
}
else
{
delete
$flag
->
{
id
};
$flag
->
{
type_id
}
=
$type_matches
[
0
]
->
id
;
}
}
}
if
(
$flag
->
{
id
})
{
push
(
@old_flags
,
$flag
);
}
else
{
push
(
@new_flags
,
$flag
);
}
}
return
(
\
@old_flags
,
\
@new_flags
);
}
sub
filter
($$;$) {
my
(
$params
,
$hash
,
$prefix
)
=
@_
;
my
%
newhash
=
%
$hash
;
...
...
@@ -232,6 +313,12 @@ Allows for certain parameters related to authentication such as Bugzilla_login,
Bugzilla_password, and Bugzilla_token to have shorter named equivalents passed in.
This function converts the shorter versions to their respective internal names.
=head2 extract_flags
Subroutine that takes a list of hashes that are potential flag changes for
both bugs and attachments. Then breaks the list down into two separate lists
based on if the change is to add a new flag or to update an existing flag.
=head1 B<Methods in need of POD>
=over
...
...
template/en/default/global/user-error.html.tmpl
View file @
44e26f06
...
...
@@ -745,6 +745,16 @@
You are not allowed to edit properties of the '[% flagtype.name FILTER html %]'
flag type, because this flag type is not available for the products you can administer.
[% ELSIF error == "flag_not_unique" %]
[% title = "Flag not Unique" %]
The flag '[% value FILTER html %]' has been set multiple times.
You must specify the id value to update the flag.
[% ELSIF error == "flag_type_not_unique" %]
[% title = "Flag Type not Unique" %]
The flag type '[% value FILTER html %]' matches several flag types.
You must specify the type id value to update or add a flag.
[% ELSIF error == "flag_type_not_multiplicable" %]
[% docslinks = {'flags-overview.html' => 'An overview on Flags',
'flags.html' => 'Using Flags'} %]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment