Repository: cloudstack
Updated Branches:
  refs/heads/master 52803ae6b -> c25d4fdea


CLOUDSTACK-7847: Separate ListDomains cmd to use two different views


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

Branch: refs/heads/master
Commit: c25d4fdea2671160deee53ad25f45fab5dc408cb
Parents: 52803ae
Author: Wei Zhou <[email protected]>
Authored: Wed Dec 3 12:33:57 2014 +0100
Committer: Wei Zhou <[email protected]>
Committed: Wed Dec 3 12:33:57 2014 +0100

----------------------------------------------------------------------
 .../command/admin/domain/ListDomainsCmd.java    |  7 +-
 .../admin/domain/ListDomainsCmdByAdmin.java     | 28 +++++++
 server/src/com/cloud/api/ApiDBUtils.java        |  4 +-
 .../com/cloud/api/query/QueryManagerImpl.java   |  9 ++-
 .../com/cloud/api/query/ViewResponseHelper.java |  4 +-
 .../com/cloud/api/query/dao/DomainJoinDao.java  |  3 +-
 .../cloud/api/query/dao/DomainJoinDaoImpl.java  | 81 ++++++++++----------
 .../com/cloud/server/ManagementServerImpl.java  |  2 +
 8 files changed, 90 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25d4fde/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java 
b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java
index db910f4..e382ed9 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java
@@ -22,10 +22,13 @@ import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseListCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ListResponse;
 
