cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [14/51] git commit: ApiDiscovery: Fix listApis interface, fix getProperties
Date Mon, 14 Jan 2013 18:00:34 GMT
ApiDiscovery: Fix listApis interface, fix getProperties

In case of api discovery, it does not make sense to create a separate properties file
If this plugin is enabled in components.xml, a user should be able to discover
all the apis accessible to their role.

listApis based on role type of caller user

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/0b1c2a59
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/0b1c2a59
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/0b1c2a59

Branch: refs/heads/ui-quick-view-v2
Commit: 0b1c2a5981fea3d4455acee6ac77e9fa84c9724b
Parents: c4e890c
Author: Rohit Yadav <bhaisaab@apache.org>
Authored: Thu Jan 10 15:47:59 2013 -0800
Committer: Rohit Yadav <bhaisaab@apache.org>
Committed: Thu Jan 10 15:55:02 2013 -0800

----------------------------------------------------------------------
 .../api/command/user/discovery/ListApisCmd.java    |    7 ++++++-
 .../cloudstack/discovery/ApiDiscoveryService.java  |    3 ++-
 .../discovery/ApiDiscoveryServiceImpl.java         |   10 +++++++---
 3 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/0b1c2a59/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java
----------------------------------------------------------------------
diff --git a/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java
b/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java
index dcbaec1..feab20a 100644
--- a/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java
+++ b/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java
@@ -16,6 +16,9 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.discovery;
 
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.BaseListCmd;
@@ -39,7 +42,9 @@ public class ListApisCmd extends BaseListCmd {
     @Override
     public void execute() throws ServerApiException {
         if (_apiDiscoveryService != null) {
-            ListResponse<ApiDiscoveryResponse> response = (ListResponse<ApiDiscoveryResponse>)
_apiDiscoveryService.listApis();
+            Account caller = UserContext.current().getCaller();
+            RoleType roleType = _accountService.getRoleType(UserContext.current().getCaller());
+            ListResponse<ApiDiscoveryResponse> response = (ListResponse<ApiDiscoveryResponse>)
_apiDiscoveryService.listApis(roleType);
             if (response == null) {
                 throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Api Discovery plugin
was unable to find and process any apis");
             }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/0b1c2a59/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryService.java
----------------------------------------------------------------------
diff --git a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryService.java
b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryService.java
index 96ea3ee..a1d440e 100644
--- a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryService.java
+++ b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryService.java
@@ -17,9 +17,10 @@
 package org.apache.cloudstack.discovery;
 
 import com.cloud.utils.component.PluggableService;
+import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.BaseResponse;
 import org.apache.cloudstack.api.response.ListResponse;
 
 public interface ApiDiscoveryService extends PluggableService {
-    ListResponse<? extends BaseResponse> listApis();
+    ListResponse<? extends BaseResponse> listApis(RoleType roleType);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/0b1c2a59/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
----------------------------------------------------------------------
diff --git a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
index ea6b206..2bc17bd 100644
--- a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
+++ b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
@@ -16,7 +16,9 @@
 // under the License.
 package org.apache.cloudstack.discovery;
 
+import com.cloud.utils.PropertiesUtil;
 import com.cloud.utils.ReflectUtil;
+import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.BaseAsyncCmd;
@@ -108,12 +110,14 @@ public class ApiDiscoveryServiceImpl implements ApiDiscoveryService
{
     }
 
     @Override
-    public ListResponse<? extends BaseResponse> listApis() {
+    public ListResponse<? extends BaseResponse> listApis(RoleType roleType) {
         return _discoveryResponse;
     }
 
     @Override
-    public String[] getPropertiesFiles() {
-        return new String[] { "api-discovery_commands.properties" };
+    public Map<String, String> getProperties() {
+        Map<String, String> apiDiscoveryPropertyMap = new HashMap<String, String>();
+        apiDiscoveryPropertyMap.put("listApis", "15");
+        return apiDiscoveryPropertyMap;
     }
 }


Mime
View raw message