From e52e7a5634d57f4d9dec2587b10658ae8d75643a Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Wed, 23 Oct 2013 14:07:47 -0700 Subject: [PATCH] CLOUDSTACK-4874: rever the previous commits. Service offering details are already being returned in "serviceofferingdetails" field of the service offering response --- .../apache/cloudstack/api/ApiConstants.java | 2 +- .../offering/ListServiceOfferingsCmd.java | 22 --------------- .../api/response/ServiceOfferingResponse.java | 10 ------- .../com/cloud/api/query/QueryManagerImpl.java | 27 +------------------ 4 files changed, 2 insertions(+), 59 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java index dbf668598dc..61eeb958429 100755 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/org/apache/cloudstack/api/ApiConstants.java @@ -521,7 +521,7 @@ public class ApiConstants { public static final String ROUTING = "isrouting"; public static final String MAX_CONNECTIONS = "maxconnections"; public static final String SERVICE_STATE = "servicestate"; - public static final String RESOURCE_TAGS = "resourcetags"; + public static final String RESOURCE_DETAIL = "resourcedetail"; public static final String EXPUNGE = "expunge"; public enum HostDetails { diff --git a/api/src/org/apache/cloudstack/api/command/user/offering/ListServiceOfferingsCmd.java b/api/src/org/apache/cloudstack/api/command/user/offering/ListServiceOfferingsCmd.java index 2869d625cd2..60eb438050f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/offering/ListServiceOfferingsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/offering/ListServiceOfferingsCmd.java @@ -63,9 +63,6 @@ public class ListServiceOfferingsCmd extends BaseListCmd { @Parameter(name=ApiConstants.SYSTEM_VM_TYPE, type=CommandType.STRING, description="the system VM type. Possible types are \"consoleproxy\", \"secondarystoragevm\" or \"domainrouter\".") private String systemVmType; - - @Parameter(name = ApiConstants.RESOURCE_TAGS, type = CommandType.MAP, description = "List service offerings by resource tags (key/value pairs)", since="4.3") - private Map resourceTag; ///////////////////////////////////////////////////// @@ -95,25 +92,6 @@ public class ListServiceOfferingsCmd extends BaseListCmd { public String getSystemVmType(){ return systemVmType; } - - public Map getResourceTags() { - Map tagsMap = null; - if (resourceTag != null && !resourceTag.isEmpty()) { - tagsMap = new HashMap(); - Collection servicesCollection = resourceTag.values(); - Iterator iter = servicesCollection.iterator(); - while (iter.hasNext()) { - HashMap services = (HashMap) iter.next(); - String key = services.get("key"); - String value = services.get("value"); - if (value == null) { - throw new InvalidParameterValueException("No value is passed in for key " + key); - } - tagsMap.put(key, value); - } - } - return tagsMap; - } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// diff --git a/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java index 204de3bc2b1..e305ee95e70 100644 --- a/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java +++ b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java @@ -17,9 +17,7 @@ package org.apache.cloudstack.api.response; import java.util.Date; -import java.util.LinkedHashSet; import java.util.Map; -import java.util.Set; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; @@ -107,13 +105,8 @@ public class ServiceOfferingResponse extends BaseResponse { @Param(description = "additional key/value details tied with this service offering", since = "4.2.0") private Map details; - @SerializedName(ApiConstants.RESOURCE_TAGS) @Param(description="the list of resource tags associated with service offering." + - " The resource tags are not used for Volume/VM placement on the specific host.", - responseObject = ResourceTagResponse.class, since="4.3") - private Set resourceTags; public ServiceOfferingResponse(){ - resourceTags = new LinkedHashSet(); } public String getId() { @@ -295,7 +288,4 @@ public class ServiceOfferingResponse extends BaseResponse { this.details = details; } - public void addTag(ResourceTagResponse tag){ - this.resourceTags.add(tag); - } } diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java index cbe5e247535..eff5d38d3c4 100644 --- a/server/src/com/cloud/api/query/QueryManagerImpl.java +++ b/server/src/com/cloud/api/query/QueryManagerImpl.java @@ -2390,22 +2390,8 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { Long domainId = cmd.getDomainId(); Boolean isSystem = cmd.getIsSystem(); String vmTypeStr = cmd.getSystemVmType(); - Map resourceTags = cmd.getResourceTags(); - SearchBuilder sb = _srvOfferingJoinDao.createSearchBuilder(); - if (resourceTags != null && !resourceTags.isEmpty()) { - SearchBuilder tagSearch = _resourceTagDao.createSearchBuilder(); - for (int count=0; count < resourceTags.size(); count++) { - tagSearch.or().op("key" + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ); - tagSearch.and("value" + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ); - tagSearch.cp(); - } - tagSearch.and("resourceType", tagSearch.entity().getResourceType(), SearchCriteria.Op.EQ); - sb.groupBy(sb.entity().getId()); - sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER); - } - - SearchCriteria sc = sb.create(); + SearchCriteria sc = _srvOfferingJoinDao.createSearchCriteria(); if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && isSystem) { throw new InvalidParameterValueException("Only ROOT admins can access system's offering"); @@ -2515,17 +2501,6 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { if (vmTypeStr != null) { sc.addAnd("vm_type", SearchCriteria.Op.EQ, vmTypeStr); } - - - if (resourceTags != null && !resourceTags.isEmpty()) { - int count = 0; - sc.setJoinParameters("tagSearch", "resourceType", TaggedResourceType.ServiceOffering.toString()); - for (String key : resourceTags.keySet()) { - sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), key); - sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), resourceTags.get(key)); - count++; - } - } return _srvOfferingJoinDao.searchAndCount(sc, searchFilter); }