incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [18/50] [abbrv] git commit: Resource tags: CS-15661 - don't accept NULL or empty key value when create resource tag
Date Tue, 24 Jul 2012 21:20:36 GMT
Resource tags: CS-15661 - don't accept NULL or empty key value when create resource tag


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/7bef9a96
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7bef9a96
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7bef9a96

Branch: refs/heads/rbd
Commit: 7bef9a961d968e4187d1bf843404b29992c21a67
Parents: 65551cf
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Jul 23 10:50:21 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Jul 23 10:51:20 2012 -0700

----------------------------------------------------------------------
 api/src/com/cloud/api/commands/CreateTagsCmd.java  |    1 +
 .../com/cloud/tags/TaggedResourceManagerImpl.java  |   12 +++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bef9a96/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
index f87ae6e..a981363 100644
--- a/api/src/com/cloud/api/commands/CreateTagsCmd.java
+++ b/api/src/com/cloud/api/commands/CreateTagsCmd.java
@@ -33,6 +33,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.ServerApiException;
 import com.cloud.api.response.SuccessResponse;
 import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.server.ResourceTag;
 import com.cloud.server.ResourceTag.TaggedResourceType;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bef9a96/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 f79eba4..84a2692 100644
--- a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
+++ b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
@@ -233,7 +233,7 @@ public class TaggedResourceManagerImpl implements TaggedResourceService,
Manager
         Transaction txn = Transaction.currentTxn();
         txn.start();
         
-        for (String tag : tags.keySet()) {
+        for (String key : tags.keySet()) {
             for (String resourceId : resourceIds) {
                 Long id = getResourceId(resourceId, resourceType);
                 String resourceUuid = getUuid(resourceId, resourceType);
@@ -254,10 +254,16 @@ public class TaggedResourceManagerImpl implements TaggedResourceService,
Manager
                     _accountMgr.checkAccess(caller, _domainMgr.getDomain(domainId));
                 } else {
                     throw new PermissionDeniedException("Account " + caller + " doesn't have
permissions to create tags" +
-                    		" for resource " + tag);
+                    		" for resource " + key);
+                }
+                
+                String value = tags.get(key);
+                
+                if (value == null || value.isEmpty()) {
+                    throw new InvalidParameterValueException("Value for the key " + key +
" is either null or empty");
                 }
                
-                ResourceTagVO resourceTag = new ResourceTagVO(tag, tags.get(tag), accountDomainPair.first(),
+                ResourceTagVO resourceTag = new ResourceTagVO(key, value, accountDomainPair.first(),
                         accountDomainPair.second(), 
                         id, resourceType, customer, resourceUuid);
                 resourceTag = _resourceTagDao.persist(resourceTag);


Mime
View raw message