mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Fixed list* api commands.
This commit is contained in:
		
							parent
							
								
									d4bc7c8d2e
								
							
						
					
					
						commit
						af4459f24f
					
				| @ -27,7 +27,6 @@ import com.cloud.api.ApiConstants; | |||||||
| import com.cloud.api.BaseListCmd; | import com.cloud.api.BaseListCmd; | ||||||
| import com.cloud.api.Implementation; | import com.cloud.api.Implementation; | ||||||
| import com.cloud.api.Parameter; | import com.cloud.api.Parameter; | ||||||
| import com.cloud.api.BaseCmd.CommandType; |  | ||||||
| import com.cloud.api.response.HostResponse; | import com.cloud.api.response.HostResponse; | ||||||
| import com.cloud.api.response.ListResponse; | import com.cloud.api.response.ListResponse; | ||||||
| import com.cloud.async.AsyncJob; | import com.cloud.async.AsyncJob; | ||||||
|  | |||||||
| @ -38,7 +38,6 @@ public class ListHypervisorsCmd extends BaseCmd { | |||||||
| 	public String getCommandName() { | 	public String getCommandName() { | ||||||
| 		return s_name; | 		return s_name; | ||||||
| 	} | 	} | ||||||
| 	 |  | ||||||
| 
 | 
 | ||||||
|     ///////////////////////////////////////////////////// |     ///////////////////////////////////////////////////// | ||||||
|     //////////////// API parameters ///////////////////// |     //////////////// API parameters ///////////////////// | ||||||
|  | |||||||
| @ -6,7 +6,6 @@ import com.cloud.api.ResponseObject; | |||||||
| 
 | 
 | ||||||
| public class ListResponse<T extends ResponseObject> extends BaseResponse { | public class ListResponse<T extends ResponseObject> extends BaseResponse { | ||||||
|     List<T> responses; |     List<T> responses; | ||||||
|     Integer count; |  | ||||||
| 
 | 
 | ||||||
|     public List<T> getResponses() { |     public List<T> getResponses() { | ||||||
|         return responses; |         return responses; | ||||||
| @ -17,10 +16,11 @@ public class ListResponse<T extends ResponseObject> extends BaseResponse { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Integer getCount() { |     public Integer getCount() { | ||||||
|         return count; |         if (responses != null) { | ||||||
|  |             return responses.size(); | ||||||
|  |         } else { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setCount(Integer count) { |  | ||||||
|         this.count = count; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -445,10 +445,6 @@ public class ApiServer implements HttpRequestHandler { | |||||||
|         if (responses != null && responses.size() > defaultPageLimit && command.getPage() == null && command.getPageSize() == null) { |         if (responses != null && responses.size() > defaultPageLimit && command.getPage() == null && command.getPageSize() == null) { | ||||||
|             throw new ServerApiException(BaseCmd.PAGE_LIMIT_EXCEED, "Number of returned objects per page exceed default page limit " + defaultPageLimit + "; please specify \"page\"/\"pagesize\" parameters"); |             throw new ServerApiException(BaseCmd.PAGE_LIMIT_EXCEED, "Number of returned objects per page exceed default page limit " + defaultPageLimit + "; please specify \"page\"/\"pagesize\" parameters"); | ||||||
|         } |         } | ||||||
|          |  | ||||||
|         if (responses.size() > 0) { |  | ||||||
|             ((ListResponse<ResponseObject>)command.getResponseObject()).setCount(responses.size());    |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     private void buildAsyncListResponse(BaseListCmd command, Account account) { |     private void buildAsyncListResponse(BaseListCmd command, Account account) { | ||||||
|  | |||||||
| @ -92,13 +92,11 @@ public class ApiResponseSerializer { | |||||||
|         StringBuilder sb = new StringBuilder(); |         StringBuilder sb = new StringBuilder(); | ||||||
|         sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); |         sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); | ||||||
|         sb.append("<" + result.getResponseName() + " cloud-stack-version=\""+ApiDBUtils.getVersion()+ "\">"); |         sb.append("<" + result.getResponseName() + " cloud-stack-version=\""+ApiDBUtils.getVersion()+ "\">"); | ||||||
|          |  | ||||||
|         if (((ListResponse)result).getCount() != null) { |  | ||||||
|             sb.append("<" + ApiConstants.COUNT + ">" + ((ListResponse)result).getCount() + "</" + ApiConstants.COUNT + ">"); |  | ||||||
| 
 |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         if (result instanceof ListResponse) { |         if (result instanceof ListResponse) { | ||||||
|  |             if (((ListResponse)result).getCount() != null) { | ||||||
|  |                 sb.append("<" + ApiConstants.COUNT + ">" + ((ListResponse)result).getCount() + "</" + ApiConstants.COUNT + ">"); | ||||||
|  |             } | ||||||
|             List<? extends ResponseObject> responses = ((ListResponse)result).getResponses(); |             List<? extends ResponseObject> responses = ((ListResponse)result).getResponses(); | ||||||
|             if ((responses != null) && !responses.isEmpty()) { |             if ((responses != null) && !responses.isEmpty()) { | ||||||
|                 for (ResponseObject obj : responses) { |                 for (ResponseObject obj : responses) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user