You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ki...@apache.org on 2013/06/06 15:33:06 UTC

[2/2] git commit: updated refs/heads/master to 62e125c

check for null protocol while validating ACL item


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

Branch: refs/heads/master
Commit: aa2fb311124599113ee73e00b583683976be615f
Parents: cc7e9ee
Author: Kishan Kavala <ki...@cloud.com>
Authored: Wed Jun 5 16:40:24 2013 +0530
Committer: Kishan Kavala <ki...@cloud.com>
Committed: Thu Jun 6 19:02:44 2013 +0530

----------------------------------------------------------------------
 .../cloud/network/vpc/NetworkACLServiceImpl.java   |   40 ++++++++-------
 1 files changed, 21 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aa2fb311/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
index d6e86e2..4ad22d9 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
@@ -303,28 +303,30 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
         }
 
         //Validate Protocol
-        //Check if protocol is a number
-        if(StringUtils.isNumeric(protocol)){
-            int protoNumber = Integer.parseInt(protocol);
-            if(protoNumber < 0 || protoNumber > 255){
-                throw new InvalidParameterValueException("Invalid protocol number: " + protoNumber);
-            }
-        } else {
-            //Protocol is not number
-            //Check for valid protocol strings
-            String supportedProtocols = "tcp,udp,icmp,all";
-            if(!supportedProtocols.contains(protocol.toLowerCase())){
-                throw new InvalidParameterValueException("Invalid protocol: " + protocol);
+        if(protocol != null){
+            //Check if protocol is a number
+            if(StringUtils.isNumeric(protocol)){
+                int protoNumber = Integer.parseInt(protocol);
+                if(protoNumber < 0 || protoNumber > 255){
+                    throw new InvalidParameterValueException("Invalid protocol number: " + protoNumber);
+                }
+            } else {
+                //Protocol is not number
+                //Check for valid protocol strings
+                String supportedProtocols = "tcp,udp,icmp,all";
+                if(!supportedProtocols.contains(protocol.toLowerCase())){
+                    throw new InvalidParameterValueException("Invalid protocol: " + protocol);
+                }
             }
-        }
 
-        // icmp code and icmp type can't be passed in for any other protocol rather than icmp
-        if (!protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO) && (icmpCode != null || icmpType != null)) {
-            throw new InvalidParameterValueException("Can specify icmpCode and icmpType for ICMP protocol only");
-        }
+            // icmp code and icmp type can't be passed in for any other protocol rather than icmp
+            if (!protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO) && (icmpCode != null || icmpType != null)) {
+                throw new InvalidParameterValueException("Can specify icmpCode and icmpType for ICMP protocol only");
+            }
 
-        if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO) && (portStart != null || portEnd != null)) {
-            throw new InvalidParameterValueException("Can't specify start/end port when protocol is ICMP");
+            if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO) && (portStart != null || portEnd != null)) {
+                throw new InvalidParameterValueException("Can't specify start/end port when protocol is ICMP");
+            }
         }
 
         //validate icmp code and type