Allow users to save update of parent project for review

Only Gerrit administrators are allowed to change the parent of a
project. Now normal users can change the parent project in the WebUI
and save the modification for review. This creates a change for the
refs/meta/config branch that can be approved and submitted by
administrators. Since the administrators are the only ones who can
submit this change they are automatically added as reviewer. This way
we have an integrated workflow for requesting and approving changes of
parent projects, instead of having requests by email outside of
Gerrit.

Change-Id: I080649990f80edf78fd6eb465cef25fb8012352d
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-11-18 16:37:42 +01:00
parent ebc0a5c51a
commit 91fefc45e9
5 changed files with 49 additions and 14 deletions

View File

@@ -62,7 +62,7 @@ public class SetParent implements RestModifyView<ProjectResource, Input> {
throws AuthException, ResourceConflictException,
ResourceNotFoundException, UnprocessableEntityException, IOException {
ProjectControl ctl = rsrc.getControl();
validateParentUpdate(ctl, input.parent);
validateParentUpdate(ctl, input.parent, true);
IdentifiedUser user = (IdentifiedUser) ctl.getCurrentUser();
try {
MetaDataUpdate md = updateFactory.create(rsrc.getNameKey());
@@ -97,11 +97,11 @@ public class SetParent implements RestModifyView<ProjectResource, Input> {
}
}
public void validateParentUpdate(final ProjectControl ctl, String newParent)
throws AuthException, ResourceConflictException,
public void validateParentUpdate(final ProjectControl ctl, String newParent,
boolean checkIfAdmin) throws AuthException, ResourceConflictException,
UnprocessableEntityException {
IdentifiedUser user = (IdentifiedUser) ctl.getCurrentUser();
if (!user.getCapabilities().canAdministrateServer()) {
if (checkIfAdmin && !user.getCapabilities().canAdministrateServer()) {
throw new AuthException("not administrator");
}