CLOUDSTACK-5960: Domain admin or user cannot register a template using

S3/Swift object store.(cherry picked from commit 6d1475182c)

Signed-off-by: Animesh Chaturvedi <animesh@apache.org>
This commit is contained in:
Min Chen 2014-01-27 11:54:38 -08:00 committed by Animesh Chaturvedi
parent 8d1d0c54f2
commit 7e8b8e6cd0
1 changed files with 8 additions and 2 deletions

View File

@ -162,8 +162,14 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
}
boolean isAdmin = _accountDao.findById(templateOwner.getId()).getType() == Account.ACCOUNT_TYPE_ADMIN;
if (!isAdmin && zoneId == null) {
boolean isRegionStore = false;
List<ImageStoreVO> stores = _imgStoreDao.findRegionImageStores();
if (stores != null && stores.size() > 0) {
isRegionStore = true;
}
if (!isAdmin && zoneId == null && !isRegionStore ) {
// domain admin and user should also be able to register template on a region store
throw new InvalidParameterValueException("Please specify a valid zone Id.");
}