Simplify InfraUtils 03/5303/2
authorGary Wu <gary.i.wu@huawei.com>
Mon, 10 Apr 2017 23:29:44 +0000 (16:29 -0700)
committerGary Wu <gary.i.wu@huawei.com>
Wed, 19 Apr 2017 01:21:22 +0000 (01:21 +0000)
Change-Id: I23659102feccaa5bf97194e052a6b28cd1e7705f
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/InfraUtils.java

index 37cbb4d..7088a33 100644 (file)
@@ -22,6 +22,8 @@ package org.openecomp.mso.apihandlerinfra;
 
 
 
+import java.util.Arrays;
+
 import org.openecomp.mso.properties.MsoJavaProperties;
 
 public class InfraUtils {
@@ -29,27 +31,12 @@ public class InfraUtils {
                 // Check for allowable actions
         String actionsPropertyName = requestType + "." + version + ".ApiAllowableActions";
         String allowableActions = props.getProperty(actionsPropertyName, null);
-        boolean actionAllowed = false;
-        if (allowableActions != null) {
-               String allowableActionsList[] = allowableActions.split(",");
-               for (int i=0; i<allowableActionsList.length; i++) {                     
-                       if (action.equals (allowableActionsList[i])) {
-                               actionAllowed = true;
-                               break;
-                       }
-               }
-        }
-        else {
-               actionAllowed = true;
-        }
-        return actionAllowed;
+        return allowableActions == null || Arrays.asList(allowableActions.split(",")).contains(action);
        }
        
        // Checks if the name is acceptable for heat stack
        public static boolean isValidHeatName(String name) {
-               if (name.matches("^[a-zA-Z][a-zA-Z0-9_\\.-]*$"))
-                       return true;
-               return false;
+               return name.matches("^[a-zA-Z][a-zA-Z0-9_\\.-]*$");
        }