Implemented condition that only admin or owner of the template can change its permissions using updateTemplatePermissions API

This commit is contained in:
Maneesha.P 2015-08-05 14:28:00 +05:30
parent 3df847dfbb
commit f7e8d44552
1 changed files with 5 additions and 0 deletions

View File

@ -1324,6 +1324,11 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
throw new InvalidParameterValueException("Update template permissions is an invalid operation on template " + template.getName());
}
//Only admin or owner of the template should be able to change its permissions
if (caller.getId() != ownerId && !isAdmin) {
throw new InvalidParameterValueException("Unable to grant permission to account " + caller.getAccountName() + " as it is neither admin nor owner or the template");
}
VMTemplateVO updatedTemplate = _tmpltDao.createForUpdate();
if (isPublic != null) {