diff options
Diffstat (limited to 'adapters')
17 files changed, 178 insertions, 128 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java index 6d3f8f7b1c..f51cb0dd64 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java @@ -55,7 +55,7 @@ public class MapDeserializer extends JsonDeserializer<Map<String, String>> { ObjectMapper mapper = new ObjectMapper(); JsonNode tree = mapper.readTree(parser); - Map<String, String> map = new LinkedHashMap<String, String>(); + Map<String, String> map = new LinkedHashMap<>(); Iterator<JsonNode> iterator = tree.iterator(); while (iterator.hasNext()) { @@ -71,4 +71,4 @@ public class MapDeserializer extends JsonDeserializer<Map<String, String>> { return map; } -}
\ No newline at end of file +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapSerializer.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapSerializer.java index 1db69f41ab..c2ea8242c3 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapSerializer.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapSerializer.java @@ -53,8 +53,9 @@ public class MapSerializer extends JsonSerializer<Map<String, String>> { jsonGenerator.writeStartObject(); jsonGenerator.writeArrayFieldStart("entry"); - for (String key : map.keySet()) { - String value = map.get(key); + for (Map.Entry<String,String> entry : map.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("key", key); jsonGenerator.writeStringField("value", value); @@ -64,4 +65,4 @@ public class MapSerializer extends JsonSerializer<Map<String, String>> { jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); } -}
\ No newline at end of file +} 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 9f709140ec..a1bc08599b 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 @@ -40,7 +40,7 @@ public abstract class CatalogQueryExceptionCommon { public String toJsonString() { try { - String jsonString = null; + String jsonString; ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); jsonString = mapper.writeValueAsString(this); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java index 75262e3597..9a82ed2c6e 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java @@ -54,7 +54,7 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { "\t}"; // "\t}}"; - public QueryAllottedResourceCustomization() { super(); allottedResourceCustomization = new ArrayList<AllottedResourceCustomization>(); } + public QueryAllottedResourceCustomization() { super(); allottedResourceCustomization = new ArrayList<>(); } public QueryAllottedResourceCustomization(List<AllottedResourceCustomization> vlist) { allottedResourceCustomization = vlist; } public List<AllottedResourceCustomization> getServiceAllottedResources(){ return this.allottedResourceCustomization; } @@ -62,7 +62,7 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { @Override public String toString () { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); boolean first = true; int i = 1; @@ -76,10 +76,10 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean isEmbed) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); if (!isEmbed && isArray) buf.append("{ "); if (isArray) buf.append("\"serviceAllottedResources\": ["); - Map<String, String> valueMap = new HashMap<String, String>(); + Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; @@ -114,4 +114,4 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { return buf.toString(); } -}
\ No newline at end of file +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java index 0e2aa714f6..e5147671f3 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java @@ -60,8 +60,8 @@ public class QueryServiceMacroHolder extends CatalogQuery { Service service = serviceMacroHolder.getService(); if (service == null) return "\"serviceResources\": null"; - StringBuffer buf = new StringBuffer(); - Map<String, String> valueMap = new HashMap<String, String>(); + StringBuilder buf = new StringBuilder(); + Map<String, String> valueMap = new HashMap<>(); put(valueMap, "SERVICE_MODEL_NAME", service.getModelName()); //getServiceModelName()); put(valueMap, "SERVICE_MODEL_UUID", service.getModelUUID()); //getServiceModelUuid()); @@ -84,4 +84,4 @@ public class QueryServiceMacroHolder extends CatalogQuery { return buf.toString(); } -}
\ No newline at end of file +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java index 42b6b651ef..59c601ef19 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java @@ -51,10 +51,10 @@ public class QueryServiceNetworks extends CatalogQuery { "\t}"; // "\t}}"; - public QueryServiceNetworks() { super(); serviceNetworks = new ArrayList<NetworkResourceCustomization>(); } + public QueryServiceNetworks() { super(); serviceNetworks = new ArrayList<>(); } public QueryServiceNetworks(List<NetworkResourceCustomization> vlist) { LOGGER.debug ("QueryServiceNetworks:"); - serviceNetworks = new ArrayList<NetworkResourceCustomization>(); + serviceNetworks = new ArrayList<>(); for (NetworkResourceCustomization o : vlist) { LOGGER.debug (o.toString()); serviceNetworks.add(o); @@ -67,7 +67,7 @@ public class QueryServiceNetworks extends CatalogQuery { @Override public String toString () { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); boolean first = true; int i = 1; @@ -81,11 +81,11 @@ public class QueryServiceNetworks extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean isEmbed) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); if (!isEmbed && isArray) buf.append("{ "); if (isArray) buf.append("\"serviceNetworks\": ["); //if (isArray) buf.append("["); - Map<String, String> valueMap = new HashMap<String, String>(); + Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; @@ -112,4 +112,4 @@ public class QueryServiceNetworks extends CatalogQuery { if (!isEmbed && isArray) buf.append("}"); return buf.toString(); } -}
\ No newline at end of file +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java index ee3c86ab94..cfbb781ae8 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java @@ -55,10 +55,10 @@ public class QueryServiceVnfs extends CatalogQuery { "\t}"; // "\t}}"; - public QueryServiceVnfs() { super(); serviceVnfs = new ArrayList<VnfResourceCustomization>(); } + public QueryServiceVnfs() { super(); serviceVnfs = new ArrayList<>(); } public QueryServiceVnfs(List<VnfResourceCustomization> vlist) { LOGGER.debug ("QueryServiceVnfs:"); - serviceVnfs = new ArrayList<VnfResourceCustomization>(); + serviceVnfs = new ArrayList<>(); for (VnfResourceCustomization o : vlist) { LOGGER.debug ("-- o is a serviceVnfs ----"); LOGGER.debug (o.toString()); @@ -72,7 +72,7 @@ public class QueryServiceVnfs extends CatalogQuery { @Override public String toString () { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); boolean first = true; int i = 1; @@ -86,10 +86,10 @@ public class QueryServiceVnfs extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean isEmbed) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); if (!isEmbed && isArray) buf.append("{ "); if (isArray) buf.append("\"serviceVnfs\": ["); - Map<String, String> valueMap = new HashMap<String, String>(); + Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; @@ -121,4 +121,4 @@ public class QueryServiceVnfs extends CatalogQuery { if (!isEmbed && isArray) buf.append("}"); return buf.toString(); } -}
\ No newline at end of file +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java index 4675858936..309aa0641a 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java @@ -50,10 +50,10 @@ public class QueryVfModule extends CatalogQuery { "\t}"; // "\t}}"; - public QueryVfModule() { super(); vfModules = new ArrayList<VfModuleCustomization>(); } + public QueryVfModule() { super(); vfModules = new ArrayList<>(); } public QueryVfModule(List<VfModuleCustomization> vlist) { LOGGER.debug ("QueryVfModule:"); - vfModules = new ArrayList<VfModuleCustomization>(); + vfModules = new ArrayList<>(); if (vlist != null) { for (VfModuleCustomization o : vlist) { LOGGER.debug ("-- o is a vfModules ----"); @@ -69,7 +69,7 @@ public class QueryVfModule extends CatalogQuery { @Override public String toString () { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); boolean first = true; int i = 1; @@ -83,9 +83,9 @@ public class QueryVfModule extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean x) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); if (isArray) buf.append("\"vfModules\": ["); - Map<String, String> valueMap = new HashMap<String, String>(); + Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; @@ -95,7 +95,7 @@ public class QueryVfModule extends CatalogQuery { boolean vfNull = o.getVfModule() == null ? true : false; boolean hasVolumeGroup = false; String envt = o.getHeatEnvironmentArtifactUuid(); - if (envt != null && !envt.equals("")) { + if (envt != null && !"".equals(envt)) { hasVolumeGroup = true; } @@ -116,4 +116,4 @@ public class QueryVfModule extends CatalogQuery { if (isArray) buf.append("]"); return buf.toString(); } -}
\ No newline at end of file +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java index b755cad220..ec523b87d9 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java @@ -34,22 +34,22 @@ import org.openecomp.mso.openstack.beans.Subnet; import static org.openecomp.mso.openstack.utils.MsoCommonUtils.isNullOrEmpty; public class ContrailSubnet { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet") private ContrailSubnetIp subnet = new ContrailSubnetIp(); @JsonProperty("network_ipam_refs_data_ipam_subnets_default_gateway") - private String default_gateway; + private String defaultGateway; @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet_name") - private String subnet_name; + private String subnetName; @JsonProperty("network_ipam_refs_data_ipam_subnets_enable_dhcp") - private Boolean enable_dhcp; + private Boolean enableDhcp; @JsonProperty("network_ipam_refs_data_ipam_subnets_addr_from_start") - private Boolean addr_from_start = true; + private Boolean addrFromStart = true; /** future - leave this commented private String subnet_uuid; @@ -60,18 +60,18 @@ public class ContrailSubnet { **/ @JsonProperty("network_ipam_refs_data_ipam_subnets_allocation_pools") - private List<ContrailSubnetPool> allocation_pools = new ArrayList <> (); + private List<ContrailSubnetPool> allocationPools = new ArrayList <> (); public ContrailSubnet() { super(); } - public String getDefault_gateway() { - return default_gateway; + public String getDefaultGateway() { + return defaultGateway; } - public void setDefault_gateway(String default_gateway) { - this.default_gateway = default_gateway; + public void setDefaultGateway(String defaultGateway) { + this.defaultGateway = defaultGateway; } public ContrailSubnetIp getSubnet() { @@ -82,36 +82,36 @@ public class ContrailSubnet { this.subnet = subnet; } - public Boolean isEnable_dhcp() { - return enable_dhcp; + public Boolean isEnableDhcp() { + return enableDhcp; } - public void setEnable_dhcp(Boolean enable_dhcp) { - this.enable_dhcp = enable_dhcp; + public void setEnableDhcp(Boolean enableDhcp) { + this.enableDhcp = enableDhcp; } - public String getSubnet_name() { - return subnet_name; + public String getSubnetName() { + return subnetName; } - public void setSubnet_name(String subnet_name) { - this.subnet_name = subnet_name; + public void setSubnetName(String subnetName) { + this.subnetName = subnetName; } - public List<ContrailSubnetPool> getAllocation_pools() { - return allocation_pools; + public List<ContrailSubnetPool> getAllocationPools() { + return allocationPools; } - public void setPools(List<ContrailSubnetPool> allocation_pools) { - this.allocation_pools = allocation_pools; + public void setPools(List<ContrailSubnetPool> allocationPools) { + this.allocationPools = allocationPools; } - public Boolean isAddr_from_start() { - return addr_from_start; + public Boolean isAddrFromStart() { + return addrFromStart; } - public void setAddr_from_start(Boolean addr_from_start) { - this.addr_from_start = addr_from_start; + public void setAddrFromStart(Boolean addrFromStart) { + this.addrFromStart = addrFromStart; } public JsonNode toJsonNode() @@ -124,8 +124,8 @@ public class ContrailSubnet { } catch (Exception e) { - String error = "Error creating JsonNode for Contrail Subnet:" + subnet_name; - LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonNode for Contrail Subnet", e); + String error = "Error creating JsonNode for Contrail Subnet:" + subnetName; + logger.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonNode for Contrail Subnet", e); } return node; @@ -141,41 +141,41 @@ public class ContrailSubnet { } catch (Exception e) { - String error = "Error creating JsonString for Contrail Subnet:" + subnet_name; - LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Subnet", e); + String error = "Error creating JsonString for Contrail Subnet:" + subnetName; + logger.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Subnet", e); } return jsonString; } //poulate contrail subnet with input(from bopel) subnet - public void populateWith(Subnet i_subnet) + public void populateWith(Subnet inputSubnet) { - if (i_subnet != null) + if (inputSubnet != null) { - if (!isNullOrEmpty(i_subnet.getSubnetName())) - subnet_name = i_subnet.getSubnetName(); + if (!isNullOrEmpty(inputSubnet.getSubnetName())) + subnetName = inputSubnet.getSubnetName(); else - subnet_name = i_subnet.getSubnetId(); - enable_dhcp = i_subnet.getEnableDHCP(); - default_gateway = i_subnet.getGatewayIp(); - if (!isNullOrEmpty(i_subnet.getCidr()) ) + subnetName = inputSubnet.getSubnetId(); + enableDhcp = inputSubnet.getEnableDHCP(); + defaultGateway = inputSubnet.getGatewayIp(); + if (!isNullOrEmpty(inputSubnet.getCidr()) ) { - int idx = i_subnet.getCidr().indexOf("/"); + int idx = inputSubnet.getCidr().indexOf("/"); if (idx != -1) { - subnet.setIp_prefix(i_subnet.getCidr().substring(0, idx)); - subnet.setIp_prefix_len(i_subnet.getCidr().substring(idx+1)); + subnet.setIpPrefix(inputSubnet.getCidr().substring(0, idx)); + subnet.setIpPrefixLen(inputSubnet.getCidr().substring(idx+1)); } } - if (i_subnet.getAllocationPools() != null) + if (inputSubnet.getAllocationPools() != null) { - for (Pool pool : i_subnet.getAllocationPools()) + for (Pool pool : inputSubnet.getAllocationPools()) { if ( !isNullOrEmpty(pool.getStart()) && !isNullOrEmpty(pool.getEnd()) ) { ContrailSubnetPool csp = new ContrailSubnetPool(); csp.populateWith(pool); - allocation_pools.add (csp); + allocationPools.add (csp); } } } @@ -186,11 +186,11 @@ public class ContrailSubnet { public String toString() { StringBuilder buf = new StringBuilder (); - for (ContrailSubnetPool pool : allocation_pools) + for (ContrailSubnetPool pool : allocationPools) { buf.append(pool.toString()); } - return "ContrailSubnet [subnet=" + subnet.toString() + " default_gateway=" + default_gateway - + " enable_dhcp=" + enable_dhcp + " addr_from_start=" + addr_from_start + " subnet_name=" + subnet_name + " allocation_pools=" + buf + " ]"; + return "ContrailSubnet [subnet=" + subnet.toString() + " default_gateway=" + defaultGateway + + " enable_dhcp=" + enableDhcp + " addr_from_start=" + addrFromStart + " subnet_name=" + subnetName + " allocation_pools=" + buf + " ]"; } } diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java index ce7fec392c..b7af894f8b 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java @@ -26,33 +26,34 @@ import org.codehaus.jackson.annotate.JsonProperty; public class ContrailSubnetIp { @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet_ip_prefix") - private String ip_prefix; + private String ipPrefix; @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet_ip_prefix_len") - private String ip_prefix_len; + private String ipPrefixLen; public ContrailSubnetIp() { + /* Empty constructor */ } - public String getIp_prefix() { - return ip_prefix; + public String getIpPrefix() { + return ipPrefix; } - public void setIp_prefix(String ip_prefix) { - this.ip_prefix = ip_prefix; + public void setIpPrefix(String ipPrefix) { + this.ipPrefix = ipPrefix; } - public String getIp_prefix_len() { - return ip_prefix_len; + public String getIpPrefixLen() { + return ipPrefixLen; } - public void setIp_prefix_len(String ip_prefix_len) { - this.ip_prefix_len = ip_prefix_len; + public void setIpPrefixLen(String ipPrefixLen) { + this.ipPrefixLen = ipPrefixLen; } @Override public String toString() { - return "ContrailSubnetIp [ip_prefix=" + ip_prefix + ", ip_prefix_len=" + ip_prefix_len + "]"; + return "ContrailSubnetIp [ip_prefix=" + ipPrefix + ", ip_prefix_len=" + ipPrefixLen + "]"; } } diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java index 71b9ebb4e2..6429e49e41 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java @@ -32,6 +32,7 @@ public class ContrailSubnetPool { private String end; public ContrailSubnetPool() { + /* Empty constructor */ } public String getStart() { diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java index 15f74c4d94..9648922d41 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java @@ -27,7 +27,6 @@ import javax.xml.bind.annotation.XmlElement; import org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbException; import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.SiteStatus; /** * MSO Request DB Adapter Web Service diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index a5e9690252..f8a2c986da 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -21,7 +21,6 @@ package org.openecomp.mso.adapters.requestsdb; import java.sql.Timestamp; -import java.util.List; import javax.jws.WebService; @@ -43,7 +42,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager (); - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); @Override public void updateInfraRequest (String requestId, @@ -110,90 +109,90 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { } queryString += "lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId"; - LOGGER.debug("Executing update: " + queryString); + logger.debug("Executing update: " + queryString); Query query = session.createQuery (queryString); query.setParameter ("requestId", requestId); if (statusMessage != null) { query.setParameter ("statusMessage", statusMessage); - LOGGER.debug ("StatusMessage in updateInfraRequest is set to: " + statusMessage); + logger.debug ("StatusMessage in updateInfraRequest is set to: " + statusMessage); } if (responseBody != null) { query.setParameter ("responseBody", responseBody); - LOGGER.debug ("ResponseBody in updateInfraRequest is set to: " + responseBody); + logger.debug ("ResponseBody in updateInfraRequest is set to: " + responseBody); } if (requestStatus != null) { query.setParameter ("requestStatus", requestStatus.toString ()); - LOGGER.debug ("RequestStatus in updateInfraRequest is set to: " + requestStatus.toString()); + logger.debug ("RequestStatus in updateInfraRequest is set to: " + requestStatus.toString()); } if (progress != null) { query.setParameter ("progress", Long.parseLong (progress)); - LOGGER.debug ("Progress in updateInfraRequest is set to: " + progress); + logger.debug ("Progress in updateInfraRequest is set to: " + progress); } if (vnfOutputs != null) { query.setParameter ("vnfOutputs", vnfOutputs); - LOGGER.debug ("VnfOutputs in updateInfraRequest is set to: " + vnfOutputs); + logger.debug ("VnfOutputs in updateInfraRequest is set to: " + vnfOutputs); } if (serviceInstanceId != null) { query.setParameter ("serviceInstanceId", serviceInstanceId); - LOGGER.debug ("ServiceInstanceId in updateInfraRequest is set to: " + serviceInstanceId); + logger.debug ("ServiceInstanceId in updateInfraRequest is set to: " + serviceInstanceId); } if (networkId != null) { query.setParameter ("networkId", networkId); - LOGGER.debug ("NetworkId in updateInfraRequest is set to: " + networkId); + logger.debug ("NetworkId in updateInfraRequest is set to: " + networkId); } if (vnfId != null) { query.setParameter ("vnfId", vnfId); - LOGGER.debug ("VnfId in updateInfraRequest is set to: " + vnfId); + logger.debug ("VnfId in updateInfraRequest is set to: " + vnfId); } if (vfModuleId != null) { query.setParameter ("vfModuleId", vfModuleId); - LOGGER.debug ("vfModuleId in updateInfraRequest is set to: " + vfModuleId); + logger.debug ("vfModuleId in updateInfraRequest is set to: " + vfModuleId); } if (volumeGroupId != null) { query.setParameter ("volumeGroupId", volumeGroupId); - LOGGER.debug ("VolumeGroupId in updateInfraRequest is set to: " + volumeGroupId); + logger.debug ("VolumeGroupId in updateInfraRequest is set to: " + volumeGroupId); } if (serviceInstanceName != null) { query.setParameter ("serviceInstanceName", serviceInstanceName); - LOGGER.debug ("ServiceInstanceName in updateInfraRequest is set to: " + serviceInstanceName); + logger.debug ("ServiceInstanceName in updateInfraRequest is set to: " + serviceInstanceName); } if (vfModuleName != null) { query.setParameter ("vfModuleName", vfModuleName); - LOGGER.debug ("vfModuleName in updateInfraRequest is set to: " + vfModuleName); + logger.debug ("vfModuleName in updateInfraRequest is set to: " + vfModuleName); } Timestamp nowTimeStamp = new Timestamp (System.currentTimeMillis ()); if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) { query.setParameter ("endTime", nowTimeStamp); - LOGGER.debug ("EndTime in updateInfraRequest is set to: " + nowTimeStamp); + logger.debug ("EndTime in updateInfraRequest is set to: " + nowTimeStamp); } else { query.setParameter ("modifyTime", nowTimeStamp); - LOGGER.debug ("ModifyTime in updateInfraRequest is set to: " + nowTimeStamp); + logger.debug ("ModifyTime in updateInfraRequest is set to: " + nowTimeStamp); } query.setParameter ("lastModifiedBy", lastModifiedBy); - LOGGER.debug ("LastModifiedBy in updateInfraRequest is set to: " + lastModifiedBy); + logger.debug ("LastModifiedBy in updateInfraRequest is set to: " + lastModifiedBy); result = query.executeUpdate (); - checkIfExists (result, requestId, startTime); + checkIfExists (result, requestId); session.getTransaction ().commit (); } catch (HibernateException e) { String error = "Unable to update MSO Requests DB: " + e.getMessage (); - LOGGER.error (MessageEnum.RA_CANT_UPDATE_REQUEST, "infra request parameters", requestId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); + logger.error (MessageEnum.RA_CANT_UPDATE_REQUEST, "infra request parameters", requestId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e); + logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); throw new MsoRequestsDbException (error, e); } finally { if (session != null && session.isOpen ()) { session.close (); } } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); } - private void checkIfExists (int result, String requestId, long startTime) throws MsoRequestsDbException { + private void checkIfExists (int result, String requestId) throws MsoRequestsDbException { if (result == 0) { String error = "Request ID does not exist in MSO Requests DB: " + requestId; - LOGGER.error (MessageEnum.RA_DB_REQUEST_NOT_EXIST, requestId, "", "", MsoLogger.ErrorCode.DataError, error); + logger.error (MessageEnum.RA_DB_REQUEST_NOT_EXIST, requestId, "", "", MsoLogger.ErrorCode.DataError, error); throw new MsoRequestsDbException (error); } } @@ -205,7 +204,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { MsoLogger.setLogContext (requestId, null); Session session = requestsDbSessionFactoryManager.getSessionFactory ().openSession (); - LOGGER.debug ("Call to MSO Infra RequestsDb adapter get method with request Id: " + requestId); + logger.debug ("Call to MSO Infra RequestsDb adapter get method with request Id: " + requestId); InfraActiveRequests request = null; try { @@ -216,15 +215,15 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { } catch (HibernateException e) { String error = "Unable to retrieve MSO Infra Requests DB for Request ID " + requestId; - LOGGER.error (MessageEnum.RA_DB_REQUEST_NOT_EXIST, "Get Infra request", requestId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); + logger.error (MessageEnum.RA_DB_REQUEST_NOT_EXIST, "Get Infra request", requestId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e); + logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); throw new MsoRequestsDbException (error, e); } finally { if (session != null && session.isOpen ()) { session.close (); } } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); return request; } @@ -235,13 +234,14 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { * @param siteName The unique name of the site * @return Status of that site */ + @Override public boolean getSiteStatus (String siteName) { - UUIDChecker.generateUUID (LOGGER); + UUIDChecker.generateUUID (logger); Session session = requestsDbSessionFactoryManager.getSessionFactory ().openSession (); long startTime = System.currentTimeMillis (); SiteStatus siteStatus = null; - LOGGER.debug ("Request database - get Site Status with Site name:" + siteName); + logger.debug ("Request database - get Site Status with Site name:" + siteName); try { String hql = "FROM SiteStatus WHERE siteName = :site_name"; Query query = session.createQuery (hql); @@ -255,10 +255,10 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { } if (siteStatus == null) { // if not exist in DB, it means the site is not disabled, thus return true - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); return true; } else { - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); return siteStatus.getStatus(); } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterPortType.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterPortType.java index 0e72861f39..1b717b483a 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterPortType.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterPortType.java @@ -40,6 +40,7 @@ import org.openecomp.mso.adapters.sdnc.SDNCAdapterResponse; @WebService(targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", name = "SDNCCallbackAdapterPortType") @XmlSeeAlso({ObjectFactory.class}) @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) +@FunctionalInterface public interface SDNCCallbackAdapterPortType { @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse") diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterService.java index 9e0718cba5..d63e852258 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterService.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterService.java @@ -45,14 +45,13 @@ public class SDNCCallbackAdapterService extends Service { private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); - public final static URL WSDL_LOCATION; - public final static QName SERVICE = new QName("http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterService"); - public final static QName SDNCCallbackAdapterSoapHttpPort = new QName("http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterSoapHttpPort"); + public static final URL WSDL_LOCATION; + public static final QName SERVICE = new QName("http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterService"); + public static final QName SDNCCallbackAdapterSoapHttpPort = new QName("http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterSoapHttpPort"); static { URL wsdlUrl = null; try { wsdlUrl = Thread.currentThread().getContextClassLoader().getResource("main/resources/SDNCCallbackAdapter.wsdl"); - //wsdlUrl = SDNCCallbackAdapterService.class.getClassLoader().getResource("SDNCCallbackAdapter.wsdl"); } catch (Exception e) { msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e); } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/Utils.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/Utils.java index 525002f73d..6ab9ade143 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/Utils.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/Utils.java @@ -41,6 +41,9 @@ public class Utils { private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private Utils() { + } + public static String genSdncReq(Document reqDoc, RequestTunables rt) { try { diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java index c8c036d58a..cba378eab0 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java @@ -22,10 +22,17 @@ package org.openecomp.mso.adapters.vnf; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; + +import java.util.Arrays; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -540,6 +547,41 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { return string; } + private boolean callHeatbridge(String heatStackId) { + String executionDir = "/usr/local/lib/python2.7/dist-packages/heatbridge"; + String openstackIdentityUrl = "", username = "", password = "", tenant = "", region = "", owner = ""; + long waitTimeMs = 10000l; + try { + String[] cmdarray = {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, heatStackId}; + String[] envp = null; + File dir = new File(executionDir); + LOGGER.debug("Calling HeatBridgeMain.py in " + dir + " with arguments " + Arrays.toString(cmdarray)); + Runtime r = Runtime.getRuntime(); + Process p = r.exec(cmdarray, envp, dir); + /* + BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream())); + String linein = stdout.readLine(); + while (linein!=null) { + System.out.println(linein); + linein = stdout.readLine(); + } + */ + boolean wait = p.waitFor(waitTimeMs, TimeUnit.MILLISECONDS); + + LOGGER.debug(" HeatBridgeMain.py returned " + wait + " with code " + p.exitValue()); + return (wait && p.exitValue()==0); + } catch (IOException e) { + LOGGER.debug(" HeatBridgeMain.py failed with IO Exception! " + e); + return false; + } catch (InterruptedException e) { + LOGGER.debug(" HeatBridgeMain.py failed when interrupted! " + e); + return false; + } catch (RuntimeException e) { + LOGGER.debug(" HeatBridgeMain.py failed for unknown reasons!" + e); + return false; + } + } + private void sendMapToDebug(Map<String, Object> inputs, String optionalName) { int i = 0; StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName); @@ -731,6 +773,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfRollback.setIsBase(isBaseRequest); vfRollback.setModelCustomizationUuid(mcu); + // Put data into A&AI through Heatstack + boolean heatStackCallSuccess = callHeatbridge(baseVfHeatStackId); + // First, look up to see if the VF already exists. MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); |