-@APICommand(name = "listDomains", description = "Lists domains and provides 
detailed information for listed domains", responseObject = DomainResponse.class,
+import com.cloud.domain.Domain;
+
+@APICommand(name = "listDomains", description = "Lists domains and provides 
detailed information for listed domains", responseObject = 
DomainResponse.class, responseView = ResponseView.Restricted, entityType = 
{Domain.class},
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
 public class ListDomainsCmd extends BaseListCmd {
     public static final Logger s_logger = 
Logger.getLogger(ListDomainsCmd.class.getName());
@@ -80,7 +83,7 @@ public class ListDomainsCmd extends BaseListCmd {
     }
 
     @Override
-    public void execute(){
+    public void execute() {
         ListResponse<DomainResponse> response = 
_queryService.searchForDomains(this);
         response.setResponseName(getCommandName());
         this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25d4fde/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmdByAdmin.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmdByAdmin.java
 
b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmdByAdmin.java
new file mode 100644
index 0000000..bbe75de
--- /dev/null
+++ 
b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmdByAdmin.java
@@ -0,0 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.domain;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.response.DomainResponse;
+
+import com.cloud.domain.Domain;
+
+@APICommand(name = "listDomains", description = "Lists domains and provides 
detailed information for listed domains", responseObject = 
DomainResponse.class, responseView = ResponseView.Full, entityType = 
{Domain.class},
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class ListDomainsCmdByAdmin extends ListDomainsCmd {
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25d4fde/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java 
b/server/src/com/cloud/api/ApiDBUtils.java
index 8a6f651..94ee3a4 100644
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -1806,8 +1806,8 @@ public class ApiDBUtils {
         return s_imageStoreJoinDao.newImageStoreView(vr);
     }
 
-    public static DomainResponse newDomainResponse(DomainJoinVO ve) {
-        return s_domainJoinDao.newDomainResponse(ve);
+    public static DomainResponse newDomainResponse(ResponseView view, 
DomainJoinVO ve) {
+        return s_domainJoinDao.newDomainResponse(view, ve);
     }
 
     public static AccountResponse newAccountResponse(ResponseView view, 
AccountJoinVO ve) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25d4fde/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 5459423..9d97f3b 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -40,6 +40,7 @@ import org.apache.cloudstack.api.ResourceDetail;
 import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.command.admin.account.ListAccountsCmdByAdmin;
 import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd;
+import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmdByAdmin;
 import org.apache.cloudstack.api.command.admin.host.ListHostTagsCmd;
 import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
 import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
@@ -1840,7 +1841,13 @@ public class QueryManagerImpl extends ManagerBase 
implements QueryService {
     public ListResponse<DomainResponse> searchForDomains(ListDomainsCmd cmd) {
         Pair<List<DomainJoinVO>, Integer> result = 
searchForDomainsInternal(cmd);
         ListResponse<DomainResponse> response = new 
ListResponse<DomainResponse>();
-        List<DomainResponse> domainResponses = 
ViewResponseHelper.createDomainResponse(result.first().toArray(
+
+        ResponseView respView = ResponseView.Restricted;
+        if (cmd instanceof ListDomainsCmdByAdmin) {
+            respView = ResponseView.Full;
+        }
+
+        List<DomainResponse> domainResponses = 
ViewResponseHelper.createDomainResponse(respView, result.first().toArray(
                 new DomainJoinVO[result.first().size()]));
         response.setResponses(domainResponses, result.second());
         return response;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25d4fde/server/src/com/cloud/api/query/ViewResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/ViewResponseHelper.java 
b/server/src/com/cloud/api/query/ViewResponseHelper.java
index b8bb6ea..09f2f7d 100644
--- a/server/src/com/cloud/api/query/ViewResponseHelper.java
+++ b/server/src/com/cloud/api/query/ViewResponseHelper.java
@@ -348,10 +348,10 @@ public class ViewResponseHelper {
         return new ArrayList<StoragePoolResponse>(vrDataList.values());
     }
 
-    public static List<DomainResponse> createDomainResponse(DomainJoinVO... 
domains) {
+    public static List<DomainResponse> createDomainResponse(ResponseView view, 
DomainJoinVO... domains) {
         List<DomainResponse> respList = new ArrayList<DomainResponse>();
         for (DomainJoinVO vt : domains){
-            respList.add(ApiDBUtils.newDomainResponse(vt));
+            respList.add(ApiDBUtils.newDomainResponse(view, vt));
         }
         return respList;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25d4fde/server/src/com/cloud/api/query/dao/DomainJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/DomainJoinDao.java 
b/server/src/com/cloud/api/query/dao/DomainJoinDao.java
index e6b9f4c..164679c 100644
--- a/server/src/com/cloud/api/query/dao/DomainJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/DomainJoinDao.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.api.query.dao;
 
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ResourceLimitAndCountResponse;
 
@@ -25,7 +26,7 @@ import com.cloud.utils.db.GenericDao;
 
 public interface DomainJoinDao extends GenericDao<DomainJoinVO, Long> {
 
-    DomainResponse newDomainResponse(DomainJoinVO vol);
+    DomainResponse newDomainResponse(ResponseView view, DomainJoinVO vol);
 
     DomainJoinVO newDomainView(Domain vol);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25d4fde/server/src/com/cloud/api/query/dao/DomainJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/DomainJoinDaoImpl.java 
b/server/src/com/cloud/api/query/dao/DomainJoinDaoImpl.java
index dc6b701..220f8b6 100644
--- a/server/src/com/cloud/api/query/dao/DomainJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/DomainJoinDaoImpl.java
@@ -20,6 +20,7 @@ import java.util.List;
 
 import javax.ejb.Local;
 
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ResourceLimitAndCountResponse;
 import org.apache.log4j.Logger;
@@ -50,7 +51,7 @@ public class DomainJoinDaoImpl extends 
GenericDaoBase<DomainJoinVO, Long> implem
     }
 
     @Override
-    public DomainResponse newDomainResponse(DomainJoinVO domain) {
+    public DomainResponse newDomainResponse(ResponseView view, DomainJoinVO 
domain) {
         DomainResponse domainResponse = new DomainResponse();
         domainResponse.setDomainName(domain.getName());
         domainResponse.setId(domain.getUuid());
@@ -73,14 +74,14 @@ public class DomainJoinDaoImpl extends 
GenericDaoBase<DomainJoinVO, Long> implem
         domainResponse.setState(domain.getState().toString());
         domainResponse.setNetworkDomain(domain.getNetworkDomain());
 
-        boolean isRootDomain = (domain.getId() == Domain.ROOT_DOMAIN);
-        setResourceLimits(domain, isRootDomain, domainResponse);
+        boolean fullView = (view == ResponseView.Full && domain.getId() == 
Domain.ROOT_DOMAIN);
+        setResourceLimits(domain, fullView, domainResponse);
 
         //get resource limits for projects
-        long projectLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getProjectLimit(), 
isRootDomain, ResourceType.project, domain.getId());
-        String projectLimitDisplay = (isRootDomain || projectLimit == -1) ? 
"Unlimited" : String.valueOf(projectLimit);
+        long projectLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getProjectLimit(), 
fullView, ResourceType.project, domain.getId());
+        String projectLimitDisplay = (fullView || projectLimit == -1) ? 
"Unlimited" : String.valueOf(projectLimit);
         long projectTotal = (domain.getProjectTotal() == null) ? 0 : 
domain.getProjectTotal();
-        String projectAvail = (isRootDomain || projectLimit == -1) ? 
"Unlimited" : String.valueOf(projectLimit - projectTotal);
+        String projectAvail = (fullView || projectLimit == -1) ? "Unlimited" : 
String.valueOf(projectLimit - projectTotal);
         domainResponse.setProjectLimit(projectLimitDisplay);
         domainResponse.setProjectTotal(projectTotal);
         domainResponse.setProjectAvailable(projectAvail);
@@ -91,98 +92,98 @@ public class DomainJoinDaoImpl extends 
GenericDaoBase<DomainJoinVO, Long> implem
     }
 
     @Override
-    public void setResourceLimits(DomainJoinVO domain, boolean isRootDomain, 
ResourceLimitAndCountResponse response) {
+    public void setResourceLimits(DomainJoinVO domain, boolean fullView, 
ResourceLimitAndCountResponse response) {
         // Get resource limits and counts
-        long vmLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getVmLimit(), isRootDomain, 
ResourceType.user_vm, domain.getId());
-        String vmLimitDisplay = (isRootDomain || vmLimit == -1) ? "Unlimited" 
: String.valueOf(vmLimit);
+        long vmLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getVmLimit(), fullView, 
ResourceType.user_vm, domain.getId());
+        String vmLimitDisplay = (fullView || vmLimit == -1) ? "Unlimited" : 
String.valueOf(vmLimit);
         long vmTotal = (domain.getVmTotal() == null) ? 0 : domain.getVmTotal();
-        String vmAvail = (isRootDomain || vmLimit == -1) ? "Unlimited" : 
String.valueOf(vmLimit - vmTotal);
+        String vmAvail = (fullView || vmLimit == -1) ? "Unlimited" : 
String.valueOf(vmLimit - vmTotal);
         response.setVmLimit(vmLimitDisplay);
         response.setVmTotal(vmTotal);
         response.setVmAvailable(vmAvail);
 
-        long ipLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getIpLimit(), isRootDomain, 
ResourceType.public_ip, domain.getId());
-        String ipLimitDisplay = (isRootDomain || ipLimit == -1) ? "Unlimited" 
: String.valueOf(ipLimit);
+        long ipLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getIpLimit(), fullView, 
ResourceType.public_ip, domain.getId());
+        String ipLimitDisplay = (fullView || ipLimit == -1) ? "Unlimited" : 
String.valueOf(ipLimit);
         long ipTotal = (domain.getIpTotal() == null) ? 0 : domain.getIpTotal();
-        String ipAvail = ((isRootDomain || ipLimit == -1)) ? "Unlimited" : 
String.valueOf(ipLimit - ipTotal);
+        String ipAvail = ((fullView || ipLimit == -1)) ? "Unlimited" : 
String.valueOf(ipLimit - ipTotal);
         response.setIpLimit(ipLimitDisplay);
         response.setIpTotal(ipTotal);
         response.setIpAvailable(ipAvail);
 
-        long volumeLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getVolumeLimit(), 
isRootDomain, ResourceType.volume, domain.getId());
-        String volumeLimitDisplay = (isRootDomain || volumeLimit == -1) ? 
"Unlimited" : String.valueOf(volumeLimit);
+        long volumeLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getVolumeLimit(), fullView, 
ResourceType.volume, domain.getId());
+        String volumeLimitDisplay = (fullView || volumeLimit == -1) ? 
"Unlimited" : String.valueOf(volumeLimit);
         long volumeTotal = (domain.getVolumeTotal() == 0) ? 0 : 
domain.getVolumeTotal();
-        String volumeAvail = (isRootDomain || volumeLimit == -1) ? "Unlimited" 
: String.valueOf(volumeLimit - volumeTotal);
+        String volumeAvail = (fullView || volumeLimit == -1) ? "Unlimited" : 
String.valueOf(volumeLimit - volumeTotal);
         response.setVolumeLimit(volumeLimitDisplay);
         response.setVolumeTotal(volumeTotal);
         response.setVolumeAvailable(volumeAvail);
 
-        long snapshotLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getSnapshotLimit(), 
isRootDomain, ResourceType.snapshot, domain.getId());
-        String snapshotLimitDisplay = (isRootDomain || snapshotLimit == -1) ? 
"Unlimited" : String.valueOf(snapshotLimit);
+        long snapshotLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getSnapshotLimit(), 
fullView, ResourceType.snapshot, domain.getId());
+        String snapshotLimitDisplay = (fullView || snapshotLimit == -1) ? 
"Unlimited" : String.valueOf(snapshotLimit);
         long snapshotTotal = (domain.getSnapshotTotal() == null) ? 0 : 
domain.getSnapshotTotal();
-        String snapshotAvail = (isRootDomain || snapshotLimit == -1) ? 
"Unlimited" : String.valueOf(snapshotLimit - snapshotTotal);
+        String snapshotAvail = (fullView || snapshotLimit == -1) ? "Unlimited" 
: String.valueOf(snapshotLimit - snapshotTotal);
         response.setSnapshotLimit(snapshotLimitDisplay);
         response.setSnapshotTotal(snapshotTotal);
         response.setSnapshotAvailable(snapshotAvail);
 
-        Long templateLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getTemplateLimit(), 
isRootDomain, ResourceType.template, domain.getId());
-        String templateLimitDisplay = (isRootDomain || templateLimit == -1) ? 
"Unlimited" : String.valueOf(templateLimit);
+        Long templateLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getTemplateLimit(), 
fullView, ResourceType.template, domain.getId());
+        String templateLimitDisplay = (fullView || templateLimit == -1) ? 
"Unlimited" : String.valueOf(templateLimit);
         Long templateTotal = (domain.getTemplateTotal() == null) ? 0 : 
domain.getTemplateTotal();
-        String templateAvail = (isRootDomain || templateLimit == -1) ? 
"Unlimited" : String.valueOf(templateLimit - templateTotal);
+        String templateAvail = (fullView || templateLimit == -1) ? "Unlimited" 
: String.valueOf(templateLimit - templateTotal);
         response.setTemplateLimit(templateLimitDisplay);
         response.setTemplateTotal(templateTotal);
         response.setTemplateAvailable(templateAvail);
 
         //get resource limits for networks
-        long networkLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getNetworkLimit(), 
isRootDomain, ResourceType.network, domain.getId());
-        String networkLimitDisplay = (isRootDomain || networkLimit == -1) ? 
"Unlimited" : String.valueOf(networkLimit);
+        long networkLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getNetworkLimit(), 
fullView, ResourceType.network, domain.getId());
+        String networkLimitDisplay = (fullView || networkLimit == -1) ? 
"Unlimited" : String.valueOf(networkLimit);
         long networkTotal = (domain.getNetworkTotal() == null) ? 0 : 
domain.getNetworkTotal();
-        String networkAvail = (isRootDomain || networkLimit == -1) ? 
"Unlimited" : String.valueOf(networkLimit - networkTotal);
+        String networkAvail = (fullView || networkLimit == -1) ? "Unlimited" : 
String.valueOf(networkLimit - networkTotal);
         response.setNetworkLimit(networkLimitDisplay);
         response.setNetworkTotal(networkTotal);
         response.setNetworkAvailable(networkAvail);
 
         //get resource limits for vpcs
-        long vpcLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getVpcLimit(), 
isRootDomain, ResourceType.vpc, domain.getId());
-        String vpcLimitDisplay = (isRootDomain || vpcLimit == -1) ? 
"Unlimited" : String.valueOf(vpcLimit);
+        long vpcLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getVpcLimit(), fullView, 
ResourceType.vpc, domain.getId());
+        String vpcLimitDisplay = (fullView || vpcLimit == -1) ? "Unlimited" : 
String.valueOf(vpcLimit);
         long vpcTotal = (domain.getVpcTotal() == null) ? 0 : 
domain.getVpcTotal();
-        String vpcAvail = (isRootDomain || vpcLimit == -1) ? "Unlimited" : 
String.valueOf(vpcLimit - vpcTotal);
+        String vpcAvail = (fullView || vpcLimit == -1) ? "Unlimited" : 
String.valueOf(vpcLimit - vpcTotal);
         response.setVpcLimit(vpcLimitDisplay);
         response.setVpcTotal(vpcTotal);
         response.setVpcAvailable(vpcAvail);
 
         //get resource limits for cpu cores
-        long cpuLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getCpuLimit(), 
isRootDomain, ResourceType.cpu, domain.getId());
-        String cpuLimitDisplay = (isRootDomain || cpuLimit == -1) ? 
"Unlimited" : String.valueOf(cpuLimit);
+        long cpuLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getCpuLimit(), fullView, 
ResourceType.cpu, domain.getId());
+        String cpuLimitDisplay = (fullView || cpuLimit == -1) ? "Unlimited" : 
String.valueOf(cpuLimit);
         long cpuTotal = (domain.getCpuTotal() == null) ? 0 : 
