Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5D2C810798 for ; Fri, 31 Jan 2014 02:08:26 +0000 (UTC) Received: (qmail 81158 invoked by uid 500); 31 Jan 2014 02:08:08 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 81005 invoked by uid 500); 31 Jan 2014 02:08:05 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 80970 invoked by uid 99); 31 Jan 2014 02:08:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Jan 2014 02:08:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8C9AA9170DF; Fri, 31 Jan 2014 02:08:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: animesh@apache.org To: commits@cloudstack.apache.org Date: Fri, 31 Jan 2014 02:08:04 -0000 Message-Id: <3d39c8fdaac8452dbeb36f775d37ff2d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/11] git commit: updated refs/heads/4.3 to e089b91 Updated Branches: refs/heads/4.3 210b19c1f -> e089b9138 LOUDSTACK-5987: when listTemplates with filter=community/featured, get public templates from all domains in the system, not just parent/child subdomains of the caller Conflicts: server/src/com/cloud/api/query/QueryManagerImpl.java (cherry picked from commit b1d4c06ad1d8931f5c810dcd8b1f1df01db174f3) Signed-off-by: Animesh Chaturvedi Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/45e45b93 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/45e45b93 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/45e45b93 Branch: refs/heads/4.3 Commit: 45e45b930a6e3217feb6a60de412564091a13015 Parents: 210b19c Author: Alena Prokharchyk Authored: Wed Jan 29 17:12:46 2014 -0800 Committer: Animesh Chaturvedi Committed: Thu Jan 30 17:39:28 2014 -0800 ---------------------------------------------------------------------- .../com/cloud/api/query/QueryManagerImpl.java | 30 +++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/45e45b93/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 3cbe727..6671ab9 100644 --- a/server/src/com/cloud/api/query/QueryManagerImpl.java +++ b/server/src/com/cloud/api/query/QueryManagerImpl.java @@ -26,10 +26,6 @@ import java.util.Set; import javax.ejb.Local; import javax.inject.Inject; -import org.apache.cloudstack.engine.subsystem.api.storage.*; -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO; import org.apache.cloudstack.affinity.AffinityGroupResponse; @@ -85,8 +81,15 @@ import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.api.response.VolumeResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; +import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.query.QueryService; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; import com.cloud.api.query.dao.AccountJoinDao; import com.cloud.api.query.dao.AffinityGroupJoinDao; @@ -172,8 +175,8 @@ import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VolumeDetailsDao; import com.cloud.tags.ResourceTagVO; import com.cloud.tags.dao.ResourceTagDao; -import com.cloud.template.VirtualMachineTemplate.TemplateFilter; import com.cloud.template.VirtualMachineTemplate.State; +import com.cloud.template.VirtualMachineTemplate.TemplateFilter; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.user.DomainManager; @@ -2930,10 +2933,17 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { if (!permittedAccounts.isEmpty()) { for (Account account : permittedAccounts) { permittedAccountIds.add(account.getId()); - DomainVO accountDomain = _domainDao.findById(account.getDomainId()); + boolean publicTemplates = (templateFilter == TemplateFilter.featured || templateFilter == TemplateFilter.community); // get all parent domain ID's all the way till root domain - DomainVO domainTreeNode = accountDomain; + DomainVO domainTreeNode = null; + //if template filter is featured, or community, all child domains should be included in search + if (publicTemplates) { + domainTreeNode = _domainDao.findById(Domain.ROOT_DOMAIN); + + } else { + domainTreeNode = _domainDao.findById(account.getDomainId()); + } relatedDomainIds.add(domainTreeNode.getId()); while (domainTreeNode.getParent() != null) { domainTreeNode = _domainDao.findById(domainTreeNode.getParent()); @@ -2941,10 +2951,8 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { } // get all child domain ID's - if (_accountMgr.isAdmin(account.getType()) - || (templateFilter == TemplateFilter.featured || templateFilter == TemplateFilter.community)) { - List allChildDomains = _domainDao.findAllChildren(accountDomain.getPath(), - accountDomain.getId()); + if (_accountMgr.isAdmin(account.getType()) || publicTemplates) { + List allChildDomains = _domainDao.findAllChildren(domainTreeNode.getPath(), domainTreeNode.getId()); for (DomainVO childDomain : allChildDomains) { relatedDomainIds.add(childDomain.getId()); }