diff options
author | Ramya Balaji <rb111y@att.com> | 2017-10-17 12:24:06 -0400 |
---|---|---|
committer | Skip Wonnell <skip@att.com> | 2017-10-17 19:05:23 +0000 |
commit | 140355fd6ab11e3dec5106ef060b264857a4c775 (patch) | |
tree | 59e812fb44504f0e3ab7663cb97ea39242e55fad | |
parent | 9df68e136e8be86f50115f7cf3e6a481561612e0 (diff) |
Changes for capability artifact check
Ignore capability check for non VM level
Start, Stop,Restart
Issue-ID: APPC-281
Change-Id: I0bc888a9fbfede5923ba8b130f8ab4850559abcb
Signed-off-by: Ramya Balaji <rb111y@att.com>
3 files changed, 59 insertions, 19 deletions
diff --git a/appc-config/appc-data-services/provider/src/main/java/org/openecomp/appc/data/services/AppcDataServiceConstant.java b/appc-config/appc-data-services/provider/src/main/java/org/openecomp/appc/data/services/AppcDataServiceConstant.java index fed2e7cae..39ed51a57 100644 --- a/appc-config/appc-data-services/provider/src/main/java/org/openecomp/appc/data/services/AppcDataServiceConstant.java +++ b/appc-config/appc-data-services/provider/src/main/java/org/openecomp/appc/data/services/AppcDataServiceConstant.java @@ -23,24 +23,29 @@ package org.openecomp.appc.data.services; public class AppcDataServiceConstant { - + - public static String INPUT_PARAM_RESPONSE_PREFIX = "responsePrefix"; - public static String OUTPUT_STATUS_SUCCESS = "success"; - public static String OUTPUT_STATUS_FAILURE = "failure"; - public static final String INPUT_PARAM_MESSAGE = "message"; - public static final String INPUT_PARAM_MESSAGE_TYPE = "messageType"; - public static String OUTPUT_PARAM_STATUS = "status"; - public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; - public static final String INPUT_PARAM_FILE_CATEGORY = "fileCategory"; - public static final String INPUT_PARAM_VM_INSTANCE = "vmInstance"; - public static final String INPUT_PARAM_SDC_ARTIFACT_IND = "asdcArtifactInd"; - public static final Object INPUT_PARAM_VNF_ID = "vnfId"; - public static final Object INPUT_PARAM_VM_NAME = "vmName"; - - public static final String INPUT_PARAM_FILE_ID = "fileId"; - - public static String INPUT_PARAM_UPLOAD_CONFIG_ID= "uploadConfigId"; - - + public static String INPUT_PARAM_RESPONSE_PREFIX = "responsePrefix"; + public static String OUTPUT_STATUS_SUCCESS = "success"; + public static String OUTPUT_STATUS_FAILURE = "failure"; + public static final String INPUT_PARAM_MESSAGE = "message"; + public static final String INPUT_PARAM_MESSAGE_TYPE = "messageType"; + public static String OUTPUT_PARAM_STATUS = "status"; + public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; + public static final String INPUT_PARAM_FILE_CATEGORY = "fileCategory"; + public static final String INPUT_PARAM_VM_INSTANCE = "vmInstance"; + public static final String INPUT_PARAM_SDC_ARTIFACT_IND = "asdcArtifactInd"; + public static final Object INPUT_PARAM_VNF_ID = "vnfId"; + public static final Object INPUT_PARAM_VM_NAME = "vmName"; + + public static final String INPUT_PARAM_FILE_ID = "fileId"; + + public static String INPUT_PARAM_UPLOAD_CONFIG_ID= "uploadConfigId"; + public static String CAPABILITY_VM_LEVEL="vm"; + public enum ACTIONS + { + Start, Stop, Restart; + } + + } diff --git a/appc-config/appc-data-services/provider/src/main/java/org/openecomp/appc/data/services/node/ConfigResourceNode.java b/appc-config/appc-data-services/provider/src/main/java/org/openecomp/appc/data/services/node/ConfigResourceNode.java index f389ff8d9..3be53ab77 100644 --- a/appc-config/appc-data-services/provider/src/main/java/org/openecomp/appc/data/services/node/ConfigResourceNode.java +++ b/appc-config/appc-data-services/provider/src/main/java/org/openecomp/appc/data/services/node/ConfigResourceNode.java @@ -21,6 +21,9 @@ package org.openecomp.appc.data.services.node; import java.util.Map; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.apache.commons.lang3.StringUtils; import com.att.eelf.configuration.EELFLogger; @@ -672,6 +675,13 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin { String caplevel = inParams.get("caplevel"); String findCapability = inParams.get("checkCapability"); + if (!checkIfCapabilityCheckNeeded(caplevel, findCapability)) + { + ctx.setAttribute(responsePrefix + AppcDataServiceConstant.OUTPUT_PARAM_STATUS, + AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS); + log.info("getCapability Successful - No need for capability check for this action"); + return; + } try { DGGeneralDBService db = DGGeneralDBService.initialise(); String cap = db.getCapability(ctx, inParams.get("vnf-type")); @@ -722,5 +732,20 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin { } } + public boolean checkIfCapabilityCheckNeeded(String caplevel, String findCapability) { + boolean capabilityCheckNeeded = true; + if (!StringUtils.equalsIgnoreCase(caplevel, AppcDataServiceConstant.CAPABILITY_VM_LEVEL)) { + List<AppcDataServiceConstant.ACTIONS> actionList = new ArrayList<AppcDataServiceConstant.ACTIONS>( + Arrays.asList(AppcDataServiceConstant.ACTIONS.values())); + for (AppcDataServiceConstant.ACTIONS action : actionList) { + if (StringUtils.equalsIgnoreCase(action.toString(), findCapability)) { + capabilityCheckNeeded = false; + break; + } + } + } + return capabilityCheckNeeded; + } + } diff --git a/appc-config/appc-data-services/provider/src/test/java/org/openecomp/appc/data/services/db/TestConfigResourceNode.java b/appc-config/appc-data-services/provider/src/test/java/org/openecomp/appc/data/services/db/TestConfigResourceNode.java index edfc76f93..ee4db30b8 100644 --- a/appc-config/appc-data-services/provider/src/test/java/org/openecomp/appc/data/services/db/TestConfigResourceNode.java +++ b/appc-config/appc-data-services/provider/src/test/java/org/openecomp/appc/data/services/db/TestConfigResourceNode.java @@ -26,6 +26,7 @@ package org.openecomp.appc.data.services.db; import java.util.HashMap; import java.util.Map; +import static org.junit.Assert.assertFalse; import org.junit.Test; import org.openecomp.appc.data.services.AppcDataServiceConstant; import org.openecomp.appc.data.services.node.ConfigResourceNode; @@ -148,4 +149,13 @@ public class TestConfigResourceNode { node.saveConfigBlock(inParams, ctx); } + @Test + public void testcheckIfCapabilityCheckNeeded () throws Exception { + ConfigResourceNode node = new ConfigResourceNode(); + String findCapability="Start"; + String capLevel="vnf"; + boolean result=node.checkIfCapabilityCheckNeeded(capLevel,findCapability); + assertFalse(result); + } + } |