diff options
author | Dunietz, Irwin <id1681@att.com> | 2020-01-16 15:13:14 -0500 |
---|---|---|
committer | Takamune Cho <takamune.cho@att.com> | 2020-01-29 19:44:48 +0000 |
commit | b5fe8a69e90b950c07dc11af481eab7e9bab52c6 (patch) | |
tree | 3da81ce60554e65b93776b9aea647f3c6d8679ab /appc-inbound/appc-artifact-handler/provider/src/main/java/org | |
parent | 9b32cb60360a2a2973c621053510718de0072111 (diff) |
Change code in appc dispatcher for new LCMs in R6
Also introduce some minor improvements to robustness, efficiency, & formatting.
Issue-ID: APPC-1789
Signed-off-by: Dunietz, Irwin <id1681@att.com>
Change-Id: I82d970c2f7cde6c8dab1222af86ea70ce93b7e50
Diffstat (limited to 'appc-inbound/appc-artifact-handler/provider/src/main/java/org')
3 files changed, 151 insertions, 134 deletions
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java index b6fd2f599..48dd67f02 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java +++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -60,6 +60,7 @@ import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.R import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.REQUEST_ID; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.REQUEST_INFORMATION; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME; +import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.RESOURCE_NAME; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.RESOURCE_TYPE; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.RESOURCE_UUID; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.RESOURCE_VERSION; @@ -82,7 +83,6 @@ import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.V import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.URL; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.OPENSTACK; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.ANSIBLE; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import java.io.ByteArrayOutputStream; @@ -93,6 +93,7 @@ import java.util.function.Function; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.lang.StringUtils; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import org.onap.appc.artifact.handler.dbservices.DBException; import org.onap.appc.artifact.handler.dbservices.DBService; @@ -104,8 +105,6 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.sdnc.config.params.transformer.tosca.ArtifactProcessorImpl; import org.onap.sdnc.config.params.transformer.tosca.exceptions.ArtifactProcessorException; - -import org.json.JSONException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -120,20 +119,21 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { private static final String CONFIG_SCALE_OUT_PARAM = "ConfigScaleOut"; private static final String CONFIG_MODIFY_PARAM = "ConfigModify"; private static final String GET_CONFIG = "GetConfig"; - private static final String POST_EVACUATE= "PostEvacuate"; + private static final String POST_EVACUATE = "PostEvacuate"; private static final String PRE_EVACUATE = "PreEvacuate"; private static final String POST_MIGRATE = "PostMigrate"; private static final String PRE_MIGRATE = "PreMigrate"; private static final String PRE_REBUILD = "PreRebuild"; private static final String POST_REBUILD = "PostRebuild"; private static final String STOP_TRAFFIC = "StopTraffic"; + public void processArtifact(Map<String, String> inParams, SvcLogicContext ctx) throws ArtifactProcessorException { if (inParams == null || inParams.isEmpty()) { return; } String postData = inParams.get("postData"); - if ( StringUtils.isBlank(postData)) { + if (StringUtils.isBlank(postData)) { return; } try { @@ -147,14 +147,15 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { } private boolean storeUpdateSdcArtifacts(JSONObject postDataJson) throws ArtifactHandlerInternalException { - log.info("Starting processing of SDC Artifacs into Handler with Data : " + postDataJson.toString()); + log.info("Starting processing of SDC Artifacts into Handler with Data: " + postDataJson.toString()); try { JSONObject requestInfo = (JSONObject) postDataJson.get(REQUEST_INFORMATION); JSONObject documentInfo = (JSONObject) postDataJson.get(DOCUMENT_PARAMETERS); String artifactName = documentInfo.getString(ARTIFACT_NAME); - if (StringUtils.isBlank(artifactName)) - throw new ArtifactHandlerInternalException("Missing Artifact Name "); + if (StringUtils.isBlank(artifactName)) { + throw new ArtifactHandlerInternalException("Missing Artifact Name"); + } if (artifactName.toLowerCase().startsWith(ANSIBLE)) { validateAnsibleAdminArtifact(documentInfo); @@ -174,7 +175,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { + ((JSONObject) postDataJson.get(REQUEST_INFORMATION)).getString(REQUEST_ID), e); throw new ArtifactHandlerInternalException("Error while processing request with id: " + ((JSONObject) postDataJson.get(REQUEST_INFORMATION)).getString(REQUEST_ID) - + ", Exception Message : " + e.getMessage(), e); + + ", Exception Message: " + e.getMessage(), e); } return false; } @@ -183,16 +184,15 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { String fn = "ArtifactHandlerNode.validateAnsibleAdminArtifact"; String artifactName = documentInfo.getString(ARTIFACT_NAME); - log.info(fn + ": Received Admin File Name: " + artifactName + " ArtifactCotent : " - + documentInfo.getString(ARTIFACT_CONTENTS)); + log.info(fn + ": Received Admin File Name: " + artifactName + + ", ArtifactContent: " + documentInfo.getString(ARTIFACT_CONTENTS)); try { ArtifactHandlerProviderUtil ahpUtil = new ArtifactHandlerProviderUtil(); String contentString = ahpUtil.escapeSql(documentInfo.getString(ARTIFACT_CONTENTS)); JSONObject artifact = new JSONObject(contentString); JSONArray fqdnList = artifact.getJSONArray("fqdn-list"); Map<String, List<String>> artifactMap = new HashMap<>(); - - + for (int i = 0; i < fqdnList.length(); i++) { JSONObject fqdn = fqdnList.getJSONObject(i); List<String> valuesforFQDN = populateValueForFQDN(fqdn); @@ -202,56 +202,66 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { validateKeyValue(artifactMap); } catch (JSONException je) { - log.error( - fn + " ansible_admin artifact content may not be a valid JSON, error message : " + je.getMessage()); + log.error(fn + " ansible admin artifact content may not be a valid JSON, error message: " + + je.getMessage()); throw new ArtifactHandlerInternalException( - "JSON Exception:ansible admin artifact content may not be a valid JSON, error message : " + je.getMessage(), je); + "JSON Exception:ansible admin artifact content may not be a valid JSON, error message: " + + je.getMessage(), + je); } catch (ArtifactHandlerInternalException ae) { - throw ae; + throw ae; } catch (Exception e) { - log.error(fn + "Error while creating Admin data records", e); - throw new ArtifactHandlerInternalException("Error while processing ansible admin artifact" + e.getMessage(), e); + throw new ArtifactHandlerInternalException( + "Error while processing ansible admin artifact: " + e.getMessage(), e); } } + private void validateKeyValue(Map<String, List<String>> artifactMap) throws ArtifactHandlerInternalException { - for (Map.Entry<String,List<String>> entry1:artifactMap.entrySet()) { - for (String value : entry1.getValue()) { - for(Map.Entry<String,List<String>> entry2:artifactMap.entrySet() ) { - if (!entry1.getKey().equals(entry2.getKey()) && entry2.getValue().contains(value)) { - log.info("Validation Failure, error message : Ansible Admin artifact has CloudOwner-RegionId-Tenant : " + value - + " mapped to multiple FQDN :" + entry1.getKey() + " & " + entry2.getKey()); - throw new ArtifactHandlerInternalException( - "Validation Failure, error message : Ansible Admin artifact has CloudOwner-RegionId-Tenant : " + value - + " mapped to multiple FQDN :" + entry1.getKey() + " & " + entry2.getKey()); - } + for (String fqdn1 : artifactMap.keySet()) { + + for (String value : artifactMap.get(fqdn1)) { + for (String fqdn2 : artifactMap.keySet()) { + + if (!fqdn1.equals(fqdn2) && artifactMap.get(fqdn2).contains(value)) { + String msg = "Validation Failure: Ansible Admin artifact has CloudOwner-RegionId-Tenant: " + + value + " mapped to multiple FQDN: " + fqdn1 + " & " + fqdn2; + log.info(msg); + throw new ArtifactHandlerInternalException(msg); + } } } + + } + } -} private List<String> populateValueForFQDN(JSONObject fqdn) { - log.info("Inside populateValueForFQDN :" + fqdn.getString("vnf-management-server-fqdn")); + log.info("Inside populateValueForFQDN: " + fqdn.getString("vnf-management-server-fqdn")); List<String> valuesforFQDN = new ArrayList<>(); JSONArray cloudJsonList = fqdn.getJSONArray("cloud-owner-list"); for (int j = 0; j < cloudJsonList.length(); j++) { String cloudOwner = cloudJsonList.getJSONObject(j).getString("cloud-owner"); JSONArray regionList = cloudJsonList.getJSONObject(j).getJSONArray("region-id-list"); + for (int i = 0; i < regionList.length(); i++) { + String region = regionList.getJSONObject(i).getString("region-id"); + JSONArray tenantList = regionList.getJSONObject(i).getJSONArray("tenant-id-list"); for (int k = 0; k < tenantList.length(); k++) { - String tenant = tenantList.getString(k); + String tenant = tenantList.getString(k); String valueforFQDN = cloudOwner + "-" + region + "-" + tenant; - log.info("valueforFQDN for i " + i + " & j " + j + " :" + valueforFQDN); + log.info("valueforFQDN for i " + i + " & j " + j + ": " + valueforFQDN); valuesforFQDN.add(valueforFQDN); } } } + return valuesforFQDN; } @@ -260,7 +270,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { String fn = "ArtifactHandlerNode.createReferenceDataForPD"; String artifactName = documentInfo.getString(ARTIFACT_NAME); - log.info(fn + "Received PD File Name: " + artifactName + " and suffix length " + PD.length()); + log.info(fn + " Received PD File Name: " + artifactName + " and suffix length " + PD.length()); try { String suffix = artifactName.substring(PD.length()); @@ -276,7 +286,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { throws ArtifactHandlerInternalException { try { - log.info("Creating Tosca Records and storing into SDC Artifacs"); + log.info("Creating Tosca Records and storing into SDC Artifacts"); String[] docs = { TOSCA_PARAM, YANG_PARAM }; ArtifactHandlerProviderUtil ahpUtil = new ArtifactHandlerProviderUtil(); String pdFileContents = documentInfo.getString(ARTIFACT_CONTENTS); @@ -287,7 +297,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { ArtifactProcessorImpl toscaGenerator = getArtifactProcessorImpl(); toscaGenerator.generateArtifact(pdFileContents, toscaStream); toscaContents = toscaStream.toString(); - log.info("Generated Tosca File : " + toscaContents); + log.info("Generated Tosca File: " + toscaContents); String yangContents = "YANG generation is in Progress"; String yangName = null; @@ -333,16 +343,18 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { return dbservice.getArtifactID(context, yangName); } - protected boolean updateStoreArtifacts(JSONObject requestInfo, JSONObject documentInfo) throws SvcLogicException { - log.info("UpdateStoreArtifactsStarted storing of SDC Artifacs "); + protected boolean updateStoreArtifacts(JSONObject requestInfo, JSONObject documentInfo) + throws SvcLogicException, SQLException { + log.info("updateStoreArtifacts started storing of SDC Artifacts"); + SvcLogicContext context = new SvcLogicContext(); DBService dbservice = DBService.initialise(); ArtifactHandlerProviderUtil ahpUtil = new ArtifactHandlerProviderUtil(); int intversion = 0; context.setAttribute("artifact_name", documentInfo.getString(ARTIFACT_NAME)); - String internalVersion = dbservice.getInternalVersionNumber(context, documentInfo.getString(ARTIFACT_NAME), - null); - log.info("Internal Version number received from Database : " + internalVersion); + String internalVersion = + dbservice.getInternalVersionNumber(context, documentInfo.getString(ARTIFACT_NAME), null); + log.info("Internal Version number received from Database: " + internalVersion); if (internalVersion != null) { intversion = Integer.parseInt(internalVersion); intversion++; @@ -354,6 +366,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { setAttribute(context, documentInfo::getString, RESOURCE_UUID); setAttribute(context, documentInfo::getString, RESOURCE_INSTANCE_NAME); setAttribute(context, documentInfo::getString, RESOURCE_VERSION); + setAttribute(context, documentInfo::getString, RESOURCE_NAME); setAttribute(context, documentInfo::getString, RESOURCE_TYPE); setAttribute(context, documentInfo::getString, ARTIFACT_UUID); setAttribute(context, documentInfo::getString, ARTIFACT_TYPE); @@ -368,15 +381,14 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { public boolean storeReferenceData(JSONObject requestInfo, JSONObject documentInfo) throws ArtifactHandlerInternalException { - - log.info("Started storing of SDC Artifacs into Handler"); + log.info("Started storing of SDC Artifacts into Handler"); try { DBService dbservice = DBService.initialise(); ArtifactHandlerProviderUtil ahpUtil = new ArtifactHandlerProviderUtil(); String contentString = ahpUtil.escapeSql(documentInfo.getString(ARTIFACT_CONTENTS)); String artifactName = ahpUtil.escapeSql(documentInfo.getString(ARTIFACT_NAME)); - String capabilityArtifactName = StringUtils.replace(artifactName, ARTIFACT_NAME_REFERENCE, - ARTIFACT_NAME_CAPABILITY); + String capabilityArtifactName = + StringUtils.replace(artifactName, ARTIFACT_NAME_REFERENCE, ARTIFACT_NAME_CAPABILITY); JSONObject capabilities = new JSONObject(); JSONArray vnfActionList = new JSONArray(); JSONArray vfModuleActionList = new JSONArray(); @@ -386,11 +398,12 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { JSONObject contentObject = new JSONObject(contentString); JSONArray contentArray = contentObject.getJSONArray("reference_data"); boolean storeCapabilityArtifact = true; + for (int a = 0; a < contentArray.length(); a++) { - JSONObject content = (JSONObject) contentArray.get(a); - log.info("contentString =" + content.toString()); + JSONObject content = contentArray.getJSONObject(a); + log.info("contentString = " + content.toString()); JSONObject scope = content.getJSONObject("scope"); - log.info("scope :" + scope); + log.info("scope: " + scope); SvcLogicContext context = new SvcLogicContext(); vnfType = scope.getString(VNF_TYPE); setAttribute(context, scope::getString, VNF_TYPE); @@ -402,6 +415,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { vmActionVnfcFunctionCodesList); JSONArray vnfcTypeList = setVnfcTypeInformation(scope, context); storeCapabilityArtifact = isCapabilityArtifactNeeded(context); + if (content.has(DEVICE_PROTOCOL)) { setAttribute(context, content::getString, DEVICE_PROTOCOL); } @@ -423,9 +437,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { if (!StringUtils.equalsIgnoreCase(actionProtocol, OPENSTACK)) { populateProtocolReference(dbservice, content); } - context.setAttribute(VNFC_TYPE, null); - if (content.has(VM) && content.get(VM) instanceof JSONArray) { processVmList(content, context, dbservice); } @@ -464,7 +476,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { String vnfcTypeScope = scope.getString(VNFC_TYPE); if (StringUtils.isNotBlank(vnfcTypeScope)) { setAttribute(context, scope::getString, VNFC_TYPE); - log.info("VNFC Type has been set for this reference artifact!!" + vnfcTypeScope); + log.info("VNFC type has been set for this reference artifact!! " + vnfcTypeScope); } else { context.setAttribute(VNFC_TYPE, null); } @@ -491,7 +503,8 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { vnfActionList.put(content.getString(ACTION)); } if (validateActionLevel(actionLevel, ACTION_LEVEL_VM)) { - if (content.has(VNFC_FUNCTION_CODE_LIST) && !content.isNull(VNFC_FUNCTION_CODE_LIST) + if (content.has(VNFC_FUNCTION_CODE_LIST) + && !content.isNull(VNFC_FUNCTION_CODE_LIST) && content.get(VNFC_FUNCTION_CODE_LIST) instanceof JSONArray) { log.info("Found vnfc-function-code-list!!"); JSONArray vnfcList = content.getJSONArray(VNFC_FUNCTION_CODE_LIST); @@ -510,7 +523,8 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { } public void processArtifactList(JSONObject content, DBService dbservice, SvcLogicContext context, - JSONArray vnfcTypeList) throws ArtifactHandlerInternalException { + JSONArray vnfcTypeList) + throws ArtifactHandlerInternalException { try { if (content.has(ARTIFACT_LIST_PARAM) && content.get(ARTIFACT_LIST_PARAM) instanceof JSONArray) { @@ -521,7 +535,6 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { templateIdList = content.getJSONArray("template-id-list"); } doProcessArtifactList(dbservice, context, artifactLists, templateIdList, vnfcTypeList); - } } catch (Exception e) { log.error("An error occurred when processing artifact list", e); @@ -533,7 +546,9 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { JSONArray templateIdList, JSONArray vnfcTypeList) throws SvcLogicException, SQLException, ConfigurationException, DBException { boolean pdFile = false; - int modelInd = 0, vnfcRefInd = 0; + int modelInd = 0; + int vnfcRefInd = 0; + for (int i = 0; i < artifactLists.length(); i++) { String suffix = null; String model = null; @@ -541,9 +556,8 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { log.info("artifact is " + artifact); // Get Model details - if (null != templateIdList && i > 0 && i % 2 == 0) {// Should this be changed to 3 to account for 3 - // artifacts - modelInd++; + if (null != templateIdList && i > 0 && i % 2 == 0) { // Should this be changed to 3 + modelInd++; // to account for 3 artifacts } if (null != vnfcTypeList && i > 0 && i % 3 == 0) { // TDP 517180 - CD tool has made changes to send 3 artifacts instead of 2 @@ -563,18 +577,19 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { if (null != templateIdList && modelInd < templateIdList.length()) { model = templateIdList.getString(modelInd); - log.info("Model is ::: " + model + " ,modelInd = " + modelInd); + log.info("Model is ::: " + model + ", modelInd = " + modelInd); } if (null != vnfcTypeList && vnfcRefInd < vnfcTypeList.length()) { String vnfcType = vnfcTypeList.getString(vnfcRefInd); if (StringUtils.isNotBlank(vnfcType)) { context.setAttribute(VNFC_TYPE, vnfcType); } - log.info("Setting vnfc type from vnfc-type-list ::" + vnfcType); + log.info("Setting vnfc type from vnfc-type-list :: " + vnfcType); } if (StringUtils.isNotBlank(model)) { dbservice.processSdcReferences(context, - dbservice.isArtifactUpdateRequired(context, DB_SDC_REFERENCE, model), model); + dbservice.isArtifactUpdateRequired(context, DB_SDC_REFERENCE, model), + model); } else { dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context, DB_SDC_REFERENCE)); } @@ -584,14 +599,14 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { if (pdFile) { log.info("Sending information related to pdfile Artifact"); tryUpdateContext(dbservice, context, pdFile, suffix, model); - pdFile = false;// set to false afterprocessing yang and Tosca + pdFile = false; // set to false after processing yang and Tosca } } - } private void tryUpdateContext(DBService dbservice, SvcLogicContext context, boolean pdFile, String suffix, - String model) throws SvcLogicException, SQLException, ConfigurationException, DBException { + String model) + throws SvcLogicException, SQLException, ConfigurationException, DBException { if (pdFile) { context.setAttribute(ARTIFACT_NAME, "Tosca".concat(suffix)); context.setAttribute(FILE_CATEGORY, TOSCA_MODEL); @@ -606,8 +621,11 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { public void processConfigTypeActions(JSONObject content, DBService dbservice, SvcLogicContext context) throws ArtifactHandlerInternalException { + try { - if (isContentActionConfig(content) + if (contentsActionEquals(content, CONFIGURE_PARAM) + || contentsActionEquals(content, CONFIG_MODIFY_PARAM) + || contentsActionEquals(content, CONFIG_SCALE_OUT_PARAM) || contentsActionEquals(content, GET_CONFIG) || contentsActionEquals(content, POST_EVACUATE) || contentsActionEquals(content, PRE_EVACUATE) @@ -616,7 +634,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { || contentsActionEquals(content, POST_REBUILD) || contentsActionEquals(content, PRE_REBUILD) || contentsActionEquals(content, STOP_TRAFFIC) - ) { + ) { if (content.has(DOWNLOAD_DG_REFERENCE) && content.getString(DOWNLOAD_DG_REFERENCE).length() > 0) { @@ -640,20 +658,17 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { private void tryProcessInterfaceProtocol(JSONObject content, DBService dbservice, SvcLogicContext context) throws SvcLogicException, SQLException, ConfigurationException, DBException { - if (isContentActionConfig(content)) { + + if (contentsActionEquals(content, CONFIGURE_PARAM) || contentsActionEquals(content, CONFIG_SCALE_OUT_PARAM)) { boolean isUpdateRequired = dbservice.isArtifactUpdateRequired(context, DB_DEVICE_INTERFACE_PROTOCOL); - if (isContentActionConfig(content) && !isUpdateRequired) { + if (contentsActionEquals(content, CONFIGURE_PARAM) + || (contentsActionEquals(content, CONFIG_SCALE_OUT_PARAM) + && !isUpdateRequired)) { + dbservice.processDeviceInterfaceProtocol(context, isUpdateRequired); } } } - - //Consolidates the if statements required to check if the action is one of the config actions - private boolean isContentActionConfig(JSONObject content) { - return contentsActionEquals(content, CONFIGURE_PARAM) - || contentsActionEquals(content, CONFIG_MODIFY_PARAM) - || contentsActionEquals(content, CONFIG_SCALE_OUT_PARAM); - } private boolean contentsActionEquals(JSONObject content, String action) { return content.getString(ACTION).equals(action); @@ -734,7 +749,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { JSONObject capabilities, String capabilityArtifactName, String vnfType) throws ArtifactHandlerInternalException { - log.info("Begin-->processAndStoreCapabilitiesArtifact "); + log.info("Begin-->processAndStoreCapabilitiesArtifact"); try { JSONObject newCapabilitiesObject = new JSONObject(); @@ -749,9 +764,9 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { context.setAttribute(ARTIFACT_CONTENTS, newCapabilitiesObject.toString()); dbService.processSdcReferences(context, dbService.isArtifactUpdateRequired(context, DB_SDC_REFERENCE)); int intVersion = 0; - String internalVersion = dbService.getInternalVersionNumber(context, context.getAttribute(ARTIFACT_NAME), - null); - log.info("Internal Version number received from Database : " + internalVersion); + String internalVersion = + dbService.getInternalVersionNumber(context, context.getAttribute(ARTIFACT_NAME), null); + log.info("Internal Version number received from Database: " + internalVersion); if (internalVersion != null) { intVersion = Integer.parseInt(internalVersion) + 1; } @@ -771,7 +786,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { log.error("Error saving capabilities artifact to DB", e); throw new ArtifactHandlerInternalException("Error saving capabilities artifact to DB", e); } finally { - log.info("End-->processAndStoreCapabilitiesArtifact "); + log.info("End-->processAndStoreCapabilitiesArtifact"); } } diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/ArtifactHandlerProviderUtil.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/ArtifactHandlerProviderUtil.java index 214e6db68..359e6fea8 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/ArtifactHandlerProviderUtil.java +++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/ArtifactHandlerProviderUtil.java @@ -2,22 +2,21 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= * Licensed 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. - * * ============LICENSE_END========================================================= */ @@ -84,28 +83,28 @@ public class ArtifactHandlerProviderUtil { JSONObject docParams = new JSONObject(); docParams.put(SdcArtifactHandlerConstants.SERVICE_UUID, - "TLSUUID" + templateData.getRequestInformation().getRequestId()); + "TLSUUID" + templateData.getRequestInformation().getRequestId()); docParams.put(SdcArtifactHandlerConstants.DISTRIBUTION_ID, "TLDID" + random); docParams.put(SdcArtifactHandlerConstants.SERVICE_NAME, "TLServiceName"); docParams.put(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION, "Template Loader Test"); docParams.put(SdcArtifactHandlerConstants.SERVICE_ARTIFACTS, "[]"); docParams.put(SdcArtifactHandlerConstants.RESOURCE_UUID, "TLRUID" + random); docParams.put(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME, "TLRIName"); - docParams.put(SdcArtifactHandlerConstants.REOURCE_NAME, "TLResourceName"); + docParams.put(SdcArtifactHandlerConstants.RESOURCE_NAME, "TLResourceName"); docParams.put(SdcArtifactHandlerConstants.RESOURCE_VERSION, "TLResourceVersion"); docParams.put(SdcArtifactHandlerConstants.RESOURCE_TYPE, "TLResourceType"); docParams.put(SdcArtifactHandlerConstants.ARTIFACT_UUID, "TLAUUID" + random); docParams - .put(SdcArtifactHandlerConstants.ARTIFACT_NAME, templateData.getDocumentParameters().getArtifactName()); + .put(SdcArtifactHandlerConstants.ARTIFACT_NAME, templateData.getDocumentParameters().getArtifactName()); docParams.put(SdcArtifactHandlerConstants.ARTIFACT_TYPE, "APPC-CONFIG"); docParams.put(SdcArtifactHandlerConstants.ARTIFACT_VERSION, - templateData.getDocumentParameters().getArtifactVersion()); - docParams.put(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION, "SdcTestDescription"); + templateData.getDocumentParameters().getArtifactVersion()); + docParams.put(SdcArtifactHandlerConstants.ARTIFACT_DESCRIPTION, "SdcTestDescription"); docParams.put("artifact-contents", templateData.getDocumentParameters().getArtifactContents()); json.put(SdcArtifactHandlerConstants.REQUEST_INFORMATION, requestInfo); json.put(SdcArtifactHandlerConstants.DOCUMENT_PARAMETERS, docParams); - log.info("Final data =" + this.templateData); + log.info("Final data = " + this.templateData); return String.format("{\"input\": %s}", json.toString()); } @@ -136,41 +135,42 @@ public class ArtifactHandlerProviderUtil { requestInfo.put(SdcArtifactHandlerConstants.SOURCE, templateData.getRequestInformation().getSource()); String serviceDescription = serviceDescriptionData( - templateData.getDocumentParameters().getServiceDescription()); + templateData.getDocumentParameters().getServiceDescription()); JSONObject docParams = new JSONObject(); docParams.put(SdcArtifactHandlerConstants.SERVICE_UUID, templateData.getDocumentParameters().getResourceUuid()); - docParams - .put(SdcArtifactHandlerConstants.DISTRIBUTION_ID, templateData.getDocumentParameters().getDistributionId()); + docParams.put(SdcArtifactHandlerConstants.DISTRIBUTION_ID, + templateData.getDocumentParameters().getDistributionId()); docParams.put(SdcArtifactHandlerConstants.SERVICE_NAME, templateData.getDocumentParameters().getServiceName()); docParams.put(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION, serviceDescription); docParams.put(SdcArtifactHandlerConstants.SERVICE_ARTIFACTS, - templateData.getDocumentParameters().getServiceArtifacts()); + templateData.getDocumentParameters().getServiceArtifacts()); docParams - .put(SdcArtifactHandlerConstants.RESOURCE_UUID, templateData.getDocumentParameters().getResourceUuid()); + .put(SdcArtifactHandlerConstants.RESOURCE_UUID, templateData.getDocumentParameters().getResourceUuid()); docParams.put(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME, - templateData.getDocumentParameters().getResourceInstanceName()); - docParams.put(SdcArtifactHandlerConstants.REOURCE_NAME, templateData.getDocumentParameters().getResourceName()); + templateData.getDocumentParameters().getResourceInstanceName()); + docParams + .put(SdcArtifactHandlerConstants.RESOURCE_NAME, templateData.getDocumentParameters().getResourceName()); docParams.put(SdcArtifactHandlerConstants.RESOURCE_VERSION, - templateData.getDocumentParameters().getResourceVersion()); + templateData.getDocumentParameters().getResourceVersion()); docParams - .put(SdcArtifactHandlerConstants.RESOURCE_TYPE, templateData.getDocumentParameters().getResourceType()); + .put(SdcArtifactHandlerConstants.RESOURCE_TYPE, templateData.getDocumentParameters().getResourceType()); docParams - .put(SdcArtifactHandlerConstants.ARTIFACT_UUID, templateData.getDocumentParameters().getArtifactUuid()); + .put(SdcArtifactHandlerConstants.ARTIFACT_UUID, templateData.getDocumentParameters().getArtifactUuid()); docParams - .put(SdcArtifactHandlerConstants.ARTIFACT_NAME, templateData.getDocumentParameters().getArtifactName()); + .put(SdcArtifactHandlerConstants.ARTIFACT_NAME, templateData.getDocumentParameters().getArtifactName()); docParams - .put(SdcArtifactHandlerConstants.ARTIFACT_TYPE, templateData.getDocumentParameters().getArtifactType()); + .put(SdcArtifactHandlerConstants.ARTIFACT_TYPE, templateData.getDocumentParameters().getArtifactType()); docParams.put(SdcArtifactHandlerConstants.ARTIFACT_VERSION, - templateData.getDocumentParameters().getArtifactVersion()); - docParams.put(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION, - templateData.getDocumentParameters().getArtifactDescription()); + templateData.getDocumentParameters().getArtifactVersion()); + docParams.put(SdcArtifactHandlerConstants.ARTIFACT_DESCRIPTION, + templateData.getDocumentParameters().getArtifactDescription()); docParams.put("artifact-contents", templateData.getDocumentParameters().getArtifactContents()); json.put(SdcArtifactHandlerConstants.REQUEST_INFORMATION, requestInfo); json.put(SdcArtifactHandlerConstants.DOCUMENT_PARAMETERS, docParams); - log.info("Final data =" + this.templateData); + log.info("Final data = " + this.templateData); return String.format("{\"input\": %s}", json.toString()); } diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java index f4f623cce..63ac5767b 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java +++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java @@ -2,22 +2,22 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= * Licensed 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. - * + * * ============LICENSE_END========================================================= */ @@ -26,24 +26,26 @@ package org.onap.appc.artifact.handler.utils; public class SdcArtifactHandlerConstants { public static final String DOCUMENT_PARAMETERS = "document-parameters"; - public static final String SERVICE_UUID = "service-uuid"; - public static final String DISTRIBUTION_ID = "distribution-id"; + public static final String SERVICE_UUID = "service-uuid"; + public static final String DISTRIBUTION_ID = "distribution-id"; public static final String REQUEST_ID = "request-id"; - public static final String REQUEST_ACTION = "request-action"; + public static final String REQUEST_ACTION = "request-action"; public static final String SOURCE = "source"; - public static final String SERVICE_NAME = "service-name"; - public static final String SERVICE_DESCRIPTION ="service-description"; - public static final String SERVICE_ARTIFACTS = "service-artifacts"; - public static final String RESOURCE_UUID ="resource-uuid"; + public static final String SERVICE_NAME = "service-name"; + public static final String SERVICE_DESCRIPTION = "service-description"; + public static final String SERVICE_ARTIFACTS = "service-artifacts"; + public static final String RESOURCE_UUID = "resource-uuid"; public static final String RESOURCE_INSTANCE_NAME = "resource-instance-name"; - public static final String REOURCE_NAME = "resource-name"; - public static final String RESOURCE_VERSION ="resource-version"; - public static final String RESOURCE_TYPE= "resource-type"; - public static final String ARTIFACT_UUID ="artifact-uuid"; - public static final String ARTIFACT_NAME = "artifact-name"; - public static final String ARTIFACT_TYPE = "artifact-type"; + public static final String RESOURCE_NAME = "resource-name"; + public static final String REOURCE_NAME = "resource-name"; // misspelling that was once supported + public static final String RESOURCE_VERSION = "resource-version"; + public static final String RESOURCE_TYPE = "resource-type"; + public static final String ARTIFACT_UUID = "artifact-uuid"; + public static final String ARTIFACT_NAME = "artifact-name"; + public static final String ARTIFACT_TYPE = "artifact-type"; public static final String ARTIFACT_VERSION = "artifact-version"; - public static final String ARTIFACT_DESRIPTION = "artifact-description"; + public static final String ARTIFACT_DESCRIPTION = "artifact-description"; + public static final String ARTIFACT_DESRIPTION = "artifact-description"; // misspelling that was once supported public static final String ARTIFACT_CONTENTS = "artifact-contents"; public static final String REQUEST_INFORMATION = "request-information"; public static final String INTERNAL_VERSION = "internal-versoin"; @@ -58,8 +60,8 @@ public class SdcArtifactHandlerConstants { public static final String VNFC_FUNCTION_CODE = "vnfc-function-code"; public static final String VNFC_FUNCTION_CODE_LIST = "vnfc-function-code-list"; public static final String GROUP_NOTATION = "group-notation"; - public static final String IPADDRESS_V4_OAM_VIP = "ipaddress-v4-oam-vip"; - public static final String GROUP_NOTATION_TYPE = "group-notation-type"; + public static final String IPADDRESS_V4_OAM_VIP = "ipaddress-v4-oam-vip"; + public static final String GROUP_NOTATION_TYPE = "group-notation-type"; public static final String GROUP_NOTATION_VALUE = "group-notation-value"; public static final String TEMPLATE_ID = "template-id"; public static final String REFERENCE = "reference"; @@ -71,7 +73,8 @@ public class SdcArtifactHandlerConstants { public static final String PORT_NUMBER = "port-number"; public static final String DOWNLOAD_DG_REFERENCE = "download-dg-reference"; public static final String VNFC_TYPE_LIST = "vnfc-type-list"; - + + public static final String DB_DOWNLOAD_DG_REFERENCE = "DOWNLOAD_DG_REFERENCE"; public static final String DB_SDC_REFERENCE = "ASDC_REFERENCE"; public static final String DB_DEVICE_INTERFACE_PROTOCOL = "DEVICE_INTERFACE_PROTOCOL"; @@ -83,17 +86,16 @@ public class SdcArtifactHandlerConstants { public static final String TOSCA_MODEL = "tosca_model"; public static final String DESIGN_TOOL = "Design-tool"; public static final String ACTION_LEVEL_VNFC = "VNFC"; - public static final String ACTION_LEVEL_VF_MODULE ="VF-MODULE"; + public static final String ACTION_LEVEL_VF_MODULE = "VF-MODULE"; public static final String ACTION_LEVEL_VNF = "VNF"; public static final String ACTION_LEVEL_VM = "VM"; public static final String CAPABILITY = "capability"; public static final String TEMPLATE = "template"; public static final String ARTIFACT_NAME_REFERENCE = "reference"; public static final String ARTIFACT_NAME_CAPABILITY = "capability"; - public static final String APPC_CONFIG_DIR="/opt/appcauth"; - public static final String URL="url"; - public static final String OPENSTACK = "OS"; - public static final String ANSIBLE = "ansible"; - + public static final String APPC_CONFIG_DIR = "/opt/appcauth"; + public static final String URL = "url"; + public static final String OPENSTACK = "OS"; + public static final String ANSIBLE = "ansible"; } |