diff options
Diffstat (limited to 'adapters')
38 files changed, 693 insertions, 441 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java index fd252b634a..3aa77c2c7a 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +27,12 @@ import java.util.HashSet; import java.util.ArrayList; import java.util.Set; import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; +import org.openecomp.mso.logger.MsoLogger; public class MsoHeatEnvironmentEntry { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private Set<MsoHeatEnvironmentParameter> parameters = null; private Set<MsoHeatEnvironmentResource> resources = null; private StringBuilder rawEntry = null; @@ -48,7 +52,7 @@ public class MsoHeatEnvironmentEntry { private void processRawEntry() { try { - if (this.rawEntry == null || this.rawEntry.equals("")) + if (this.rawEntry == null || "".equals(this.rawEntry)) return; byte[] b = this.rawEntry.toString().getBytes(); MsoYamlEditorWithEnvt yaml = new MsoYamlEditorWithEnvt(b); @@ -61,6 +65,7 @@ public class MsoHeatEnvironmentEntry { this.resourceRegistryEntryRaw = sb; } } catch (Exception e) { + LOGGER.debug("Exception:", e); this.valid = false; this.errorString = e.getMessage(); //e.printStackTrace(); @@ -97,13 +102,13 @@ public class MsoHeatEnvironmentEntry { public void addParameter(MsoHeatEnvironmentParameter hep) { if (this.parameters == null) { - this.parameters = new HashSet<MsoHeatEnvironmentParameter>(); + this.parameters = new HashSet<>(); } this.parameters.add(hep); } public void addResource(MsoHeatEnvironmentResource her) { if (this.resources == null) { - this.resources = new HashSet<MsoHeatEnvironmentResource>(); + this.resources = new HashSet<>(); } this.resources.add(her); } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java index f5dffc3297..31e2fca4c1 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +21,12 @@ package org.openecomp.mso.openstack.utils; - +import org.openecomp.mso.logger.MsoLogger; public class MsoHeatEnvironmentResource { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private String name; private String value; @@ -77,7 +80,7 @@ public class MsoHeatEnvironmentResource { try { result = this.name.hashCode(); } catch (Exception e) { - // in case it's null - return zero + LOGGER.debug("Exception:", e); } return result; } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java index 8073c953e9..fad0c2368b 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java @@ -91,12 +91,12 @@ public class MsoHeatUtils extends MsoCommonUtils { // token will be used until it expires. // // The cache key is "tenantId:cloudId" - private static Map <String, HeatCacheEntry> heatClientCache = new HashMap <String, HeatCacheEntry> (); + private static Map <String, HeatCacheEntry> heatClientCache = new HashMap <> (); // Fetch cloud configuration each time (may be cached in CloudConfig class) protected CloudConfig cloudConfig; - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); protected MsoJavaProperties msoProps = null; @@ -343,7 +343,7 @@ public class MsoHeatUtils extends MsoCommonUtils { if (haveFiles && haveHeatFiles) { // Let's do this here - not in the bean LOGGER.debug ("Found files AND heatFiles - combine and add!"); - Map <String, Object> combinedFiles = new HashMap <String, Object> (); + Map <String, Object> combinedFiles = new HashMap <> (); for (String keyString : files.keySet ()) { combinedFiles.put (keyString, files.get (keyString)); } @@ -584,7 +584,7 @@ public class MsoHeatUtils extends MsoCommonUtils { } } // end while !deleted - StringBuilder errorContextMessage = null; + StringBuilder errorContextMessage; if (createTimedOut) { errorContextMessage = new StringBuilder("Stack Creation Timeout"); } else { @@ -737,7 +737,14 @@ public class MsoHeatUtils extends MsoCommonUtils { String canonicalName = heatStack.getStackName () + "/" + heatStack.getId (); try { - OpenStackRequest <Void> request = heatClient.getStacks ().deleteByName (canonicalName); + OpenStackRequest <Void> request = null; + if(null != heatClient) { + request = heatClient.getStacks ().deleteByName (canonicalName); + } + else { + LOGGER.debug ("Heat Client is NULL" ); + } + executeAndRecordOpenstackRequest (request, msoProps); } catch (OpenStackResponseException e) { if (e.getStatus () == 404) { @@ -845,7 +852,7 @@ public class MsoHeatUtils extends MsoCommonUtils { OpenStackRequest <Stacks> request = heatClient.getStacks ().list (); Stacks stacks = executeAndRecordOpenstackRequest (request, msoProps); - List <StackInfo> stackList = new ArrayList <StackInfo> (); + List <StackInfo> stackList = new ArrayList <> (); // Not sure if returns an empty list or null if no stacks exist if (stacks != null) { @@ -859,7 +866,7 @@ public class MsoHeatUtils extends MsoCommonUtils { if (e.getStatus () == 404) { // Not sure if this can happen, but return an empty list LOGGER.debug ("queryAllStacks - stack not found: "); - return new ArrayList <StackInfo> (); + return new ArrayList <> (); } else { // Convert the OpenStackResponseException to an MsoOpenstackException throw heatExceptionToMsoException (e, QUERY_ALL_STACKS); @@ -891,7 +898,7 @@ public class MsoHeatUtils extends MsoCommonUtils { HeatTemplate heatTemplate) throws IllegalArgumentException { // Check that required parameters have been supplied for this template type String missingParams = null; - List <String> paramList = new ArrayList <String> (); + List <String> paramList = new ArrayList <> (); // TODO: Enhance DB to support defaults for Heat Template parameters @@ -913,8 +920,8 @@ public class MsoHeatUtils extends MsoCommonUtils { } // Remove any extraneous parameters (don't throw an error) - Map <String, Object> updatedParams = new HashMap <String, Object> (); - List <String> extraParams = new ArrayList <String> (); + Map <String, Object> updatedParams = new HashMap <> (); + List <String> extraParams = new ArrayList <> (); for (String key : inputParams.keySet ()) { if (!paramList.contains (key)) { // This is not a valid parameter for this template @@ -1139,7 +1146,7 @@ public class MsoHeatUtils extends MsoCommonUtils { * This may be useful if cached credentials get out of sync. */ public static void heatCacheReset () { - heatClientCache = new HashMap <String, HeatCacheEntry> (); + heatClientCache = new HashMap <> (); } public Map<String, Object> queryStackForOutputs(String cloudSiteId, @@ -1273,7 +1280,7 @@ public class MsoHeatUtils extends MsoCommonUtils { sb.append("(outputs is empty)"); return sb; } - Map<String, Object> outputs = new HashMap<String,Object>(); + Map<String, Object> outputs = new HashMap<>(); for (Output outputItem : outputList) { outputs.put(outputItem.getOutputKey(), outputItem.getOutputValue()); } @@ -1419,7 +1426,7 @@ public class MsoHeatUtils extends MsoCommonUtils { } else { cdl3 = cdl2; } - ArrayList<String> list = new ArrayList<String>(Arrays.asList(cdl3.split(","))); + ArrayList<String> list = new ArrayList<>(Arrays.asList(cdl3.split(","))); return list; } @@ -1441,9 +1448,9 @@ public class MsoHeatUtils extends MsoCommonUtils { * @return HashMap<String, Object> of the inputs, cleaned and converted */ public HashMap<String, Object> convertInputMap(Map<String, String> inputs, HeatTemplate template) { - HashMap<String, Object> newInputs = new HashMap<String, Object>(); - HashMap<String, HeatTemplateParam> params = new HashMap<String, HeatTemplateParam>(); - HashMap<String, HeatTemplateParam> paramAliases = new HashMap<String, HeatTemplateParam>(); + HashMap<String, Object> newInputs = new HashMap<>(); + HashMap<String, HeatTemplateParam> params = new HashMap<>(); + HashMap<String, HeatTemplateParam> paramAliases = new HashMap<>(); if (inputs == null) { LOGGER.debug("convertInputMap - inputs is null - nothing to do here"); @@ -1462,7 +1469,7 @@ public class MsoHeatUtils extends MsoCommonUtils { for (HeatTemplateParam htp : template.getParameters()) { LOGGER.debug("Adding " + htp.getParamName()); params.put(htp.getParamName(), htp); - if (htp.getParamAlias() != null && !htp.getParamAlias().equals("")) { + if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) { LOGGER.debug("\tFound ALIAS " + htp.getParamName() + "->" + htp.getParamAlias()); paramAliases.put(htp.getParamAlias(), htp); } @@ -1485,20 +1492,20 @@ public class MsoHeatUtils extends MsoCommonUtils { } } String type = params.get(key).getParamType(); - if (type == null || type.equals("")) { + if (type == null || "".equals(type)) { LOGGER.debug("**PARAM_TYPE is null/empty for " + key + ", will default to string"); type = "string"; } LOGGER.debug("Parameter: " + key + " is of type " + type); - if (type.equalsIgnoreCase("string")) { + if ("string".equalsIgnoreCase(type)) { // Easiest! String str = inputs.get(key); if (alias) newInputs.put(realName, str); else newInputs.put(key, str); - } else if (type.equalsIgnoreCase("number")) { - String integerString = inputs.get(key).toString(); + } else if ("number".equalsIgnoreCase(type)) { + String integerString = inputs.get(key); Integer anInteger = null; try { anInteger = Integer.parseInt(integerString); @@ -1518,8 +1525,8 @@ public class MsoHeatUtils extends MsoCommonUtils { else newInputs.put(key, integerString); } - } else if (type.equalsIgnoreCase("json")) { - String jsonString = inputs.get(key).toString(); + } else if ("json".equalsIgnoreCase(type)) { + String jsonString = inputs.get(key); JsonNode jsonNode = null; try { jsonNode = new ObjectMapper().readTree(jsonString); @@ -1539,8 +1546,8 @@ public class MsoHeatUtils extends MsoCommonUtils { else newInputs.put(key, jsonString); } - } else if (type.equalsIgnoreCase("comma_delimited_list")) { - String commaSeparated = inputs.get(key).toString(); + } else if ("comma_delimited_list".equalsIgnoreCase(type)) { + String commaSeparated = inputs.get(key); try { ArrayList<String> anArrayList = this.convertCdlToArrayList(commaSeparated); if (alias) @@ -1554,8 +1561,8 @@ public class MsoHeatUtils extends MsoCommonUtils { else newInputs.put(key, commaSeparated); } - } else if (type.equalsIgnoreCase("boolean")) { - String booleanString = inputs.get(key).toString(); + } else if ("boolean".equalsIgnoreCase(type)) { + String booleanString = inputs.get(key); Boolean aBool = new Boolean(booleanString); if (alias) newInputs.put(realName, aBool); diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java index 4e715fa06e..bd649e867f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java @@ -36,9 +36,12 @@ import java.util.LinkedHashMap; import org.yaml.snakeyaml.Yaml; +import org.openecomp.mso.logger.MsoLogger; public class MsoYamlEditorWithEnvt { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private Map <String, Object> yml; private Yaml yaml = new Yaml (); private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); @@ -65,6 +68,7 @@ public class MsoYamlEditorWithEnvt { try { resourceMap = (Map<String,Object>) yml.get("parameters"); } catch (Exception e) { + LOGGER.debug("Exception:", e); return paramSet; } if (resourceMap == null) { @@ -90,6 +94,7 @@ public class MsoYamlEditorWithEnvt { try { value = JSON_MAPPER.writeValueAsString(obj); } catch (Exception e) { + LOGGER.debug("Exception:", e); value = "_BAD_JSON_MAPPING"; } } else { @@ -104,7 +109,7 @@ public class MsoYamlEditorWithEnvt { } public synchronized Set <MsoHeatEnvironmentResource> getResourceListFromEnvt() { try { - Set<MsoHeatEnvironmentResource> resourceList = new HashSet<MsoHeatEnvironmentResource>(); + Set<MsoHeatEnvironmentResource> resourceList = new HashSet<>(); @SuppressWarnings("unchecked") Map<String, Object> resourceMap = (Map<String,Object>) yml.get("resource_registry"); Iterator<Entry <String,Object>> it = resourceMap.entrySet().iterator(); @@ -118,12 +123,12 @@ public class MsoYamlEditorWithEnvt { } return resourceList; } catch (Exception e) { - + LOGGER.debug("Exception:", e); } return null; } public synchronized Set <HeatTemplateParam> getParameterList () { - Set <HeatTemplateParam> paramSet = new HashSet <HeatTemplateParam> (); + Set <HeatTemplateParam> paramSet = new HashSet <> (); @SuppressWarnings("unchecked") Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters"); Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator (); @@ -137,6 +142,7 @@ public class MsoYamlEditorWithEnvt { try { value = resourceEntry.get ("default"); } catch (java.lang.ClassCastException cce) { + LOGGER.debug("Exception:", cce); // This exception only - the value is an integer. For what we're doing // here - we don't care - so set value to something - and it will // get marked as not being required - which is correct. diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java index 0b62be6dd0..d9b09fa1b0 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,11 +30,13 @@ import javax.xml.bind.Marshaller; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; +import org.openecomp.mso.logger.MsoLogger; /** * Everything that is common between all Network Requests. */ public abstract class NetworkRequestCommon { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); private Boolean skipAAI = false; private String messageId; private String notificationUrl; @@ -63,7 +66,7 @@ public abstract class NetworkRequestCommon { } public boolean isSynchronous() { - return notificationUrl == null || (notificationUrl != null && notificationUrl.isEmpty()); + return notificationUrl == null || (notificationUrl.isEmpty()); } public String toJsonString() { @@ -73,7 +76,7 @@ public abstract class NetworkRequestCommon { mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); jsonString = mapper.writeValueAsString(this); } catch (Exception e) { - // ignore + LOGGER.debug("Exception:", e); } return jsonString; } @@ -87,8 +90,7 @@ public abstract class NetworkRequestCommon { marshaller.marshal(this, bs); return bs.toString(); } catch (Exception e) { - // Shouldn't happen... - e.printStackTrace(); + LOGGER.debug("Exception:", e); return ""; } } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java index 40d2aba1c8..56ec73d94a 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,12 +30,13 @@ import javax.xml.bind.Marshaller; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; - +import org.openecomp.mso.logger.MsoLogger; /** * Everything that is common between all Volume Group Responses, except for QueryVolumeGroupResponse. */ public abstract class NetworkResponseCommon { private String messageId; + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); public NetworkResponseCommon() { messageId = null; @@ -59,7 +61,7 @@ public abstract class NetworkResponseCommon { mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); jsonString = mapper.writeValueAsString(this); } catch (Exception e) { - // ignore + LOGGER.debug("Exception:", e); } return jsonString; } @@ -73,8 +75,7 @@ public abstract class NetworkResponseCommon { marshaller.marshal(this, bs); return bs.toString(); } catch (Exception e) { - // Shouldn't happen... - e.printStackTrace(); + LOGGER.debug("Exception:", e); return ""; } } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java index 418a15abf2..1ca36aface 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +32,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.codehaus.jackson.map.ObjectMapper; import org.jboss.resteasy.annotations.providers.NoJackson; +import org.openecomp.mso.logger.MsoLogger; @XmlRootElement(name = "queryNetworkResponse") @NoJackson @@ -44,6 +46,7 @@ public class QueryNetworkResponse { private List<String> routeTargets; private Map<String, String> subnetIdMap; private Map<String, String> networkOutputs; + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); public QueryNetworkResponse() { super(); @@ -138,7 +141,9 @@ public class QueryNetworkResponse { ObjectMapper mapper = new ObjectMapper(); jsonString = mapper.writeValueAsString(this); } - catch (Exception e) {} + catch (Exception e) { + LOGGER.debug("Exception:", e); + } return jsonString; } } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java index ed10540491..09c1b3ee38 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java @@ -32,6 +32,7 @@ import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.jboss.resteasy.annotations.providers.NoJackson; import org.codehaus.jackson.map.annotate.JsonRootName; +import org.openecomp.mso.logger.MsoLogger; @JsonRootName("updateNetworkRequest") @XmlRootElement(name = "updateNetworkRequest") @@ -50,9 +51,10 @@ public class UpdateNetworkRequest extends NetworkRequestCommon { private ProviderVlanNetwork providerVlanNetwork; private ContrailNetwork contrailNetwork; private Boolean backout = true; - private Map<String,String> networkParams = new HashMap<String, String>(); + private Map<String,String> networkParams = new HashMap<>(); private MsoRequest msoRequest = new MsoRequest(); - + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + public UpdateNetworkRequest() { super(); } @@ -129,7 +131,7 @@ public class UpdateNetworkRequest extends NetworkRequestCommon { try { this.networkTechnology = NetworkTechnology.valueOf(networkTechnology.toUpperCase()); } catch (IllegalArgumentException e) { - // ignore + LOGGER.debug("Exception:", e); } } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java index 2cf5ca2638..9b9c214129 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +37,7 @@ import java.io.IOException; import java.io.Serializable; import java.util.LinkedHashMap; import java.util.Map; +import org.openecomp.mso.logger.MsoLogger; // NOTE: the JAXB (XML) annotations are required with JBoss AS7 and RESTEasy, // even though we are using JSON exclusively. The @NoJackson annotation @@ -61,6 +63,8 @@ import java.util.Map; @NoJackson public class SDNCEvent implements Serializable { private static final long serialVersionUID = 1L; + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); // Event type private String eventType; @@ -143,7 +147,7 @@ public class SDNCEvent implements Serializable { mapper.setSerializationInclusion(Inclusion.NON_NULL); return mapper.writeValueAsString(this); } catch (IOException e) { - e.printStackTrace(); + LOGGER.debug("Exception:", e); throw new UnsupportedOperationException("Cannot convert " + getClass().getSimpleName() + " to JSON", e); } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java index 4a756aeccd..45609168ee 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java @@ -28,12 +28,15 @@ import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; import javax.xml.bind.annotation.XmlElement; import java.io.IOException; import java.io.Serializable; +import org.openecomp.mso.logger.MsoLogger; /** * Base class for all SDNC adapter requests. */ public abstract class SDNCRequestCommon implements Serializable { private static final long serialVersionUID = 1L; + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); // Endpoint on which BPMN can receive notifications from the SDNC adapter. private String bpNotificationUrl; @@ -101,7 +104,7 @@ public abstract class SDNCRequestCommon implements Serializable { mapper.setSerializationInclusion(Inclusion.NON_NULL); return mapper.writeValueAsString(this); } catch (IOException e) { - e.printStackTrace(); + LOGGER.debug("Exception:", e); throw new UnsupportedOperationException("Cannot convert " + getClass().getSimpleName() + " to JSON", e); } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java index f141116aeb..5e6b9394a6 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,12 +28,15 @@ import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; import javax.xml.bind.annotation.XmlElement; import java.io.IOException; import java.io.Serializable; +import org.openecomp.mso.logger.MsoLogger; /** * Base class for all SDNC adapter responses, including errors. */ public abstract class SDNCResponseCommon implements Serializable { private static final long serialVersionUID = 1L; + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); // Identifies the MSO transaction with SDNC. private String sdncRequestId; @@ -109,7 +113,7 @@ public abstract class SDNCResponseCommon implements Serializable { mapper.setSerializationInclusion(Inclusion.NON_NULL); return mapper.writeValueAsString(this); } catch (IOException e) { - e.printStackTrace(); + LOGGER.debug("Exception:", e); throw new UnsupportedOperationException("Cannot convert " + getClass().getSimpleName() + " to JSON", e); } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java index 75668143e2..aa6af56082 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +46,7 @@ public abstract class VfRequestCommon extends VfResponseCommon { } public boolean isSynchronous() { - return notificationUrl == null || (notificationUrl != null && notificationUrl.isEmpty()); + return notificationUrl == null || notificationUrl.isEmpty(); } // getMessageId, setMessageId, toJsonString, toJsonString are all defined in VfResponseCommon. diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java index 7fe8892ee8..6c7d584f6d 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,6 +74,7 @@ public abstract class CatalogQuery { jsonString = mapper.writeValueAsString(this); } catch (Exception e) { + LOGGER.debug("Exception:", e); LOGGER.debug ("jsonString exception:"+e.getMessage()); jsonString = "invalid"; //throws instead? } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java index 2407581f55..9f709140ec 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +26,11 @@ import org.codehaus.jackson.map.SerializationConfig; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import java.io.ByteArrayOutputStream; +import org.openecomp.mso.logger.MsoLogger; public abstract class CatalogQueryExceptionCommon { private String messageId; + protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); public CatalogQueryExceptionCommon() { messageId = null; } public CatalogQueryExceptionCommon(String messageId) { this.messageId = messageId; } @@ -43,7 +46,7 @@ public abstract class CatalogQueryExceptionCommon { jsonString = mapper.writeValueAsString(this); return jsonString; } catch (Exception e) { - e.printStackTrace(); + LOGGER.debug ("Exception:", e); return ""; } } @@ -57,7 +60,7 @@ public abstract class CatalogQueryExceptionCommon { marshaller.marshal(this, bs); return bs.toString(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.debug ("Exception:", e); return ""; } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java index f687aca683..3ffb0c6744 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,6 +75,7 @@ public class QueryVfModules { LOGGER.debug ("QueryVfModules jsonString: "+jsonString); } catch (Exception e) { + LOGGER.debug ("Exception:", e); LOGGER.debug ("QueryVfModules jsonString exception:"+e.getMessage()); } return jsonString; 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 83cadb8878..b7ab5043f3 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 @@ -143,9 +143,10 @@ public class BpelRestClient { } public void setRetryCount(int retryCount) { + int retCnt = 0; if (retryCount < 0) - retryCount = DEFAULT_RETRY_COUNT; - this.retryCount = retryCount; + retCnt = DEFAULT_RETRY_COUNT; + this.retryCount = retCnt; } public int getRetryInterval() { @@ -172,7 +173,7 @@ public class BpelRestClient { } public void setRetryList(String retryList) { - Set<Integer> s = new TreeSet<Integer>(); + Set<Integer> s = new TreeSet<>(); for (String t : retryList.split("[, ]")) { try { s.add(Integer.parseInt(t)); diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java index 0878bc54c9..74c39af68a 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,10 +132,10 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory); // Synchronous Web Service Outputs - Holder <String> networkId = new Holder <String> (); - Holder <String> neutronNetworkId = new Holder <String> (); - Holder <NetworkRollback> networkRollback = new Holder <NetworkRollback> (); - Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> (); + Holder <String> networkId = new Holder <> (); + Holder <String> neutronNetworkId = new Holder <> (); + Holder <NetworkRollback> networkRollback = new Holder <> (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); try { networkAdapter.createNetwork (cloudSiteId, @@ -423,8 +424,6 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoRequest msoRequest, String notificationUrl) { String error; - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); MsoLogger.setLogContext (msoRequest); String serviceName = "DeleteNetworkA"; MsoLogger.setServiceName (serviceName); @@ -434,7 +433,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory); // Synchronous Web Service Outputs - Holder <Boolean> networkDeleted = new Holder <Boolean> (); + Holder <Boolean> networkDeleted = new Holder <> (); try { networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId, msoRequest, networkDeleted); @@ -488,8 +487,6 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { String error; String serviceName = "RollbackNetworkA"; MsoLogger.setServiceName (serviceName); - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); // rollback may be null (e.g. if network already existed when Create was called) if (rollback == null) { LOGGER.warn (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.SchemaError, "Rollback is null"); @@ -602,13 +599,16 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { if(null != epUrl) { LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ()); + bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ()); + } + else { + LOGGER.debug ("Notification Endpoint URL is NULL: "); } - bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ()); // authentication try { Map <String, Object> reqCtx = bp.getRequestContext (); - Map <String, List <String>> headers = new HashMap <String, List <String>> (); + Map <String, List <String>> headers = new HashMap <> (); String userCredentials = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_NETWORK_ADAPTER).getEncryptedProperty (BPEL_AUTH_PROP, "", @@ -631,7 +631,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); sMap = hMap.value; CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry (); @@ -649,7 +649,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); sMap = hMap.value; UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry (); @@ -667,7 +667,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); sMap = hMap.value; QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry (); diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java index cf61d9af73..ccac38a58c 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,7 +128,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { Holder <String> neutronNetworkId, Holder <Map <String, String>> subnetIdMap, Holder <NetworkRollback> rollback) throws NetworkException { - Holder <String> networkFqdn = new Holder <String> (); + Holder <String> networkFqdn = new Holder <> (); createNetwork (cloudSiteId, tenantId, networkType, @@ -315,13 +316,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null); } catch (MsoException me) { LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack", "OpenStack", "QueryNetwork", null); - String error = "Create Network (neutron): query network " + networkName - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack", me); me.addContext (CREATE_NETWORK_CONTEXT); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack"); @@ -472,7 +466,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); } Map <String, Object> outputs = heatStack.getOutputs (); - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); if (outputs != null) { for (String key : outputs.keySet ()) { if (key != null && key.startsWith ("subnet")) { @@ -490,7 +484,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } subnetIdMap.value = sMap; - String msg = "Found Existing network stack, status=" + heatStack.getStatus () + " for Heat mode"; LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Found Existing network stack, status=" + heatStack.getStatus ()); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Found Existing network stack"); } @@ -588,7 +581,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Deploy the network stack // Ignore MsoStackAlreadyExists exception because we already checked. - long createStackStartTime = System.currentTimeMillis (); try { if (backout == null) backout = true; @@ -628,7 +620,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); } Map <String, Object> outputs = heatStack.getOutputs (); - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); if (outputs != null) { for (String key : outputs.keySet ()) { if (key != null && key.startsWith ("subnet")) { @@ -943,7 +935,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String previousNetworkName = (String) heatParams.get("network_name"); String previousPhysicalNetwork = (String) heatParams.get(PHYSICAL_NETWORK); - List<Integer> previousVlans = new ArrayList<Integer>(); + List<Integer> previousVlans = new ArrayList<>(); String vlansParam = (String) heatParams.get(VLANS); if (vlansParam != null) { for (String vlan : vlansParam.split(",")) { @@ -1087,7 +1079,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } Map<String, Object> outputs = heatStack.getOutputs(); - Map<String, String> sMap = new HashMap<String, String>(); + Map<String, String> sMap = new HashMap<>(); if (outputs != null) { for (String key : outputs.keySet()) { if (key != null && key.startsWith("subnet")) { @@ -1108,7 +1100,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Reach this point if createStack is successful. // Populate remaining rollback info and response parameters. networkRollback.setNetworkStackId(heatStack.getCanonicalName()); - networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID)); + if(null != outputs) { + networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID)); + } + else { + LOGGER.debug("outputs is NULL"); + } networkRollback.setNetworkType(networkType); // Save previous parameters networkRollback.setNetworkName(previousNetworkName); @@ -1332,8 +1329,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER,msoPropertiesFactory,cloudConfigFactory); MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); - String mode = null; - String neutronId = null; + String mode; + String neutronId; // Try Heat first, since networks may be named the same as the Heat stack StackInfo heatStack = null; long queryStackStarttime = System.currentTimeMillis (); @@ -1362,7 +1359,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { neutronId = (String) outputs.get (NETWORK_ID); mode = "HEAT"; - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); if (outputs != null) { for (String key : outputs.keySet ()) { if (key != null && key.startsWith ("subnet_id_")) //multiples subnet_%aaid% outputs @@ -1726,7 +1723,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String external, boolean aic3template) { // Build the common set of HEAT template parameters - Map <String, Object> stackParams = new HashMap <String, Object> (); + Map <String, Object> stackParams = new HashMap <> (); stackParams.put ("network_name", networkName); if (neutronNetworkType == NetworkType.PROVIDER) { @@ -1758,9 +1755,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (!isNullOrEmpty(rt)) { if (aic3template) - buf.append (sep).append ("target:" + rt.toString ()); + buf.append (sep).append ("target:" + rt); else - buf.append (sep).append (rt.toString ()); + buf.append (sep).append (rt); sep = ","; } @@ -1802,7 +1799,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { **/ private void mergePolicyRefs(List <String> pFqdns, Map <String, Object> stackParams) throws MsoException { //Resource Property - List<ContrailPolicyRef> prlist = new ArrayList <ContrailPolicyRef> (); + List<ContrailPolicyRef> prlist = new ArrayList <> (); int index = 1; for (String pf : pFqdns) { if (!isNullOrEmpty(pf)) @@ -1837,7 +1834,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { for (String pf : pFqdns) { if (!isNullOrEmpty(pf)) { - buf.append (sep).append (pf.toString ()); + buf.append (sep).append (pf); sep = ","; } } @@ -1860,7 +1857,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { for (String rtf : rtFqdns) { if (!isNullOrEmpty(rtf)) { - buf.append (sep).append (rtf.toString ()); + buf.append (sep).append (rtf); sep = ","; } } @@ -1929,7 +1926,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private String mergeSubnetsAIC3 (String heatTemplate, List <Subnet> subnets, Map <String, Object> stackParams) throws MsoException { //Resource Property - List<ContrailSubnet> cslist = new ArrayList <ContrailSubnet> (); + List<ContrailSubnet> cslist = new ArrayList <> (); for (Subnet subnet : subnets) { ContrailSubnet cs = new ContrailSubnet(); LOGGER.debug("Input Subnet:" + subnet.toString()); @@ -1990,8 +1987,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String outputTempl = " subnet_id_%subnetId%:\n" + " description: Openstack subnet identifier\n" + " value: {get_resource: subnet_%subnetId%}\n"; - String curR = ""; - String curO = ""; + String curR; + String curO; StringBuilder resourcesBuf = new StringBuilder (); StringBuilder outputsBuf = new StringBuilder (); for (Subnet subnet : subnets) { @@ -2063,7 +2060,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private Map <String, String> getSubnetUUId(String key, Map <String, Object> outputs, List <Subnet> subnets) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); try{ Object obj = outputs.get(key); @@ -2107,7 +2104,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private static String insertStr (String template, String snippet, int index) { - String updatedTemplate = ""; + String updatedTemplate; LOGGER.debug ("Index:" + index + " Snippet:" + snippet); diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java index b90bfdf9d6..7c775eeb88 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -135,11 +136,11 @@ public class NetworkAdapterRest { LOGGER.debug ("CreateNetworkTask start"); try { // Synchronous Web Service Outputs - Holder<String> networkId = new Holder<String>(); - Holder<String> neutronNetworkId = new Holder<String>(); - Holder<String> networkFqdn = new Holder<String>(); - Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>(); - Holder<NetworkRollback> rollback = new Holder<NetworkRollback>(); + Holder<String> networkId = new Holder<>(); + Holder<String> neutronNetworkId = new Holder<>(); + Holder<String> networkFqdn = new Holder<>(); + Holder<Map<String, String>> subnetIdMap = new Holder<>(); + Holder<NetworkRollback> rollback = new Holder<>(); String cloudsite = req.getCloudSiteId(); if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { @@ -211,6 +212,7 @@ public class NetworkAdapterRest { rollback.value, req.getMessageId()); } catch (NetworkException e) { + LOGGER.debug ("Exception:", e); eresp = new CreateNetworkError( e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } @@ -292,7 +294,7 @@ public class NetworkAdapterRest { public void run() { LOGGER.debug("DeleteNetworkTask start"); try { - Holder<Boolean> networkDeleted = new Holder<Boolean>(); + Holder<Boolean> networkDeleted = new Holder<>(); if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { networkDeleted.value = true; } else { @@ -307,6 +309,7 @@ public class NetworkAdapterRest { } response = new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId()); } catch (NetworkException e) { + LOGGER.debug ("Exception:", e); eresp = new DeleteNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -337,12 +340,12 @@ public class NetworkAdapterRest { try { int respStatus = HttpStatus.SC_OK; QueryNetworkResponse resp = new QueryNetworkResponse(networkStackId, null, networkStackId, null, null); - Holder<Boolean> networkExists = new Holder<Boolean>(); - Holder<String> networkId = new Holder<String>(); - Holder<String> neutronNetworkId = new Holder<String>(); - Holder<NetworkStatus> status = new Holder<NetworkStatus>(); - Holder<List<String>> routeTargets = new Holder<List<String>>(); - Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>(); + Holder<Boolean> networkExists = new Holder<>(); + Holder<String> networkId = new Holder<>(); + Holder<String> neutronNetworkId = new Holder<>(); + Holder<NetworkStatus> status = new Holder<>(); + Holder<List<String>> routeTargets = new Holder<>(); + Holder<Map<String, String>> subnetIdMap = new Holder<>(); adapter.queryNetworkContrail(cloudSiteId, tenantId, aaiNetworkId, msoRequest, networkExists, networkId, neutronNetworkId, status, routeTargets, subnetIdMap); @@ -441,6 +444,7 @@ public class NetworkAdapterRest { adapter.rollbackNetwork(nwr); response = new RollbackNetworkResponse(true, req.getMessageId()); } catch (NetworkException e) { + LOGGER.debug ("Exception:", e); eresp = new RollbackNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -521,8 +525,8 @@ public class NetworkAdapterRest { public void run() { LOGGER.debug("UpdateNetworkTask start"); try { - Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>(); - Holder<NetworkRollback> rollback = new Holder<NetworkRollback> (); + Holder<Map<String, String>> subnetIdMap = new Holder<>(); + Holder<NetworkRollback> rollback = new Holder<> (); if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { subnetIdMap.value = testMap(); @@ -579,6 +583,7 @@ public class NetworkAdapterRest { subnetIdMap.value, req.getMessageId()); } catch (NetworkException e) { + LOGGER.debug ("Exception:", e); eresp = new UpdateNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -591,7 +596,7 @@ public class NetworkAdapterRest { } public static Map<String, String> testMap() { - Map<String, String> m = new HashMap<String, String>(); + Map<String, String> m = new HashMap<>(); m.put("mickey", "7"); m.put("clyde", "10"); m.put("wayne", "99"); diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java index 28f5403afd..757ea8207d 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -271,7 +272,7 @@ public class SDNCRestClient implements Runnable { msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with SDNC", e); alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, respMsg); - return(sdncResp); + return sdncResp; } finally { @@ -308,18 +309,23 @@ public class SDNCRestClient implements Runnable { SDNCCallbackAdapterPortType cbPort = cbSvc.getSDNCCallbackAdapterSoapHttpPort(); BindingProvider bp = (BindingProvider)cbPort; - + + if(null != wsdlUrl) { bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlUrl.toExternalForm()); + } + else { + msoLogger.debug("wsdlUrl is NULL:"); + } //authentication try { - Map<String, Object> req_ctx = bp.getRequestContext(); - Map<String, List<String>> headers = new HashMap<String, List<String>>(); + Map<String, Object> reqCtx = bp.getRequestContext(); + Map<String, List<String>> headers = new HashMap<>(); String userCredentials = msoPropertiesFactoryp.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getEncryptedProperty(Constants.BPEL_AUTH_PROP, Constants.DEFAULT_BPEL_AUTH, Constants.ENCRYPTION_KEY); String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); - req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers); + reqCtx.put(MessageContext.HTTP_REQUEST_HEADERS, headers); headers.put ("Authorization", Collections.singletonList(basicAuth)); } catch (Exception e2) { diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java index 656334f2e7..d41291420e 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -171,7 +172,7 @@ public class SDNCNotifyResource { msoLogger.error (MessageEnum.RA_MISSING_PARAM, Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_RESP_MSG, "SDNC", "SDNCNotify", MsoLogger.ErrorCode.DataError, "Exception - Missing param", e); } - String bpelUrl = null; + String bpelUrl; /* * TODO Hibernate * try { @@ -182,8 +183,10 @@ public class SDNCNotifyResource { * logger.error("Unable to get SDNC_CALLBACK_URL from ActiveRequests, using default for reqid:" + reqId, e); * } */ + + bpelUrl = SDNCAdapterPortTypeImpl.getProperty (Constants.BPEL_URL_PROP, Constants.DEFAULT_BPEL_URL,msoPropertiesFactory); if (bpelUrl == null) { - bpelUrl = SDNCAdapterPortTypeImpl.getProperty (Constants.BPEL_URL_PROP, Constants.DEFAULT_BPEL_URL,msoPropertiesFactory); + msoLogger.debug("bpelUrl is NULL:"); } SDNCResponse sdncResp = new SDNCResponse (reqId); diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java index 5b18002f22..0622c48c41 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -155,7 +156,7 @@ public class BPRestCallback { try { EntityUtils.consume(httpResponse.getEntity()); } catch (Exception e) { - // Ignore + LOGGER.debug("Exception:", e); } } @@ -163,7 +164,7 @@ public class BPRestCallback { try { method.reset(); } catch (Exception e) { - // Ignore + LOGGER.debug("Exception:", e); } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java index 1e28920ab2..893ff82f11 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,16 +28,24 @@ import org.w3c.dom.NodeList; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; +import org.openecomp.mso.logger.MsoLogger; /** * Utility methods used by SDNCAdapterRest. */ public final class SDNCAdapterUtils { - /** + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + /** + * Instantiation is not allowed. + */ + private SDNCAdapterUtils() { + } + + /** * Returns a node's child elements in a list. */ public static List<Element> childElements(Node node) { - List<Element> elements = new ArrayList<Element>(); + List<Element> elements = new ArrayList<>(); NodeList nodeList = node.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { @@ -58,13 +67,8 @@ public final class SDNCAdapterUtils { try { return UriUtils.encodePathSegment(pathSegment, "UTF-8"); } catch (UnsupportedEncodingException e) { + LOGGER.debug("Exception:", e); throw new RuntimeException("UTF-8 encoding is not supported"); } } - - /** - * Instantiation is not allowed. - */ - private SDNCAdapterUtils() { - } }
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java index 19a93da5b5..262d23bd09 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,9 +104,15 @@ public abstract class SDNCConnector { String userCredentials = SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP, Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); String authorization = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); - method.setHeader("Authorization", authorization); + if(null != method) { + method.setHeader("Authorization", authorization); + method.setHeader("Accept", "application/yang.data+xml"); + } + else { + LOGGER.debug("method is NULL:"); + } - method.setHeader("Accept", "application/yang.data+xml"); + httpResponse = client.execute(method); @@ -134,8 +141,14 @@ public abstract class SDNCConnector { } httpResponse = null; + + if(null != method) { + method.reset(); + } + else { + LOGGER.debug("method is NULL:"); + } - method.reset(); method = null; LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, responseContent, "SDNC", ""); @@ -161,7 +174,7 @@ public abstract class SDNCConnector { try { EntityUtils.consume(httpResponse.getEntity()); } catch (Exception e) { - // Ignore + LOGGER.debug("Exception:", e); } } @@ -169,7 +182,7 @@ public abstract class SDNCConnector { try { method.reset(); } catch (Exception e) { - // Ignore + LOGGER.debug("Exception:", e); } } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java index 6ea43d828c..2263ab74df 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,7 @@ package org.openecomp.mso.adapters.sdnc.sdncrest; import org.openecomp.mso.adapters.sdncrest.SDNCEvent; +import org.openecomp.mso.logger.MsoLogger; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; @@ -33,7 +35,13 @@ import java.text.ParseException; * SDNCConnector for "agnostic" API services. */ public class SDNCEventParser { - /** + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + // Instantiation is not allowed. + private SDNCEventParser() { + } + + /** * Parses SDNC event XML. If the content can be parsed and contains all required * elements, then an object is returned. Otherwise, a ParseException is thrown. * This method performs no logging or alarming. @@ -79,7 +87,7 @@ public class SDNCEventParser { } else if ("event-correlator".equals(child.getNodeName())) { eventCorrelator = child.getTextContent(); } else if ("event-parameters".equals(child.getNodeName())) { - eventParameters = (Element) child; + eventParameters = child; } } @@ -146,11 +154,8 @@ public class SDNCEventParser { } catch (ParseException e) { throw e; } catch (Exception e) { - throw new ParseException("Failed to parse SDNC event", 0); + LOGGER.debug("Exception:", e); + throw new ParseException("Failed to parse SDNC event:", 0 ); } } - - // Instantiation is not allowed. - private SDNCEventParser() { - } }
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java index e12384071c..f0fcf18afd 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,12 +35,14 @@ import java.net.HttpURLConnection; import java.text.ParseException; import java.util.ArrayList; import java.util.List; +import org.openecomp.mso.logger.MsoLogger; /** * SDNCConnector for "agnostic" API services. */ public class SDNCServiceRequestConnector extends SDNCConnector { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); @Override protected SDNCResponseCommon createResponseFromContent(int statusCode, String statusMessage, String responseContent, TypedRequestTunables rt) { @@ -99,7 +102,7 @@ public class SDNCServiceRequestConnector extends SDNCConnector { String responseMessage = null; String svcRequestId = null; String ackFinalIndicator = null; - List<Element> responseParameters = new ArrayList<Element>(); + List<Element> responseParameters = new ArrayList<>(); for (Element child : SDNCAdapterUtils.childElements(configurationResponseCommon)) { if ("response-code".equals(child.getNodeName())) { @@ -133,7 +136,7 @@ public class SDNCServiceRequestConnector extends SDNCConnector { ackFinalIndicator = "Y"; } - if (!ackFinalIndicator.equals("Y") && !ackFinalIndicator.equals("N")) { + if (!ackFinalIndicator.equals("Y") && !"N".equals(ackFinalIndicator)) { throw new ParseException("Invalid ack-final-indicator in SDNC response: '" + ackFinalIndicator + "'", 0); } @@ -189,6 +192,7 @@ public class SDNCServiceRequestConnector extends SDNCConnector { } catch (ParseException e) { throw e; } catch (Exception e) { + LOGGER.debug("Exception:", e); throw new ParseException("Failed to parse SDNC response", 0); } } diff --git a/adapters/mso-vfc-adapter/pom.xml b/adapters/mso-vfc-adapter/pom.xml index 4f049c350f..fcf0682ca5 100644 --- a/adapters/mso-vfc-adapter/pom.xml +++ b/adapters/mso-vfc-adapter/pom.xml @@ -1,89 +1,94 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.openecomp.so</groupId> - <artifactId>adapters</artifactId> - <version>1.1.0-SNAPSHOT</version> - </parent> - <groupId>org.openecomp.so.adapters</groupId> - <artifactId>mso-vfc-adapter</artifactId> - <packaging>war</packaging> - <name>mso-vfc-adapter</name> - <description>Web service endpoint for vfc operations</description> - - <!-- <properties> --> - <!-- <project.build.sourceEncoding/> --> - <!-- <project.reporting.outputEncoding/> --> - <!-- </properties> --> - - <build> - <finalName>${project.artifactId}-${project.version}</finalName> - <plugins> - <plugin> - <artifactId>maven-war-plugin</artifactId> - <version>2.4</version> - <configuration> - <warSourceDirectory>WebContent</warSourceDirectory> - <failOnMissingWebXml>false</failOnMissingWebXml> - <attachClasses>true</attachClasses> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>javax</groupId> - <artifactId>javaee-web-api</artifactId> - <version>6.0</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.openecomp.so.adapters</groupId> - <artifactId>mso-adapter-utils</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.so.adapters</groupId> - <artifactId>mso-adapters-rest-interface</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - <version>1.10.19</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <version>3.1.0</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.jboss.spec.javax.ejb</groupId> - <artifactId>jboss-ejb-api_3.2_spec</artifactId> - <version>1.0.0.Final</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.jboss.ejb3</groupId> - <artifactId>jboss-ejb3-ext-api</artifactId> - <version>2.2.0.Final</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.openecomp.so</groupId> - <artifactId>status-control</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.so</groupId> - <artifactId>mso-requests-db</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.so</groupId> + <artifactId>adapters</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.so.adapters</groupId> + <artifactId>mso-vfc-adapter</artifactId> + <packaging>war</packaging> + <name>mso-vfc-adapter</name> + <description>Web service endpoint for vfc operations</description> + <!-- <properties> --> + <!-- <project.build.sourceEncoding/> --> + <!-- <project.reporting.outputEncoding/> --> + <!-- </properties> --> + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.4</version> + <configuration> + <warSourceDirectory>WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + <attachClasses>true</attachClasses> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <!--<dependency> + <groupId>javax</groupId> + <artifactId>javaee-web-api</artifactId> + <version>6.0</version> + <scope>provided</scope> + </dependency>--> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>org.openecomp.so.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.so.adapters</groupId> + <artifactId>mso-adapters-rest-interface</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.10.19</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.2_spec</artifactId> + <version>1.0.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.ejb3</groupId> + <artifactId>jboss-ejb3-ext-api</artifactId> + <version>2.2.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.so</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.so</groupId> + <artifactId>mso-requests-db</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> <groupId>org.jmockit</groupId> <artifactId>jmockit</artifactId> <version>1.19</version> @@ -101,5 +106,16 @@ <version>1.19</version> <scope>test</scope> </dependency> - </dependencies> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + <version>2.22.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + </dependency> + </dependencies> </project> diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java index 1be5bab1c3..438393bc35 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.openecomp.mso.adapters.vfc; import javax.servlet.http.HttpServletRequest; @@ -29,6 +30,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.ResponseBuilder; +import org.openecomp.mso.adapters.vfc.exceptions.ApplicationException; import org.openecomp.mso.adapters.vfc.model.NSResourceInputParameter; import org.openecomp.mso.adapters.vfc.model.NsOperationKey; import org.openecomp.mso.adapters.vfc.model.RestfulResponse; @@ -44,7 +46,7 @@ import org.openecomp.mso.logger.MsoLogger; * </p> * * @author - * @version ONAP Amsterdam Release 2017-08-28 + * @version ONAP Amsterdam Release 2017-08-28 */ @Path("/v1/vfcdrivers") public class VfcAdapterRest { @@ -53,6 +55,10 @@ public class VfcAdapterRest { private final VfcManager driverMgr = new VfcManager(); + public VfcAdapterRest() { + + } + /** * Create a NS * <br> @@ -67,12 +73,16 @@ public class VfcAdapterRest { @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response createNfvoNs(HttpServletRequest servletReq) { // Step 1: get parameters from request for current node - String body = RestfulUtil.getRequestBody(servletReq); - ValidateUtil.assertObjectNotNull(body); - LOGGER.debug("body from request is {}" + body); - NSResourceInputParameter nsInput = JsonUtil.unMarshal(body, NSResourceInputParameter.class); - RestfulResponse rsp = driverMgr.createNs(nsInput); - return buildResponse(rsp); + try { + String body = RestfulUtil.getRequestBody(servletReq); + ValidateUtil.assertObjectNotNull(body); + LOGGER.debug("body from request is {}" + body); + NSResourceInputParameter nsInput = JsonUtil.unMarshal(body, NSResourceInputParameter.class); + RestfulResponse rsp = driverMgr.createNs(nsInput); + return buildResponse(rsp); + } catch(ApplicationException e) { + return e.buildErrorResponse(); + } } /** @@ -87,14 +97,17 @@ public class VfcAdapterRest { @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response deleteNfvoNs(HttpServletRequest servletReq, @PathParam("nsInstanceId") String nsInstanceId) { - // Step 1: get parameters from request for current node - String body = RestfulUtil.getRequestBody(servletReq); - ValidateUtil.assertObjectNotNull(body); - LOGGER.debug("body from request is {}" + body); - NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class); - - RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId); - return buildResponse(rsp); + try { + // Step 1: get parameters from request for current node + String body = RestfulUtil.getRequestBody(servletReq); + ValidateUtil.assertObjectNotNull(body); + LOGGER.debug("body from request is {}" + body); + NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class); + RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId); + return buildResponse(rsp); + } catch(ApplicationException e) { + return e.buildErrorResponse(); + } } /** @@ -102,7 +115,7 @@ public class VfcAdapterRest { * <br> * * @param servletReq The Http Request - * @param jobId The job id + * @param jobId The job id * @return * @since ONAP Amsterdam Release */ @@ -111,15 +124,19 @@ public class VfcAdapterRest { @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response queryNfvoJobStatus(HttpServletRequest servletReq, @PathParam("jobId") String jobId) { - ValidateUtil.assertObjectNotNull(jobId); - String body = RestfulUtil.getRequestBody(servletReq); - ValidateUtil.assertObjectNotNull(body); - LOGGER.debug("body from request is {}" + body); - NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class); - RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId); - return buildResponse(rsp); - } + try { + ValidateUtil.assertObjectNotNull(jobId); + String body = RestfulUtil.getRequestBody(servletReq); + ValidateUtil.assertObjectNotNull(body); + LOGGER.debug("body from request is {}" + body); + NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class); + RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId); + return buildResponse(rsp); + } catch(ApplicationException e) { + return e.buildErrorResponse(); + } + } /** * Instantiate NS instance @@ -136,11 +153,15 @@ public class VfcAdapterRest { @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response instantiateNfvoNs(HttpServletRequest servletReq, @PathParam("nsInstanceId") String nsInstanceId) { String body = RestfulUtil.getRequestBody(servletReq); - ValidateUtil.assertObjectNotNull(body); - LOGGER.debug("body from request is {}" + body); - NSResourceInputParameter nsInput = JsonUtil.unMarshal(body, NSResourceInputParameter.class); - RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput); - return buildResponse(rsp); + try { + ValidateUtil.assertObjectNotNull(body); + LOGGER.debug("body from request is {}" + body); + NSResourceInputParameter nsInput = JsonUtil.unMarshal(body, NSResourceInputParameter.class); + RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput); + return buildResponse(rsp); + } catch(ApplicationException e) { + return e.buildErrorResponse(); + } } /** @@ -157,16 +178,19 @@ public class VfcAdapterRest { @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response terminateNfvoNs(HttpServletRequest servletReq, @PathParam("nsInstanceId") String nsInstanceId) { - ValidateUtil.assertObjectNotNull(nsInstanceId); - String body = RestfulUtil.getRequestBody(servletReq); - ValidateUtil.assertObjectNotNull(body); - LOGGER.debug("body from request is {}" + body); - NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class); - RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId); - return buildResponse(rsp); + try { + ValidateUtil.assertObjectNotNull(nsInstanceId); + String body = RestfulUtil.getRequestBody(servletReq); + ValidateUtil.assertObjectNotNull(body); + LOGGER.debug("body from request is {}" + body); + NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class); + RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId); + return buildResponse(rsp); + } catch(ApplicationException e) { + return e.buildErrorResponse(); + } } - /** * build response from restful response * <br> diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java index 171949aa8e..f4572c8351 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java @@ -71,6 +71,9 @@ public class VfcManager { nfvoUrlMap.put(Step.QUERY, CommonConstant.NFVO_QUERY_URL); } + public VfcManager(){ + + } /** * create network service * <br> @@ -79,10 +82,10 @@ public class VfcManager { * @return * @since ONAP Amsterdam Release */ - public RestfulResponse createNs(NSResourceInputParameter segInput) { + public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException { // Step1: get service template by node type - String nsdId = segInput.getNsOperationKey().getNodeTemplateId(); + String nsdId = segInput.getNsOperationKey().getNodeTemplateUUID(); // nsdId for NFVO is "id" in the response, while for SDNO is "servcice template id" LOGGER.info("serviceTemplateId is {}, id is {}", nsdId); @@ -94,8 +97,8 @@ public class VfcManager { // Step3: Prepare restful parameters and options NsCreateReq oRequest = new NsCreateReq(); oRequest.setNsdId(nsdId); - oRequest.setNsName(segInput.getSubServiceName()); - oRequest.setDescription(segInput.getSubServiceDesc()); + oRequest.setNsName(segInput.getNsServiceName()); + oRequest.setDescription(segInput.getNsServiceDescription()); String createReq = JsonUtil.marshal(oRequest); // Step4: Call NFVO or SDNO lcm to create ns @@ -119,7 +122,7 @@ public class VfcManager { // Step 6: save resource operation information ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus( segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(), - segInput.getNsOperationKey().getNodeTemplateId()); + segInput.getNsOperationKey().getNodeTemplateUUID()); nsOperInfo.setStatus(RequestsDbConstant.Status.PROCESSING); (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); @@ -143,7 +146,7 @@ public class VfcManager { * @return * @since ONAP Amsterdam Release */ - public RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId) { + public RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId) throws ApplicationException{ LOGGER.info("delete ns -> begin"); // Step1: prepare url and methodType String url = getUrl(nsInstanceId, CommonConstant.Step.DELETE); @@ -156,7 +159,7 @@ public class VfcManager { LOGGER.info("delete ns response content is : {}", deleteRsp.getResponseContent()); LOGGER.info("delete ns -> end"); ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(), - nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateId()); + nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); if(!HttpCode.isSucess(deleteRsp.getStatus())) { LOGGER.error("fail to delete ns"); @@ -190,7 +193,7 @@ public class VfcManager { * @return * @since ONAP Amsterdam Release */ - public RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput) { + public RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput) throws ApplicationException{ // Call the NFVO or SDNO service to instantiate service LOGGER.info("instantiate ns -> begin"); @@ -215,7 +218,7 @@ public class VfcManager { String jobId = rsp.get(CommonConstant.JOB_ID); ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus( segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(), - segInput.getNsOperationKey().getNodeTemplateId()); + segInput.getNsOperationKey().getNodeTemplateUUID()); if(ValidateUtil.isStrEmpty(jobId)) { LOGGER.error("Invalid jobId from instantiate operation"); nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); @@ -254,11 +257,11 @@ public class VfcManager { * @return * @since ONAP Amsterdam Release */ - public RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId) { + public RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId) throws ApplicationException{ // Step1: save segment operation info for delete process LOGGER.info("save segment operation for delete process"); ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(), - nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateId()); + nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); nsOperInfo.setStatus(RequestsDbConstant.Status.PROCESSING); (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); @@ -319,12 +322,12 @@ public class VfcManager { * @return * @since ONAP Amsterdam Release */ - public RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId) { + public RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId) throws ApplicationException{ ValidateUtil.assertObjectNotNull(jobId); // Step 1: query the current resource operation status ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(), - nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateId()); + nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); // Step 2: start query LOGGER.info("query ns status -> begin"); diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java index 652de97f5f..a160b82e8a 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.openecomp.mso.adapters.vfc.constant; /** @@ -30,12 +31,6 @@ package org.openecomp.mso.adapters.vfc.constant; */ public class DriverExceptionID { - public static final String INVALID_PARAM = "Invalid parameter"; - - public static final String INTERNAL_ERROR = "Internal error"; - - public static final String FAILED_TO_SVCTMPL_CATALOGUE = "Failed to get service template from catalogue"; - public static final String INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION = "Invalid response from instantiate operation"; @@ -45,8 +40,6 @@ public class DriverExceptionID { public static final String FAIL_TO_CREATE_NS = "Fail to create ns"; - public static final String INVALID_RESPONSEE_FROM_DELETE_OPERATION = "Invalid response from delete operation"; - public static final String INVALID_RESPONSE_FROM_TERMINATE_OPERATION = "Invalid response from terminate operation"; public static final String FAIL_TO_DELETE_NS = "Fail to delete ns"; diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java index 6a78d2e73e..61966d07f2 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java @@ -17,19 +17,22 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.openecomp.mso.adapters.vfc.exceptions; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response;; -public class ApplicationException extends WebApplicationException { +public class ApplicationException extends Exception { /** * Serial number. */ private static final long serialVersionUID = 1L; + private int errorCode; + + private String errorMsg; + /** * Constructor<br/> * <p> @@ -37,9 +40,37 @@ public class ApplicationException extends WebApplicationException { * * @param errorCode error status * @param errorDetail error detail - * @since ONAP Amsterdam Release 2017-9-6 + * @since ONAP Amsterdam Release 2017-9-6 + */ + public ApplicationException(int errorCode, String errorMsg) { + this.errorCode = errorCode; + this.errorMsg = errorMsg; + } + + public int getErrorCode() { + return errorCode; + } + + public void setErrorCode(int errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + /** + * build error Response + * <br> + * + * @return + * @since ONAP Amsterdam Release */ - public ApplicationException(int errorCode, Object errorDetail) { - super(Response.status(errorCode).entity(errorDetail).type(MediaType.APPLICATION_JSON).build()); + public Response buildErrorResponse() { + return Response.status(errorCode).entity(errorMsg).build(); } } diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java index ca1807ce62..f88a11dee8 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java @@ -30,38 +30,44 @@ public class NSResourceInputParameter { private NsOperationKey nsOperationKey; - private String subServiceName; + private String nsServiceName; - private String subServiceDesc; + private String nsServiceDescription; private NsParameters nsParameters; + + + /** - * @return Returns the subServiceName. + * @return Returns the nsServiceName. */ - public String getSubServiceName() { - return subServiceName; + public String getNsServiceName() { + return nsServiceName; } + /** - * @param subServiceName The subServiceName to set. + * @param nsServiceName The nsServiceName to set. */ - public void setSubServiceName(String subServiceName) { - this.subServiceName = subServiceName; + public void setNsServiceName(String nsServiceName) { + this.nsServiceName = nsServiceName; } + /** - * @return Returns the subServiceDesc. + * @return Returns the nsServiceDescription. */ - public String getSubServiceDesc() { - return subServiceDesc; + public String getNsServiceDescription() { + return nsServiceDescription; } + /** - * @param subServiceDesc The subServiceDesc to set. + * @param nsServiceDescription The nsServiceDescription to set. */ - public void setSubServiceDesc(String subServiceDesc) { - this.subServiceDesc = subServiceDesc; + public void setNsServiceDescription(String nsServiceDescription) { + this.nsServiceDescription = nsServiceDescription; } /** diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java index 884c3d2468..d6cfbde906 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java @@ -43,7 +43,7 @@ public class NsOperationKey { /**
* the NS template uuid
*/
- private String nodeTemplateId;
+ private String nodeTemplateUUID;
/**
*
@@ -89,26 +89,20 @@ public class NsOperationKey { this.operationId = operationId;
}
+
/**
- *
- * <br>
- *
- * @return
- * @since ONAP Amsterdam Release
+ * @return Returns the nodeTemplateUUID.
*/
- public String getNodeTemplateId() {
- return nodeTemplateId;
+ public String getNodeTemplateUUID() {
+ return nodeTemplateUUID;
}
+
/**
- *
- * <br>
- *
- * @param nodeTemplateId
- * @since ONAP Amsterdam Release
+ * @param nodeTemplateUUID The nodeTemplateUUID to set.
*/
- public void setNodeTemplateId(String nodeTemplateId) {
- this.nodeTemplateId = nodeTemplateId;
+ public void setNodeTemplateUUID(String nodeTemplateUUID) {
+ this.nodeTemplateUUID = nodeTemplateUUID;
}
-
+
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java index 34beb02c13..a9546d5c4c 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.openecomp.mso.adapters.vfc.util; import java.io.IOException; @@ -29,7 +30,6 @@ import org.openecomp.mso.adapters.vfc.exceptions.ApplicationException; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; - /** * Interface for json analyzing.<br/> * <p> @@ -43,7 +43,7 @@ public class JsonUtil { /** * Log service */ - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); /** * Mapper. @@ -75,11 +75,12 @@ public class JsonUtil { * @return model object * @since ONAP Amsterdam Release 2017-9-6 */ - public static <T> T unMarshal(String jsonstr, Class<T> type) { + public static <T> T unMarshal(String jsonstr, Class<T> type) throws ApplicationException { try { return MAPPER.readValue(jsonstr, type); } catch(IOException e) { - LOGGER.error(MessageEnum.RA_NS_EXC, "","", MsoLogger.ErrorCode.BusinessProcesssError, "fail to unMarshal json", e); + LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, + "fail to unMarshal json", e); throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json"); } } @@ -92,11 +93,12 @@ public class JsonUtil { * @return model object * @since ONAP Amsterdam Release 2017-9-6 */ - public static <T> T unMarshal(String jsonstr, TypeReference<T> type) { + public static <T> T unMarshal(String jsonstr, TypeReference<T> type) throws ApplicationException { try { return MAPPER.readValue(jsonstr, type); } catch(IOException e) { - LOGGER.error(MessageEnum.RA_NS_EXC, "","", MsoLogger.ErrorCode.BusinessProcesssError, "fail to unMarshal json", e); + LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, + "fail to unMarshal json", e); throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json"); } } @@ -108,11 +110,12 @@ public class JsonUtil { * @return json string * @since ONAP Amsterdam Release 2017-9-6 */ - public static String marshal(Object srcObj) { + public static String marshal(Object srcObj) throws ApplicationException { try { return MAPPER.writeValueAsString(srcObj); } catch(IOException e) { - LOGGER.error(MessageEnum.RA_NS_EXC, "","", MsoLogger.ErrorCode.BusinessProcesssError, "fail to marshal json", e); + LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, + "fail to marshal json", e); throw new ApplicationException(HttpCode.BAD_REQUEST, "srcObj marshal failed!"); } } diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java index dfedce8531..8e5f0b4274 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java @@ -130,31 +130,37 @@ public class RestfulUtil { if(httpResponse.getStatusLine().getStatusCode() >= 300) { String errMsg = "VFC returned " + statusCode + " " + statusMessage; logError(errMsg); - return CreateResponse(statusCode, errMsg); + return createResponse(statusCode, errMsg); } httpResponse = null; - method.reset(); + if(null != method) { + method.reset(); + } + else { + LOGGER.debug("method is NULL:"); + } + method = null; LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, responseContent, "SDNC", ""); - return CreateResponse(statusCode, responseContent); + return createResponse(statusCode, responseContent); } catch(SocketTimeoutException e) { String errMsg = "Request to SDNC timed out"; logError(errMsg, e); - return CreateResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg); + return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg); } catch(ConnectTimeoutException e) { String errMsg = "Request to SDNC timed out"; logError(errMsg, e); - return CreateResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg); + return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg); } catch(Exception e) { String errMsg = "Error processing request to SDNC"; logError(errMsg, e); - return CreateResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg); + return createResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg); } finally { if(httpResponse != null) { @@ -185,7 +191,7 @@ public class RestfulUtil { ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); } - private static RestfulResponse CreateResponse(int statusCode, String content) { + private static RestfulResponse createResponse(int statusCode, String content) { RestfulResponse rsp = new RestfulResponse(); rsp.setStatus(statusCode); rsp.setResponseContent(content); diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java index 37228c805c..a6fa2d29e2 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java @@ -17,6 +17,7 @@ * limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.mso.adapters.vfc.util;
import org.openecomp.mso.adapters.vfc.constant.HttpCode;
@@ -49,7 +50,7 @@ public class ValidateUtil { * @param name of parameter
* @since ONAP Amsterdam Release 2017-9-6
*/
- public static void assertStringNotNull(String paramValue, String paramName) {
+ public static void assertStringNotNull(String paramValue, String paramName) throws ApplicationException {
if(null != paramValue && !paramValue.isEmpty()) {
return;
}
@@ -64,7 +65,7 @@ public class ValidateUtil { * @param object data object
* @since ONAP Amsterdam Release 2017-9-6
*/
- public static void assertObjectNotNull(Object object) {
+ public static void assertObjectNotNull(Object object) throws ApplicationException {
if(null == object) {
LOGGER.error("Object is null.");
throw new ApplicationException(HttpCode.BAD_REQUEST, "Object is null.");
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java index 46ab134bce..4c316f3196 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java @@ -17,17 +17,29 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.vfc; +package org.openecomp.mso.adapters.vfc; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.io.IOUtils; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; +import org.openecomp.mso.adapters.vfc.constant.CommonConstant; +import org.openecomp.mso.adapters.vfc.constant.HttpCode; +import org.openecomp.mso.adapters.vfc.model.RestfulResponse; import org.openecomp.mso.adapters.vfc.util.RestfulUtil; import org.openecomp.mso.adapters.vfc.util.ValidateUtil; -import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.requestsdb.ResourceOperationStatus; +import mockit.Mock; import mockit.MockUp; /** @@ -37,89 +49,150 @@ import mockit.MockUp; * </p> * * @author - * @version ONAP Amsterdam Release 2017-08-31 + * @version ONAP Amsterdam Release 2017-08-31 */ public class VfcAdapterTest { - @Mock - private static CatalogDatabase db; + private VfcAdapterRest vfcAdapter = new VfcAdapterRest(); /** * File path */ private static final String FILE_PATH = "src/test/resources/json/"; - @Test - public void createTest () { -// // get request -// mockGetRequestBody(FILE_PATH + "createNfvoNsReq.json"); -// // get service template -// ServiceTemplate svcTmpl = new ServiceTemplate(); -// svcTmpl.setId("id"); -// svcTmpl.setServiceTemplateId("svcTmplId"); -// new MockUp<CatalogProxyImpl>() { -// @Mock -// public ServiceTemplate getSvcTmplByNodeType(String nodeType, String domainHost){ -// return svcTmpl; -// } -// }; -// // get response -// RestfulResponse restRsp = new RestfulResponse(); -// restRsp.setStatus(HttpStatus.SC_OK); -// restRsp.setResponseJson(getJsonString(FILE_PATH + "createNfvoNsRsp.json")); -// mockGetRestfulRsp(restRsp); -// // insert data -// new MockUp<ServiceSegmentDaoImpl>() { -// @Mock -// public void insertSegment(ServiceSegmentModel serviceSegment) { -// // do nothing -// } -// @Mock -// public void insertSegmentOper(ServiceSegmentOperation svcSegmentOper) { -// // do nothing -// } -// }; -// Response rsp = impl.createNfvoNs(servletReq); -// JSONObject obj = JSONObject.fromObject(rsp.getEntity()); -// Assert.assertEquals(null, "1", obj.getString("nsInstanceId")); + /** + * Mock the request body form a file + * <br> + * + * @param fileName + * @since ONAP Amsterdam Release + */ + private void mockRestfulUtil(String fileName) { + new MockUp<RestfulUtil>() { + + /** + * mock get request body + * <br> + * + * @param request + * @return + * @since ONAP Amsterdam Release + */ + @Mock + public String getRequestBody(HttpServletRequest request) { + return getJsonString(fileName); + } + + /** + * mock get send method + * <br> + * + * @param url + * @param methodType + * @param content + * @return + * @since ONAP Amsterdam Release + */ + @Mock + public RestfulResponse send(String url, String methodType, String content) { + if(url.contains(CommonConstant.NFVO_CREATE_URL) && methodType.equals(CommonConstant.MethodType.POST)) { + return getResponse("createNsRsp.json"); + } else { + return null; + } + } + }; + } + + /** + * Mock the request body form a file + * <br> + * + * @param fileName + * @since ONAP Amsterdam Release + */ + private void mockRequestDatabase() { + new MockUp<RequestsDatabase>() { + + /** + * mock get resource operation status + * <br> + * + * @param request + * @return + * @since ONAP Amsterdam Release + */ + @Mock + public ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, + String resourceTemplateUUID) { + ResourceOperationStatus resStatus = new ResourceOperationStatus(); + resStatus.setServiceId("111"); + resStatus.setOperationId("111"); + return resStatus; + } + + /** + * Mock update Res Oper Status + * <br> + * + * @param operStatus + * @since ONAP Amsterdam Release + */ + @Mock + public void updateResOperStatus(ResourceOperationStatus operStatus) { + + } + }; + } + + /** + * Before executing UT, start mock requst database + * <br> + * + * @since ONAP Amsterdam Release + */ + @Before + public void start() { + mockRequestDatabase(); + } + + /** + * After executing UT, close session<br/> + * + * @since ONAP Amsterdam Release + */ + @After + public void stop() { + } @Test - public void deleteTest () { - + public void createTest() { + // get request + mockRestfulUtil(FILE_PATH + "createNsReq.json"); + vfcAdapter.createNfvoNs(null); } @Test - public void instantiateTest () { + public void deleteTest() { } @Test - public void terminateTest () { - + public void instantiateTest() { + } @Test - public void queryJobTest () { + public void terminateTest() { } - - /** - * Mock to get request body.<br/> - * - * @param file json file path. - * @since ONAP Amsterdam Release 2017-9-6 - */ - private void mockGetRequestBody(final String file) { - new MockUp<RestfulUtil>() { -// @Mock -// public String getRequestBody(HttpServletRequest request) { -// return getJsonString(file); -// } - }; + @Test + public void queryJobTest() { + } - + /** * Get json string from file.<br/> * @@ -128,19 +201,37 @@ public class VfcAdapterTest { * @throws IOException when fail to read * @since ONAP Amsterdam Release 2017-9-6 */ + @SuppressWarnings("deprecation") private String getJsonString(final String file) { if(ValidateUtil.isStrEmpty(file)) { return ""; } String json = null; -// try { -// FileInputStream fileStream = new FileInputStream(new File(file)); -// json = IOUtils.toString(fileStream); -// } catch(Exception e) { -// Assert.fail(e.getMessage()); -// } - + try { + FileInputStream fileStream = new FileInputStream(new File(file)); + json = IOUtils.toString(fileStream); + } catch(Exception e) { + Assert.fail(e.getMessage()); + } return json; } + + /** + * get the response from file + * <br> + * + * @param fileName + * @return + * @since ONAP Amsterdam Release + */ + private RestfulResponse getResponse(String fileName) { + RestfulResponse responseSuccess = new RestfulResponse(); + responseSuccess.setStatus(HttpCode.RESPOND_OK); + if(null != fileName) { + String jsonStr = getJsonString(FILE_PATH + fileName); + responseSuccess.setResponseContent(jsonStr); + } + return responseSuccess; + } } diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java index ff2e93b426..b3756c4ccb 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +59,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { CloudConfigFactory cloudConfigFactory=new CloudConfigFactory(); public static final String MSO_PROP_VNF_ADAPTER="MSO_PROP_VNF_ADAPTER"; - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); private static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.vnf.bpelauth"; private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; @@ -129,15 +130,13 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName (serviceName); LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF, vnfName, vnfType, cloudSiteId, tenantId, "", "createVnfA"); - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); // Use the synchronous method to perform the actual Create MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory); // Synchronous Web Service Outputs - Holder <String> vnfId = new Holder <String> (); - Holder <Map <String, String>> outputs = new Holder <Map <String, String>> (); - Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> (); + Holder <String> vnfId = new Holder <> (); + Holder <Map <String, String>> outputs = new Holder <> (); + Holder <VnfRollback> vnfRollback = new Holder <> (); try { vnfAdapter.createVnf (cloudSiteId, @@ -216,17 +215,15 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String serviceName = "UpdateVnfA"; MsoLogger.setServiceName (serviceName); MsoLogger.setLogContext (msoRequest); - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF, vnfName, vnfType, cloudSiteId, tenantId, "", "UpdateVnfA"); // Use the synchronous method to perform the actual Create MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory,cloudConfigFactory); // Synchronous Web Service Outputs - Holder <String> vnfId = new Holder <String> (); - Holder <Map <String, String>> outputs = new Holder <Map <String, String>> (); - Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> (); + Holder <String> vnfId = new Holder <> (); + Holder <Map <String, String>> outputs = new Holder <> (); + Holder <VnfRollback> vnfRollback = new Holder <> (); try { vnfAdapter.updateVnf (cloudSiteId, tenantId, vnfType,vnfVersion, vnfName, requestType, volumeGroupHeatStackId, inputs, msoRequest, outputs, vnfRollback); @@ -299,18 +296,16 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String serviceName = "QueryVnfA"; MsoLogger.setServiceName (serviceName); MsoLogger.setLogContext (msoRequest); - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF, vnfName, cloudSiteId, tenantId); // Use the synchronous method to perform the actual query MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory,cloudConfigFactory); // Synchronous Web Service Outputs - Holder <Boolean> vnfExists = new Holder <Boolean> (); - Holder <String> vnfId = new Holder <String> (); - Holder <VnfStatus> status = new Holder <VnfStatus> (); - Holder <Map <String, String>> outputs = new Holder <Map <String, String>> (); + Holder <Boolean> vnfExists = new Holder <> (); + Holder <String> vnfId = new Holder <> (); + Holder <VnfStatus> status = new Holder <> (); + Holder <Map <String, String>> outputs = new Holder <> (); try { vnfAdapter.queryVnf (cloudSiteId, tenantId, vnfName, msoRequest, vnfExists, vnfId, status, outputs); @@ -391,8 +386,6 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String serviceName = "DeleteVnfA"; MsoLogger.setServiceName (serviceName); MsoLogger.setLogContext (msoRequest); - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF, vnfName, cloudSiteId, tenantId); // Use the synchronous method to perform the actual delete @@ -453,8 +446,6 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { public void rollbackVnfA (VnfRollback rollback, String messageId, String notificationUrl) { String serviceName = "RollbackVnfA"; MsoLogger.setServiceName (serviceName); - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); String error; // rollback may be null (e.g. if stack already existed when Create was called) if (rollback == null) { @@ -542,7 +533,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { CreateVnfNotification.Outputs outputs = new CreateVnfNotification.Outputs (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); sMap = hMap.value; CreateVnfNotification.Outputs.Entry entry = new CreateVnfNotification.Outputs.Entry (); @@ -560,7 +551,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { UpdateVnfNotification.Outputs outputs = new UpdateVnfNotification.Outputs (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); sMap = hMap.value; UpdateVnfNotification.Outputs.Entry entry = new UpdateVnfNotification.Outputs.Entry (); @@ -578,7 +569,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { QueryVnfNotification.Outputs outputs = new QueryVnfNotification.Outputs (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); sMap = hMap.value; QueryVnfNotification.Outputs.Entry entry = new QueryVnfNotification.Outputs.Entry (); @@ -625,21 +616,25 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "MalformedURLException", e1); } - LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ()); - - bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ()); + if(null != epUrl) { + LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ()); + bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ()); + } + else { + LOGGER.debug ("epUrl is NULL:"); + } // authentication try { - Map <String, Object> req_ctx = bp.getRequestContext (); - Map <String, List <String>> headers = new HashMap <String, List <String>> (); + Map <String, Object> reqCtx = bp.getRequestContext (); + Map <String, List <String>> headers = new HashMap <> (); String userCredentials = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER).getEncryptedProperty (BPEL_AUTH_PROP, "", ENCRYPTION_KEY); String basicAuth = "Basic " + DatatypeConverter.printBase64Binary (userCredentials.getBytes ()); - req_ctx.put (MessageContext.HTTP_REQUEST_HEADERS, headers); + reqCtx.put (MessageContext.HTTP_REQUEST_HEADERS, headers); headers.put ("Authorization", Collections.singletonList (basicAuth)); } catch (Exception e) { LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Unable to set authorization in callback request", e); |