|
| 1 | +// Copyright 2012 Citrix Systems, Inc. Licensed under the |
| 2 | +// Apache License, Version 2.0 (the "License"); you may not use this |
| 3 | +// file except in compliance with the License. Citrix Systems, Inc. |
| 4 | +// reserves all rights not expressly granted by the License. |
| 5 | +// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +// Unless required by applicable law or agreed to in writing, software |
| 7 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 8 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 9 | +// See the License for the specific language governing permissions and |
| 10 | +// limitations under the License. |
| 11 | +// |
| 12 | +// Automatically generated by addcopyright.py at 04/03/2012 |
| 13 | +package com.cloud.api; |
| 14 | + |
| 15 | +import java.util.Collection; |
| 16 | +import java.util.HashMap; |
| 17 | +import java.util.Iterator; |
| 18 | +import java.util.Map; |
| 19 | + |
| 20 | +import com.cloud.exception.InvalidParameterValueException; |
| 21 | + |
| 22 | +/** |
| 23 | + * @author Alena Prokharchyk |
| 24 | + */ |
| 25 | +public abstract class BaseListTaggedResourcesCmd extends BaseListProjectAndAccountResourcesCmd{ |
| 26 | + @Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, description = "List resources by tags (key/value pairs)") |
| 27 | + private Map tags; |
| 28 | + |
| 29 | + public Map<String, String> getTags() { |
| 30 | + Map<String, String> tagsMap = null; |
| 31 | + if (tags != null && !tags.isEmpty()) { |
| 32 | + tagsMap = new HashMap<String, String>(); |
| 33 | + Collection<?> servicesCollection = tags.values(); |
| 34 | + Iterator<?> iter = servicesCollection.iterator(); |
| 35 | + while (iter.hasNext()) { |
| 36 | + HashMap<String, String> services = (HashMap<String, String>) iter.next(); |
| 37 | + String key = services.get("key"); |
| 38 | + String value = services.get("value"); |
| 39 | + if (value == null) { |
| 40 | + throw new InvalidParameterValueException("No value is passed in for key " + key); |
| 41 | + } |
| 42 | + tagsMap.put(key, value); |
| 43 | + } |
| 44 | + } |
| 45 | + return tagsMap; |
| 46 | + } |
| 47 | +} |
0 commit comments