diff options
8 files changed, 104 insertions, 111 deletions
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java index 6c571f3e06..f51b27282c 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java @@ -241,9 +241,6 @@ public class BpelRestClient { LOGGER.debug("Sending to BPEL server: "+bpelUrl); LOGGER.debug("Content is: "+toBpelStr); - //Client 4.3+ - CloseableHttpClient client = null; - //POST HttpPost post = new HttpPost(bpelUrl); if (credentials != null && !credentials.isEmpty()) @@ -263,8 +260,7 @@ public class BpelRestClient { //Client 4.3+ //Execute & GetResponse - try { - client = HttpClients.createDefault(); + try (CloseableHttpClient client = HttpClients.createDefault()) { CloseableHttpResponse response = client.execute(post); if (response != null) { lastResponseCode = response.getStatusLine().getStatusCode(); @@ -279,14 +275,6 @@ public class BpelRestClient { LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception sending Bpel notification", e); lastResponseCode = 900; lastResponse = ""; - } finally { - if(client != null){ - try { - client.close(); - } catch (IOException e) { - LOGGER.debug("Exception while closing client", e); - } - } } LOGGER.debug("Response code from BPEL server: "+lastResponseCode); LOGGER.debug("Response body is: "+lastResponse); diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java index cba378eab0..a8e03d98f3 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java @@ -86,7 +86,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER"; private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError"; private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter."; - private static final String LOG_REPLY_NAME = "MSO-VnfAdapter:MSO-BPMN."; private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); private static final String CHECK_REQD_PARAMS = "org.openecomp.mso.adapters.vnf.checkRequiredParameters"; @@ -433,34 +432,36 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } private Map <String, String> copyStringOutputs (Map <String, Object> stackOutputs) { - Map <String, String> stringOutputs = new HashMap <String, String> (); - for (String key : stackOutputs.keySet ()) { - if (stackOutputs.get (key) instanceof String) { - stringOutputs.put (key, (String) stackOutputs.get (key)); - } else if (stackOutputs.get(key) instanceof Integer) { + Map <String, String> stringOutputs = new HashMap <> (); + for (Map.Entry<String,Object> entry : stackOutputs.entrySet ()) { + String key = entry.getKey(); + Object value = entry.getValue(); + if (value instanceof String) { + stringOutputs.put (key, (String) value); + } else if (value instanceof Integer) { try { - String str = "" + stackOutputs.get(key); + String str = "" + value; stringOutputs.put(key, str); } catch (Exception e) { LOGGER.debug("Unable to add " + key + " to outputs",e); } - } else if (stackOutputs.get(key) instanceof JsonNode) { + } else if (value instanceof JsonNode) { try { - String str = this.convertNode((JsonNode) stackOutputs.get(key)); + String str = this.convertNode((JsonNode) value); stringOutputs.put(key, str); } catch (Exception e) { LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode",e); } - } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) { + } else if (value instanceof java.util.LinkedHashMap) { try { - String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key)); + String str = JSON_MAPPER.writeValueAsString(value); stringOutputs.put(key, str); } catch (Exception e) { LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap",e); } } else { try { - String str = stackOutputs.get(key).toString(); + String str = value.toString(); stringOutputs.put(key, str); } catch (Exception e) { LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(),e); @@ -471,7 +472,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } private Map <String, Object> copyStringInputs (Map <String, String> stringInputs) { - return new HashMap <String, Object> (stringInputs); + return new HashMap <> (stringInputs); } /* @@ -485,7 +486,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { StringBuilder sb = new StringBuilder (); try (Scanner scanner = new Scanner (environment)) { scanner.useDelimiter ("\n"); - String line = null; + String line; Pattern resource = Pattern.compile ("\\s*\"\\w+::\\S+\"\\s*:"); LOGGER.debug ("regex pattern for finding a resource_registry: \\s*\"\\w+::\\S+\"\\s*:"); while (scanner.hasNextLine ()) { @@ -569,7 +570,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { boolean wait = p.waitFor(waitTimeMs, TimeUnit.MILLISECONDS); LOGGER.debug(" HeatBridgeMain.py returned " + wait + " with code " + p.exitValue()); - return (wait && p.exitValue()==0); + return wait && p.exitValue()==0; } catch (IOException e) { LOGGER.debug(" HeatBridgeMain.py failed with IO Exception! " + e); return false; @@ -591,10 +592,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { else if (inputs.size() < 1) { sb.append("\tEMPTY"); } else { - for (String str : inputs.keySet()) { + for (Map.Entry<String,Object> entry : inputs.entrySet()) { String outputString; + String str = entry.getKey(); + Object value = entry.getValue(); try { - outputString = inputs.get(str).toString(); + outputString = value.toString(); } catch (Exception e) { LOGGER.debug("Exception :",e); outputString = "Unable to call toString() on the value for " + str; @@ -708,7 +711,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String mcu = modelCustomizationUuid; boolean useMCUuid = false; if (mcu != null && !mcu.isEmpty()) { - if (mcu.equalsIgnoreCase("null")) { + if ("null".equalsIgnoreCase(mcu)) { LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid); useMCUuid = false; mcu = ""; @@ -720,25 +723,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("CreateVfModule"); String requestTypeString = ""; - if (requestType != null && !requestType.equals("")) { + if (requestType != null && !"".equals(requestType)) { requestTypeString = requestType; } String nestedStackId = null; - if (volumeGroupHeatStackId != null && !volumeGroupHeatStackId.equals("")) { - if (!volumeGroupHeatStackId.equalsIgnoreCase("null")) { + if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) { + if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) { nestedStackId = volumeGroupHeatStackId; } } String nestedBaseStackId = null; - if (baseVfHeatStackId != null && !baseVfHeatStackId.equals("")) { - if (!baseVfHeatStackId.equalsIgnoreCase("null")) { + if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) { + if (!"null".equalsIgnoreCase(baseVfHeatStackId)) { nestedBaseStackId = baseVfHeatStackId; } } if (inputs == null) { // Create an empty set of inputs - inputs = new HashMap<String,String>(); + inputs = new HashMap<>(); LOGGER.debug("inputs == null - setting to empty"); } else { this.sendMapToDebug(inputs); @@ -774,7 +777,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfRollback.setModelCustomizationUuid(mcu); // Put data into A&AI through Heatstack - boolean heatStackCallSuccess = callHeatbridge(baseVfHeatStackId); + callHeatbridge(baseVfHeatStackId); // First, look up to see if the VF already exists. MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); @@ -1037,17 +1040,16 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { minVersionVnf = null; maxVersionVnf = null; } - if (minVersionVnf != null && minVersionVnf.equals("")) { + if (minVersionVnf != null && "".equals(minVersionVnf)) { minVersionVnf = null; } - if (maxVersionVnf != null && maxVersionVnf.equals("")) { + if (maxVersionVnf != null && "".equals(maxVersionVnf)) { maxVersionVnf = null; } } if (minVersionVnf != null && maxVersionVnf != null) { MavenLikeVersioning aicV = new MavenLikeVersioning(); CloudSite cloudSite = null; - String aicVersion = ""; if (this.cloudConfig == null) { this.cloudConfig = this.cloudConfigFactory.getCloudConfig(); } @@ -1133,7 +1135,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null) HeatTemplate heatTemplate = null; - if (heatTemplateArtifactUuid == null || heatTemplateArtifactUuid.equals("")) { + if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) { String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString; LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); @@ -1158,7 +1160,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { HeatEnvironment heatEnvironment = null; String heatEnvironmentString = null; - if (heatEnvironmentArtifactUuid != null && !heatEnvironmentArtifactUuid.equals("")) { + if (heatEnvironmentArtifactUuid != null && !"".equals(heatEnvironmentArtifactUuid)) { LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":"); heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid); if (heatEnvironment == null) { @@ -1184,13 +1186,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug ("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId=" + heatTemplate.getArtifactUuid()); Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid()); - Map <String, Object> nestedTemplatesChecked = new HashMap <String, Object> (); + Map <String, Object> nestedTemplatesChecked = new HashMap <> (); if (nestedTemplates != null) { // for debugging print them out LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); - for (String providerResourceFile : nestedTemplates.keySet ()) { + for (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) { + String providerResourceFile = entry.getKey(); + Object value = entry.getValue(); String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile); - String childTemplateBody = (String) nestedTemplates.get (providerResourceFile); + String childTemplateBody = (String) value; LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody); nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody); } @@ -1202,7 +1206,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 1510 - Also add the files: for any get_files associated with this vnf_resource_id // *if* there are any Map<String, HeatFiles> heatFiles = null; - Map<String, Object> heatFilesObjects = new HashMap<String, Object>(); + Map<String, Object> heatFilesObjects = new HashMap<>(); // Add ability to turn on adding get_files with volume requests (by property). boolean addGetFilesOnVolumeReq = false; @@ -1234,7 +1238,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // this will match the nested templates format LOGGER.debug("Contents of heatFiles - to be added to files: on stack:"); - for (String heatFileName : heatFiles.keySet()) { + for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) { + String heatFileName = entry.getKey(); + HeatFiles value = entry.getValue(); if (heatFileName.startsWith("_ERROR|")) { // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); @@ -1246,8 +1252,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); throw new VnfException (error, MsoExceptionCategory.INTERNAL); } - String heatFileBody = heatFiles.get(heatFileName) - .getFileBody(); + String heatFileBody = value.getFileBody(); String heatFileNameChecked = heatFileName; LOGGER.debug(heatFileNameChecked + " -> " + heatFileBody); @@ -1263,14 +1268,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Check that required parameters have been supplied String missingParams = null; - List <String> paramList = new ArrayList <String> (); + List <String> paramList = new ArrayList <> (); // New for 1510 - consult the PARAM_ALIAS field to see if we've been // supplied an alias. Only check if we don't find it initially. // Also new in 1510 - don't flag missing parameters if there's an environment - because they might be there. // And also new - add parameter to turn off checking all together if we find we're blocking orders we // shouldn't - boolean haveEnvironmentParameters = false; boolean checkRequiredParameters = true; try { String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER) @@ -1292,7 +1296,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heatEnvironmentString != null && heatEnvironmentString.contains ("parameters:")) { //LOGGER.debug ("Have an Environment argument with a parameters: section - will bypass checking for valid params - but will still check for aliases"); LOGGER.debug("Enhanced environment checking enabled - 1604"); - haveEnvironmentParameters = true; StringBuilder sb = new StringBuilder(heatEnvironmentString); //LOGGER.debug("About to create MHEE with " + sb); mhee = new MsoHeatEnvironmentEntry(sb); @@ -1314,15 +1317,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { HashMap<String, Object> goldenInputs = null; LOGGER.debug("Now handle the inputs....first convert"); - ArrayList<String> parameterNames = new ArrayList<String>(); - HashMap<String, String> aliasToParam = new HashMap<String, String>(); + ArrayList<String> parameterNames = new ArrayList<>(); + HashMap<String, String> aliasToParam = new HashMap<>(); StringBuilder sb = new StringBuilder("\nTemplate Parameters:\n"); int cntr = 0; try { for (HeatTemplateParam htp : heatTemplate.getParameters()) { sb.append("param[" + cntr++ + "]=" + htp.getParamName()); parameterNames.add(htp.getParamName()); - if (htp.getParamAlias() != null && !htp.getParamAlias().equals("")) { + if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) { aliasToParam.put(htp.getParamAlias(), htp.getParamName()); sb.append(" ** (alias=" + htp.getParamAlias() + ")"); } @@ -1534,7 +1537,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Holder <VnfRollback> rollback) throws VnfException { String vfModuleName = vnfName; String vfModuleType = vnfType; - String vfVersion = vnfVersion; String methodName = "updateVfModule"; MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ()); String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName; @@ -1568,25 +1570,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } String requestTypeString = ""; - if (requestType != null && !requestType.equals("")) { + if (requestType != null && !"".equals(requestType)) { requestTypeString = requestType; } String nestedStackId = null; - if (volumeGroupHeatStackId != null && !volumeGroupHeatStackId.equals("")) { - if (!volumeGroupHeatStackId.equalsIgnoreCase("null")) { + if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) { + if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) { nestedStackId = volumeGroupHeatStackId; } } String nestedBaseStackId = null; - if (baseVfHeatStackId != null && !baseVfHeatStackId.equals("")) { - if (!baseVfHeatStackId.equalsIgnoreCase("null")) { + if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) { + if (!"null".equalsIgnoreCase(baseVfHeatStackId)) { nestedBaseStackId = baseVfHeatStackId; } } if (inputs == null) { // Create an empty set of inputs - inputs = new HashMap<String,String>(); + inputs = new HashMap<>(); LOGGER.debug("inputs == null - setting to empty"); } else { this.sendMapToDebug(inputs); @@ -1596,7 +1598,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (requestTypeString.startsWith("VOLUME")) { isVolumeRequest = true; } - if (vfModuleName == null || vfModuleName.trim().equals("")) { + if (vfModuleName == null || "".equals(vfModuleName.trim())) { if (vfModuleStackId != null) { vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId); } @@ -1790,10 +1792,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { minVersionVnf = null; maxVersionVnf = null; } - if (minVersionVnf != null && minVersionVnf.equals("")) { + if (minVersionVnf != null && "".equals(minVersionVnf)) { minVersionVnf = null; } - if (maxVersionVnf != null && maxVersionVnf.equals("")) { + if (maxVersionVnf != null && "".equals(maxVersionVnf)) { maxVersionVnf = null; } } @@ -1898,13 +1900,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" + heatTemplate.getArtifactUuid ()); Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid ()); - Map <String, Object> nestedTemplatesChecked = new HashMap <String, Object> (); + Map <String, Object> nestedTemplatesChecked = new HashMap <> (); if (nestedTemplates != null) { // for debugging print them out LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); - for (String providerResourceFile : nestedTemplates.keySet ()) { + for (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) { + String providerResourceFile = entry.getKey(); + Object value = entry.getValue(); String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile); - String childTemplateBody = (String) nestedTemplates.get (providerResourceFile); + String childTemplateBody = (String) value; nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody); LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody); } @@ -1920,7 +1924,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Map <String, HeatFiles> heatFiles = null; // Map <String, HeatFiles> heatFiles = db.getHeatFiles (vnf.getId ()); - Map <String, Object> heatFilesObjects = new HashMap <String, Object> (); + Map <String, Object> heatFilesObjects = new HashMap <> (); // Add ability to turn on adding get_files with volume requests (by property). boolean addGetFilesOnVolumeReq = false; @@ -1944,7 +1948,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // this will match the nested templates format LOGGER.debug ("Contents of heatFiles - to be added to files: on stack:"); - for (String heatFileName : heatFiles.keySet ()) { + for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet ()) { + String heatFileName = entry.getKey(); + HeatFiles value = entry.getValue(); if (heatFileName.startsWith("_ERROR|")) { // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); @@ -1956,7 +1962,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); throw new VnfException (error, MsoExceptionCategory.INTERNAL); } - String heatFileBody = heatFiles.get (heatFileName).getFileBody (); + String heatFileBody = value.getFileBody (); LOGGER.debug (heatFileName + " -> " + heatFileBody); heatFilesObjects.put (heatFileName, heatFileBody); } @@ -1968,7 +1974,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Check that required parameters have been supplied String missingParams = null; - List <String> paramList = new ArrayList <String> (); + List <String> paramList = new ArrayList <> (); // New for 1510 - consult the PARAM_ALIAS field to see if we've been // supplied an alias. Only check if we don't find it initially. @@ -2016,7 +2022,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // New for 1607 - support params of json type - HashMap<String, JsonNode> jsonParams = new HashMap<String, JsonNode>(); + HashMap<String, JsonNode> jsonParams = new HashMap<>(); boolean hasJson = false; for (HeatTemplateParam parm : heatTemplate.getParameters ()) { @@ -2027,11 +2033,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { + parm.getParamAlias ()); // handle json String parameterType = parm.getParamType(); - if (parameterType == null || parameterType.trim().equals("")) { + if (parameterType == null || "".equals(parameterType.trim())) { parameterType = "String"; } JsonNode jsonNode = null; - if (parameterType.equalsIgnoreCase("json") && inputs != null) { + if ("json".equalsIgnoreCase(parameterType) && inputs != null) { if (inputs.containsKey(parm.getParamName()) ) { hasJson = true; String jsonString = null; @@ -2138,7 +2144,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Remove any extraneous parameters (don't throw an error) if (inputs != null) { - List <String> extraParams = new ArrayList <String> (); + List <String> extraParams = new ArrayList <> (); extraParams.addAll (inputs.keySet ()); // This is not a valid parameter for this template extraParams.removeAll (paramList); @@ -2150,12 +2156,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 1607 - when we get here - we have clean inputs. Create inputsTwo in case we have json Map<String, Object> inputsTwo = null; if (hasJson && jsonParams.size() > 0) { - inputsTwo = new HashMap<String, Object>(); - for (String keyParamName : inputs.keySet()) { + inputsTwo = new HashMap<>(); + for (Map.Entry<String, String> entry : inputs.entrySet()) { + String keyParamName = entry.getKey(); + String value = entry.getValue(); if (jsonParams.containsKey(keyParamName)) { inputsTwo.put(keyParamName, jsonParams.get(keyParamName)); } else { - inputsTwo.put(keyParamName, inputs.get(keyParamName)); + inputsTwo.put(keyParamName, value); } } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java index e938a25fab..787453ed28 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java @@ -28,9 +28,9 @@ public class CryptoHandler implements ICryptoHandler { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
private static String msoKey = "aa3871669d893c7fb8abbcda31b88b4f";
- //private static String msoAaiPwd = "mso0206";
private static String msoAaiEncryptedPwd = "C1FC4A39E16419DD41DFC1212843F440";
+ @Override
public String getMsoAaiPassword() {
try {
return CryptoUtils.decrypt(msoAaiEncryptedPwd, msoKey);
@@ -41,6 +41,7 @@ public class CryptoHandler implements ICryptoHandler { }
+ @Override
public String encryptMsoPassword(String plainMsoPwd) {
try {
return CryptoUtils.encrypt(plainMsoPwd, msoKey);
@@ -50,7 +51,7 @@ public class CryptoHandler implements ICryptoHandler { }
}
-
+ @Override
public String decryptMsoPassword(String encryptedPwd) {
try {
return CryptoUtils.decrypt(encryptedPwd, msoKey);
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy index 18dbbea573..73066b3722 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy @@ -160,10 +160,10 @@ public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) try { - String requestId = execution.getVariable("msoRequestId") + String operationId = execution.getVariable("operationId") String serviceInstanceId = execution.getVariable("serviceInstanceId") // RESTResponse for API Handler (APIH) Reply Task - String createServiceRestRequest = """{"service":{"serviceId":"${serviceInstanceId}","operationId":"${requestId}"}}""".trim() + String createServiceRestRequest = """{"service":{"serviceId":"${serviceInstanceId}","operationId":"${operationId}"}}""".trim() utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + createServiceRestRequest, isDebugEnabled) sendWorkflowResponse(execution, 202, createServiceRestRequest) execution.setVariable("sentSyncResponse", true) diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/ProcessInstanceResource.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/ProcessInstanceResource.java index 5cf6f6ca05..484981c99d 100644 --- a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/ProcessInstanceResource.java +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/ProcessInstanceResource.java @@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory; import org.camunda.bpm.cockpit.db.QueryParameters;
import org.camunda.bpm.cockpit.plugin.resource.AbstractPluginResource;
-import org.camunda.bpm.cockpit.db.CommandExecutor;
import org.openecomp.camunda.bpmn.plugin.urnmap.db.*;
public class ProcessInstanceResource extends AbstractPluginResource {
@@ -61,25 +60,25 @@ public class ProcessInstanceResource extends AbstractPluginResource { }
@PUT
- //public void insertNewRow(String key_, String value_)
+ //public void insertNewRow(String key, String value)
public void insertNewRow(String temp)
{
log.info("AddNewRow: XXXXXXXXXXXXXXXXX ---> " + temp);
StringTokenizer st = new StringTokenizer(temp, "|");
- String key_ = "";
- String value_ = "";
+ String key = "";
+ String value = "";
while(st.hasMoreTokens()) {
- key_ = st.nextToken();
- value_ = st.nextToken();
- System.out.println(key_ + "\t" + value_);
+ key = st.nextToken();
+ value = st.nextToken();
+ log.info(key + "\t" + value);
}
- log.info("AddNewRow: XXXXXXXXXXXXXXXXX ---> key: " + key_ + " , Value: " + value_);
+ log.info("AddNewRow: XXXXXXXXXXXXXXXXX ---> key: " + key + " , Value: " + value);
URNData nRow = new URNData();
nRow.setVer_("1");
- nRow.setURNName(key_);
- nRow.setURNValue(value_);
+ nRow.setURNName(key);
+ nRow.setURNValue(value);
getQueryService().executeQuery("cockpit.urnMap.insertNewRow", nRow, URNData.class);
@@ -87,14 +86,12 @@ public class ProcessInstanceResource extends AbstractPluginResource { }
@POST
- // public void getPersistData(List<URNData > myList) {
public void getPersistData(URNData d) {
log.info("getPersistData: UrnName: " + d.getURNName() + " , URNValue: " + d.getURNValue() );
getQueryService().executeQuery("cockpit.urnMap.persistURNData", d, URNData.class);
- //getQueryService().executeQuery("cockpit.sample.persistURNData", d, ProcessInstanceCountDto.class);
-
+
log.info("XXXXXXXXXX - END - XXXXXXXXXXXXXXX");
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java index fb507a69cf..92a45a71dd 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java @@ -54,6 +54,7 @@ import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoAlarmLogger; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.OperationStatus; import org.openecomp.mso.requestsdb.RequestsDatabase; import com.wordnik.swagger.annotations.Api; @@ -146,10 +147,10 @@ public class OrchestrationRequests { long startTime = System.currentTimeMillis(); - InfraActiveRequests requestDB = null; + OperationStatus requestDB = null; try { - requestDB = requestsDB.getRequestFromInfraActive(serviceId); + requestDB = requestsDB.getOperationStatus(serviceId, operationId); } catch (Exception e) { msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", @@ -181,9 +182,7 @@ public class OrchestrationRequests { } - E2ERequest e2erequest = mapInfraActiveRequestToE2ERequest(requestDB); - - e2eServiceResponse.setE2eRequest(e2erequest); + e2eServiceResponse.setE2eRequest(requestDB); return Response.status(200).entity(e2eServiceResponse).build(); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java index 1e8bea0c55..92e3e5b078 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java @@ -86,7 +86,7 @@ public class TasksHandler { // Prepare the query string to /task interface TaskVariables tv = new TaskVariables(); - List<TaskVariableValue> tvvList = new ArrayList<TaskVariableValue>(); + List<TaskVariableValue> tvvList = new ArrayList<>(); if (originalRequestId != null) { TaskVariableValue tvv = new TaskVariableValue(); @@ -168,7 +168,7 @@ public class TasksHandler { return resp; } TasksGetResponse trr = new TasksGetResponse(); - List<TaskList> taskList = new ArrayList<TaskList>(); + List<TaskList> taskList = new ArrayList<>(); ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ()); int bpelStatus = respHandler.getStatus (); @@ -250,7 +250,6 @@ public class TasksHandler { msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); responseBack = Response.status (HttpStatus.SC_ACCEPTED).entity (jsonResponse).build (); - // msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); return responseBack; } @@ -261,9 +260,9 @@ public class TasksHandler { // Makes a GET call to Camunda to get variables for this task private TaskList getTaskInfo(String taskId) throws Exception { - TaskList taskList = null; + TaskList taskList; String getRequestUrl = requestUrl + taskId + "/variables"; - HttpResponse getResponse = null; + HttpResponse getResponse; long subStartTime = System.currentTimeMillis(); RequestClient requestClient = RequestClientFactory.getRequestClient (getRequestUrl, MsoPropertiesUtils.loadMsoProperties ()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java index 8145afca6d..4c749b7e58 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java @@ -22,18 +22,19 @@ package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.openecomp.mso.requestsdb.OperationStatus;
@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
public class GetE2EServiceInstanceResponse {
- protected E2ERequest e2eRequest;
+ protected OperationStatus e2eRequest;
- public E2ERequest getE2eRequest() {
+ public OperationStatus getE2eRequest() {
return e2eRequest;
}
- public void setE2eRequest(E2ERequest e2eRequest) {
- this.e2eRequest = e2eRequest;
+ public void setE2eRequest(OperationStatus requestDB) {
+ this.e2eRequest = requestDB;
}
}
|