summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java10
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java37
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java15
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java9
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java9
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java1
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java14
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java18
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java58
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java1
-rw-r--r--adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml18
-rw-r--r--adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml16
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java276
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java87
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/LocationConstraint.java10
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java35
-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/model/NsParameters.java11
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VimLocation.java (renamed from adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java)95
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java359
-rw-r--r--adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java369
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java142
24 files changed, 847 insertions, 775 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java
index 0777c60278..052f09ab85 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java
@@ -22,17 +22,15 @@ package org.openecomp.mso.cloud;
import java.io.IOException;
import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
-import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
public class IdentityAuthenticationTypeJsonSerializer extends JsonSerializer<IdentityAuthenticationTypeAbstract> {
@Override
public void serialize(IdentityAuthenticationTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
- throws IOException, JsonProcessingException {
+ throws IOException {
jsonGenerator.writeObject(tmpObj.toString());
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java
index ff1cd43b05..b8a7a5571c 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java
@@ -61,6 +61,6 @@ public abstract class MsoException extends Exception
if (this.context == null)
return getMessage();
else
- return ("[" + context + "] " + getMessage());
+ return "[" + context + "] " + getMessage();
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java
index a62339d0f4..8aa8d3f5e8 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java
@@ -71,7 +71,13 @@ public class MsoOpenstackException extends MsoException
@Override
public String toString () {
- String error = "" + statusCode + " " + statusMessage + ": " + errorDetail;
- return error;
+ StringBuilder error = new StringBuilder();
+ error.append("");
+ error.append(statusCode);
+ error.append(" ");
+ error.append(statusMessage);
+ error.append(": ");
+ error.append(errorDetail);
+ return error.toString();
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java
index cd5879c093..e47dea6350 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java
@@ -21,7 +21,6 @@
package org.openecomp.mso.openstack.utils;
-import java.lang.StackTraceElement;
import org.openecomp.mso.logger.MsoAlarmLogger;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.logger.MessageEnum;
@@ -41,7 +40,7 @@ import com.woorea.openstack.quantum.model.NeutronError;
public class MsoCommonUtils {
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+ private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
protected static String retryDelayProp = "ecomp.mso.adapters.po.retryDelay";
@@ -111,18 +110,18 @@ public class MsoCommonUtils {
boolean retry = false;
if (retryCodes != null ) {
int code = e.getStatus();
- LOGGER.debug ("Config values RetryDelay:" + retryDelay + " RetryCount:" + retryCount + " RetryCodes:" + retryCodes + " ResponseCode:" + code);
+ logger.debug ("Config values RetryDelay:" + retryDelay + " RetryCount:" + retryCount + " RetryCodes:" + retryCodes + " ResponseCode:" + code);
for (String rCode : retryCodes.split (",")) {
try {
if (retryCount > 0 && code == Integer.parseInt (rCode))
{
retryCount--;
retry = true;
- LOGGER.debug ("OpenStackResponseException ResponseCode:" + code + " at:" + parentServiceMethodName + " request:" + requestType + " Retry indicated. Attempts remaining:" + retryCount);
+ logger.debug ("OpenStackResponseException ResponseCode:" + code + " at:" + parentServiceMethodName + " request:" + requestType + " Retry indicated. Attempts remaining:" + retryCount);
break;
}
} catch (NumberFormatException e1) {
- LOGGER.error (MessageEnum.RA_CONFIG_EXC, "No retries. Exception in parsing retry code in config:" + rCode, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in parsing retry code in config");
+ logger.error (MessageEnum.RA_CONFIG_EXC, "No retries. Exception in parsing retry code in config:" + rCode, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in parsing retry code in config");
throw e;
}
}
@@ -132,7 +131,7 @@ public class MsoCommonUtils {
try {
Thread.sleep (retryDelay * 1000L);
} catch (InterruptedException e1) {
- LOGGER.debug ("Thread interrupted while sleeping", e1);
+ logger.debug ("Thread interrupted while sleeping", e1);
}
}
else
@@ -143,11 +142,11 @@ public class MsoCommonUtils {
if (retryCount > 0)
{
retryCount--;
- LOGGER.debug ("OpenstackConnectException at:" + parentServiceMethodName + " request:" + requestType + " Retry indicated. Attempts remaining:" + retryCount);
+ logger.debug ("OpenstackConnectException at:" + parentServiceMethodName + " request:" + requestType + " Retry indicated. Attempts remaining:" + retryCount);
try {
Thread.sleep (retryDelay * 1000L);
} catch (InterruptedException e1) {
- LOGGER.debug ("Thread interrupted while sleeping", e1);
+ logger.debug ("Thread interrupted while sleeping", e1);
}
}
else
@@ -170,11 +169,11 @@ public class MsoCommonUtils {
try {
// Failed Keystone calls return an Error entity body.
Error error = re.getResponse ().getErrorEntity (Error.class);
- LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "Openstack Keystone Error on " + context + ": " + error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone Error on " + context);
+ logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "Openstack Keystone Error on " + context + ": " + error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone Error on " + context);
me = new MsoOpenstackException (error.getCode (), error.getTitle (), error.getMessage ());
} catch (Exception e2) {
// Can't parse the body as an "Error". Report the HTTP error
- LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "HTTP Error on " + context + ": " + re.getStatus() + "," + re.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "HTTP Error on " + context, e2);
+ logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "HTTP Error on " + context + ": " + re.getStatus() + "," + re.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "HTTP Error on " + context, e2);
me = new MsoOpenstackException (re.getStatus (), re.getMessage (), "");
}
@@ -192,7 +191,7 @@ public class MsoCommonUtils {
me.addContext (context);
// Generate an alarm for all connection errors.
- LOGGER.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "Openstack Keystone connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone connection error on " + context);
+ logger.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "Openstack Keystone connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone connection error on " + context);
alarmLogger.sendAlarm ("KeystoneIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ());
}
@@ -212,16 +211,16 @@ public class MsoCommonUtils {
try {
// Failed Heat calls return an Explanation entity body.
Explanation explanation = re.getResponse ().getErrorEntity (Explanation.class);
- LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Error on " + context + ": " + explanation.toString(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - Openstack Error on " + context);
+ logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Error on " + context + ": " + explanation.toString(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - Openstack Error on " + context);
String fullError = explanation.getExplanation() + ", error.type=" + explanation.getError().getType() + ", error.message=" + explanation.getError().getMessage();
- LOGGER.debug(fullError);
+ logger.debug(fullError);
me = new MsoOpenstackException (explanation.getCode (),
explanation.getTitle (),
//explanation.getExplanation ());
fullError);
} catch (Exception e2) {
// Couldn't parse the body as an "Explanation". Report the original HTTP error.
- LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "HTTP Error on " + context + ": " + re.getStatus() + "," + e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - HTTP Error on " + context, e2);
+ logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "HTTP Error on " + context + ": " + re.getStatus() + "," + e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - HTTP Error on " + context, e2);
me = new MsoOpenstackException (re.getStatus (), re.getMessage (), "");
}
@@ -240,7 +239,7 @@ public class MsoCommonUtils {
// Generate an alarm for all connection errors.
alarmLogger.sendAlarm ("HeatIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ());
- LOGGER.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Heat connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Heat connection error on " + context);
+ logger.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Heat connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Heat connection error on " + context);
}
return me;
@@ -259,11 +258,11 @@ public class MsoCommonUtils {
try {
// Failed Neutron calls return an NeutronError entity body
NeutronError error = re.getResponse ().getErrorEntity (NeutronError.class);
- LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Error on " + context + ": " + error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Error on " + context);
+ logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Error on " + context + ": " + error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Error on " + context);
me = new MsoOpenstackException (re.getStatus (), error.getType (), error.getMessage ());
} catch (Exception e2) {
// Couldn't parse body as a NeutronError. Report the HTTP error.
- LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "HTTP Error on " + context + ": " + re.getStatus() + "," + e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack HTTP Error on " + context, e2);
+ logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "HTTP Error on " + context + ": " + re.getStatus() + "," + e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack HTTP Error on " + context, e2);
me = new MsoOpenstackException (re.getStatus (), re.getMessage (), null);
}
@@ -282,7 +281,7 @@ public class MsoCommonUtils {
// Generate an alarm for all connection errors.
alarmLogger.sendAlarm ("NeutronIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ());
- LOGGER.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Connection error on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Connection error on "+ context);
+ logger.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Connection error on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Connection error on "+ context);
}
return me;
@@ -300,7 +299,7 @@ public class MsoCommonUtils {
me.setCategory (MsoExceptionCategory.INTERNAL);
// Always generate an alarm for internal exceptions
- LOGGER.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "An exception occured on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "An exception occured on "+ context);
+ logger.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "An exception occured on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "An exception occured on "+ context);
alarmLogger.sendAlarm ("AdapterInternalError", MsoAlarmLogger.CRITICAL, me.getContextMessage ());
return me;
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 31e2fca4c1..a2e605f897 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
@@ -56,10 +56,18 @@ public class MsoHeatEnvironmentResource {
public void setValue(String value) {
this.value = value;
}
+
+ @Override
public String toString() {
- return "\"" + this.name + "\": " + this.value;
+ StringBuilder str = new StringBuilder();
+ str.append("\"");
+ str.append(this.name);
+ str.append("\": ");
+ str.append(this.value);
+ return str.toString();
}
-
+
+ @Override
public boolean equals(Object o) {
if (!(o instanceof MsoHeatEnvironmentResource)) {
return false;
@@ -74,7 +82,8 @@ public class MsoHeatEnvironmentResource {
}
return false;
}
-
+
+ @Override
public int hashCode() {
int result = 0;
try {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java
index bceb7496ab..be49cd947f 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java
@@ -33,11 +33,12 @@ import java.lang.reflect.InvocationTargetException;
public class MsoTenantUtilsFactory {
private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
- private CloudConfigFactory cloudConfigFactory= new CloudConfigFactory();
+
+ private CloudConfigFactory cloudConfigFactory= new CloudConfigFactory();
protected CloudConfig cloudConfig;
protected MsoJavaProperties msoProps = null;
private String msoPropID;
-
+
public MsoTenantUtilsFactory (String msoPropID) {
this.msoPropID = msoPropID;
}
@@ -45,7 +46,7 @@ public class MsoTenantUtilsFactory {
//based on Cloud IdentityServerType returns ORM or KEYSTONE Utils
public MsoTenantUtils getTenantUtils(String cloudSiteId) {
- // Obtain the cloud site information
+ // Obtain the cloud site information
cloudConfig = cloudConfigFactory.getCloudConfig();
CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId);
@@ -54,7 +55,7 @@ public class MsoTenantUtilsFactory {
public MsoTenantUtils getTenantUtilsByServerType(String serverType) {
- MsoTenantUtils tenantU = null;
+ MsoTenantUtils tenantU;
if (CloudIdentity.IdentityServerType.KEYSTONE.toString().equals(serverType)) {
tenantU = new MsoKeystoneUtils (msoPropID);
} else {
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 bd649e867f..c227d72f0c 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
@@ -32,7 +32,6 @@ import java.util.Set;
import java.util.Map.Entry;
import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
import org.codehaus.jackson.map.ObjectMapper;
-import java.util.LinkedHashMap;
import org.yaml.snakeyaml.Yaml;
@@ -63,7 +62,7 @@ public class MsoYamlEditorWithEnvt {
public synchronized Set <MsoHeatEnvironmentParameter> getParameterListFromEnvt() {
// In an environment entry, the parameters section can only contain the name:value -
// not other attributes.
- Set <MsoHeatEnvironmentParameter> paramSet = new HashSet<MsoHeatEnvironmentParameter>();
+ Set <MsoHeatEnvironmentParameter> paramSet = new HashSet<>();
Map<String, Object> resourceMap = null;
try {
resourceMap = (Map<String,Object>) yml.get("parameters");
@@ -79,13 +78,9 @@ public class MsoYamlEditorWithEnvt {
while (it.hasNext()) {
MsoHeatEnvironmentParameter hep = new MsoHeatEnvironmentParameter();
Map.Entry <String, Object> pair = it.next();
- //Map<String, String> resourceEntry = (Map <String, String>) pair.getValue();
- //String value = null;
- String value = null;
+ String value;
Object obj = pair.getValue();
if (obj instanceof java.lang.String) {
- //value = (String) pair.getValue();
- // handle block scalar - literals and folded:
value = yaml.dump(obj);
// but this adds an extra '\n' at the end - which won't hurt - but we don't need it
value = value.substring(0, value.length() - 1);
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java
index f3f252d96e..2395495a36 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java
@@ -30,7 +30,6 @@ 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;
import org.openecomp.mso.openstack.beans.VnfStatus;
@XmlRootElement(name = "queryVfModuleResponse")
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java
index 6c571f3e06..f51b27282c 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java
@@ -241,9 +241,6 @@ public class BpelRestClient {
LOGGER.debug("Sending to BPEL server: "+bpelUrl);
LOGGER.debug("Content is: "+toBpelStr);
- //Client 4.3+
- CloseableHttpClient client = null;
-
//POST
HttpPost post = new HttpPost(bpelUrl);
if (credentials != null && !credentials.isEmpty())
@@ -263,8 +260,7 @@ public class BpelRestClient {
//Client 4.3+
//Execute & GetResponse
- try {
- client = HttpClients.createDefault();
+ try (CloseableHttpClient client = HttpClients.createDefault()) {
CloseableHttpResponse response = client.execute(post);
if (response != null) {
lastResponseCode = response.getStatusLine().getStatusCode();
@@ -279,14 +275,6 @@ public class BpelRestClient {
LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception sending Bpel notification", e);
lastResponseCode = 900;
lastResponse = "";
- } finally {
- if(client != null){
- try {
- client.close();
- } catch (IOException e) {
- LOGGER.debug("Exception while closing client", e);
- }
- }
}
LOGGER.debug("Response code from BPEL server: "+lastResponseCode);
LOGGER.debug("Response body is: "+lastResponse);
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java
index 43273df14f..877012c2fe 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java
@@ -27,6 +27,7 @@ import javax.xml.bind.annotation.XmlElement;
import org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbException;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.ResourceOperationStatus;
/**
* MSO Request DB Adapter Web Service
@@ -59,6 +60,7 @@ public interface MsoRequestsDbAdapter {
@WebMethod
public void updateServiceOperationStatus (@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
@WebParam(name = "operationId") @XmlElement(required = false) String operationId,
+ @WebParam(name = "serviceName") @XmlElement(required = false) String serviceName,
@WebParam(name = "operationType") @XmlElement(required = false) String operationType,
@WebParam(name = "userId") @XmlElement(required = false) String userId,
@WebParam(name = "result") @XmlElement(required = false) String result,
@@ -71,5 +73,21 @@ public interface MsoRequestsDbAdapter {
@WebParam(name = "operationId") @XmlElement(required = true) String operationId,
@WebParam(name = "operationType") @XmlElement(required = true) String operationType,
@WebParam(name = "resourceTemplateUUIDs") @XmlElement(required = true) String resourceTemplateUUIDs) throws MsoRequestsDbException;
+
+ @WebMethod
+ public ResourceOperationStatus getResourceOperationStatus (@WebParam(name="serviceId") @XmlElement(required = true) String serviceId,
+ @WebParam(name = "operationId") @XmlElement(required = true) String operationId,
+ @WebParam(name = "resourceTemplateUUID") @XmlElement(required = true) String resourceTemplateUUID) throws MsoRequestsDbException;
+ @WebMethod
+ public void updateResourceOperationStatus (@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
+ @WebParam(name = "operationId") @XmlElement(required = true) String operationId,
+ @WebParam(name = "resourceTemplateUUID") @XmlElement(required = true) String resourceTemplateUUID,
+ @WebParam(name = "operType") @XmlElement(required = false) String operType,
+ @WebParam(name = "resourceInstanceID") @XmlElement(required = false) String resourceInstanceID,
+ @WebParam(name = "jobId") @XmlElement(required = false) String jobId,
+ @WebParam(name = "status") @XmlElement(required = false) String status,
+ @WebParam(name = "progress") @XmlElement(required = false) String progress,
+ @WebParam(name = "errorCode") @XmlElement(required = false) String errorCode,
+ @WebParam(name = "statusDescription") @XmlElement(required = false) String statusDescription) throws MsoRequestsDbException;
}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
index 87be2e1ccb..0bdead4835 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
@@ -22,7 +22,6 @@ package org.openecomp.mso.adapters.requestsdb;
import java.sql.Timestamp;
-import javax.jws.WebMethod;
import javax.jws.WebService;
import org.hibernate.HibernateException;
@@ -283,11 +282,13 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
* @since ONAP Amsterdam Release
*/
@Override
- public void updateServiceOperationStatus(String serviceId, String operationId, String operationType, String userId,
+ public void updateServiceOperationStatus(String serviceId, String operationId, String serviceName,String operationType, String userId,
String result, String operationContent, String progress, String reason) throws MsoRequestsDbException {
OperationStatus operStatus = new OperationStatus();
+ operStatus.setResult(RequestsDbConstant.Status.PROCESSING);
operStatus.setServiceId(serviceId);
operStatus.setOperationId(operationId);
+ operStatus.setServiceName(serviceName);
operStatus.setUserId(userId);
operStatus.setOperation(operationType);
operStatus.setReason(reason);
@@ -322,5 +323,56 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
RequestsDatabase.getInstance().updateResOperStatus(resourceStatus);
}
}
-
+
+ /**
+ * get resource operation status
+ * <br>
+ *
+ * @param serviceId
+ * @param operationId
+ * @param resourceUUID
+ * @return
+ * @throws MsoRequestsDbException
+ * @since ONAP Amsterdam Release
+ */
+ @Override
+ public ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID)
+ throws MsoRequestsDbException {
+ return RequestsDatabase.getInstance().getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID);
+ }
+
+ /**
+ * update resource operation status
+ * <br>
+ *
+ * @param serviceId
+ * @param operationId
+ * @param resourceUUID
+ * @param operationType
+ * @param resourceInstanceID
+ * @param jobId
+ * @param status
+ * @param progress
+ * @param errorCode
+ * @param statusDescription
+ * @throws MsoRequestsDbException
+ * @since ONAP Amsterdam Release
+ */
+ @Override
+ public void updateResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID,
+ String operType, String resourceInstanceID, String jobId, String status, String progress,
+ String errorCode, String statusDescription) throws MsoRequestsDbException {
+ ResourceOperationStatus resStatus = new ResourceOperationStatus();
+ resStatus.setServiceId(serviceId);
+ resStatus.setOperationId(operationId);
+ resStatus.setResourceTemplateUUID(resourceTemplateUUID);
+ resStatus.setOperType(operType);
+ resStatus.setResourceInstanceID(resourceInstanceID);
+ resStatus.setJobId(jobId);
+ resStatus.setStatus(status);
+ resStatus.setProgress(progress);
+ resStatus.setErrorCode(errorCode);
+ resStatus.setStatusDescription(statusDescription);
+ RequestsDatabase.getInstance().updateResOperStatus(resStatus);
+ }
}
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 d41291420e..a4d9f278ba 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
@@ -41,7 +41,6 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
-import javax.ejb.EJB;
import org.openecomp.mso.utils.UUIDChecker;
import org.w3c.dom.Document;
diff --git a/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml
index e7bc08ae83..fb268917f2 100644
--- a/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml
+++ b/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml
@@ -1,17 +1,21 @@
<jboss-deployment-structure>
<deployment>
- <!-- Exclusions allow you to prevent the server from automatically adding
- some dependencies -->
+ <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.log4j" />
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
+ <module name="org.jboss.resteasy.resteasy-jackson-provider" />
+ <module name="org.jboss.resteasy.resteasy-jettison-provider" />
</exclusions>
<dependencies>
- <module name="org.jboss.jandex" slot="main" />
- <module name="org.javassist" slot="main" />
- <module name="org.antlr" slot="main" />
- <module name="org.dom4j" slot="main" />
+ <module name="org.jboss.jandex" slot="main" />
+ <module name="org.javassist" slot="main" />
+ <module name="org.antlr" slot="main" />
+ <module name="org.dom4j" slot="main" />
+ <module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import" />
+ <!-- This module contain the ProviderBase class: -->
+ <module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" export="true" />
</dependencies>
</deployment>
-</jboss-deployment-structure> \ No newline at end of file
+</jboss-deployment-structure>
diff --git a/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml
index 0c198defa0..cd97471b5b 100644
--- a/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml
+++ b/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml
@@ -41,22 +41,10 @@
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
- <url-pattern>/vfcadapter/*</url-pattern>
+ <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
- <web-resource-name>SoapRequests</web-resource-name>
- <description>Soap Ingress Requests</description>
- <url-pattern>/VfcAdapter</url-pattern>
- <url-pattern>/VfcAdapterAsync</url-pattern>
- <http-method>POST</http-method>
- </web-resource-collection>
- <auth-constraint>
- <role-name>BPEL-Client</role-name>
- </auth-constraint>
- </security-constraint>
- <security-constraint>
- <web-resource-collection>
<web-resource-name>SiteStatus</web-resource-name>
<description>SiteStatus APIs</description>
<url-pattern>/rest/setStatus/*</url-pattern>
@@ -70,7 +58,7 @@
<web-resource-collection>
<web-resource-name>RestRequests</web-resource-name>
<description>Rest Ingress Requests</description>
- <url-pattern>/rest/v1/vfc/*</url-pattern>
+ <url-pattern>/rest/v1/vfcadapter/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
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 6c2ab4d081..ef3c1b79ca 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
@@ -20,7 +20,6 @@
package org.openecomp.mso.adapters.vfc;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.POST;
@@ -29,14 +28,12 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
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;
import org.openecomp.mso.adapters.vfc.util.JsonUtil;
-import org.openecomp.mso.adapters.vfc.util.RestfulUtil;
import org.openecomp.mso.adapters.vfc.util.ValidateUtil;
import org.openecomp.mso.logger.MsoLogger;
@@ -48,164 +45,149 @@ import org.openecomp.mso.logger.MsoLogger;
* @author
* @version ONAP Amsterdam Release 2017-08-28
*/
-@Path("/vfcadapter/v1")
+@Path("/v1/vfcadapter")
public class VfcAdapterRest {
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
- private final VfcManager driverMgr = new VfcManager();
+ private final VfcManager driverMgr = new VfcManager();
- public VfcAdapterRest() {
+ public VfcAdapterRest() {
- }
-
- /**
- * Create a NS <br>
- *
- * @param servletReq the http request
- * @return
- * @since ONAP Amsterdam Release
- */
- @POST
- @Path("/ns")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public Response createNfvoNs(HttpServletRequest servletReq) {
- // Step 1: get parameters from request for current node
- 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) {
- LOGGER.debug("ApplicationException: ", e);
- return e.buildErrorResponse();
}
- }
- /**
- * Delete NS instance<br>
- *
- * @param servletReq http request
- * @return response
- * @since ONAP Amsterdam Release
- */
- @DELETE
- @Path("/ns/{nsInstanceId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public Response deleteNfvoNs(HttpServletRequest servletReq,
- @PathParam("nsInstanceId") String nsInstanceId) {
- 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) {
- LOGGER.debug("ApplicationException: ", e);
- return e.buildErrorResponse();
+ /**
+ * Create a NS <br>
+ *
+ * @param servletReq the http request
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @POST
+ @Path("/ns")
+ @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ public Response createNfvoNs(String data) {
+ try {
+ ValidateUtil.assertObjectNotNull(data);
+ LOGGER.debug("body from request is {}" + data);
+ NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class);
+ RestfulResponse rsp = driverMgr.createNs(nsInput);
+ return buildResponse(rsp);
+ } catch(ApplicationException e) {
+ LOGGER.debug("ApplicationException: ", e);
+ return e.buildErrorResponse();
+ }
}
- }
- /**
- * Query Operation job status <br>
- *
- * @param servletReq The Http Request
- * @param jobId The job id
- * @return
- * @since ONAP Amsterdam Release
- */
- @POST
- @Path("/jobs/{jobId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public Response queryNfvoJobStatus(HttpServletRequest servletReq,
- @PathParam("jobId") String jobId) {
- 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);
+ /**
+ * Delete NS instance<br>
+ *
+ * @param servletReq http request
+ * @return response
+ * @since ONAP Amsterdam Release
+ */
+ @DELETE
+ @Path("/ns/{nsInstanceId}")
+ @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ public Response deleteNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) {
+ try {
+
+ ValidateUtil.assertObjectNotNull(data);
+ LOGGER.debug("body from request is {}" + data);
+ NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
+ RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId);
+ return buildResponse(rsp);
+ } catch(ApplicationException e) {
+ LOGGER.debug("ApplicationException: ", e);
+ return e.buildErrorResponse();
+ }
+ }
- RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId);
- return buildResponse(rsp);
- } catch (ApplicationException e) {
- LOGGER.debug("ApplicationException: ", e);
- return e.buildErrorResponse();
+ /**
+ * Query Operation job status <br>
+ *
+ * @param servletReq The Http Request
+ * @param jobId The job id
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @POST
+ @Path("/jobs/{jobId}")
+ @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ public Response queryNfvoJobStatus(String data, @PathParam("jobId") String jobId) {
+ try {
+ ValidateUtil.assertObjectNotNull(data);
+ LOGGER.debug("body from request is {}" + data);
+ NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
+ RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId);
+ return buildResponse(rsp);
+ } catch(ApplicationException e) {
+ LOGGER.debug("ApplicationException: ", e);
+ return e.buildErrorResponse();
+ }
}
- }
- /**
- * Instantiate NS instance <br>
- *
- * @param servletReq The http request
- * @param nsInstanceId The NS instance id
- * @return
- * @since ONAP Amsterdam Release
- */
- @POST
- @Path("/ns/{nsInstanceId}/instantiate")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public Response instantiateNfvoNs(HttpServletRequest servletReq,
- @PathParam("nsInstanceId") String nsInstanceId) {
- String body = RestfulUtil.getRequestBody(servletReq);
- 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) {
- LOGGER.debug("ApplicationException: ", e);
- return e.buildErrorResponse();
+ /**
+ * Instantiate NS instance <br>
+ *
+ * @param servletReq The http request
+ * @param nsInstanceId The NS instance id
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @POST
+ @Path("/ns/{nsInstanceId}/instantiate")
+ @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ public Response instantiateNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) {
+ try {
+ ValidateUtil.assertObjectNotNull(data);
+ LOGGER.debug("body from request is {}" + data);
+ NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class);
+ RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput);
+ return buildResponse(rsp);
+ } catch(ApplicationException e) {
+ LOGGER.debug("ApplicationException: ", e);
+ return e.buildErrorResponse();
+ }
}
- }
- /**
- * Terminate NS instance <br>
- *
- * @param servletReq The http request
- * @param nsInstanceId The NS instance id
- * @return
- * @since ONAP Amsterdam Release
- */
- @POST
- @Path("/ns/{nsInstanceId}/terminate")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public Response terminateNfvoNs(HttpServletRequest servletReq,
- @PathParam("nsInstanceId") String nsInstanceId) {
- 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) {
- LOGGER.debug("ApplicationException: ", e);
- return e.buildErrorResponse();
+ /**
+ * Terminate NS instance <br>
+ *
+ * @param servletReq The http request
+ * @param nsInstanceId The NS instance id
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @POST
+ @Path("/ns/{nsInstanceId}/terminate")
+ @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ public Response terminateNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) {
+ try {
+ ValidateUtil.assertObjectNotNull(data);
+ LOGGER.debug("body from request is {}" + data);
+ NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
+ RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId);
+ return buildResponse(rsp);
+ } catch(ApplicationException e) {
+ LOGGER.debug("ApplicationException: ", e);
+ return e.buildErrorResponse();
+ }
}
- }
- /**
- * build response from restful response <br>
- *
- * @param rsp general response object
- * @return
- * @since ONAP Amsterdam Release
- */
- private Response buildResponse(RestfulResponse rsp) {
- ResponseBuilder rspBuilder = Response.status(rsp.getStatus());
- rspBuilder.entity(rsp.getResponseContent());
- return rspBuilder.build();
- }
+ /**
+ * build response from restful response <br>
+ *
+ * @param rsp general response object
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ private Response buildResponse(RestfulResponse rsp) {
+ return Response.status(rsp.getStatus()).entity(rsp.getResponseContent()).build();
+ }
}
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 fed6d5e805..35c8eade0c 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
@@ -111,22 +111,8 @@ public class VfcManager {
ValidateUtil.assertObjectNotNull(createRsp);
LOGGER.info("create ns response status is : {}", createRsp.getStatus());
LOGGER.info("create ns response content is : {}", createRsp.getResponseContent());
- @SuppressWarnings("unchecked")
- Map<String, String> rsp = JsonUtil.unMarshal(createRsp.getResponseContent(), Map.class);
- String nsInstanceId = rsp.get(CommonConstant.NS_INSTANCE_ID);
- if (ValidateUtil.isStrEmpty(nsInstanceId)) {
- LOGGER.error("Invalid instanceId from create operation");
- throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
- DriverExceptionID.INVALID_RESPONSEE_FROM_CREATE_OPERATION);
- }
- LOGGER.info("create ns -> end");
- LOGGER.info("save segment and operaton info -> begin");
- // Step 5: add relation between service and NS
- AaiUtil.addRelation(segInput.getNsOperationKey().getGlobalSubscriberId(),
- segInput.getNsOperationKey().getServiceType(), segInput.getNsOperationKey().getServiceId(),
- nsInstanceId);
- // Step 6: save resource operation information
+ // Step 5: save resource operation information
ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance())
.getResourceOperationStatus(segInput.getNsOperationKey().getServiceId(),
segInput.getNsOperationKey().getOperationId(),
@@ -142,7 +128,16 @@ public class VfcManager {
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.FAIL_TO_CREATE_NS);
}
- LOGGER.info("save segment and operation info -> end");
+ @SuppressWarnings("unchecked")
+ Map<String, String> rsp = JsonUtil.unMarshal(createRsp.getResponseContent(), Map.class);
+ String nsInstanceId = rsp.get(CommonConstant.NS_INSTANCE_ID);
+ if (ValidateUtil.isStrEmpty(nsInstanceId)) {
+ LOGGER.error("Invalid instanceId from create operation");
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
+ DriverExceptionID.INVALID_RESPONSEE_FROM_CREATE_OPERATION);
+ }
+ LOGGER.info("create ns -> end");
+
return createRsp;
}
@@ -181,11 +176,6 @@ public class VfcManager {
DriverExceptionID.FAIL_TO_DELETE_NS);
}
- // Step3: remove relation info between service and ns
- AaiUtil.removeRelation(nsOperationKey.getGlobalSubscriberId(), nsOperationKey.getServiceType(),
- nsOperationKey.getServiceId(), nsInstanceId);
- LOGGER.info("delete segment information -> end");
-
// Step4: update service segment operation status
nsOperInfo.setStatus(RequestsDbConstant.Status.FINISHED);
nsOperInfo.setErrorCode(String.valueOf(deleteRsp.getStatus()));
@@ -220,18 +210,27 @@ public class VfcManager {
String url = getUrl(nsInstanceId, CommonConstant.Step.INSTANTIATE);
String methodType = CommonConstant.MethodType.POST;
- RestfulResponse instRsp = RestfulUtil.send(url, methodType, instReq);
+ RestfulResponse instRsp = RestfulUtil.send(url, methodType, instReq);
+ ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance())
+ .getResourceOperationStatus(segInput.getNsOperationKey().getServiceId(),
+ segInput.getNsOperationKey().getOperationId(),
+ segInput.getNsOperationKey().getNodeTemplateUUID());
ValidateUtil.assertObjectNotNull(instRsp);
+ if (!HttpCode.isSucess(instRsp.getStatus())) {
+ LOGGER.error("update segment operation status : fail to instantiate ns");
+ nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
+ nsOperInfo.setErrorCode(String.valueOf(instRsp.getStatus()));
+ nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED);
+ (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
+ DriverExceptionID.FAIL_TO_INSTANTIATE_NS);
+ }
LOGGER.info("instantiate ns response status is : {}", instRsp.getStatus());
LOGGER.info("instantiate ns response content is : {}", instRsp.getResponseContent());
- ValidateUtil.assertObjectNotNull(instRsp.getResponseContent());
+ ValidateUtil.assertObjectNotNull(instRsp.getResponseContent());
@SuppressWarnings("unchecked")
Map<String, String> rsp = JsonUtil.unMarshal(instRsp.getResponseContent(), Map.class);
String jobId = rsp.get(CommonConstant.JOB_ID);
- ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance())
- .getResourceOperationStatus(segInput.getNsOperationKey().getServiceId(),
- segInput.getNsOperationKey().getOperationId(),
- segInput.getNsOperationKey().getNodeTemplateUUID());
if (ValidateUtil.isStrEmpty(jobId)) {
LOGGER.error("Invalid jobId from instantiate operation");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
@@ -242,17 +241,6 @@ public class VfcManager {
DriverExceptionID.INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION);
}
LOGGER.info("instantiate ns -> end");
-
- if (!HttpCode.isSucess(instRsp.getStatus())) {
- LOGGER.error("update segment operation status : fail to instantiate ns");
- nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
- nsOperInfo.setErrorCode(String.valueOf(instRsp.getStatus()));
- nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED);
- (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
- throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
- DriverExceptionID.FAIL_TO_INSTANTIATE_NS);
- }
-
// Step 3: update segment operation job id
LOGGER.info("update resource operation status job id -> begin");
nsOperInfo.setJobId(jobId);
@@ -296,6 +284,17 @@ public class VfcManager {
ValidateUtil.assertObjectNotNull(terminateRsp);
LOGGER.info("terminate ns response status is : {}", terminateRsp.getStatus());
LOGGER.info("terminate ns response content is : {}", terminateRsp.getResponseContent());
+ // Step 3: update segment operation
+ if (!HttpCode.isSucess(terminateRsp.getStatus())) {
+ LOGGER.error("fail to instantiate ns");
+ nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
+ nsOperInfo.setErrorCode(String.valueOf(terminateRsp.getStatus()));
+ nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
+ (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
+
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
+ DriverExceptionID.FAIL_TO_TERMINATE_NS);
+ }
@SuppressWarnings("unchecked")
Map<String, String> rsp = JsonUtil.unMarshal(terminateRsp.getResponseContent(), Map.class);
String jobId = rsp.get(CommonConstant.JOB_ID);
@@ -310,17 +309,6 @@ public class VfcManager {
}
LOGGER.info("terminate ns -> end");
- // Step 3: update segment operation
- if (!HttpCode.isSucess(terminateRsp.getStatus())) {
- LOGGER.error("fail to instantiate ns");
- nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
- nsOperInfo.setErrorCode(String.valueOf(terminateRsp.getStatus()));
- nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
- (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
-
- throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
- DriverExceptionID.FAIL_TO_TERMINATE_NS);
- }
LOGGER.info("update segment job id -> begin");
nsOperInfo.setJobId(jobId);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
@@ -380,7 +368,6 @@ public class VfcManager {
&& RequestsDbConstant.Status.FINISHED.equals(rspDesc.getStatus())) {
LOGGER.info("job result is succeeded, operType is {}", nsOperInfo.getOperType());
nsOperInfo.setErrorCode(String.valueOf(rsp.getStatus()));
- nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED);
if (RequestsDbConstant.OperationType.CREATE.equals(nsOperInfo.getOperType())) {
nsOperInfo.setStatus(RequestsDbConstant.Status.FINISHED);
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/LocationConstraint.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/LocationConstraint.java
index 8b259e915b..214451b22f 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/LocationConstraint.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/LocationConstraint.java
@@ -19,8 +19,6 @@
*/
package org.openecomp.mso.adapters.vfc.model;
-import java.util.Map;
-
/**
* <br>
* <p>
@@ -39,7 +37,7 @@ public class LocationConstraint {
/**
* location constraints: vimId
*/
- private Map<String, String> locationConstraints;
+ private VimLocation locationConstraints;
/**
* @return Returns the vnfProfileId.
@@ -55,17 +53,19 @@ public class LocationConstraint {
this.vnfProfileId = vnfProfileId;
}
+
/**
* @return Returns the locationConstraints.
*/
- public Map<String, String> getLocationConstraints() {
+ public VimLocation getLocationConstraints() {
return locationConstraints;
}
+
/**
* @param locationConstraints The locationConstraints to set.
*/
- public void setLocationConstraints(Map<String, String> locationConstraints) {
+ public void setLocationConstraints(VimLocation locationConstraints) {
this.locationConstraints = locationConstraints;
}
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 f88a11dee8..1f166062d1 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
@@ -19,6 +19,15 @@
*/
package org.openecomp.mso.adapters.vfc.model;
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.openecomp.mso.logger.MsoLogger;
+
/**
* NS Create Input Parameter For VFC Adapter<br>
* <p>
@@ -28,6 +37,8 @@ package org.openecomp.mso.adapters.vfc.model;
*/
public class NSResourceInputParameter {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+
private NsOperationKey nsOperationKey;
private String nsServiceName;
@@ -91,5 +102,29 @@ public class NSResourceInputParameter {
public void setNsOperationKey(NsOperationKey nsOperationKey) {
this.nsOperationKey = nsOperationKey;
}
+ public String toJsonString() {
+ String jsonString = null;
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE);
+ jsonString = mapper.writeValueAsString(this);
+ } catch (Exception e) {
+ LOGGER.debug("Exception:", e);
+ }
+ return jsonString;
+ }
+ public String toXmlString() {
+ try {
+ ByteArrayOutputStream bs = new ByteArrayOutputStream();
+ JAXBContext context = JAXBContext.newInstance(this.getClass());
+ Marshaller marshaller = context.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML
+ marshaller.marshal(this, bs);
+ return bs.toString();
+ } catch (Exception e) {
+ LOGGER.debug("Exception:", e);
+ return "";
+ }
+ }
}
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 e4d6d66cda..23bf36fe0c 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.mso.adapters.vfc.model;
/**
@@ -26,20 +27,20 @@ package org.openecomp.mso.adapters.vfc.model;
* </p>
*
* @author
- * @version ONAP Amsterdam Release 2017-09-15
+ * @version ONAP Amsterdam Release 2017-09-15
*/
public class NsOperationKey {
-
+
/**
* The subscriber id
*/
private String globalSubscriberId;
-
+
/**
* The serviceType
*/
private String serviceType;
-
+
/**
* The service ID
*/
@@ -49,15 +50,12 @@ public class NsOperationKey {
* The Operation ID
*/
private String operationId;
-
+
/**
* the NS template uuid
*/
private String nodeTemplateUUID;
-
-
-
/**
* @return Returns the globalSubscriberId.
*/
@@ -65,14 +63,13 @@ public class NsOperationKey {
return globalSubscriberId;
}
-
/**
* @param globalSubscriberId The globalSubscriberId to set.
*/
public void setGlobalSubscriberId(String globalSubscriberId) {
this.globalSubscriberId = globalSubscriberId;
}
-
+
/**
* @return Returns the serviceType.
*/
@@ -80,8 +77,6 @@ public class NsOperationKey {
return serviceType;
}
-
-
/**
* @param serviceType The serviceType to set.
*/
@@ -89,9 +84,7 @@ public class NsOperationKey {
this.serviceType = serviceType;
}
-
/**
- *
* <br>
*
* @return
@@ -102,7 +95,6 @@ public class NsOperationKey {
}
/**
- *
* <br>
*
* @param serviceId
@@ -113,7 +105,6 @@ public class NsOperationKey {
}
/**
- *
* <br>
*
* @return
@@ -124,7 +115,6 @@ public class NsOperationKey {
}
/**
- *
* <br>
*
* @param operationId
@@ -134,7 +124,6 @@ public class NsOperationKey {
this.operationId = operationId;
}
-
/**
* @return Returns the nodeTemplateUUID.
*/
@@ -142,7 +131,6 @@ public class NsOperationKey {
return nodeTemplateUUID;
}
-
/**
* @param nodeTemplateUUID The nodeTemplateUUID to set.
*/
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsParameters.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsParameters.java
index 79d770ba4d..2a5c305926 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsParameters.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsParameters.java
@@ -19,6 +19,7 @@
*/
package org.openecomp.mso.adapters.vfc.model;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -34,8 +35,7 @@ public class NsParameters {
private List<LocationConstraint> locationConstraints;
- private Map<String, String> additionalParamForNs;
-
+ private Map<String, Object> additionalParamForNs = new HashMap<String,Object>();
/**
* @return Returns the locationConstraints.
*/
@@ -50,18 +50,19 @@ public class NsParameters {
this.locationConstraints = locationConstraints;
}
+
/**
* @return Returns the additionalParamForNs.
*/
- public Map<String, String> getAdditionalParamForNs() {
+ public Map<String, Object> getAdditionalParamForNs() {
return additionalParamForNs;
}
+
/**
* @param additionalParamForNs The additionalParamForNs to set.
*/
- public void setAdditionalParamForNs(Map<String, String> additionalParamForNs) {
+ public void setAdditionalParamForNs(Map<String, Object> additionalParamForNs) {
this.additionalParamForNs = additionalParamForNs;
}
-
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VimLocation.java
index 719385f97f..3c07f9cd8b 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VimLocation.java
@@ -1,45 +1,50 @@
-/*-
- * ============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.adapters.vfc;
-
-import org.openecomp.mso.adapters.vfc.model.RestfulResponse;
-
-/**
- * Implement class of operating aai database table <br>
- * <p>
- * </p>
- *
- * @author
- * @version ONAP Amsterdam Release 2017-08-28
- */
-public class AaiUtil {
-
- public static RestfulResponse addRelation(String globalSubsriberId, String serviceType,
- String serviceInstanceId, String resourceInstanceId) {
- // sent rest to aai to add relation for service and ns.
- return null;
- }
-
- public static RestfulResponse removeRelation(String globalSubsriberId, String serviceType,
- String serviceInstanceId, String resourceInstanceId) {
- // sent rest to aai to remove relation between service an ns.
- return null;
- }
-}
+/*-
+ * ============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.adapters.vfc.model;
+
+/**
+ *
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Amsterdam Release 2017-10-18
+ */
+public class VimLocation {
+ private String vimId;
+
+
+ /**
+ * @return Returns the vimId.
+ */
+ public String getVimId() {
+ return vimId;
+ }
+
+
+ /**
+ * @param vimId The vimId to set.
+ */
+ public void setVimId(String vimId) {
+ this.vimId = vimId;
+ }
+
+}
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 85065c0953..e8718fafc2 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
@@ -18,17 +18,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.mso.adapters.vfc.util;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
-import javax.servlet.http.HttpServletRequest;
-
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
@@ -46,6 +41,8 @@ import org.openecomp.mso.adapters.vfc.model.RestfulResponse;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoAlarmLogger;
import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.properties.MsoPropertiesException;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
/**
* <br>
@@ -58,179 +55,197 @@ import org.openecomp.mso.logger.MsoLogger;
*/
public class RestfulUtil {
- /**
- * Log service
- */
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
-
- private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger();
-
- private static final int DEFAULT_TIME_OUT = 60;
-
- private RestfulUtil() {
-
- }
-
- public static RestfulResponse send(String url, String methodType, String content) {
- LOGGER.info(MessageEnum.RA_NS_EXC, url, "VFC", "");
- LOGGER.debug("VFC Request Body:\n" + content);
-
- HttpRequestBase method = null;
- HttpResponse httpResponse = null;
-
- try {
- int timeout = DEFAULT_TIME_OUT;
-
- RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout)
- .setConnectTimeout(timeout).setConnectionRequestTimeout(timeout).build();
-
- HttpClient client = HttpClientBuilder.create().build();
-
- if ("POST".equals(methodType)) {
- HttpPost httpPost = new HttpPost(url);
- httpPost.setConfig(requestConfig);
- httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
- method = httpPost;
- } else if ("PUT".equals(methodType)) {
- HttpPut httpPut = new HttpPut(url);
- httpPut.setConfig(requestConfig);
- httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
- method = httpPut;
- } else if ("GET".equals(methodType)) {
- HttpGet httpGet = new HttpGet(url);
- httpGet.setConfig(requestConfig);
- method = httpGet;
- } else if ("DELETE".equals(methodType)) {
- HttpDelete httpDelete = new HttpDelete(url);
- httpDelete.setConfig(requestConfig);
- method = httpDelete;
- }
-
- // now VFC have no auth
- // 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);
-
- httpResponse = client.execute(method);
-
- String responseContent = null;
- if (httpResponse.getEntity() != null) {
- responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
- }
-
- int statusCode = httpResponse.getStatusLine().getStatusCode();
- String statusMessage = httpResponse.getStatusLine().getReasonPhrase();
-
- LOGGER.debug("VFC Response: " + statusCode + " " + statusMessage
- + (responseContent == null ? "" : System.lineSeparator() + responseContent));
-
- if (httpResponse.getStatusLine().getStatusCode() >= 300) {
- String errMsg = "VFC returned " + statusCode + " " + statusMessage;
- logError(errMsg);
- return createResponse(statusCode, errMsg);
- }
-
- httpResponse = null;
-
- 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);
-
- } catch (SocketTimeoutException e) {
- String errMsg = "Request to SDNC timed out";
- logError(errMsg, e);
- 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);
-
- } catch (Exception e) {
- String errMsg = "Error processing request to SDNC";
- logError(errMsg, e);
- return createResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg);
-
- } finally {
- if (httpResponse != null) {
- try {
- EntityUtils.consume(httpResponse.getEntity());
- } catch (Exception e) {
- LOGGER.debug("Exception :", e);
- }
- }
+ /**
+ * Log service
+ */
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+
+ private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger();
- if (method != null) {
+ private static final int DEFAULT_TIME_OUT = 60000;
+
+ private static final MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
+
+ public static String getMsbHost() {
+ String msbIp = "10.229.32.131";
+ String msbPort = "8090";
try {
- method.reset();
- } catch (Exception e) {
- LOGGER.debug("Exception :", e);
+ msbIp = msoPropertiesFactory.getMsoJavaProperties("MSO_PROP_TOPOLOGY").getProperty("msb-ip",
+ "10.229.32.131");
+ msbPort = msoPropertiesFactory.getMsoJavaProperties("MSO_PROP_TOPOLOGY").getProperty("msb-port", "8099");
+
+ } catch(MsoPropertiesException e) {
+ LOGGER.error(MessageEnum.RA_NS_EXC, "VFC", "", MsoLogger.ErrorCode.AvailabilityError,
+ "Get msb properties failed");
+ e.printStackTrace();
}
- }
+ return "http://" + msbIp + ":" + msbPort;
+ }
+
+ private RestfulUtil() {
+
}
- }
-
- private static void logError(String errMsg, Throwable t) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "VFC", "", MsoLogger.ErrorCode.AvailabilityError, errMsg,
- t);
- ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg);
- }
-
- private static void logError(String errMsg) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "VFC", "", MsoLogger.ErrorCode.AvailabilityError, errMsg);
- ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg);
- }
-
- private static RestfulResponse createResponse(int statusCode, String content) {
- RestfulResponse rsp = new RestfulResponse();
- rsp.setStatus(statusCode);
- rsp.setResponseContent(content);
- return rsp;
- }
-
- /**
- * @param request
- * @return
- */
- public static String getRequestBody(HttpServletRequest request) {
- String body = null;
- StringBuilder stringBuilder = new StringBuilder();
- BufferedReader bufferedReader = null;
- try {
- InputStream inputStream = request.getInputStream();
- if (inputStream != null) {
- bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
- char[] charBuffer = new char[128];
- int bytesRead = -1;
- while ((bytesRead = bufferedReader.read(charBuffer)) > 0)
- stringBuilder.append(charBuffer, 0, bytesRead);
- }
- } catch (IOException ex) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "VFC", "", MsoLogger.ErrorCode.AvailabilityError,
- "read inputStream buffer catch exception:", ex);
- } finally {
- if (bufferedReader != null) {
+
+ public static RestfulResponse send(String url, String methodType, String content) {
+ String msbUrl = getMsbHost() + url;
+ LOGGER.info(MessageEnum.RA_NS_EXC, msbUrl, "VFC", "");
+ LOGGER.debug("VFC Request Body:\n" + content);
+
+ HttpRequestBase method = null;
+ HttpResponse httpResponse = null;
+
try {
- bufferedReader.close();
- } catch (IOException ex) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "VFC", "", MsoLogger.ErrorCode.AvailabilityError,
- "close buffer catch exception:", ex);
+ int timeout = DEFAULT_TIME_OUT;
+
+ RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout)
+ .setConnectionRequestTimeout(timeout).build();
+
+ HttpClient client = HttpClientBuilder.create().build();
+
+ if("POST".equals(methodType.toUpperCase())) {
+ HttpPost httpPost = new HttpPost(msbUrl);
+ httpPost.setConfig(requestConfig);
+ httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
+ method = httpPost;
+ } else if("PUT".equals(methodType.toUpperCase())) {
+ HttpPut httpPut = new HttpPut(msbUrl);
+ httpPut.setConfig(requestConfig);
+ httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
+ method = httpPut;
+ } else if("GET".equals(methodType.toUpperCase())) {
+ HttpGet httpGet = new HttpGet(msbUrl);
+ httpGet.setConfig(requestConfig);
+ method = httpGet;
+ } else if("DELETE".equals(methodType.toUpperCase())) {
+ HttpDelete httpDelete = new HttpDelete(msbUrl);
+ httpDelete.setConfig(requestConfig);
+ method = httpDelete;
+ }
+
+ // now VFC have no auth
+ // 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);
+
+ httpResponse = client.execute(method);
+
+ String responseContent = null;
+ if(httpResponse.getEntity() != null) {
+ responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
+ }
+
+ int statusCode = httpResponse.getStatusLine().getStatusCode();
+ String statusMessage = httpResponse.getStatusLine().getReasonPhrase();
+
+ LOGGER.debug("VFC Response: " + statusCode + " " + statusMessage
+ + (responseContent == null ? "" : System.lineSeparator() + responseContent));
+
+ if(httpResponse.getStatusLine().getStatusCode() >= 300) {
+ String errMsg = "VFC returned " + statusCode + " " + statusMessage;
+ logError(errMsg);
+ return createResponse(statusCode, errMsg);
+ }
+
+ httpResponse = null;
+
+ if(null != method) {
+ method.reset();
+ } else {
+ LOGGER.debug("method is NULL:");
+ }
+
+ method = null;
+
+ LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, responseContent, "VFC", "");
+ return createResponse(statusCode, responseContent);
+
+ } catch(SocketTimeoutException e) {
+ String errMsg = "Request to VFC timed out";
+ logError(errMsg, e);
+ return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg);
+
+ } catch(ConnectTimeoutException e) {
+ String errMsg = "Request to VFC timed out";
+ logError(errMsg, e);
+ return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg);
+
+ } catch(Exception e) {
+ String errMsg = "Error processing request to VFC";
+ logError(errMsg, e);
+ return createResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg);
+
+ } finally {
+ if(httpResponse != null) {
+ try {
+ EntityUtils.consume(httpResponse.getEntity());
+ } catch(Exception e) {
+ LOGGER.debug("Exception :", e);
+ }
+ }
+
+ if(method != null) {
+ try {
+ method.reset();
+ } catch(Exception e) {
+ LOGGER.debug("Exception :", e);
+ }
+ }
}
- }
}
- body = stringBuilder.toString();
- return body;
- }
+ private static void logError(String errMsg, Throwable t) {
+ LOGGER.error(MessageEnum.RA_NS_EXC, "VFC", "", MsoLogger.ErrorCode.AvailabilityError, errMsg, t);
+ ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg);
+ }
+
+ private static void logError(String errMsg) {
+ LOGGER.error(MessageEnum.RA_NS_EXC, "VFC", "", MsoLogger.ErrorCode.AvailabilityError, errMsg);
+ ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg);
+ }
+
+ private static RestfulResponse createResponse(int statusCode, String content) {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(statusCode);
+ rsp.setResponseContent(content);
+ return rsp;
+ }
+
+ /**
+ * @param request
+ * @return
+ */
+ // public static String getRequestBody(HttpServletRequest request) {
+ // String body = null;
+ // StringBuilder stringBuilder = new StringBuilder();
+ // BufferedReader bufferedReader = null;
+ // try {
+ // InputStream inputStream = request.getInputStream();
+ // if (inputStream != null) {
+ // bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+ // char[] charBuffer = new char[128];
+ // int bytesRead = -1;
+ // while ((bytesRead = bufferedReader.read(charBuffer)) > 0)
+ // stringBuilder.append(charBuffer, 0, bytesRead);
+ // }
+ // } catch (IOException ex) {
+ // LOGGER.error(MessageEnum.RA_NS_EXC, "VFC", "", MsoLogger.ErrorCode.AvailabilityError,
+ // "read inputStream buffer catch exception:", ex);
+ // } finally {
+ // if (bufferedReader != null) {
+ // try {
+ // bufferedReader.close();
+ // } catch (IOException ex) {
+ // LOGGER.error(MessageEnum.RA_NS_EXC, "VFC", "", MsoLogger.ErrorCode.AvailabilityError,
+ // "close buffer catch exception:", ex);
+ // }
+ // }
+ // }
+ //
+ // body = stringBuilder.toString();
+ // return body;
+ // }
}
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 84991d77c8..95d3bf610f 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
@@ -24,8 +24,6 @@ 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;
@@ -52,194 +50,191 @@ import mockit.MockUp;
*/
public class VfcAdapterTest {
- private VfcAdapterRest vfcAdapter = new VfcAdapterRest();
-
- /**
- * File path
- */
- private static final String FILE_PATH = "src/test/resources/json/";
-
- /**
- * 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) {
+ private VfcAdapterRest vfcAdapter = new VfcAdapterRest();
+
+ /**
+ * File path
+ */
+ private static final String FILE_PATH = "src/test/resources/json/";
+
+ /**
+ * mock get request body <br>
+ *
+ * @param request
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ public String getRequestBody(String fileName) {
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.equals(CommonConstant.NFVO_CREATE_URL)
- && methodType.equals(CommonConstant.MethodType.POST)) {
- return getResponse("createNsRsp.json");
- } else if (url.contains("instantiate")
- && methodType.equals(CommonConstant.MethodType.POST)) {
- return getResponse("instantiateNsRsp.json");
- } else if (methodType.equals(CommonConstant.MethodType.DELETE)) {
- return getResponse(null);
- } else if (url.contains("terminate") && methodType.equals(CommonConstant.MethodType.POST)) {
- return getResponse("terminateNsRsp.json");
- } else if (url.contains("/api/nslcm/v1/jobs")
- && methodType.equals(CommonConstant.MethodType.GET)) {
- return getResponse("queryJobRsp.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 createTest() {
- // get request
- mockRestfulUtil(FILE_PATH + "createNsReq.json");
- vfcAdapter.createNfvoNs(null);
- }
-
- @Test
- public void deleteTest() {
- // get request
- mockRestfulUtil(FILE_PATH + "deleteNsReq.json");
- vfcAdapter.deleteNfvoNs(null, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
- }
-
- @Test
- public void instantiateTest() {
- // get request
- mockRestfulUtil(FILE_PATH + "instantiateNsReq.json");
- vfcAdapter.instantiateNfvoNs(null, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
- }
-
- @Test
- public void terminateTest() {
- mockRestfulUtil(FILE_PATH + "terminateNsReq.json");
- vfcAdapter.terminateNfvoNs(null, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
- }
-
- @Test
- public void queryJobTest() {
- mockRestfulUtil(FILE_PATH + "queryJobReq.json");
- vfcAdapter.queryNfvoJobStatus(null, "1");
- }
-
- /**
- * Get json string from file.<br/>
- *
- * @param file the path of file
- * @return json string
- * @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());
+ /**
+ * Mock the request body form a file <br>
+ *
+ * @param fileName
+ * @since ONAP Amsterdam Release
+ */
+ private void mockRestfulUtil() {
+ new MockUp<RestfulUtil>() {
+
+ /**
+ * 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.equals(CommonConstant.NFVO_CREATE_URL) && methodType.equals(CommonConstant.MethodType.POST)) {
+ return getResponse("createNsRsp.json");
+ } else if(url.contains("instantiate") && methodType.equals(CommonConstant.MethodType.POST)) {
+ return getResponse("instantiateNsRsp.json");
+ } else if(methodType.equals(CommonConstant.MethodType.DELETE)) {
+ return getResponse(null);
+ } else if(url.contains("terminate") && methodType.equals(CommonConstant.MethodType.POST)) {
+ return getResponse("terminateNsRsp.json");
+ } else if(url.contains("/api/nslcm/v1/jobs") && methodType.equals(CommonConstant.MethodType.GET)) {
+ return getResponse("queryJobRsp.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();
+ mockRestfulUtil();
+ }
+
+ /**
+ * After executing UT, close session<br/>
+ *
+ * @since ONAP Amsterdam Release
+ */
+ @After
+ public void stop() {
+
+ }
+
+ @Test
+ public void createTest() {
+ // get request
+ String createReq = getRequestBody(FILE_PATH + "createNsReq.json");
+ vfcAdapter.createNfvoNs(createReq);
+ }
+
+ @Test
+ public void deleteTest() {
+ // get request
+ String req = getRequestBody(FILE_PATH + "deleteNsReq.json");
+ vfcAdapter.deleteNfvoNs(req, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
}
- 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);
+
+ @Test
+ public void instantiateTest() {
+ // get request
+ String req = getRequestBody(FILE_PATH + "instantiateNsReq.json");
+ vfcAdapter.instantiateNfvoNs(req, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
+ }
+
+ @Test
+ public void terminateTest() {
+ String req = getRequestBody(FILE_PATH + "terminateNsReq.json");
+ vfcAdapter.deleteNfvoNs(req, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
+ }
+
+ @Test
+ public void queryJobTest() {
+ String req = getRequestBody(FILE_PATH + "queryJobReq.json");
+ vfcAdapter.queryNfvoJobStatus(req, "1");
+ }
+
+ /**
+ * Get json string from file.<br/>
+ *
+ * @param file the path of file
+ * @return json string
+ * @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());
+ }
+ 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;
}
- return responseSuccess;
- }
}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java
index cba378eab0..a8e03d98f3 100644
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java
+++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java
@@ -86,7 +86,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER";
private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError";
private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter.";
- private static final String LOG_REPLY_NAME = "MSO-VnfAdapter:MSO-BPMN.";
private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
private static final String CHECK_REQD_PARAMS = "org.openecomp.mso.adapters.vnf.checkRequiredParameters";
@@ -433,34 +432,36 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
private Map <String, String> copyStringOutputs (Map <String, Object> stackOutputs) {
- Map <String, String> stringOutputs = new HashMap <String, String> ();
- for (String key : stackOutputs.keySet ()) {
- if (stackOutputs.get (key) instanceof String) {
- stringOutputs.put (key, (String) stackOutputs.get (key));
- } else if (stackOutputs.get(key) instanceof Integer) {
+ Map <String, String> stringOutputs = new HashMap <> ();
+ for (Map.Entry<String,Object> entry : stackOutputs.entrySet ()) {
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ if (value instanceof String) {
+ stringOutputs.put (key, (String) value);
+ } else if (value instanceof Integer) {
try {
- String str = "" + stackOutputs.get(key);
+ String str = "" + value;
stringOutputs.put(key, str);
} catch (Exception e) {
LOGGER.debug("Unable to add " + key + " to outputs",e);
}
- } else if (stackOutputs.get(key) instanceof JsonNode) {
+ } else if (value instanceof JsonNode) {
try {
- String str = this.convertNode((JsonNode) stackOutputs.get(key));
+ String str = this.convertNode((JsonNode) value);
stringOutputs.put(key, str);
} catch (Exception e) {
LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode",e);
}
- } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) {
+ } else if (value instanceof java.util.LinkedHashMap) {
try {
- String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key));
+ String str = JSON_MAPPER.writeValueAsString(value);
stringOutputs.put(key, str);
} catch (Exception e) {
LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap",e);
}
} else {
try {
- String str = stackOutputs.get(key).toString();
+ String str = value.toString();
stringOutputs.put(key, str);
} catch (Exception e) {
LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(),e);
@@ -471,7 +472,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
private Map <String, Object> copyStringInputs (Map <String, String> stringInputs) {
- return new HashMap <String, Object> (stringInputs);
+ return new HashMap <> (stringInputs);
}
/*
@@ -485,7 +486,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
StringBuilder sb = new StringBuilder ();
try (Scanner scanner = new Scanner (environment)) {
scanner.useDelimiter ("\n");
- String line = null;
+ String line;
Pattern resource = Pattern.compile ("\\s*\"\\w+::\\S+\"\\s*:");
LOGGER.debug ("regex pattern for finding a resource_registry: \\s*\"\\w+::\\S+\"\\s*:");
while (scanner.hasNextLine ()) {
@@ -569,7 +570,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
boolean wait = p.waitFor(waitTimeMs, TimeUnit.MILLISECONDS);
LOGGER.debug(" HeatBridgeMain.py returned " + wait + " with code " + p.exitValue());
- return (wait && p.exitValue()==0);
+ return wait && p.exitValue()==0;
} catch (IOException e) {
LOGGER.debug(" HeatBridgeMain.py failed with IO Exception! " + e);
return false;
@@ -591,10 +592,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
else if (inputs.size() < 1) {
sb.append("\tEMPTY");
} else {
- for (String str : inputs.keySet()) {
+ for (Map.Entry<String,Object> entry : inputs.entrySet()) {
String outputString;
+ String str = entry.getKey();
+ Object value = entry.getValue();
try {
- outputString = inputs.get(str).toString();
+ outputString = value.toString();
} catch (Exception e) {
LOGGER.debug("Exception :",e);
outputString = "Unable to call toString() on the value for " + str;
@@ -708,7 +711,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
String mcu = modelCustomizationUuid;
boolean useMCUuid = false;
if (mcu != null && !mcu.isEmpty()) {
- if (mcu.equalsIgnoreCase("null")) {
+ if ("null".equalsIgnoreCase(mcu)) {
LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid);
useMCUuid = false;
mcu = "";
@@ -720,25 +723,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
MsoLogger.setLogContext (msoRequest);
MsoLogger.setServiceName ("CreateVfModule");
String requestTypeString = "";
- if (requestType != null && !requestType.equals("")) {
+ if (requestType != null && !"".equals(requestType)) {
requestTypeString = requestType;
}
String nestedStackId = null;
- if (volumeGroupHeatStackId != null && !volumeGroupHeatStackId.equals("")) {
- if (!volumeGroupHeatStackId.equalsIgnoreCase("null")) {
+ if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) {
+ if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
nestedStackId = volumeGroupHeatStackId;
}
}
String nestedBaseStackId = null;
- if (baseVfHeatStackId != null && !baseVfHeatStackId.equals("")) {
- if (!baseVfHeatStackId.equalsIgnoreCase("null")) {
+ if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) {
+ if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
nestedBaseStackId = baseVfHeatStackId;
}
}
if (inputs == null) {
// Create an empty set of inputs
- inputs = new HashMap<String,String>();
+ inputs = new HashMap<>();
LOGGER.debug("inputs == null - setting to empty");
} else {
this.sendMapToDebug(inputs);
@@ -774,7 +777,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
vfRollback.setModelCustomizationUuid(mcu);
// Put data into A&AI through Heatstack
- boolean heatStackCallSuccess = callHeatbridge(baseVfHeatStackId);
+ callHeatbridge(baseVfHeatStackId);
// First, look up to see if the VF already exists.
MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
@@ -1037,17 +1040,16 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
minVersionVnf = null;
maxVersionVnf = null;
}
- if (minVersionVnf != null && minVersionVnf.equals("")) {
+ if (minVersionVnf != null && "".equals(minVersionVnf)) {
minVersionVnf = null;
}
- if (maxVersionVnf != null && maxVersionVnf.equals("")) {
+ if (maxVersionVnf != null && "".equals(maxVersionVnf)) {
maxVersionVnf = null;
}
}
if (minVersionVnf != null && maxVersionVnf != null) {
MavenLikeVersioning aicV = new MavenLikeVersioning();
CloudSite cloudSite = null;
- String aicVersion = "";
if (this.cloudConfig == null) {
this.cloudConfig = this.cloudConfigFactory.getCloudConfig();
}
@@ -1133,7 +1135,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
// By the time we get here - heatTemplateId and heatEnvtId should be populated (or null)
HeatTemplate heatTemplate = null;
- if (heatTemplateArtifactUuid == null || heatTemplateArtifactUuid.equals("")) {
+ if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) {
String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString;
LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
@@ -1158,7 +1160,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
HeatEnvironment heatEnvironment = null;
String heatEnvironmentString = null;
- if (heatEnvironmentArtifactUuid != null && !heatEnvironmentArtifactUuid.equals("")) {
+ if (heatEnvironmentArtifactUuid != null && !"".equals(heatEnvironmentArtifactUuid)) {
LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid);
if (heatEnvironment == null) {
@@ -1184,13 +1186,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
LOGGER.debug ("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId="
+ heatTemplate.getArtifactUuid());
Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid());
- Map <String, Object> nestedTemplatesChecked = new HashMap <String, Object> ();
+ Map <String, Object> nestedTemplatesChecked = new HashMap <> ();
if (nestedTemplates != null) {
// for debugging print them out
LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:");
- for (String providerResourceFile : nestedTemplates.keySet ()) {
+ for (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) {
+ String providerResourceFile = entry.getKey();
+ Object value = entry.getValue();
String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile);
- String childTemplateBody = (String) nestedTemplates.get (providerResourceFile);
+ String childTemplateBody = (String) value;
LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody);
nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody);
}
@@ -1202,7 +1206,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 1510 - Also add the files: for any get_files associated with this vnf_resource_id
// *if* there are any
Map<String, HeatFiles> heatFiles = null;
- Map<String, Object> heatFilesObjects = new HashMap<String, Object>();
+ Map<String, Object> heatFilesObjects = new HashMap<>();
// Add ability to turn on adding get_files with volume requests (by property).
boolean addGetFilesOnVolumeReq = false;
@@ -1234,7 +1238,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// this will match the nested templates format
LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
- for (String heatFileName : heatFiles.keySet()) {
+ for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) {
+ String heatFileName = entry.getKey();
+ HeatFiles value = entry.getValue();
if (heatFileName.startsWith("_ERROR|")) {
// This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1);
@@ -1246,8 +1252,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
throw new VnfException (error, MsoExceptionCategory.INTERNAL);
}
- String heatFileBody = heatFiles.get(heatFileName)
- .getFileBody();
+ String heatFileBody = value.getFileBody();
String heatFileNameChecked = heatFileName;
LOGGER.debug(heatFileNameChecked + " -> "
+ heatFileBody);
@@ -1263,14 +1268,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// Check that required parameters have been supplied
String missingParams = null;
- List <String> paramList = new ArrayList <String> ();
+ List <String> paramList = new ArrayList <> ();
// New for 1510 - consult the PARAM_ALIAS field to see if we've been
// supplied an alias. Only check if we don't find it initially.
// Also new in 1510 - don't flag missing parameters if there's an environment - because they might be there.
// And also new - add parameter to turn off checking all together if we find we're blocking orders we
// shouldn't
- boolean haveEnvironmentParameters = false;
boolean checkRequiredParameters = true;
try {
String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER)
@@ -1292,7 +1296,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
if (heatEnvironmentString != null && heatEnvironmentString.contains ("parameters:")) {
//LOGGER.debug ("Have an Environment argument with a parameters: section - will bypass checking for valid params - but will still check for aliases");
LOGGER.debug("Enhanced environment checking enabled - 1604");
- haveEnvironmentParameters = true;
StringBuilder sb = new StringBuilder(heatEnvironmentString);
//LOGGER.debug("About to create MHEE with " + sb);
mhee = new MsoHeatEnvironmentEntry(sb);
@@ -1314,15 +1317,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
HashMap<String, Object> goldenInputs = null;
LOGGER.debug("Now handle the inputs....first convert");
- ArrayList<String> parameterNames = new ArrayList<String>();
- HashMap<String, String> aliasToParam = new HashMap<String, String>();
+ ArrayList<String> parameterNames = new ArrayList<>();
+ HashMap<String, String> aliasToParam = new HashMap<>();
StringBuilder sb = new StringBuilder("\nTemplate Parameters:\n");
int cntr = 0;
try {
for (HeatTemplateParam htp : heatTemplate.getParameters()) {
sb.append("param[" + cntr++ + "]=" + htp.getParamName());
parameterNames.add(htp.getParamName());
- if (htp.getParamAlias() != null && !htp.getParamAlias().equals("")) {
+ if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) {
aliasToParam.put(htp.getParamAlias(), htp.getParamName());
sb.append(" ** (alias=" + htp.getParamAlias() + ")");
}
@@ -1534,7 +1537,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
Holder <VnfRollback> rollback) throws VnfException {
String vfModuleName = vnfName;
String vfModuleType = vnfType;
- String vfVersion = vnfVersion;
String methodName = "updateVfModule";
MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ());
String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName;
@@ -1568,25 +1570,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
String requestTypeString = "";
- if (requestType != null && !requestType.equals("")) {
+ if (requestType != null && !"".equals(requestType)) {
requestTypeString = requestType;
}
String nestedStackId = null;
- if (volumeGroupHeatStackId != null && !volumeGroupHeatStackId.equals("")) {
- if (!volumeGroupHeatStackId.equalsIgnoreCase("null")) {
+ if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) {
+ if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
nestedStackId = volumeGroupHeatStackId;
}
}
String nestedBaseStackId = null;
- if (baseVfHeatStackId != null && !baseVfHeatStackId.equals("")) {
- if (!baseVfHeatStackId.equalsIgnoreCase("null")) {
+ if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) {
+ if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
nestedBaseStackId = baseVfHeatStackId;
}
}
if (inputs == null) {
// Create an empty set of inputs
- inputs = new HashMap<String,String>();
+ inputs = new HashMap<>();
LOGGER.debug("inputs == null - setting to empty");
} else {
this.sendMapToDebug(inputs);
@@ -1596,7 +1598,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
if (requestTypeString.startsWith("VOLUME")) {
isVolumeRequest = true;
}
- if (vfModuleName == null || vfModuleName.trim().equals("")) {
+ if (vfModuleName == null || "".equals(vfModuleName.trim())) {
if (vfModuleStackId != null) {
vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId);
}
@@ -1790,10 +1792,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
minVersionVnf = null;
maxVersionVnf = null;
}
- if (minVersionVnf != null && minVersionVnf.equals("")) {
+ if (minVersionVnf != null && "".equals(minVersionVnf)) {
minVersionVnf = null;
}
- if (maxVersionVnf != null && maxVersionVnf.equals("")) {
+ if (maxVersionVnf != null && "".equals(maxVersionVnf)) {
maxVersionVnf = null;
}
}
@@ -1898,13 +1900,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId="
+ heatTemplate.getArtifactUuid ());
Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid ());
- Map <String, Object> nestedTemplatesChecked = new HashMap <String, Object> ();
+ Map <String, Object> nestedTemplatesChecked = new HashMap <> ();
if (nestedTemplates != null) {
// for debugging print them out
LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:");
- for (String providerResourceFile : nestedTemplates.keySet ()) {
+ for (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) {
+ String providerResourceFile = entry.getKey();
+ Object value = entry.getValue();
String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile);
- String childTemplateBody = (String) nestedTemplates.get (providerResourceFile);
+ String childTemplateBody = (String) value;
nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody);
LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody);
}
@@ -1920,7 +1924,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
Map <String, HeatFiles> heatFiles = null;
// Map <String, HeatFiles> heatFiles = db.getHeatFiles (vnf.getId ());
- Map <String, Object> heatFilesObjects = new HashMap <String, Object> ();
+ Map <String, Object> heatFilesObjects = new HashMap <> ();
// Add ability to turn on adding get_files with volume requests (by property).
boolean addGetFilesOnVolumeReq = false;
@@ -1944,7 +1948,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// this will match the nested templates format
LOGGER.debug ("Contents of heatFiles - to be added to files: on stack:");
- for (String heatFileName : heatFiles.keySet ()) {
+ for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet ()) {
+ String heatFileName = entry.getKey();
+ HeatFiles value = entry.getValue();
if (heatFileName.startsWith("_ERROR|")) {
// This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1);
@@ -1956,7 +1962,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
throw new VnfException (error, MsoExceptionCategory.INTERNAL);
}
- String heatFileBody = heatFiles.get (heatFileName).getFileBody ();
+ String heatFileBody = value.getFileBody ();
LOGGER.debug (heatFileName + " -> " + heatFileBody);
heatFilesObjects.put (heatFileName, heatFileBody);
}
@@ -1968,7 +1974,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// Check that required parameters have been supplied
String missingParams = null;
- List <String> paramList = new ArrayList <String> ();
+ List <String> paramList = new ArrayList <> ();
// New for 1510 - consult the PARAM_ALIAS field to see if we've been
// supplied an alias. Only check if we don't find it initially.
@@ -2016,7 +2022,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
// New for 1607 - support params of json type
- HashMap<String, JsonNode> jsonParams = new HashMap<String, JsonNode>();
+ HashMap<String, JsonNode> jsonParams = new HashMap<>();
boolean hasJson = false;
for (HeatTemplateParam parm : heatTemplate.getParameters ()) {
@@ -2027,11 +2033,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
+ parm.getParamAlias ());
// handle json
String parameterType = parm.getParamType();
- if (parameterType == null || parameterType.trim().equals("")) {
+ if (parameterType == null || "".equals(parameterType.trim())) {
parameterType = "String";
}
JsonNode jsonNode = null;
- if (parameterType.equalsIgnoreCase("json") && inputs != null) {
+ if ("json".equalsIgnoreCase(parameterType) && inputs != null) {
if (inputs.containsKey(parm.getParamName()) ) {
hasJson = true;
String jsonString = null;
@@ -2138,7 +2144,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// Remove any extraneous parameters (don't throw an error)
if (inputs != null) {
- List <String> extraParams = new ArrayList <String> ();
+ List <String> extraParams = new ArrayList <> ();
extraParams.addAll (inputs.keySet ());
// This is not a valid parameter for this template
extraParams.removeAll (paramList);
@@ -2150,12 +2156,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 1607 - when we get here - we have clean inputs. Create inputsTwo in case we have json
Map<String, Object> inputsTwo = null;
if (hasJson && jsonParams.size() > 0) {
- inputsTwo = new HashMap<String, Object>();
- for (String keyParamName : inputs.keySet()) {
+ inputsTwo = new HashMap<>();
+ for (Map.Entry<String, String> entry : inputs.entrySet()) {
+ String keyParamName = entry.getKey();
+ String value = entry.getValue();
if (jsonParams.containsKey(keyParamName)) {
inputsTwo.put(keyParamName, jsonParams.get(keyParamName));
} else {
- inputsTwo.put(keyParamName, inputs.get(keyParamName));
+ inputsTwo.put(keyParamName, value);
}
}
}