aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java11
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java7
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java61
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java12
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java10
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java9
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java7
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java8
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java6
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java5
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java6
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java3
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java7
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java2
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java7
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java28
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java55
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java35
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java16
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java7
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java5
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java20
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java23
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java19
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java8
-rw-r--r--adapters/mso-vfc-adapter/pom.xml190
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java98
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java29
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java9
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java45
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java34
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java26
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java19
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java20
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java5
-rw-r--r--adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java225
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java55
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java21
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java4
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java11
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java22
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java3
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java5
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java7
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java20
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java15
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericE2EServiceInstance.groovy160
-rw-r--r--bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/FileUtil.java21
-rw-r--r--bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java2
-rw-r--r--bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java6
-rw-r--r--bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java6
-rw-r--r--bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/HostNameVerifier.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/pom.xml6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java22
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java469
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java491
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java2
60 files changed, 1922 insertions, 514 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);
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java
index f9fd9c395d..27a21ecced 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java
@@ -87,8 +87,6 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
private MsoLogger logger;
- private Service catalogService;
-
private static final Pattern lastDigit = Pattern.compile("(\\d+)$");
public ToscaResourceInstaller() {
@@ -98,7 +96,6 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
//@Override
public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct)
throws ArtifactInstallerException {
- CatalogDatabase db = CatalogDatabase.getInstance();
boolean status = false;
VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct;
@@ -178,8 +175,6 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
try {
- String vfModuleModelUUID = null;
-
createToscaCsar(toscaResourceStruct);
catalogDB.saveToscaCsar(toscaResourceStruct.getCatalogToscaCsar());
@@ -225,10 +220,10 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
// get the Main IArtifactInfo
HeatTemplate heatMainTemplate = null;
- HeatEnvironment heatEnv = null;
+ HeatEnvironment heatEnv;
HeatTemplate heatVolumeTemplate = null;
- HeatEnvironment heatVolumeEnv = null;
+ HeatEnvironment heatVolumeEnv;
IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
@@ -571,8 +566,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED, vfResourceStructure.getResourceInstance().getResourceName(),
vfResourceStructure.getNotification().getServiceVersion(), "", "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e);
} else {
- String endEvent = "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.";
- String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed");
+ String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed");
logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError, "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback", e);
catalogDB.rollback();
throw new ArtifactInstallerException(
@@ -642,7 +636,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
// heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- List<String> typeList = new ArrayList<String>();
+ List<String> typeList = new ArrayList<>();
typeList.add(ASDCConfiguration.HEAT_NESTED);
typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
@@ -684,7 +678,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
// TODO Set the label
// heatEnvironment.setAsdcLabel("Label");
- List<String> typeList = new ArrayList<String>();
+ List<String> typeList = new ArrayList<>();
typeList.add(ASDCConfiguration.HEAT);
typeList.add(ASDCConfiguration.HEAT_VOL);
@@ -835,7 +829,6 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
private static void createVFModule(Group group, NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, IVfModuleData vfModuleData) {
VfModule vfModule = new VfModule();
- boolean isBase = false;
Metadata vfMetadata = group.getMetadata();
@@ -895,7 +888,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
vfModule.setVnfResourceModelUUId(toscaResourceStructure.getCatalogVnfResource().getModelUuid());
String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
- if(vfModuleType != null && vfModuleType.equalsIgnoreCase("Base")){
+ if(vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)){
vfModule.setIsBase(1);
}else {
vfModule.setIsBase(0);
@@ -1100,7 +1093,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
private static String testNull(Object object) {
if (object == null) {
return "";
- } else if (object.equals("null")) {
+ } else if ("null".equals(object)) {
return null;
}else if (object instanceof Integer) {
return object.toString();
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java
index e8dc5af90c..e9752e04cf 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java
@@ -37,9 +37,12 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
+import org.openecomp.mso.logger.MsoLogger;
public class ApplicationControllerClient {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+
private static final int ACCEPT_SERIES = 100;
private static final int ERROR_SERIES = 200;
private static final int REJECT_SERIES = 300;
@@ -113,6 +116,7 @@ public class ApplicationControllerClient {
requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class)
.invoke(requestObject, identifier);
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
+ LOGGER.debug("Exception:", e);
throw new Exception("Error Building AppC Request: " + e.getMessage());
}
return requestObject;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java
index 74bb59c908..d505210abd 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java
@@ -13,12 +13,19 @@ import org.openecomp.mso.logger.MsoLogger;
public class CamundaDBSetup {
private static boolean isDBConfigured = false;
private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+
+ private CamundaDBSetup() {
+ /**
+ * Constructor.
+ */
+ }
+
public static synchronized void configure() throws SQLException {
if (isDBConfigured) {
return;
}
- System.out.println("Configuring the Camunda H2 database for MSO");
+ LOGGER.debug ("Configuring the Camunda H2 database for MSO");
Connection connection = null;
PreparedStatement stmt = null;
@@ -67,7 +74,7 @@ public class CamundaDBSetup {
isDBConfigured = true;
} catch (SQLException e) {
- System.out.println("CamundaDBSetup caught " + e.getClass().getSimpleName());
+ LOGGER.debug ("CamundaDBSetup caught " + e.getClass().getSimpleName());
LOGGER.debug("SQLException :",e);
} finally {
if (stmt != null) {
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java
index 70f67a5a77..4e67bd171d 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java
@@ -85,15 +85,22 @@ public class PropertyConfiguration {
private volatile String msoConfigPath = null;
private final ConcurrentHashMap<String, Map<String, String>> propFileCache =
- new ConcurrentHashMap<String, Map<String, String>>();
+ new ConcurrentHashMap<>();
private final Object CACHELOCK = new Object();
private FileWatcherThread fileWatcherThread = null;
// The key is the file name
- private Map<String, TimerTask> timerTaskMap = new HashMap<String, TimerTask>();
+ private Map<String, TimerTask> timerTaskMap = new HashMap<>();
/**
+ * Private Constructor.
+ */
+ private PropertyConfiguration() {
+ startUp();
+ }
+
+ /**
* Singleton holder pattern eliminates locking when accessing the instance
* and still provides for lazy initialization.
*/
@@ -112,14 +119,7 @@ public class PropertyConfiguration {
* Returns the list of supported files.
*/
public static List<String> supportedFiles() {
- return new ArrayList<String>(SUPPORTED_FILES);
- }
-
- /**
- * Private Constructor.
- */
- private PropertyConfiguration() {
- startUp();
+ return new ArrayList<>(SUPPORTED_FILES);
}
/**
@@ -245,7 +245,7 @@ public class PropertyConfiguration {
String fileName = file.getName();
LOGGER.debug("Reading " + fileName);
- Map<String, String> properties = new HashMap<String, String>();
+ Map<String, String> properties = new HashMap<>();
Properties newProperties = new Properties();
FileReader reader = null;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java
index e9110eb88c..6249040342 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.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.
@@ -86,7 +87,7 @@ public class ReadConfigTask extends BaseTask {
try {
stream.close();
} catch (Exception e) {
- // Do nothing
+ msoLogger.debug("Exception:", e);
}
}
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java
index 041b3e3d03..6b3cb5a1db 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.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.
@@ -102,14 +103,14 @@ public class ReadFileTask extends BaseTask {
try {
xmlStream.close();
} catch (Exception e) {
- // Do nothing
+ msoLogger.debug("Exception ", e);
}
}
}
}
execution.setVariable(theInputVariable, value);
execution.setVariable(theOutputVariable, value);
- System.out.println("ServiceInput - " + execution.getVariable("gServiceInput"));
+ msoLogger.debug ("ServiceInput - " + execution.getVariable("gServiceInput"));
if (msoLogger.isDebugEnabled()) {
msoLogger.debug("Done Executing " + getTaskName());
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java
index b454450a63..4b34ddf0f0 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.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.
@@ -85,7 +86,7 @@ public class XQueryScriptTask extends BaseTask {
getStringField(outputVariable, execution, "outputVariable");
if (msoLogger.isDebugEnabled()) {
- System.out.println("scriptFile = " + theScriptFile
+ msoLogger.debug ("scriptFile = " + theScriptFile
+ " xmlInputVariables = " + theXmlInputVariables
+ " atomicInputVariables = " + theAtomicInputVariables
+ "outputVariable = " + theOutputVariable);
@@ -141,7 +142,7 @@ public class XQueryScriptTask extends BaseTask {
for (String atomicInputVariable : atomicInputVariableArray) {
if (msoLogger.isDebugEnabled()) {
- System.out.println("Injecting object variable '"
+ msoLogger.debug ("Injecting object variable '"
+ atomicInputVariable + "'");
}
@@ -235,7 +236,7 @@ public class XQueryScriptTask extends BaseTask {
try {
xqStream.close();
} catch (Exception e) {
- // Do nothing
+ msoLogger.debug ("Exception:", e);
}
}
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java
index 54a5732e1c..9dbd4b171d 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java
@@ -144,7 +144,7 @@ public class JsonUtils {
jsonObj = (JSONObject) obj;
keys = jsonObj.keys();
while (keys.hasNext()) {
- key = keys.next().toString();
+ key = keys.next();
// msoLogger.debug("toXMLString(): key is " + k);
curObj = jsonObj.opt(key);
if (curObj == null) {
@@ -327,7 +327,7 @@ public class JsonUtils {
return null;
} else {
if (rawValue instanceof String) {
- msoLogger.debug("getJsonValue(): the raw value is a String Object=" + ((String) rawValue).toString());
+ msoLogger.debug("getJsonValue(): the raw value is a String Object=" + ((String) rawValue));
return (String) rawValue;
} else {
msoLogger.debug("getJsonValue(): the raw value is NOT a String Object=" + rawValue.toString());
@@ -356,7 +356,7 @@ public class JsonUtils {
return null;
} else {
if (rawValue instanceof String) {
- msoLogger.debug("getJsonNodeValue(): the raw value is a String Object=" + ((String) rawValue).toString());
+ msoLogger.debug("getJsonNodeValue(): the raw value is a String Object=" + ((String) rawValue));
return (String) rawValue;
} else {
msoLogger.debug("getJsonNodeValue(): the raw value is NOT a String Object=" + rawValue.toString());
@@ -410,14 +410,13 @@ public class JsonUtils {
* @return boolean field value associated with keys - default is false
*/
public static boolean getJsonBooleanValue(String jsonStr, String keys) {
- String isDebugLogEnabled = "true";
try {
Object rawValue = getJsonRawValue(jsonStr, keys);
if (rawValue == null) {
return false;
} else {
if (rawValue instanceof Boolean) {
- msoLogger.debug("getJsonValue(): the raw value is a Boolean Object=" + ((String) rawValue).toString());
+ msoLogger.debug("getJsonValue(): the raw value is a Boolean Object=" + ((String) rawValue));
return (Boolean) rawValue;
} else {
msoLogger.debug("getJsonValue(): the raw value is NOT an Boolean Object=" + rawValue.toString());
@@ -590,7 +589,7 @@ public class JsonUtils {
try {
if (jsonObj.has(key)) {
msoLogger.debug("getJsonValueForKey(): found value for key=" + key);
- return ((Integer) jsonObj.get(key));
+ return (Integer) jsonObj.get(key);
} else {
msoLogger.debug("getJsonValueForKey(): iterating over the keys");
Iterator <String> itr = jsonObj.keys();
@@ -628,12 +627,11 @@ public class JsonUtils {
* @return String field value associated with key
*/
public static Boolean getJsonBooleanValueForKey(JSONObject jsonObj, String key) {
- String isDebugLogEnabled = "true";
Boolean keyValue = false;
try {
if (jsonObj.has(key)) {
msoLogger.debug("getJsonBooleanValueForKey(): found value for key=" + key);
- return ((Boolean) jsonObj.get(key));
+ return (Boolean) jsonObj.get(key);
} else {
msoLogger.debug("getJsonBooleanValueForKey(): iterating over the keys");
Iterator <String> itr = jsonObj.keys();
@@ -863,7 +861,7 @@ public class JsonUtils {
public Map<String, String> entryArrayToMap(Execution execution, String entryArray) {
msoLogger.debug("Started Entry Array To Map Util Method");
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
//Populate Map
String entryListJson = "{ \"entry\":" + entryArray + "}";
@@ -895,7 +893,7 @@ public class JsonUtils {
public Map<String, String> entryArrayToMap(Execution execution, String entryArray, String keyNode, String valueNode) {
msoLogger.debug("Started Entry Array To Map Util Method");
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
//Populate Map
String entryListJson = "{ \"entry\":" + entryArray + "}";
JSONObject obj = new JSONObject(entryListJson);
@@ -926,7 +924,7 @@ public class JsonUtils {
public List<String> StringArrayToList(Execution execution, String jsonArrayOfStrings) {
msoLogger.debug("Started String Array To List Util Method");
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
//Populate List
String stringListJson = "{ \"strings\":" + jsonArrayOfStrings + "}";
JSONObject obj = new JSONObject(stringListJson);
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java
index 7b6d429912..1cf434052c 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.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.
@@ -60,7 +61,7 @@ import org.xml.sax.SAXException;
*/
public final class XmlTool {
- private static final Map<String, Integer> ENTITIES = new HashMap<String, Integer>();
+ private static final Map<String, Integer> ENTITIES = new HashMap<>();
private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.BPEL);
static {
ENTITIES.put("amp", new Integer(38));
@@ -70,6 +71,12 @@ public final class XmlTool {
}
/**
+ * Instantiation is not allowed.
+ */
+ private XmlTool() {
+ }
+
+ /**
* Normalizes and formats XML. This method consolidates and moves all namespace
* declarations to the root element. The result will not have an XML prolog or
* a trailing newline.
@@ -377,10 +384,4 @@ public final class XmlTool {
// return the modified String representation of the XML
return Optional.of(writer.toString().trim());
}
-
- /**
- * Instantiation is not allowed.
- */
- private XmlTool() {
- }
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericE2EServiceInstance.groovy
new file mode 100644
index 0000000000..3302210416
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericE2EServiceInstance.groovy
@@ -0,0 +1,160 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - SO
+ * ================================================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.infrastructure.scripts;
+
+import static org.apache.commons.lang3.StringUtils.*;
+import groovy.xml.XmlUtil
+import groovy.json.*
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
+import org.openecomp.mso.bpmn.common.scripts.VidUtils
+import org.openecomp.mso.bpmn.core.WorkflowException
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.rest.APIResponse
+
+import java.util.UUID;
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.runtime.Execution
+import org.apache.commons.lang3.*
+import org.apache.commons.codec.binary.Base64;
+import org.springframework.web.util.UriUtils
+
+/**
+ * This groovy class supports the <class>CreateGenericE2EServiceInstance.bpmn</class> process.
+ * flow for E2E ServiceInstance Create
+ */
+public class CreateGenericE2EServiceInstance extends AbstractServiceTaskProcessor {
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ VidUtils vidUtils = new VidUtils()
+
+ /**
+ * Pre Process the BPMN Flow Request
+ * Inclouds:
+ * Deal with the parameters
+ * generate the service instance id
+ * generate the operation id
+ */
+ public void preProcessRequest (Execution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ String msg = ""
+ utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled)
+ try {
+
+ String siRequest = execution.getVariable("bpmnRequest")
+ utils.logAudit(siRequest)
+
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+ utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled)
+
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)) {
+ serviceInstanceId = UUID.randomUUID().toString()
+ }
+ utils.log("DEBUG", "Generated new Service Instance:" + serviceInstanceId, isDebugEnabled)
+ serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8")
+ execution.setVariable("serviceInstanceId", serviceInstanceId)
+
+ String operationId = execution.getVariable("operationId")
+ if (isBlank(operationId)) {
+ operationId = UUID.randomUUID().toString()
+ }
+ utils.log("DEBUG", "Generated new Service Instance Operation:" + operationId, isDebugEnabled)
+ serviceInstanceId = UriUtils.encode(operationId,"UTF-8")
+ execution.setVariable("operationId", operationId)
+ //subscriberInfo, TBD , there is no globalSubscriberId in R1 for E2E Service.
+ //requestInfo TBD , there is no requestDetails for R1 E2E service
+
+ //TBD need to insert operationInfo to RequestDb
+
+ //set service Instance Name
+ execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(siRequest, "service.name"))
+ execution.setVariable("serviceDescription", jsonUtil.getJsonValue(siRequest, "service.description"))
+ execution.setVariable("templateId", jsonUtil.getJsonValue(siRequest, "service.templateId"))
+
+ //serviceParamters
+ String serviceParamters = jsonUtil.getJsonValue(siRequest, "service.parameters")
+ if (isBlank(serviceParamters)) {
+ msg = "Input service paramters is null"
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("serviceParamters", serviceParamters)
+ }
+
+ utils.log("DEBUG", "service parameters:" + serviceParamters, isDebugEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
+ }
+
+ /**
+ * send the sync response
+ * the response incloudes the instance id and the operation id
+ */
+ public void sendSyncResponse(Execution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
+
+ try {
+ String requestId = execution.getVariable("msoRequestId")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String operationId = execution.getVariable("operationId")
+ // RESTResponse for API Handler (APIH) Reply Task
+ String createServiceRestResponse = """{"service":{"serviceId":"${serviceInstanceId}","operationId":"${operationId}"}}""".trim()
+ utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + createServiceRestResponse, isDebugEnabled)
+ sendWorkflowResponse(execution, 202, createServiceRestResponse)
+ execution.setVariable("sentSyncResponse", true)
+
+ } catch (Exception ex) {
+ String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
+ }
+
+ public void preCreateRequest(Execution execution) {
+ }
+
+ public void postConfigRequest(Execution execution) {
+ }
+
+ public void preVFCRequest(Execution execution) {
+ }
+
+ public void preAdaptorDataRequest(Execution execution) {
+ }
+
+ public void preSDNCRequest(Execution execution) {
+ }
+}
diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/FileUtil.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/FileUtil.java
index a2076331a3..40539fa1bd 100644
--- a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/FileUtil.java
+++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/FileUtil.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -22,9 +23,26 @@ package org.openecomp.mso.bpmn.mock;
import java.io.IOException;
import java.io.InputStream;
+import org.openecomp.mso.logger.MsoLogger;
+/**
+ *
+ * File utility class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Sep 15, 2017
+ */
public class FileUtil {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+
+ private FileUtil() {
+ /**
+ * Constructor.
+ */
+ }
/**
* Read the specified resource file and return the contents as a String.
*
@@ -42,6 +60,7 @@ public class FileUtil {
stream.close();
return new String(bytes);
} catch (IOException e) {
+ LOGGER.debug("Exception:", e);
return "";
}
}
diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java
index 1f17a8bf31..848751f055 100644
--- a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java
+++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java
@@ -127,7 +127,7 @@ public class SDNCAdapterMockTransformer extends ResponseTransformer {
} catch (InterruptedException e1) {
LOGGER.debug("Exception :",e1);
}
- System.out.println("Sending callback response:" + callbackUrl);
+ LOGGER.debug("Sending callback response:" + callbackUrl);
ClientRequest request = new ClientRequest(callbackUrl);
request.body("text/xml", payLoad);
System.err.println(payLoad);
diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java
index b782c05d38..36abbdc5ca 100644
--- a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java
+++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java
@@ -117,16 +117,16 @@ public class SDNCAdapterNetworkTopologyMockTransformer extends ResponseTransform
// TODO Auto-generated catch block
LOGGER.debug("Exception :",e1);
}
- System.out.println("Sending callback response to url: " + callbackUrl);
+ LOGGER.debug("Sending callback response to url: " + callbackUrl);
ClientRequest request = new ClientRequest(callbackUrl);
request.body("text/xml", payLoad);
//System.err.println(payLoad);
try {
ClientResponse result = request.post();
- System.out.println("Successfully posted callback? Status: " + result.getStatus());
+ LOGGER.debug("Successfully posted callback? Status: " + result.getStatus());
} catch (Exception e) {
// TODO Auto-generated catch block
- System.out.println("catch error in - request.post() ");
+ LOGGER.debug("catch error in - request.post() ");
LOGGER.debug("Exception :",e);
}
}
diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java
index ebedca8550..5bcab6a2ab 100644
--- a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java
+++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java
@@ -132,18 +132,18 @@ public class VnfAdapterCreateMockTransformer extends ResponseTransformer {
// TODO Auto-generated catch block
LOGGER.debug("Exception :",e1);
}
- System.out.println("Sending callback response to url: " + callbackUrl);
+ LOGGER.debug("Sending callback response to url: " + callbackUrl);
ClientRequest request = new ClientRequest(callbackUrl);
request.body("text/xml", payLoad);
//System.out.println("payLoad: " + payLoad);
try {
ClientResponse result = request.post();
- System.out.println("Successfully posted callback? Status: " + result.getStatus());
+ LOGGER.debug("Successfully posted callback? Status: " + result.getStatus());
//System.err.println("Successfully posted callback:" + result.getStatus());
} catch (Exception e) {
// TODO Auto-generated catch block
- System.out.println("catch error in - request.post() ");
+ LOGGER.debug("catch error in - request.post() ");
LOGGER.debug("Exception :",e);
}
}
diff --git a/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/HostNameVerifier.java b/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/HostNameVerifier.java
index 81a2bd3b96..ffef5f9385 100644
--- a/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/HostNameVerifier.java
+++ b/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/HostNameVerifier.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.
@@ -23,6 +24,7 @@ package org.openecomp.mso.rest;
import javax.net.ssl.SSLException;
import org.apache.http.conn.ssl.AbstractVerifier;
+import org.openecomp.mso.logger.MsoLogger;
/**
* @version 1.0
@@ -31,6 +33,8 @@ import org.apache.http.conn.ssl.AbstractVerifier;
*/
public class HostNameVerifier extends AbstractVerifier {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+
public final void verify(
final String host,
final String[] cns,
@@ -38,7 +42,7 @@ public class HostNameVerifier extends AbstractVerifier {
try {
verify(host, cns, subjectAlts, true);
} catch (SSLException sex) {
-
+ LOGGER.debug("Exception:", sex);
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml
index 4490d78648..f9150fabf0 100644
--- a/mso-api-handlers/mso-api-handler-infra/pom.xml
+++ b/mso-api-handlers/mso-api-handler-infra/pom.xml
@@ -240,6 +240,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java
index f3273cf144..f6abcc35b1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java
@@ -143,6 +143,7 @@ public class ManualTasks {
msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", requestUrl, null);
} catch (Exception e) {
+ msoLogger.debug ("Exception:", e);
msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", requestUrl, null);
msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
index eab232d4d5..5328780b21 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
@@ -149,7 +149,7 @@ public class MsoRequest {
RequestError re = new RequestError();
- if(exceptionType.name().equals("PolicyException")){
+ if("PolicyException".equals(exceptionType.name())){
PolicyException pe = new PolicyException();
pe.setMessageId(messageId);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
index e32f1535d4..66a14db610 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
@@ -73,10 +73,10 @@ import com.wordnik.swagger.annotations.ApiOperation;
@Api(value="/serviceInstances",description="API Requests for Service Instances")
public class ServiceInstances {
- private HashMap<String, String> instanceIdMap = new HashMap<String,String>();
+ private HashMap<String, String> instanceIdMap = new HashMap<>();
private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
- public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+ public static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
@POST
@Path("/{version:[vV][3-5]}")
@@ -404,7 +404,7 @@ public class ServiceInstances {
String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
try {
- if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance))){
+ if(!(instanceName==null && "service".equals(requestScope) && (action == Action.createInstance || action == Action.activateInstance))){
dup = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
}
} catch (Exception e) {
@@ -423,7 +423,7 @@ public class ServiceInstances {
if (dup != null) {
// Found the duplicate record. Return the appropriate error.
- String instance = null;
+ String instance;
if(instanceName != null){
instance = instanceName;
}else{
@@ -533,7 +533,7 @@ public class ServiceInstances {
String asdcServiceModelVersion = msoRequest.getAsdcServiceModelVersion ();
// Get VF Module-specific base module indicator
- VfModule vfm = null;
+ VfModule vfm;
String modelVersionId = msoRequest.getModelInfo().getModelVersionId();
@@ -627,7 +627,7 @@ public class ServiceInstances {
// Capture audit event
msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ());
- System.out.println("URL : " + requestClient.getUrl ());
+ msoLogger.debug ("URL : " + requestClient.getUrl ());
response = requestClient.post(requestId, isBaseVfModule, recipeLookupResult.getRecipeTimeout (), action.name (),
serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId,
@@ -684,7 +684,7 @@ public class ServiceInstances {
msoLogger.debug ("End of the transaction, the final response is: " + (String) camundaJSONResponseBody);
return Response.status (HttpStatus.SC_ACCEPTED).entity (camundaJSONResponseBody).build ();
} else {
- List<String> variables = new ArrayList<String>();
+ List<String> variables = new ArrayList<>();
variables.add(bpelStatus + "");
String camundaJSONResponseBody = respHandler.getResponseBody ();
if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) {
@@ -754,7 +754,7 @@ public class ServiceInstances {
// TODO need to make this a configurable property
String defaultServiceModelName = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
- Service serviceRecord = null;
+ Service serviceRecord;
ModelInfo modelInfo = msoRequest.getModelInfo();
if(msoRequest.getALaCarteFlag()){
serviceRecord = db.getServiceByModelName(defaultServiceModelName);
@@ -840,7 +840,7 @@ public class ServiceInstances {
// 1. If modelCustomizationName is NOT provided on a vnf/vfModule request, use modelCustomizationId to look it up in our catalog to construct vnf-type value to pass to BPMN.
VnfResource vnfResource = null;
- VnfResourceCustomization vrc = null;
+ VnfResourceCustomization vrc;
// Validation for vnfResource
if(modelCustomizationId!=null) {
@@ -893,7 +893,7 @@ public class ServiceInstances {
if(!msoRequest.getALaCarteFlag()) {
VfModuleCustomization vfmc = null;
- VnfResourceCustomization vnfrc = null;
+ VnfResourceCustomization vnfrc;
VfModule vfModule = null;
if( modelInfo.getModelCustomizationId() != null) {
@@ -971,7 +971,7 @@ public class ServiceInstances {
ModelInfo modelInfo = msoRequest.getModelInfo();
String modelName = modelInfo.getModelName();
- Recipe recipe = null;
+ Recipe recipe;
if(msoRequest.getALaCarteFlag()){
recipe = db.getNetworkRecipe(defaultNetworkType, action.name());
}else{
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java
new file mode 100644
index 0000000000..f656d896fe
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java
@@ -0,0 +1,469 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.ProtocolVersion;
+import org.apache.http.entity.BasicHttpEntity;
+import org.apache.http.message.BasicHttpResponse;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
+import org.junit.Test;
+import org.openecomp.mso.apihandler.common.CamundaClient;
+import org.openecomp.mso.apihandler.common.RequestClient;
+import org.openecomp.mso.apihandler.common.RequestClientFactory;
+import org.openecomp.mso.db.catalog.CatalogDatabase;
+import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
+import org.openecomp.mso.properties.MsoJavaProperties;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+public class E2EServiceInstancesTest {
+
+
+ @Test
+ public void createE2EServiceInstanceTestSuccess(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return null;
+ }
+ };
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
+ return 0;
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName (String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction, String serviceInstanceId,
+ String vnfId, String vfModuleId, String volumeGroupId, String networkId,
+ String serviceType, String vnfType, String vfModuleType, String networkType,
+ String requestDetails){
+ ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
+ HttpResponse resp = new BasicHttpResponse(pv,202, "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"E2EService\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ assertTrue(resp.getStatus() == 202);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestBpelHTTPException(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return null;
+ }
+ };
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
+ return 0;
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName (String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction, String serviceInstanceId,
+ String vnfId, String vfModuleId, String volumeGroupId, String networkId,
+ String serviceType, String vnfType, String vfModuleType, String networkType,
+ String requestDetails){
+ ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
+ HttpResponse resp = new BasicHttpResponse(pv,500, "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"E2EService\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Request Failed due to BPEL error with HTTP Status") != -1);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestBpelHTTPExceptionWithNullREsponseBody(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return null;
+ }
+ };
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
+ return 0;
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName (String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction, String serviceInstanceId,
+ String vnfId, String vfModuleId, String volumeGroupId, String networkId,
+ String serviceType, String vnfType, String vfModuleType, String networkType,
+ String requestDetails){
+ ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
+ HttpResponse resp = new BasicHttpResponse(pv,500, "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"E2EService\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Request Failed due to BPEL error with HTTP Status") != -1);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestNullBPELResponse(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return null;
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName (String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction, String serviceInstanceId,
+ String vnfId, String vfModuleId, String volumeGroupId, String networkId,
+ String serviceType, String vnfType, String vfModuleType, String networkType,
+ String requestDetails){
+ HttpResponse resp = null;
+ return resp;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"E2EService\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("bpelResponse is null") != -1);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestBPMNNullREsponse(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return null;
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName (String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String camundaReqXML, String requestId,
+ String requestTimeout, String schemaVersion, String serviceInstanceId, String action){
+ HttpResponse resp = null;
+ return resp;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"E2EService\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Failed calling bpmn null") != -1);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestNullBpmn(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return null;
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName (String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"E2EService\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Failed calling bpmn properties is null") != -1);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestNullReceipe(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return null;
+ }
+ };
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"E2EService\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Recipe could not be retrieved from catalog DB null") != -1);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestNullDBResponse(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return null;
+ }
+ };
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"e2eservice\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Recipe does not exist in catalog DB") != -1);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestInvalidRequest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ List<InfraActiveRequests> activeReqlist = new ArrayList<>();
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("39493992");
+
+ activeReqlist.add(req);
+ return activeReqlist;
+ }
+ };
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"e2eservice\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("The existing request must finish or be cleaned up before proceeding.") != -1);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestEmptyDBQuery(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return Collections.EMPTY_LIST;
+ }
+ };
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"e2eservice\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Recipe does not exist in catalog DB") != -1);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestDBQueryFail(){
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"e2eservice\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ @Test
+ public void createE2EServiceInstanceTestForEmptyRequest(){
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "";
+ Response resp = instance.createE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Mapping of request to JSON object failed. No content to map to Object due to end of input") != -1);
+ }
+
+ @Test
+ public void deleteE2EServiceInstanceTestNormal(){
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"e2eservice\",\"serviceDefId\":\"37889593\",\"templateId\":\"2000039\",\"parameters\":{\"domainHost\":\"test\"}}}";
+ Response resp = instance.deleteE2EServiceInstance(request, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java
new file mode 100644
index 0000000000..ee789a60ca
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java
@@ -0,0 +1,491 @@
+package org.openecomp.mso.apihandlerinfra;
+
+
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
+import org.junit.Test;
+
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+public class ServiceInstanceTest {
+
+ /*** Create Service Instance Test Cases ***/
+
+ @Test
+ public void createServiceInstanceInvalidModelInfo(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v5");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid model-info is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNormalNullDBFatch(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return Collections.EMPTY_LIST;
+ }
+ };
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Recipe could not be retrieved from catalog DB null") != -1);
+ }
+
+
+ @Test
+ public void createServiceInstanceInvalidModelVersionId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v5");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid modelVersionId is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNullInstanceName(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid instanceName is specified") != -1);
+ }
+
+
+ @Test
+ public void createServiceInstanceNullModelInfo(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid model-info is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceInvalidModelInvariantId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"1234\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid modelType is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNullModelVersion(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid modelType is specified") != -1);
+ }
+
+
+ @Test
+ public void createServiceInstanceNullModelType(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid modelType is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceInvalidModelType(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"testmodel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Mapping of request to JSON object failed.") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNullModelName(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid modelName is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceInvalidVersionForAutoBuildVfModules(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": true},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. AutoBuildVfModule is not valid in the v2 version") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNullRequestParameter(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid subscriptionServiceType is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNullSubscriptionType(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid subscriptionServiceType is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceAnbormalInvalidJson(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"name\":\"test\"}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ }
+
+ /*** Activate Service Instance Test Cases ***/
+
+ @Test
+ public void activateServiceInstanceAnbormalInvalidJson(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"name\":\"test\"}";
+ Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ }
+
+ @Test
+ public void activateServiceInstanceInvalidModelVersionId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId in relatedInstance is specified") != -1);
+ }
+
+ @Test
+ public void activateServiceInstanceInvalidServiceInstanceId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid serviceInstanceId matching the serviceInstanceId in request URI is specified") != -1);
+ }
+
+ @Test
+ public void activateServiceInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Deactivate Service Instance Test Cases ***/
+
+ @Test
+ public void deactivateServiceInstanceAnbormalInvalidJson(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"name\":\"test\"}";
+ Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ }
+
+ @Test
+ public void deactivateServiceInstanceInvalidModelVersionId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId in relatedInstance is specified") != -1);
+ }
+
+ @Test
+ public void deactivateServiceInstanceInvalidServiceInstanceId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid serviceInstanceId matching the serviceInstanceId in request URI is specified") != -1);
+ }
+
+ @Test
+ public void deactivateServiceInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Delete Service Instance Test Cases ***/
+
+ @Test
+ public void deleteServiceInstanceAnbormalInvalidJson(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"name\":\"test\"}";
+ Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ }
+
+ @Test
+ public void deleteServiceInstanceInvalidModelVersionId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId is specified") != -1);
+ }
+
+ @Test
+ public void deleteServiceInstanceInvalidServiceInstanceId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId is specified") != -1);
+ }
+
+ @Test
+ public void deleteServiceInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Create Vnf Instance Test Cases ***/
+
+ @Test
+ public void createVNFInstanceTestInvalidCloudConfiguration(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid cloudConfiguration is specified") != -1);
+ }
+
+ @Test
+ public void createVNFInstanceTestInvalidIcpCloudRegionId(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid lcpCloudRegionId is specified") != -1);
+ }
+
+ @Test
+ public void createVNFInstanceTestInvalidTenantId(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid tenantId is specified") != -1);
+ }
+
+ @Test
+ public void createVNFInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Replace Vnf Instance Test Cases ***/
+ @Test
+ public void replaceVNFInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.replaceVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Update Vnf Instance Test Cases ***/
+
+ @Test
+ public void updateVNFInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.updateVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Update Vnf Instance Test Cases ***/
+
+ @Test
+ public void deleteVNFInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.deleteVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
index 8db4548bad..254ae3bf39 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
@@ -332,7 +332,7 @@ public class RequestsDatabase {
}
}
catch (Exception e){
- msoLogger.debug("Exception in getOrchestrationFiltersFromInfraActive(): + " + e.getMessage());
+ msoLogger.debug("Exception in getOrchestrationFiltersFromInfraActive(): + " + e.getMessage(), e);
return null;
}
}