You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/04 11:02:55 UTC
[11/55] [abbrv] git commit: api_refactor: refactor tag apis
api_refactor: refactor tag apis
- Fix refactored apis, mappings in commands*.in
- Fix comments etc.
Signed-off-by: Rohit Yadav <bh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/316e7f22
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/316e7f22
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/316e7f22
Branch: refs/heads/api_refactoring
Commit: 316e7f226a22c9a88b892b0bc4960243e5c36a95
Parents: 37cd76e
Author: Rohit Yadav <bh...@apache.org>
Authored: Mon Dec 3 23:48:48 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Mon Dec 3 23:48:48 2012 -0800
----------------------------------------------------------------------
api/src/com/cloud/api/commands/CreateTagsCmd.java | 131 ---------------
api/src/com/cloud/api/commands/DeleteTagsCmd.java | 122 --------------
api/src/com/cloud/api/commands/ListTagsCmd.java | 96 -----------
.../com/cloud/server/TaggedResourceService.java | 2 +-
.../api/user/tag/command/CreateTagsCmd.java | 131 +++++++++++++++
.../api/user/tag/command/DeleteTagsCmd.java | 122 ++++++++++++++
.../api/user/tag/command/ListTagsCmd.java | 96 +++++++++++
client/tomcatconf/commands.properties.in | 6 +-
.../com/cloud/tags/TaggedResourceManagerImpl.java | 2 +-
9 files changed, 354 insertions(+), 354 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/316e7f22/api/src/com/cloud/api/commands/CreateTagsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateTagsCmd.java b/api/src/com/cloud/api/commands/CreateTagsCmd.java
deleted file mode 100644
index 8e697de..0000000
--- a/api/src/com/cloud/api/commands/CreateTagsCmd.java
+++ /dev/null
@@ -1,131 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.api.commands;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.server.ResourceTag;
-import com.cloud.server.ResourceTag.TaggedResourceType;
-@Implementation(description = "Creates resource tag(s)", responseObject = SuccessResponse.class, since = "Burbank")
-public class CreateTagsCmd extends BaseAsyncCmd{
- public static final Logger s_logger = Logger.getLogger(CreateTagsCmd.class.getName());
-
- private static final String s_name = "createtagsresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, required=true, description = "Map of tags (key/value pairs)")
- private Map tag;
-
- @Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, required=true, description="type of the resource")
- private String resourceType;
-
- @Parameter(name=ApiConstants.RESOURCE_IDS, type=CommandType.LIST, required=true,
- collectionType=CommandType.STRING, description="list of resources to create the tags for")
- private List<String> resourceIds;
-
- @Parameter(name=ApiConstants.CUSTOMER, type=CommandType.STRING, description="identifies client specific tag. " +
- "When the value is not null, the tag can't be used by cloudStack code internally")
- private String customer;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
-
- public TaggedResourceType getResourceType(){
- return _taggedResourceService.getResourceType(resourceType);
- }
-
- public Map<String, String> getTags() {
- Map<String, String> tagsMap = null;
- if (!tag.isEmpty()) {
- tagsMap = new HashMap<String, String>();
- Collection<?> servicesCollection = tag.values();
- Iterator<?> iter = servicesCollection.iterator();
- while (iter.hasNext()) {
- HashMap<String, String> services = (HashMap<String, String>) iter.next();
- String key = services.get("key");
- String value = services.get("value");
- tagsMap.put(key, value);
- }
- }
- return tagsMap;
- }
-
- public List<String> getResourceIds() {
- return resourceIds;
- }
-
- public String getCustomer() {
- return customer;
- }
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- //FIXME - validate the owner here
- return 1;
- }
-
- @Override
- public void execute() {
- List<ResourceTag> tags = _taggedResourceService.createTags(getResourceIds(), getResourceType(), getTags(), getCustomer());
-
- if (tags != null && !tags.isEmpty()) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create tags");
- }
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_TAGS_CREATE;
- }
-
- @Override
- public String getEventDescription() {
- return "creating tags";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/316e7f22/api/src/com/cloud/api/commands/DeleteTagsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteTagsCmd.java b/api/src/com/cloud/api/commands/DeleteTagsCmd.java
deleted file mode 100644
index 81a76e5..0000000
--- a/api/src/com/cloud/api/commands/DeleteTagsCmd.java
+++ /dev/null
@@ -1,122 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.api.commands;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.server.ResourceTag.TaggedResourceType;
-@Implementation(description = "Deleting resource tag(s)", responseObject = SuccessResponse.class, since = "Burbank")
-public class DeleteTagsCmd extends BaseAsyncCmd{
- public static final Logger s_logger = Logger.getLogger(DeleteTagsCmd.class.getName());
-
- private static final String s_name = "deletetagsresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, description = "Delete tags matching key/value pairs")
- private Map tag;
-
- @Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, required=true, description="Delete tag by resource type")
- private String resourceType;
-
- @Parameter(name=ApiConstants.RESOURCE_IDS, type=CommandType.LIST, required=true,
- collectionType=CommandType.STRING, description="Delete tags for resource id(s)")
- private List<String> resourceIds;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
-
- public TaggedResourceType getResourceType(){
- return _taggedResourceService.getResourceType(resourceType);
- }
-
- public Map<String, String> getTags() {
- Map<String, String> tagsMap = null;
- if (tag != null && !tag.isEmpty()) {
- tagsMap = new HashMap<String, String>();
- Collection<?> servicesCollection = tag.values();
- Iterator<?> iter = servicesCollection.iterator();
- while (iter.hasNext()) {
- HashMap<String, String> services = (HashMap<String, String>) iter.next();
- String key = services.get("key");
- String value = services.get("value");
- tagsMap.put(key, value);
- }
- }
- return tagsMap;
- }
-
- public List<String> getResourceIds() {
- return resourceIds;
- }
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- //FIXME - validate the owner here
- return 1;
- }
-
- @Override
- public void execute() {
- boolean success = _taggedResourceService.deleteTags(getResourceIds(), getResourceType(), getTags());
-
- if (success) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete tags");
- }
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_TAGS_DELETE;
- }
-
- @Override
- public String getEventDescription() {
- return "Deleting tags";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/316e7f22/api/src/com/cloud/api/commands/ListTagsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListTagsCmd.java b/api/src/com/cloud/api/commands/ListTagsCmd.java
deleted file mode 100644
index 8b61b66..0000000
--- a/api/src/com/cloud/api/commands/ListTagsCmd.java
+++ /dev/null
@@ -1,96 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.ListResponse;
-import com.cloud.api.response.ResourceTagResponse;
-import com.cloud.server.ResourceTag;
-import com.cloud.utils.Pair;
-
-@Implementation(description = "List resource tag(s)", responseObject = ResourceTagResponse.class, since = "Burbank")
-public class ListTagsCmd extends BaseListProjectAndAccountResourcesCmd{
- private static final String s_name = "listtagsresponse";
-
- @Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, description="list by resource type")
- private String resourceType;
-
- @Parameter(name=ApiConstants.RESOURCE_ID, type=CommandType.STRING, description="list by resource id")
- private String resourceId;
-
- @Parameter(name=ApiConstants.KEY, type=CommandType.STRING, description="list by key")
- private String key;
-
- @Parameter(name=ApiConstants.VALUE, type=CommandType.STRING, description="list by value")
- private String value;
-
- @Parameter(name=ApiConstants.CUSTOMER, type=CommandType.STRING, description="list by customer name")
- private String customer;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public void execute() {
-
- Pair<List<? extends ResourceTag>, Integer> tags = _taggedResourceService.listTags(this);
- ListResponse<ResourceTagResponse> response = new ListResponse<ResourceTagResponse>();
- List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
- for (ResourceTag tag : tags.first()) {
- ResourceTagResponse tagResponse = _responseGenerator.createResourceTagResponse(tag, false);
- tagResponses.add(tagResponse);
- }
- response.setResponses(tagResponses, tags.second());
-
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }
-
- public String getResourceType() {
- return resourceType;
- }
-
- public String getResourceId() {
- return resourceId;
- }
-
- public String getKey() {
- return key;
- }
-
- public String getValue() {
- return value;
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public String getCustomer() {
- return customer;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/316e7f22/api/src/com/cloud/server/TaggedResourceService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/TaggedResourceService.java b/api/src/com/cloud/server/TaggedResourceService.java
index d813b65..c98b02b 100644
--- a/api/src/com/cloud/server/TaggedResourceService.java
+++ b/api/src/com/cloud/server/TaggedResourceService.java
@@ -19,7 +19,7 @@ package com.cloud.server;
import java.util.List;
import java.util.Map;
-import com.cloud.api.commands.ListTagsCmd;
+import org.apache.cloudstack.api.user.tag.command.ListTagsCmd;
import com.cloud.server.ResourceTag.TaggedResourceType;
import com.cloud.utils.Pair;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/316e7f22/api/src/org/apache/cloudstack/api/user/tag/command/CreateTagsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/tag/command/CreateTagsCmd.java b/api/src/org/apache/cloudstack/api/user/tag/command/CreateTagsCmd.java
new file mode 100644
index 0000000..99b51e9
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/tag/command/CreateTagsCmd.java
@@ -0,0 +1,131 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.user.tag.command;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.SuccessResponse;
+import com.cloud.event.EventTypes;
+import com.cloud.server.ResourceTag;
+import com.cloud.server.ResourceTag.TaggedResourceType;
+@Implementation(description = "Creates resource tag(s)", responseObject = SuccessResponse.class, since = "Burbank")
+public class CreateTagsCmd extends BaseAsyncCmd{
+ public static final Logger s_logger = Logger.getLogger(CreateTagsCmd.class.getName());
+
+ private static final String s_name = "createtagsresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, required=true, description = "Map of tags (key/value pairs)")
+ private Map tag;
+
+ @Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, required=true, description="type of the resource")
+ private String resourceType;
+
+ @Parameter(name=ApiConstants.RESOURCE_IDS, type=CommandType.LIST, required=true,
+ collectionType=CommandType.STRING, description="list of resources to create the tags for")
+ private List<String> resourceIds;
+
+ @Parameter(name=ApiConstants.CUSTOMER, type=CommandType.STRING, description="identifies client specific tag. " +
+ "When the value is not null, the tag can't be used by cloudStack code internally")
+ private String customer;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+
+ public TaggedResourceType getResourceType(){
+ return _taggedResourceService.getResourceType(resourceType);
+ }
+
+ public Map<String, String> getTags() {
+ Map<String, String> tagsMap = null;
+ if (!tag.isEmpty()) {
+ tagsMap = new HashMap<String, String>();
+ Collection<?> servicesCollection = tag.values();
+ Iterator<?> iter = servicesCollection.iterator();
+ while (iter.hasNext()) {
+ HashMap<String, String> services = (HashMap<String, String>) iter.next();
+ String key = services.get("key");
+ String value = services.get("value");
+ tagsMap.put(key, value);
+ }
+ }
+ return tagsMap;
+ }
+
+ public List<String> getResourceIds() {
+ return resourceIds;
+ }
+
+ public String getCustomer() {
+ return customer;
+ }
+
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ //FIXME - validate the owner here
+ return 1;
+ }
+
+ @Override
+ public void execute() {
+ List<ResourceTag> tags = _taggedResourceService.createTags(getResourceIds(), getResourceType(), getTags(), getCustomer());
+
+ if (tags != null && !tags.isEmpty()) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create tags");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_TAGS_CREATE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "creating tags";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/316e7f22/api/src/org/apache/cloudstack/api/user/tag/command/DeleteTagsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/tag/command/DeleteTagsCmd.java b/api/src/org/apache/cloudstack/api/user/tag/command/DeleteTagsCmd.java
new file mode 100644
index 0000000..09d9a69
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/tag/command/DeleteTagsCmd.java
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.user.tag.command;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.SuccessResponse;
+import com.cloud.event.EventTypes;
+import com.cloud.server.ResourceTag.TaggedResourceType;
+@Implementation(description = "Deleting resource tag(s)", responseObject = SuccessResponse.class, since = "Burbank")
+public class DeleteTagsCmd extends BaseAsyncCmd{
+ public static final Logger s_logger = Logger.getLogger(DeleteTagsCmd.class.getName());
+
+ private static final String s_name = "deletetagsresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, description = "Delete tags matching key/value pairs")
+ private Map tag;
+
+ @Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, required=true, description="Delete tag by resource type")
+ private String resourceType;
+
+ @Parameter(name=ApiConstants.RESOURCE_IDS, type=CommandType.LIST, required=true,
+ collectionType=CommandType.STRING, description="Delete tags for resource id(s)")
+ private List<String> resourceIds;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+
+ public TaggedResourceType getResourceType(){
+ return _taggedResourceService.getResourceType(resourceType);
+ }
+
+ public Map<String, String> getTags() {
+ Map<String, String> tagsMap = null;
+ if (tag != null && !tag.isEmpty()) {
+ tagsMap = new HashMap<String, String>();
+ Collection<?> servicesCollection = tag.values();
+ Iterator<?> iter = servicesCollection.iterator();
+ while (iter.hasNext()) {
+ HashMap<String, String> services = (HashMap<String, String>) iter.next();
+ String key = services.get("key");
+ String value = services.get("value");
+ tagsMap.put(key, value);
+ }
+ }
+ return tagsMap;
+ }
+
+ public List<String> getResourceIds() {
+ return resourceIds;
+ }
+
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ //FIXME - validate the owner here
+ return 1;
+ }
+
+ @Override
+ public void execute() {
+ boolean success = _taggedResourceService.deleteTags(getResourceIds(), getResourceType(), getTags());
+
+ if (success) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete tags");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_TAGS_DELETE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Deleting tags";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/316e7f22/api/src/org/apache/cloudstack/api/user/tag/command/ListTagsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/tag/command/ListTagsCmd.java b/api/src/org/apache/cloudstack/api/user/tag/command/ListTagsCmd.java
new file mode 100644
index 0000000..ef95439
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/tag/command/ListTagsCmd.java
@@ -0,0 +1,96 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.user.tag.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.ListResponse;
+import com.cloud.api.response.ResourceTagResponse;
+import com.cloud.server.ResourceTag;
+import com.cloud.utils.Pair;
+
+@Implementation(description = "List resource tag(s)", responseObject = ResourceTagResponse.class, since = "Burbank")
+public class ListTagsCmd extends BaseListProjectAndAccountResourcesCmd{
+ private static final String s_name = "listtagsresponse";
+
+ @Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, description="list by resource type")
+ private String resourceType;
+
+ @Parameter(name=ApiConstants.RESOURCE_ID, type=CommandType.STRING, description="list by resource id")
+ private String resourceId;
+
+ @Parameter(name=ApiConstants.KEY, type=CommandType.STRING, description="list by key")
+ private String key;
+
+ @Parameter(name=ApiConstants.VALUE, type=CommandType.STRING, description="list by value")
+ private String value;
+
+ @Parameter(name=ApiConstants.CUSTOMER, type=CommandType.STRING, description="list by customer name")
+ private String customer;
+
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public void execute() {
+
+ Pair<List<? extends ResourceTag>, Integer> tags = _taggedResourceService.listTags(this);
+ ListResponse<ResourceTagResponse> response = new ListResponse<ResourceTagResponse>();
+ List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
+ for (ResourceTag tag : tags.first()) {
+ ResourceTagResponse tagResponse = _responseGenerator.createResourceTagResponse(tag, false);
+ tagResponses.add(tagResponse);
+ }
+ response.setResponses(tagResponses, tags.second());
+
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public String getCustomer() {
+ return customer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/316e7f22/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 0cd4438..83d56da 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -409,9 +409,9 @@ deleteStaticRoute=org.apache.cloudstack.api.user.vpc.command.DeleteStaticRouteCm
listStaticRoutes=org.apache.cloudstack.api.user.vpc.command.ListStaticRoutesCmd;15
#### Tags commands
-createTags=com.cloud.api.commands.CreateTagsCmd;15
-deleteTags=com.cloud.api.commands.DeleteTagsCmd;15
-listTags=com.cloud.api.commands.ListTagsCmd;15
+createTags=org.apache.cloudstack.api.user.tag.command.CreateTagsCmd;15
+deleteTags=org.apache.cloudstack.api.user.tag.command.DeleteTagsCmd;15
+listTags=org.apache.cloudstack.api.user.tag.command.ListTagsCmd;15
### Site-to-site VPN commands
createVpnCustomerGateway=org.apache.cloudstack.api.user.vpn.command.CreateVpnCustomerGatewayCmd;15
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/316e7f22/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
index 237a677..fba3079 100644
--- a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
+++ b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
@@ -26,7 +26,7 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
-import com.cloud.api.commands.ListTagsCmd;
+import org.apache.cloudstack.api.user.tag.command.ListTagsCmd;
import com.cloud.domain.Domain;
import com.cloud.event.ActionEvent;
import com.cloud.event.EventTypes;