mirror of https://github.com/apache/cloudstack.git
Revert "CLOUDSTACK-4904: Unable to see a derieved template if the"
This reverts commit 4907a8f6fa.
This commit is contained in:
parent
c71e02c10c
commit
326a46d0ac
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -2793,7 +2793,6 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
|||
TemplateFilter templateFilter = TemplateFilter.valueOf(cmd.getTemplateFilter());
|
||||
Long id = cmd.getId();
|
||||
Map<String, String> 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<List<TemplateJoinVO>, 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<Account> permittedAccounts, Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria,
|
||||
Map<String, String> tags, boolean showRemovedTmpl) {
|
||||
Map<String, String> tags) {
|
||||
|
||||
// check if zone is configured, if not, just return empty list
|
||||
List<HypervisorType> 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<List<TemplateJoinVO>, Integer> uniqueTmplPair = null;
|
||||
if(showRemovedTmpl){
|
||||
uniqueTmplPair = _templateJoinDao.searchIncludingRemovedAndCount(sc, searchFilter);
|
||||
} else {
|
||||
uniqueTmplPair = _templateJoinDao.searchAndCount(sc, searchFilter);
|
||||
}
|
||||
|
||||
Pair<List<TemplateJoinVO>, 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<String, String> 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
|
||||
|
|
|
|||
|
|
@ -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<TemplateJoinVO, Long> {
|
|||
|
||||
List<TemplateJoinVO> listActiveTemplates(long storeId);
|
||||
|
||||
public Pair<List<TemplateJoinVO>, Integer> searchIncludingRemovedAndCount(final SearchCriteria<TemplateJoinVO> sc, final Filter filter);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<TemplateJoinVO, Long> im
|
|||
return searchIncludingRemoved(sc, null, null, false);
|
||||
}
|
||||
|
||||
public Pair<List<TemplateJoinVO>, Integer> searchIncludingRemovedAndCount(final SearchCriteria<TemplateJoinVO> sc, final Filter filter) {
|
||||
List<TemplateJoinVO> objects = searchIncludingRemoved(sc, filter, null, false);
|
||||
Integer count = getCount(sc);
|
||||
return new Pair<List<TemplateJoinVO>, Integer>(objects, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue