This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 36ef85012f69af59657c87ad88184769549d8792 Merge: c856614 eec5602 Author: Rohit Yadav <rohit.ya...@shapeblue.com> AuthorDate: Wed Jul 29 14:08:02 2020 +0530 Merge remote-tracking branch 'origin/4.14' Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com> .../org/apache/cloudstack/acl/RoleService.java | 8 ++++ .../api/command/admin/acl/ListRolesCmd.java | 25 ++++++------ .../cloudstack/api/command/user/vm/ListVMsCmd.java | 12 ++++++ .../cloudstack/api/response/HostResponse.java | 6 +-- .../org/apache/cloudstack/acl/dao/RoleDao.java | 6 +++ .../org/apache/cloudstack/acl/dao/RoleDaoImpl.java | 15 ++++++- .../cloudstack/ca/provider/RootCAProviderTest.java | 2 - .../java/com/cloud/api/query/QueryManagerImpl.java | 15 +++---- .../com/cloud/api/query/dao/HostJoinDaoImpl.java | 12 +++++- .../cloud/api/query/dao/TemplateJoinDaoImpl.java | 10 ++--- .../cloud/network/vpc/NetworkACLServiceImpl.java | 2 +- .../org/apache/cloudstack/acl/RoleManagerImpl.java | 46 ++++++++++++++++------ .../apache/cloudstack/acl/RoleManagerImplTest.java | 19 ++++----- 13 files changed, 123 insertions(+), 55 deletions(-) diff --cc api/src/main/java/org/apache/cloudstack/acl/RoleService.java index d7eef92,86f8a77..2e181dc --- a/api/src/main/java/org/apache/cloudstack/acl/RoleService.java +++ b/api/src/main/java/org/apache/cloudstack/acl/RoleService.java @@@ -18,8 -18,9 +18,10 @@@ package org.apache.cloudstack.acl; import java.util.List; +import java.util.Map; + import com.cloud.utils.Pair; + import org.apache.cloudstack.acl.RolePermission.Permission; import org.apache.cloudstack.framework.config.ConfigKey; @@@ -81,7 -82,7 +87,9 @@@ public interface RoleService */ List<Role> findRolesByType(RoleType roleType); + Pair<List<Role>, Integer> findRolesByType(RoleType roleType, Long startIndex, Long limit); + List<RolePermission> findAllPermissionsBy(Long roleId); + + Permission getRolePermission(String permission); } diff --cc engine/schema/src/main/java/org/apache/cloudstack/acl/dao/RoleDao.java index 4a53965,06c07ba..ec1051b --- a/engine/schema/src/main/java/org/apache/cloudstack/acl/dao/RoleDao.java +++ b/engine/schema/src/main/java/org/apache/cloudstack/acl/dao/RoleDao.java @@@ -17,8 -17,8 +17,9 @@@ package org.apache.cloudstack.acl.dao; + import com.cloud.utils.Pair; import com.cloud.utils.db.GenericDao; + import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.acl.RoleVO; @@@ -26,7 -26,10 +27,12 @@@ import java.util.List public interface RoleDao extends GenericDao<RoleVO, Long> { List<RoleVO> findAllByName(String roleName); + + Pair<List<RoleVO>, Integer> findAllByName(final String roleName, Long offset, Long limit); + List<RoleVO> findAllByRoleType(RoleType type); + List<RoleVO> findByName(String roleName); + RoleVO findByNameAndType(String roleName, RoleType type); + + Pair<List<RoleVO>, Integer> findAllByRoleType(RoleType type, Long offset, Long limit); } diff --cc engine/schema/src/main/java/org/apache/cloudstack/acl/dao/RoleDaoImpl.java index 4dc11fc,b220049..dda836a --- a/engine/schema/src/main/java/org/apache/cloudstack/acl/dao/RoleDaoImpl.java +++ b/engine/schema/src/main/java/org/apache/cloudstack/acl/dao/RoleDaoImpl.java @@@ -59,23 -59,12 +66,27 @@@ public class RoleDaoImpl extends Generi @Override public List<RoleVO> findAllByRoleType(final RoleType type) { + return findAllByRoleType(type, null, null).first(); + } + + public Pair<List<RoleVO>, Integer> findAllByRoleType(final RoleType type, Long offset, Long limit) { SearchCriteria<RoleVO> sc = RoleByTypeSearch.create(); sc.setParameters("roleType", type); - return listBy(sc); + return searchAndCount(sc, new Filter(RoleVO.class, "id", true, offset, limit)); } + + @Override + public List<RoleVO> findByName(String roleName) { + SearchCriteria<RoleVO> sc = RoleByNameSearch.create(); + sc.setParameters("roleName", roleName); + return listBy(sc); + } + + @Override + public RoleVO findByNameAndType(String roleName, RoleType type) { + SearchCriteria<RoleVO> sc = RoleByNameAndTypeSearch.create(); + sc.setParameters("roleName", roleName); + sc.setParameters("roleType", type); + return findOneBy(sc); + } }