cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [6/50] git commit: AccountManager: Add method to translate account type to role type
Date Mon, 14 Jan 2013 16:15:59 GMT
AccountManager: Add method to translate account type to role type

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>


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

Branch: refs/heads/cloud-agent-with-openvswitch
Commit: 1425736c193c56a51ec59b23e35080bd74926baf
Parents: f2ae0ae
Author: Rohit Yadav <bhaisaab@apache.org>
Authored: Thu Jan 10 15:31:32 2013 -0800
Committer: Rohit Yadav <bhaisaab@apache.org>
Committed: Thu Jan 10 15:55:01 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/user/AccountService.java         |    3 ++
 server/src/com/cloud/user/AccountManagerImpl.java  |   26 +++++++++++++++
 .../com/cloud/user/MockAccountManagerImpl.java     |    6 +++
 3 files changed, 35 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1425736c/api/src/com/cloud/user/AccountService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java
index ce16f5e..9f5f4d2 100755
--- a/api/src/com/cloud/user/AccountService.java
+++ b/api/src/com/cloud/user/AccountService.java
@@ -20,6 +20,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 
 import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
@@ -193,6 +194,8 @@ public interface AccountService {
 
     UserAccount getUserByApiKey(String apiKey);
 
+    RoleType getRoleType(Account account);
+
     void checkAccess(Account account, Domain domain) throws PermissionDeniedException;
 
     void checkAccess(Account account, AccessType accessType, boolean sameOwner, ControlledEntity...
entities) throws PermissionDeniedException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1425736c/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index c6a7d51..b910a03 100755
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -37,6 +37,7 @@ import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
 import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
@@ -1543,6 +1544,31 @@ public class AccountManagerImpl implements AccountManager, AccountService,
Manag
     }
 
     @Override
+    public RoleType getRoleType(Account account) {
+        RoleType roleType = RoleType.Unknown;
+        if (account == null)
+            return roleType;
+        short accountType = account.getType();
+
+        // Account type to role type translation
+        switch (accountType) {
+            case Account.ACCOUNT_TYPE_ADMIN:
+                roleType = RoleType.Admin;
+                break;
+            case Account.ACCOUNT_TYPE_DOMAIN_ADMIN:
+                roleType = RoleType.DomainAdmin;
+                break;
+            case Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN:
+                roleType = RoleType.ResourceAdmin;
+                break;
+            case Account.ACCOUNT_TYPE_NORMAL:
+                roleType = RoleType.User;
+                break;
+        }
+        return roleType;
+    }
+
+    @Override
     public User getActiveUser(long userId) {
         return _userDao.findById(userId);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1425736c/server/test/com/cloud/user/MockAccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/user/MockAccountManagerImpl.java b/server/test/com/cloud/user/MockAccountManagerImpl.java
index ae5d0e5..550304a 100644
--- a/server/test/com/cloud/user/MockAccountManagerImpl.java
+++ b/server/test/com/cloud/user/MockAccountManagerImpl.java
@@ -23,6 +23,7 @@ import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 import com.cloud.api.query.vo.ControlledViewEntity;
 
@@ -344,4 +345,9 @@ public class MockAccountManagerImpl implements Manager, AccountManager,
AccountS
         return null;
     }
 
+    @Override
+    public RoleType getRoleType(Account account) {
+        return null;
+    }
+
 }


Mime
View raw message