domain.getCpuTotal();
-        String cpuAvail = (isRootDomain || cpuLimit == -1) ? "Unlimited" : 
String.valueOf(cpuLimit - cpuTotal);
+        String cpuAvail = (fullView || cpuLimit == -1) ? "Unlimited" : 
String.valueOf(cpuLimit - cpuTotal);
         response.setCpuLimit(cpuLimitDisplay);
         response.setCpuTotal(cpuTotal);
         response.setCpuAvailable(cpuAvail);
 
         //get resource limits for memory
-        long memoryLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getMemoryLimit(), 
isRootDomain, ResourceType.memory, domain.getId());
-        String memoryLimitDisplay = (isRootDomain || memoryLimit == -1) ? 
"Unlimited" : String.valueOf(memoryLimit);
+        long memoryLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getMemoryLimit(), fullView, 
ResourceType.memory, domain.getId());
+        String memoryLimitDisplay = (fullView || memoryLimit == -1) ? 
"Unlimited" : String.valueOf(memoryLimit);
         long memoryTotal = (domain.getMemoryTotal() == null) ? 0 : 
domain.getMemoryTotal();
-        String memoryAvail = (isRootDomain || memoryLimit == -1) ? "Unlimited" 
: String.valueOf(memoryLimit - memoryTotal);
+        String memoryAvail = (fullView || memoryLimit == -1) ? "Unlimited" : 
String.valueOf(memoryLimit - memoryTotal);
         response.setMemoryLimit(memoryLimitDisplay);
         response.setMemoryTotal(memoryTotal);
         response.setMemoryAvailable(memoryAvail);
 
       //get resource limits for primary storage space and convert it from 
