Repository: cloudstack
Updated Branches:
  refs/heads/master 6220947db -> 6d1482b97


CLOUDSTACK-7283: listUsers API is available for regular users now


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6d1482b9
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6d1482b9
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6d1482b9

Branch: refs/heads/master
Commit: 6d1482b97bfa9876a076c2e7a9e1fd4236d9c738
Parents: 6220947
Author: Alena Prokharchyk <[email protected]>
Authored: Thu Aug 7 10:46:11 2014 -0700
Committer: Alena Prokharchyk <[email protected]>
Committed: Thu Aug 7 14:01:58 2014 -0700

----------------------------------------------------------------------
 client/tomcatconf/commands.properties.in        |  2 +-
 .../com/cloud/api/query/QueryManagerImpl.java   | 30 +++++++++++---------
 .../cloud/api/query/vo/UserAccountJoinVO.java   | 18 +++++++++++-
 3 files changed, 35 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6d1482b9/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in 
b/client/tomcatconf/commands.properties.in
index c1d21b9..c71f4ba 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -32,7 +32,7 @@ markDefaultZoneForAccount=1
 createUser=7
 deleteUser=7
 updateUser=15
-listUsers=7
+listUsers=15
 lockUser=7
 disableUser=7
 enableUser=7

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6d1482b9/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java 
b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 39eabd1..60b082c 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -375,23 +375,20 @@ public class QueryManagerImpl extends ManagerBase 
implements QueryService {
     private Pair<List<UserAccountJoinVO>, Integer> 
searchForUsersInternal(ListUsersCmd cmd) throws PermissionDeniedException {
         Account caller = CallContext.current().getCallingAccount();
 
-        // TODO: Integrate with ACL checkAccess refactoring
-        Long domainId = cmd.getDomainId();
-        if (domainId != null) {
-            Domain domain = _domainDao.findById(domainId);
-            if (domain == null) {
-                throw new InvalidParameterValueException("Unable to find 
domain by id=" + domainId);
-            }
+        List<Long> permittedAccounts = new ArrayList<Long>();
 
-            _accountMgr.checkAccess(caller, domain);
-        } else {
-            // default domainId to the caller's domain
-            domainId = caller.getDomainId();
-        }
+        boolean listAll = cmd.listAll();
+        Long id = cmd.getId();
+        Ternary<Long, Boolean, ListProjectResourcesCriteria> 
domainIdRecursiveListProject = new Ternary<Long, Boolean, 
ListProjectResourcesCriteria>(
+                cmd.getDomainId(), cmd.isRecursive(), null);
+        _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), 
null, permittedAccounts,
+                domainIdRecursiveListProject, listAll, false);
+        Long domainId = domainIdRecursiveListProject.first();
+        Boolean isRecursive = domainIdRecursiveListProject.second();
+        ListProjectResourcesCriteria listProjectResourcesCriteria = 
domainIdRecursiveListProject.third();
 
         Filter searchFilter = new Filter(UserAccountJoinVO.class, "id", true, 
cmd.getStartIndex(), cmd.getPageSizeVal());
 
-        Long id = cmd.getId();
         Object username = cmd.getUsername();
         Object type = cmd.getAccountType();
         Object accountName = cmd.getAccountName();
@@ -399,6 +396,8 @@ public class QueryManagerImpl extends ManagerBase 
implements QueryService {
         Object keyword = cmd.getKeyword();
 
         SearchBuilder<UserAccountJoinVO> sb = 
_userAccountJoinDao.createSearchBuilder();
+        _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, 
permittedAccounts,
+                listProjectResourcesCriteria);
         sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.LIKE);
         if (id != null && id == 1) {
             // system user should NOT be searchable
@@ -422,6 +421,11 @@ public class QueryManagerImpl extends ManagerBase 
implements QueryService {
         }
 
         SearchCriteria<UserAccountJoinVO> sc = sb.create();
+
+        // building ACL condition
+        _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, 
permittedAccounts,
+                listProjectResourcesCriteria);
+
         if (keyword != null) {
             SearchCriteria<UserAccountJoinVO> ssc = 
_userAccountJoinDao.createSearchCriteria();
             ssc.addOr("username", SearchCriteria.Op.LIKE, "%" + keyword + "%");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6d1482b9/server/src/com/cloud/api/query/vo/UserAccountJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/UserAccountJoinVO.java 
b/server/src/com/cloud/api/query/vo/UserAccountJoinVO.java
index ed29284..0e66ca0 100644
--- a/server/src/com/cloud/api/query/vo/UserAccountJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/UserAccountJoinVO.java
@@ -26,12 +26,13 @@ import javax.persistence.Table;
 import org.apache.cloudstack.api.Identity;
 import org.apache.cloudstack.api.InternalIdentity;
 
+import com.cloud.user.UserAccount;
 import com.cloud.utils.db.Encrypt;
 import com.cloud.utils.db.GenericDao;
 
 @Entity
 @Table(name = "user_view")
-public class UserAccountJoinVO extends BaseViewVO implements InternalIdentity, 
Identity {
+public class UserAccountJoinVO extends BaseViewVO implements InternalIdentity, 
Identity, ControlledViewEntity {
 
     @Id
     @Column(name = "id", updatable = false, nullable = false)
@@ -235,4 +236,19 @@ public class UserAccountJoinVO extends BaseViewVO 
implements InternalIdentity, I
     public boolean isDefault() {
         return isDefault;
     }
+
+    @Override
+    public Class<?> getEntityType() {
+        return UserAccount.class;
+    }
+
+    @Override
+    public String getProjectUuid() {
+        return null;
+    }
+
+    @Override
+    public String getProjectName() {
+        return null;
+    }
 }

Reply via email to