From 326a46d0ac0307bd30b5d6e4162bc3cc41f974d4 Mon Sep 17 00:00:00 2001 From: Nitin Mehta Date: Wed, 11 Dec 2013 21:53:33 -0800 Subject: [PATCH] Revert "CLOUDSTACK-4904: Unable to see a derieved template if the" This reverts commit 4907a8f6faf17294f4ca58e05cee9faaf77a385b. --- .../apache/cloudstack/api/ApiConstants.java | 1 - .../api/command/user/iso/ListIsosCmd.java | 7 ----- .../user/template/ListTemplatesCmd.java | 7 ----- .../com/cloud/api/query/QueryManagerImpl.java | 27 ++++--------------- .../cloud/api/query/dao/TemplateJoinDao.java | 5 ---- .../api/query/dao/TemplateJoinDaoImpl.java | 8 ------ 6 files changed, 5 insertions(+), 50 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java index 1f9948198e5..e08923c29ba 100755 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/org/apache/cloudstack/api/ApiConstants.java @@ -209,7 +209,6 @@ public class ApiConstants { public static final String SENT_BYTES = "sentbytes"; public static final String SERVICE_OFFERING_ID = "serviceofferingid"; public static final String SHOW_CAPACITIES = "showcapacities"; - public static final String SHOW_REMOVED = "showremoved"; public static final String SIZE = "size"; public static final String SNAPSHOT_ID = "snapshotid"; public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid"; diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java index 9b4b414cf53..c3f558bd249 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java @@ -79,9 +79,6 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd { description="the ID of the zone") private Long zoneId; - @Parameter(name=ApiConstants.SHOW_REMOVED, type=CommandType.BOOLEAN, description="show removed ISOs as well") - private Boolean showRemoved; - ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -119,10 +116,6 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd { return zoneId; } - public Boolean getShowRemoved() { - return (showRemoved != null ? showRemoved : false); - } - public boolean listInReadyState() { Account account = CallContext.current().getCallingAccount(); // It is account specific if account is admin type and domainId and accountName are not null diff --git a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java index b055bf243ab..4b349092125 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java @@ -70,9 +70,6 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd { @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class, description="list templates by zoneId") private Long zoneId; - - @Parameter(name=ApiConstants.SHOW_REMOVED, type=CommandType.BOOLEAN, description="show removed templates as well") - private Boolean showRemoved; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -97,10 +94,6 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd { return zoneId; } - public Boolean getShowRemoved() { - return (showRemoved != null ? showRemoved : false); - } - public boolean listInReadyState() { Account account = CallContext.current().getCallingAccount(); diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java index 3830b2d0bfd..58df38c296a 100644 --- a/server/src/com/cloud/api/query/QueryManagerImpl.java +++ b/server/src/com/cloud/api/query/QueryManagerImpl.java @@ -2793,7 +2793,6 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { TemplateFilter templateFilter = TemplateFilter.valueOf(cmd.getTemplateFilter()); Long id = cmd.getId(); Map tags = cmd.getTags(); - boolean showRemovedTmpl = cmd.getShowRemoved(); Account caller = CallContext.current().getCallingAccount(); boolean listAll = false; @@ -2821,14 +2820,14 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { return searchForTemplatesInternal(id, cmd.getTemplateName(), cmd.getKeyword(), templateFilter, false, null, cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), hypervisorType, showDomr, - cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria, tags, showRemovedTmpl); + cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria, tags); } private Pair, Integer> searchForTemplatesInternal(Long templateId, String name, String keyword, TemplateFilter templateFilter, boolean isIso, Boolean bootable, Long pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean showDomr, boolean onlyReady, List permittedAccounts, Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, - Map tags, boolean showRemovedTmpl) { + Map tags) { // check if zone is configured, if not, just return empty list List hypers = null; @@ -2851,11 +2850,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { // verify templateId parameter and specially handle it if (templateId != null) { - if(showRemovedTmpl){ - template = _templateDao.findByIdIncludingRemoved(templateId); - } else { - template = _templateDao.findById(templateId); - } + template = _templateDao.findByIdIncludingRemoved(templateId); // Done for backward compatibility - Bug-5221 if (template == null) { throw new InvalidParameterValueException("Please specify a valid template ID."); }// If ISO requested then it should be ISO. @@ -2873,11 +2868,6 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { ex.addProxyObject(template.getUuid(), "templateId"); throw ex; } - // If template is removed and showRemoved flag not turned -> throw exception. findbyId returns removed template as well above. - if ((template == null) || ((template.getRemoved() != null) && !showRemovedTmpl)){ - s_logger.error("Please specify a valid template ID, template " + template.getUuid() + " is removed"); - throw new InvalidParameterValueException("Please specify a valid template ID " + template.getUuid()); - } // if template is not public, perform permission check here if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) { @@ -3061,13 +3051,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { // sc.addAnd("removed", SearchCriteria.Op.NULL); // search unique templates and find details by Ids - Pair, Integer> uniqueTmplPair = null; - if(showRemovedTmpl){ - uniqueTmplPair = _templateJoinDao.searchIncludingRemovedAndCount(sc, searchFilter); - } else { - uniqueTmplPair = _templateJoinDao.searchAndCount(sc, searchFilter); - } - + Pair, Integer> uniqueTmplPair = _templateJoinDao.searchAndCount(sc, searchFilter); Integer count = uniqueTmplPair.second(); if (count.intValue() == 0) { // empty result @@ -3104,7 +3088,6 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { TemplateFilter isoFilter = TemplateFilter.valueOf(cmd.getIsoFilter()); Long id = cmd.getId(); Map tags = cmd.getTags(); - boolean showRemovedISO = cmd.getShowRemoved(); Account caller = CallContext.current().getCallingAccount(); boolean listAll = false; @@ -3131,7 +3114,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { return searchForTemplatesInternal(cmd.getId(), cmd.getIsoName(), cmd.getKeyword(), isoFilter, true, cmd.isBootable(), cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), hypervisorType, true, - cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria, tags, showRemovedISO); + cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria, tags); } @Override diff --git a/server/src/com/cloud/api/query/dao/TemplateJoinDao.java b/server/src/com/cloud/api/query/dao/TemplateJoinDao.java index e0c3fc053e6..f73f5bdea1e 100644 --- a/server/src/com/cloud/api/query/dao/TemplateJoinDao.java +++ b/server/src/com/cloud/api/query/dao/TemplateJoinDao.java @@ -18,9 +18,6 @@ package com.cloud.api.query.dao; import java.util.List; -import com.cloud.utils.Pair; -import com.cloud.utils.db.Filter; -import com.cloud.utils.db.SearchCriteria; import org.apache.cloudstack.api.response.TemplateResponse; import com.cloud.api.query.vo.TemplateJoinVO; @@ -45,6 +42,4 @@ public interface TemplateJoinDao extends GenericDao { List listActiveTemplates(long storeId); - public Pair, Integer> searchIncludingRemovedAndCount(final SearchCriteria sc, final Filter filter); - } diff --git a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java index a35b3349c10..468fb8314c0 100644 --- a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java @@ -24,8 +24,6 @@ import java.util.Map; import javax.ejb.Local; import javax.inject.Inject; -import com.cloud.utils.Pair; -import com.cloud.utils.db.Filter; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.context.CallContext; @@ -447,12 +445,6 @@ public class TemplateJoinDaoImpl extends GenericDaoBase im return searchIncludingRemoved(sc, null, null, false); } - public Pair, Integer> searchIncludingRemovedAndCount(final SearchCriteria sc, final Filter filter) { - List objects = searchIncludingRemoved(sc, filter, null, false); - Integer count = getCount(sc); - return new Pair, Integer>(objects, count); - } - }