Bytes to GiB
-        long primaryStorageLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getPrimaryStorageLimit(), 
isRootDomain, ResourceType.primary_storage, domain.getId());
-        String primaryStorageLimitDisplay = (isRootDomain || 
primaryStorageLimit == -1) ? "Unlimited" : String.valueOf(primaryStorageLimit / 
ResourceType.bytesToGiB);
+        long primaryStorageLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getPrimaryStorageLimit(), 
fullView, ResourceType.primary_storage, domain.getId());
+        String primaryStorageLimitDisplay = (fullView || primaryStorageLimit 
== -1) ? "Unlimited" : String.valueOf(primaryStorageLimit / 
ResourceType.bytesToGiB);
         long primaryStorageTotal = (domain.getPrimaryStorageTotal() == null) ? 
0 : (domain.getPrimaryStorageTotal() / ResourceType.bytesToGiB);
-        String primaryStorageAvail = (isRootDomain || primaryStorageLimit == 
-1) ? "Unlimited" : String.valueOf((primaryStorageLimit / 
ResourceType.bytesToGiB) - primaryStorageTotal);
+        String primaryStorageAvail = (fullView || primaryStorageLimit == -1) ? 
"Unlimited" : String.valueOf((primaryStorageLimit / ResourceType.bytesToGiB) - 
primaryStorageTotal);
         response.setPrimaryStorageLimit(primaryStorageLimitDisplay);
         response.setPrimaryStorageTotal(primaryStorageTotal);
         response.setPrimaryStorageAvailable(primaryStorageAvail);
 
         //get resource limits for secondary storage space and convert it from 
Bytes to GiB
-        long secondaryStorageLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getSecondaryStorageLimit(), 
isRootDomain, ResourceType.secondary_storage, domain.getId());
-        String secondaryStorageLimitDisplay = (isRootDomain || 
secondaryStorageLimit == -1) ? "Unlimited" : 
String.valueOf(secondaryStorageLimit / ResourceType.bytesToGiB);
+        long secondaryStorageLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getSecondaryStorageLimit(), 
fullView, ResourceType.secondary_storage, domain.getId());
+        String secondaryStorageLimitDisplay = (fullView || 
secondaryStorageLimit == -1) ? "Unlimited" : 
String.valueOf(secondaryStorageLimit / ResourceType.bytesToGiB);
         long secondaryStorageTotal = (domain.getSecondaryStorageTotal() == 
null) ? 0 : (domain.getSecondaryStorageTotal() / ResourceType.bytesToGiB);
-        String secondaryStorageAvail = (isRootDomain || secondaryStorageLimit 
== -1) ? "Unlimited" : String.valueOf((secondaryStorageLimit / 
ResourceType.bytesToGiB) - secondaryStorageTotal);
+        String secondaryStorageAvail = (fullView || secondaryStorageLimit == 
-1) ? "Unlimited" : String.valueOf((secondaryStorageLimit / 
ResourceType.bytesToGiB) - secondaryStorageTotal);
         response.setSecondaryStorageLimit(secondaryStorageLimitDisplay);
         response.setSecondaryStorageTotal(secondaryStorageTotal);
         response.setSecondaryStorageAvailable(secondaryStorageAvail);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25d4fde/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java 
b/server/src/com/cloud/server/ManagementServerImpl.java
index e089cd1..f426b05 100644
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -70,6 +70,7 @@ import 
org.apache.cloudstack.api.command.admin.domain.CreateDomainCmd;
 import org.apache.cloudstack.api.command.admin.domain.DeleteDomainCmd;
 import org.apache.cloudstack.api.command.admin.domain.ListDomainChildrenCmd;
 import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd;
+import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmdByAdmin;
 import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd;
 import org.apache.cloudstack.api.command.admin.guest.AddGuestOsCmd;
 import org.apache.cloudstack.api.command.admin.guest.AddGuestOsMappingCmd;
@@ -2560,6 +2561,7 @@ public class ManagementServerImpl extends ManagerBase 
implements ManagementServe
         cmdList.add(DeleteDomainCmd.class);
         cmdList.add(ListDomainChildrenCmd.class);
         cmdList.add(ListDomainsCmd.class);
+        cmdList.add(ListDomainsCmdByAdmin.class);
         cmdList.add(UpdateDomainCmd.class);
         cmdList.add(AddHostCmd.class);
         cmdList.add(AddSecondaryStorageCmd.class);

Reply via email to