From f47919f1fe367b612fa9c96d34c59f01a541e882 Mon Sep 17 00:00:00 2001
From: "Benjamin, Max (mb388a)"
Date: Mon, 8 Apr 2019 14:14:34 -0400
Subject: Replaced all tabs with spaces in java and pom.xml
Added in maven plugins to enforce coding style rules
Added in eclipse java formatting xml
Change-Id: I3727bbf4ce8dc66abfd8ad21b6cfd0890c5d3ff0
Issue-ID: SO-1765
Signed-off-by: Benjamin, Max (mb388a)
---
.../org/onap/so/adapters/vfc/CXFConfiguration.java | 56 +-
.../org/onap/so/adapters/vfc/RequestDBConfig.java | 53 +-
.../so/adapters/vfc/WebSecurityConfigImpl.java | 31 +-
.../so/adapters/vfc/constant/CommonConstant.java | 13 +-
.../adapters/vfc/constant/DriverExceptionID.java | 30 +-
.../vfc/exceptions/ApplicationException.java | 3 +-
.../onap/so/adapters/vfc/model/CustomerModel.java | 17 +-
.../so/adapters/vfc/model/LocationConstraint.java | 4 +-
.../vfc/model/NSResourceInputParameter.java | 31 +-
.../onap/so/adapters/vfc/model/NsCreateReq.java | 10 +-
.../onap/so/adapters/vfc/model/NsOperationKey.java | 3 +-
.../onap/so/adapters/vfc/model/NsParameters.java | 5 +-
.../so/adapters/vfc/model/NsScaleParameters.java | 42 +-
.../so/adapters/vfc/model/ResponseDescriptor.java | 1 +
.../so/adapters/vfc/model/RestfulResponse.java | 19 +-
.../so/adapters/vfc/model/ScaleNsByStepsData.java | 28 +-
.../onap/so/adapters/vfc/model/ScaleNsData.java | 5 +-
.../onap/so/adapters/vfc/model/VFCScaleData.java | 14 +-
.../onap/so/adapters/vfc/model/VimLocation.java | 8 +-
.../org/onap/so/adapters/vfc/rest/AaiUtil.java | 22 +-
.../so/adapters/vfc/rest/HealthCheckHandler.java | 15 +-
.../onap/so/adapters/vfc/rest/VfcAdapterRest.java | 21 +-
.../org/onap/so/adapters/vfc/rest/VfcManager.java | 728 ++++++++++-----------
.../org/onap/so/adapters/vfc/util/JsonUtil.java | 159 +++--
.../org/onap/so/adapters/vfc/util/RestfulUtil.java | 70 +-
.../onap/so/adapters/vfc/util/ValidateUtil.java | 97 ++-
.../vfc/exceptions/ApplicationExceptionTest.java | 54 +-
.../so/adapters/vfc/model/CustomerModelTest.java | 2 +-
.../adapters/vfc/model/LocationConstraintTest.java | 2 +-
.../vfc/model/NSResourceInputParameterTest.java | 2 +-
.../so/adapters/vfc/model/NsCreateReqTest.java | 2 +-
.../adapters/vfc/model/NsInstantiateReqTest.java | 2 +-
.../so/adapters/vfc/model/NsOperationKeyTest.java | 2 +-
.../so/adapters/vfc/model/NsParametersTest.java | 3 +-
.../adapters/vfc/model/NsProgressStatusTest.java | 3 +-
.../adapters/vfc/model/ResponseDescriptorTest.java | 2 +-
.../so/adapters/vfc/model/RestfulResponseTest.java | 3 +-
.../so/adapters/vfc/model/VimLocationTest.java | 2 +-
.../adapters/vfc/rest/EmbeddedMariaDbConfig.java | 66 +-
.../adapters/vfc/rest/HealthCheckHandlerTest.java | 41 +-
.../onap/so/adapters/vfc/rest/VfcManagerTest.java | 9 +-
41 files changed, 806 insertions(+), 874 deletions(-)
(limited to 'adapters/mso-vfc-adapter')
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java
index 656a246afc..5ea68f08a2 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java
@@ -21,7 +21,6 @@
package org.onap.so.adapters.vfc;
import java.util.Arrays;
-
import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.LoggingFeature;
@@ -34,7 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
@@ -42,45 +40,45 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
@Configuration
public class CXFConfiguration {
- @Autowired
- private Bus bus;
+ @Autowired
+ private Bus bus;
- @Autowired
+ @Autowired
private VfcAdapterRest vfcAdapterRest;
-
+
@Autowired
private JaxRsFilterLogging jaxRsFilterLogging;
-
+
@Autowired
- private ObjectMapper mapper;
-
- @Bean
- public ServletRegistrationBean cxfServlet() {
- return new ServletRegistrationBean(new CXFServlet(), "/services/*");
- }
-
+ private ObjectMapper mapper;
+
+ @Bean
+ public ServletRegistrationBean cxfServlet() {
+ return new ServletRegistrationBean(new CXFServlet(), "/services/*");
+ }
+
@Bean
public Server rsServer() {
JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
endpoint.setBus(bus);
endpoint.setServiceBeans(Arrays.
*
* @author
- * @version ONAP Amsterdam Release 2017-08-28
+ * @version ONAP Amsterdam Release 2017-08-28
*/
public static class MethodType {
@@ -76,7 +75,7 @@ public class CommonConstant {
*
*
* @author
- * @version ONAP Amsterdam Release 2017-08-28
+ * @version ONAP Amsterdam Release 2017-08-28
*/
public static class Step {
@@ -133,7 +132,7 @@ public class CommonConstant {
}
}
-
+
private CommonConstant() {
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/DriverExceptionID.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/DriverExceptionID.java
index f82a38e324..61330027c5 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/DriverExceptionID.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/DriverExceptionID.java
@@ -31,34 +31,32 @@ package org.onap.so.adapters.vfc.constant;
*/
public class DriverExceptionID {
- public static final String INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION =
- "Invalid response from instantiate operation";
+ public static final String INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION =
+ "Invalid response from instantiate operation";
- public static final String INVALID_RESPONSEE_FROM_CREATE_OPERATION =
- "Invalid response from create operation";
+ public static final String INVALID_RESPONSEE_FROM_CREATE_OPERATION = "Invalid response from create operation";
- public static final String FAIL_TO_INSTANTIATE_NS = "Fail to instantiate ns";
+ public static final String FAIL_TO_INSTANTIATE_NS = "Fail to instantiate ns";
- public static final String FAIL_TO_CREATE_NS = "Fail to create ns";
+ public static final String FAIL_TO_CREATE_NS = "Fail to create ns";
- public static final String INVALID_RESPONSE_FROM_TERMINATE_OPERATION =
- "Invalid response from terminate operation";
+ public static final String INVALID_RESPONSE_FROM_TERMINATE_OPERATION = "Invalid response from terminate operation";
- public static final String FAIL_TO_DELETE_NS = "Fail to delete ns";
+ public static final String FAIL_TO_DELETE_NS = "Fail to delete ns";
- public static final String FAIL_TO_TERMINATE_NS = "Fail to terminate ns";
+ public static final String FAIL_TO_TERMINATE_NS = "Fail to terminate ns";
- public static final String JOB_STATUS_ERROR = "Job status error";
+ public static final String JOB_STATUS_ERROR = "Job status error";
- public static final String FAIL_TO_QUERY_JOB_STATUS = "Fail to query job status";
+ public static final String FAIL_TO_QUERY_JOB_STATUS = "Fail to query job status";
- public static final String FAIL_TO_SCALE_NS = "Fail to scale network service";
+ public static final String FAIL_TO_SCALE_NS = "Fail to scale network service";
- public static final String INVALID_RESPONSE_FROM_SCALE_OPERATION = "Invalid response from scale operation";
+ public static final String INVALID_RESPONSE_FROM_SCALE_OPERATION = "Invalid response from scale operation";
- private DriverExceptionID() {
+ private DriverExceptionID() {
- }
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/exceptions/ApplicationException.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/exceptions/ApplicationException.java
index 1e712cb76b..88260a7100 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/exceptions/ApplicationException.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/exceptions/ApplicationException.java
@@ -64,8 +64,7 @@ public class ApplicationException extends Exception {
}
/**
- * build error Response
- *
+ * build error Response
*
* @return
* @since ONAP Amsterdam Release
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CustomerModel.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CustomerModel.java
index 986d168482..e54f0dfb6d 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CustomerModel.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CustomerModel.java
@@ -21,21 +21,20 @@
package org.onap.so.adapters.vfc.model;
/**
- * The Customer Model
- *
+ * The Customer Model
*
*
*
* @author
- * @version ONAP Amsterdam Release 2017-10-12
+ * @version ONAP Amsterdam Release 2017-10-12
*/
public class CustomerModel {
-
+
String globalCustomerId;
String serviceType;
-
+
/**
* @return Returns the globalCustomerId.
*/
@@ -43,7 +42,7 @@ public class CustomerModel {
return globalCustomerId;
}
-
+
/**
* @param globalCustomerId The globalCustomerId to set.
*/
@@ -51,7 +50,7 @@ public class CustomerModel {
this.globalCustomerId = globalCustomerId;
}
-
+
/**
* @return Returns the serviceType.
*/
@@ -59,12 +58,12 @@ public class CustomerModel {
return serviceType;
}
-
+
/**
* @param serviceType The serviceType to set.
*/
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
-
+
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraint.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraint.java
index a28bd9a501..b79565d7a9 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraint.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraint.java
@@ -54,7 +54,7 @@ public class LocationConstraint {
this.vnfProfileId = vnfProfileId;
}
-
+
/**
* @return Returns the locationConstraints.
*/
@@ -62,7 +62,7 @@ public class LocationConstraint {
return locationConstraints;
}
-
+
/**
* @param locationConstraints The locationConstraints to set.
*/
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NSResourceInputParameter.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NSResourceInputParameter.java
index 5d9b7ce558..266e5ee5d8 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NSResourceInputParameter.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NSResourceInputParameter.java
@@ -23,10 +23,8 @@
package org.onap.so.adapters.vfc.model;
import java.io.ByteArrayOutputStream;
-
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.slf4j.Logger;
@@ -42,20 +40,20 @@ import org.slf4j.LoggerFactory;
public class NSResourceInputParameter {
private static final Logger logger = LoggerFactory.getLogger(NSResourceInputParameter.class);
-
+
private NsOperationKey nsOperationKey;
private String nsServiceName;
private String nsServiceDescription;
-
+
private String nsServiceModelUUID;
private NsParameters nsParameters;
private NsScaleParameters nsScaleParameters;
-
+
/**
* @return Returns the nsServiceName.
*/
@@ -63,7 +61,7 @@ public class NSResourceInputParameter {
return nsServiceName;
}
-
+
/**
* @param nsServiceName The nsServiceName to set.
*/
@@ -71,7 +69,7 @@ public class NSResourceInputParameter {
this.nsServiceName = nsServiceName;
}
-
+
/**
* @return Returns the nsServiceDescription.
*/
@@ -79,7 +77,7 @@ public class NSResourceInputParameter {
return nsServiceDescription;
}
-
+
/**
* @param nsServiceDescription The nsServiceDescription to set.
*/
@@ -108,6 +106,7 @@ public class NSResourceInputParameter {
public void setNsOperationKey(NsOperationKey nsOperationKey) {
this.nsOperationKey = nsOperationKey;
}
+
public String toJsonString() {
String jsonString = null;
try {
@@ -125,7 +124,7 @@ public class NSResourceInputParameter {
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.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); // pretty print XML
marshaller.marshal(this, bs);
return bs.toString();
} catch (Exception e) {
@@ -143,13 +142,13 @@ public class NSResourceInputParameter {
}
- public String getNsServiceModelUUID() {
- return nsServiceModelUUID;
- }
+ public String getNsServiceModelUUID() {
+ return nsServiceModelUUID;
+ }
+
+ public void setNsServiceModelUUID(String nsServiceModelUUID) {
+ this.nsServiceModelUUID = nsServiceModelUUID;
+ }
- public void setNsServiceModelUUID(String nsServiceModelUUID) {
- this.nsServiceModelUUID = nsServiceModelUUID;
- }
-
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCreateReq.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCreateReq.java
index 2d09f55de2..63358cb384 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCreateReq.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCreateReq.java
@@ -31,14 +31,14 @@ package org.onap.so.adapters.vfc.model;
public class NsCreateReq {
CustomerModel context;
-
+
String csarId;
String nsName;
String description;
-
-
+
+
/**
* @return Returns the context.
*/
@@ -47,7 +47,7 @@ public class NsCreateReq {
}
-
+
/**
* @param context The context to set.
*/
@@ -63,7 +63,7 @@ public class NsCreateReq {
return csarId;
}
-
+
/**
* @param csarId The csarId to set.
*/
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsOperationKey.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsOperationKey.java
index bc67832cb2..2088d68b56 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsOperationKey.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsOperationKey.java
@@ -21,8 +21,7 @@
package org.onap.so.adapters.vfc.model;
/**
- * The operation key object for NS
- *
+ * The operation key object for NS
*
*
*
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsParameters.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsParameters.java
index 5da3d806f1..e82ee2a79a 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsParameters.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsParameters.java
@@ -37,6 +37,7 @@ public class NsParameters {
private List locationConstraints;
private Map additionalParamForNs = new HashMap<>();
+
/**
* @return Returns the locationConstraints.
*/
@@ -51,7 +52,7 @@ public class NsParameters {
this.locationConstraints = locationConstraints;
}
-
+
/**
* @return Returns the additionalParamForNs.
*/
@@ -59,7 +60,7 @@ public class NsParameters {
return additionalParamForNs;
}
-
+
/**
* @param additionalParamForNs The additionalParamForNs to set.
*/
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleParameters.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleParameters.java
index e4e217a9f5..6d089c0479 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleParameters.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleParameters.java
@@ -38,29 +38,29 @@ public class NsScaleParameters {
/**
* @return Returns the scaleNsByStepsData.
*/
- public List getScaleNsByStepsData() {
- return scaleNsByStepsData;
- }
+ public List getScaleNsByStepsData() {
+ return scaleNsByStepsData;
+ }
- /**
- * @param scaleNsByStepsData The scaleNsByStepsData to set.
- */
- public void setScaleNsByStepsData(List scaleNsByStepsData) {
- this.scaleNsByStepsData = scaleNsByStepsData;
- }
+ /**
+ * @param scaleNsByStepsData The scaleNsByStepsData to set.
+ */
+ public void setScaleNsByStepsData(List scaleNsByStepsData) {
+ this.scaleNsByStepsData = scaleNsByStepsData;
+ }
- /**
- * @return Returns the scale Type.
- */
- public String getScaleType() {
- return scaleType;
- }
+ /**
+ * @return Returns the scale Type.
+ */
+ public String getScaleType() {
+ return scaleType;
+ }
- /**
- * @param scaleType The scaleType to set.
- */
- public void setScaleType(String scaleType) {
- this.scaleType = scaleType;
- }
+ /**
+ * @param scaleType The scaleType to set.
+ */
+ public void setScaleType(String scaleType) {
+ this.scaleType = scaleType;
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResponseDescriptor.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResponseDescriptor.java
index 08e3dcae4f..3ea51c107b 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResponseDescriptor.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResponseDescriptor.java
@@ -19,6 +19,7 @@
*/
package org.onap.so.adapters.vfc.model;
+
/**
*
*
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/RestfulResponse.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/RestfulResponse.java
index ee5ecd6e19..27c9a89282 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/RestfulResponse.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/RestfulResponse.java
@@ -23,23 +23,22 @@ package org.onap.so.adapters.vfc.model;
import java.util.Map;
/**
- * The Unified Restful Reponse Class
- *
+ * The Unified Restful Reponse Class
*
*
*
* @author
- * @version ONAP Amsterdam Release 2017-09-06
+ * @version ONAP Amsterdam Release 2017-09-06
*/
public class RestfulResponse {
// the response content
private String responseContent;
- //the response status
+ // the response status
private int status;
- //the response header
+ // the response header
private Map respHeaderMap;
public RestfulResponse() {
@@ -65,9 +64,9 @@ public class RestfulResponse {
}
public int getRespHeaderInt(String key) {
- if(this.respHeaderMap != null) {
+ if (this.respHeaderMap != null) {
String result = this.respHeaderMap.get(key);
- if(result != null) {
+ if (result != null) {
return Integer.parseInt(result);
}
}
@@ -75,9 +74,9 @@ public class RestfulResponse {
}
public long getRespHeaderLong(String key) {
- if(this.respHeaderMap != null) {
+ if (this.respHeaderMap != null) {
String result = this.respHeaderMap.get(key);
- if(result != null) {
+ if (result != null) {
return Long.parseLong(result);
}
}
@@ -85,7 +84,7 @@ public class RestfulResponse {
}
public String getRespHeaderStr(String key) {
- if(this.respHeaderMap != null) {
+ if (this.respHeaderMap != null) {
return this.respHeaderMap.get(key);
}
return null;
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsByStepsData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsByStepsData.java
index 938064d3a2..f9d6274643 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsByStepsData.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsByStepsData.java
@@ -33,12 +33,12 @@ public class ScaleNsByStepsData {
* scaling Direction
*/
private String scalingDirection;
-
+
/**
* aspect ID
*/
private String aspectId;
-
+
/**
* number of Steps
*/
@@ -61,28 +61,28 @@ public class ScaleNsByStepsData {
/**
* @return Returns the aspectId.
*/
- public String getAspectId() {
- return aspectId;
- }
+ public String getAspectId() {
+ return aspectId;
+ }
/**
* @param aspectId The aspectId to set.
*/
- public void setAspectId(String aspectId) {
- this.aspectId = aspectId;
- }
+ public void setAspectId(String aspectId) {
+ this.aspectId = aspectId;
+ }
/**
* @return Returns the numberOfSteps.
*/
- public Integer getNumberOfSteps() {
- return numberOfSteps;
- }
+ public Integer getNumberOfSteps() {
+ return numberOfSteps;
+ }
/**
* @param numberOfSteps The numberOfSteps to set.
*/
- public void setNumberOfSteps(int numberOfSteps) {
- this.numberOfSteps = numberOfSteps;
- }
+ public void setNumberOfSteps(int numberOfSteps) {
+ this.numberOfSteps = numberOfSteps;
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsData.java
index b0ad26ae3f..bd50827549 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsData.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsData.java
@@ -23,11 +23,10 @@ package org.onap.so.adapters.vfc.model;
import java.util.List;
/**
- * aim to wrap List as a new list
- * then be provided for the usage of vfc json
+ * aim to wrap List as a new list then be provided for the usage of vfc json
*
* added on 2018/01/30 by Qihui Zhao from CMCC
- * */
+ */
public class ScaleNsData {
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VFCScaleData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VFCScaleData.java
index 4a393e1064..1939fa4ec4 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VFCScaleData.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VFCScaleData.java
@@ -24,10 +24,10 @@ import java.util.ArrayList;
import java.util.List;
/**
- * Object totally matches required VFC input json format
- * JsonUtil.marshal will convert this Object to string
+ * Object totally matches required VFC input json format JsonUtil.marshal will convert this Object to string
*
- * added on 2018/01/30 by Qihui Zhao from CMCC*/
+ * added on 2018/01/30 by Qihui Zhao from CMCC
+ */
public class VFCScaleData {
@@ -66,14 +66,16 @@ public class VFCScaleData {
}
/**
- *@return Returns the scaleNsDate.
+ * @return Returns the scaleNsDate.
*/
- public List getScaleNsData(){return scaleNsData;}
+ public List getScaleNsData() {
+ return scaleNsData;
+ }
/**
* The scaleNsData to set.
*/
- public void setScaleNsData(List scaleNsByStepsData){
+ public void setScaleNsData(List scaleNsByStepsData) {
ScaleNsData scaleNsDataObj = new ScaleNsData();
scaleNsDataObj.setScaleNsByStepsData(scaleNsByStepsData);
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VimLocation.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VimLocation.java
index 9f6f8ec274..456835b431 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VimLocation.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VimLocation.java
@@ -27,12 +27,12 @@ package org.onap.so.adapters.vfc.model;
*
*
* @author
- * @version ONAP Amsterdam Release 2017-10-18
+ * @version ONAP Amsterdam Release 2017-10-18
*/
public class VimLocation {
private String vimId;
-
+
/**
* @return Returns the vimId.
*/
@@ -40,12 +40,12 @@ public class VimLocation {
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/onap/so/adapters/vfc/rest/AaiUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/AaiUtil.java
index 6ae2ba0aca..7f81dfbdaf 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/AaiUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/AaiUtil.java
@@ -32,16 +32,16 @@ import org.onap.so.adapters.vfc.model.RestfulResponse;
*/
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 addRelation(String globalSubsriberId, String serviceType, String serviceInstanceId,
+ String resourceInstanceId) {
+ // sent rest to aai to add relation for service and ns.
- 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;
- }
+ 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;
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java
index 52fd8fb103..cff36061b1 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java
@@ -27,20 +27,18 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-
import org.apache.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
- * Health Check
- *
+ * Health Check
*
*
*
* @author
- * @version ONAP Amsterdam Release 2017-08-28
+ * @version ONAP Amsterdam Release 2017-08-28
*/
@Path("/")
@Component
@@ -48,12 +46,11 @@ public class HealthCheckHandler {
private static Logger logger = LoggerFactory.getLogger(HealthCheckHandler.class);
-
- private static final String CHECK_HTML = "Health CheckApplication ready";
- public static final Response HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_OK)
- .entity (CHECK_HTML)
- .build ();
+ private static final String CHECK_HTML =
+ "Health CheckApplication ready";
+
+ public static final Response HEALTH_CHECK_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();
@HEAD
@Path("/healthcheck")
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java
index db613ea988..bb9ae69f51 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java
@@ -55,10 +55,10 @@ import org.springframework.stereotype.Component;
public class VfcAdapterRest {
private static final Logger logger = LoggerFactory.getLogger(VfcAdapterRest.class);
- private static final String REQUEST_DEBUG_MSG="body from request is {}";
- private static final String APPLICATION_EXCEPTION="ApplicationException: ";
+ private static final String REQUEST_DEBUG_MSG = "body from request is {}";
+ private static final String APPLICATION_EXCEPTION = "ApplicationException: ";
@Autowired
- private VfcManager driverMgr ;
+ private VfcManager driverMgr;
public VfcAdapterRest() {
@@ -82,7 +82,7 @@ public class VfcAdapterRest {
NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class);
RestfulResponse rsp = driverMgr.createNs(nsInput);
return buildResponse(rsp);
- } catch(ApplicationException e) {
+ } catch (ApplicationException e) {
logger.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
@@ -92,7 +92,7 @@ public class VfcAdapterRest {
* Delete NS instance
*
* @param data The http request
- * @param nsInstanceId The NS instance id
+ * @param nsInstanceId The NS instance id
* @return response
* @since ONAP Amsterdam Release
*/
@@ -108,7 +108,7 @@ public class VfcAdapterRest {
NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId);
return buildResponse(rsp);
- } catch(ApplicationException e) {
+ } catch (ApplicationException e) {
logger.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
@@ -133,7 +133,7 @@ public class VfcAdapterRest {
NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId);
return buildResponse(rsp);
- } catch(ApplicationException e) {
+ } catch (ApplicationException e) {
logger.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
@@ -158,7 +158,7 @@ public class VfcAdapterRest {
NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class);
RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput);
return buildResponse(rsp);
- } catch(ApplicationException e) {
+ } catch (ApplicationException e) {
logger.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
@@ -183,15 +183,14 @@ public class VfcAdapterRest {
NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId);
return buildResponse(rsp);
- } catch(ApplicationException e) {
+ } catch (ApplicationException e) {
logger.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
/**
- * Scale NS instance
- *
+ * Scale NS instance
*
* @param servletReq The http request
* @param nsInstanceId The NS instance id
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcManager.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcManager.java
index 86aba2f84b..b817b5bf9a 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcManager.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcManager.java
@@ -22,7 +22,6 @@ package org.onap.so.adapters.vfc.rest;
import java.util.HashMap;
import java.util.Map;
-
import org.onap.so.adapters.vfc.constant.CommonConstant;
import org.onap.so.adapters.vfc.constant.CommonConstant.Step;
import org.onap.so.adapters.vfc.constant.DriverExceptionID;
@@ -64,363 +63,357 @@ import org.springframework.stereotype.Component;
@Primary
public class VfcManager {
- private static final Logger LOGGER = LoggerFactory.getLogger(VfcManager.class);
-
- /**
- * nfvo url map
- */
- private Map nfvoUrlMap;
-
- @Autowired
- private ResourceOperationStatusRepository resourceOperationStatusRepository;
-
- @Autowired
- private RestfulUtil restfulUtil;
-
-
- public VfcManager() {
- nfvoUrlMap = new HashMap<>();
- nfvoUrlMap.put(Step.CREATE, CommonConstant.NFVO_CREATE_URL);
- nfvoUrlMap.put(Step.INSTANTIATE, CommonConstant.NFVO_INSTANTIATE_URL);
- nfvoUrlMap.put(Step.TERMINATE, CommonConstant.NFVO_TERMINATE_URL);
- nfvoUrlMap.put(Step.DELETE, CommonConstant.NFVO_DELETE_URL);
- nfvoUrlMap.put(Step.QUERY, CommonConstant.NFVO_QUERY_URL);
- nfvoUrlMap.put(Step.SCALE, CommonConstant.NFVO_SCALE_URL);
- }
-
- /**
- * create network service
- *
- * @param segInput input parameters for current node from http request
- * @return
- * @since ONAP Amsterdam Release
- */
- public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException {
-
- // Step1: get service template by node type
- String csarId = segInput.getNsServiceModelUUID();
- // nsdId for NFVO is "id" in the response, while for SDNO is "servcice template id"
- LOGGER.info("serviceTemplateId is {}, id is {}", csarId, csarId);
-
- LOGGER.info("create ns -> begin");
- // Step2: Prepare url and method type
- String url = getUrl(null, CommonConstant.Step.CREATE);
- String methodType = CommonConstant.MethodType.POST;
-
- // Step3: Prepare restful parameters and options
- NsCreateReq oRequest = new NsCreateReq();
- oRequest.setCsarId(csarId);
- oRequest.setNsName(segInput.getNsServiceName());
- oRequest.setDescription(segInput.getNsServiceDescription());
- CustomerModel context = new CustomerModel();
- context.setGlobalCustomerId(segInput.getNsOperationKey().getGlobalSubscriberId());
- context.setServiceType(segInput.getNsOperationKey().getServiceType());
- oRequest.setContext(context);
- String createReq = JsonUtil.marshal(oRequest);
-
- // Step4: Call NFVO or SDNO lcm to create ns
- RestfulResponse createRsp = restfulUtil.send(url, methodType, createReq);
- ValidateUtil.assertObjectNotNull(createRsp);
- LOGGER.info("create ns response status is : {}", createRsp.getStatus());
- LOGGER.info("create ns response content is : {}", createRsp.getResponseContent());
-
- // Step 5: save resource operation information
- ResourceOperationStatus status = new ResourceOperationStatus(segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(), segInput.getNsOperationKey().getNodeTemplateUUID());
- status.setStatus(RequestsDbConstant.Status.PROCESSING);
- status = resourceOperationStatusRepository.save(status);
- if (!HttpCode.isSucess(createRsp.getStatus())) {
- LOGGER.error("update segment operation status : fail to create ns");
- status.setProgress("40");
- status.setStatusDescription("NS is created");
- status.setStatus(RequestsDbConstant.Status.ERROR);
- status.setErrorCode(String.valueOf(createRsp.getStatus()));
- resourceOperationStatusRepository.save(status);
- throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
- DriverExceptionID.FAIL_TO_CREATE_NS);
- }
- @SuppressWarnings("unchecked")
- Map 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);
+ private static final Logger LOGGER = LoggerFactory.getLogger(VfcManager.class);
+
+ /**
+ * nfvo url map
+ */
+ private Map nfvoUrlMap;
+
+ @Autowired
+ private ResourceOperationStatusRepository resourceOperationStatusRepository;
+
+ @Autowired
+ private RestfulUtil restfulUtil;
+
+
+ public VfcManager() {
+ nfvoUrlMap = new HashMap<>();
+ nfvoUrlMap.put(Step.CREATE, CommonConstant.NFVO_CREATE_URL);
+ nfvoUrlMap.put(Step.INSTANTIATE, CommonConstant.NFVO_INSTANTIATE_URL);
+ nfvoUrlMap.put(Step.TERMINATE, CommonConstant.NFVO_TERMINATE_URL);
+ nfvoUrlMap.put(Step.DELETE, CommonConstant.NFVO_DELETE_URL);
+ nfvoUrlMap.put(Step.QUERY, CommonConstant.NFVO_QUERY_URL);
+ nfvoUrlMap.put(Step.SCALE, CommonConstant.NFVO_SCALE_URL);
}
- LOGGER.info("create ns -> end");
- LOGGER.info("save segment and operaton info -> begin");
- // Step 6: add relation between service and NS
- AaiUtil.addRelation(segInput.getNsOperationKey().getGlobalSubscriberId(),
- segInput.getNsOperationKey().getServiceType(), segInput.getNsOperationKey().getServiceId(),
- nsInstanceId);
- LOGGER.info("save segment and operation info -> end");
- return createRsp;
- }
-
- /**
- * delete network service
- *
- * @param nsOperationKey The operation key of the NS resource
- * @param nsInstanceId The NS instance id
- * @return
- * @since ONAP Amsterdam Release
- */
- public RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId)
- throws ApplicationException {
- LOGGER.info("delete ns -> begin");
- // Step1: prepare url and methodType
- String url = getUrl(nsInstanceId, CommonConstant.Step.DELETE);
- String methodType = CommonConstant.MethodType.DELETE;
-
- // Step2: prepare restful parameters and options
- RestfulResponse deleteRsp = restfulUtil.send(url, methodType, "");
- ValidateUtil.assertObjectNotNull(deleteRsp);
- LOGGER.info("delete ns response status is : {}", deleteRsp.getStatus());
- LOGGER.info("delete ns response content is : {}", deleteRsp.getResponseContent());
- LOGGER.info("delete ns -> end");
-
- ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(), nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
- if (!HttpCode.isSucess(deleteRsp.getStatus())) {
- LOGGER.error("fail to delete ns");
-
- status.setStatus(RequestsDbConstant.Status.ERROR);
- status.setErrorCode(String.valueOf(deleteRsp.getStatus()));
- status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
- resourceOperationStatusRepository.save(status);
- throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
- DriverExceptionID.FAIL_TO_DELETE_NS);
+
+ /**
+ * create network service
+ *
+ * @param segInput input parameters for current node from http request
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException {
+
+ // Step1: get service template by node type
+ String csarId = segInput.getNsServiceModelUUID();
+ // nsdId for NFVO is "id" in the response, while for SDNO is "servcice template id"
+ LOGGER.info("serviceTemplateId is {}, id is {}", csarId, csarId);
+
+ LOGGER.info("create ns -> begin");
+ // Step2: Prepare url and method type
+ String url = getUrl(null, CommonConstant.Step.CREATE);
+ String methodType = CommonConstant.MethodType.POST;
+
+ // Step3: Prepare restful parameters and options
+ NsCreateReq oRequest = new NsCreateReq();
+ oRequest.setCsarId(csarId);
+ oRequest.setNsName(segInput.getNsServiceName());
+ oRequest.setDescription(segInput.getNsServiceDescription());
+ CustomerModel context = new CustomerModel();
+ context.setGlobalCustomerId(segInput.getNsOperationKey().getGlobalSubscriberId());
+ context.setServiceType(segInput.getNsOperationKey().getServiceType());
+ oRequest.setContext(context);
+ String createReq = JsonUtil.marshal(oRequest);
+
+ // Step4: Call NFVO or SDNO lcm to create ns
+ RestfulResponse createRsp = restfulUtil.send(url, methodType, createReq);
+ ValidateUtil.assertObjectNotNull(createRsp);
+ LOGGER.info("create ns response status is : {}", createRsp.getStatus());
+ LOGGER.info("create ns response content is : {}", createRsp.getResponseContent());
+
+ // Step 5: save resource operation information
+ ResourceOperationStatus status = new ResourceOperationStatus(segInput.getNsOperationKey().getServiceId(),
+ segInput.getNsOperationKey().getOperationId(), segInput.getNsOperationKey().getNodeTemplateUUID());
+ status.setStatus(RequestsDbConstant.Status.PROCESSING);
+ status = resourceOperationStatusRepository.save(status);
+ if (!HttpCode.isSucess(createRsp.getStatus())) {
+ LOGGER.error("update segment operation status : fail to create ns");
+ status.setProgress("40");
+ status.setStatusDescription("NS is created");
+ status.setStatus(RequestsDbConstant.Status.ERROR);
+ status.setErrorCode(String.valueOf(createRsp.getStatus()));
+ resourceOperationStatusRepository.save(status);
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_CREATE_NS);
+ }
+ @SuppressWarnings("unchecked")
+ Map 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 6: add relation between service and NS
+ AaiUtil.addRelation(segInput.getNsOperationKey().getGlobalSubscriberId(),
+ segInput.getNsOperationKey().getServiceType(), segInput.getNsOperationKey().getServiceId(),
+ nsInstanceId);
+ LOGGER.info("save segment and operation info -> end");
+ return createRsp;
}
- // 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
- status.setStatus(RequestsDbConstant.Status.FINISHED);
- status.setErrorCode(String.valueOf(deleteRsp.getStatus()));
- status.setProgress("100");
- status.setStatusDescription("VFC resource deletion finished");
- resourceOperationStatusRepository.save(status);
- LOGGER.info("update segment operaton status for delete -> end");
-
- return deleteRsp;
-
- }
-
- /**
- * instantiate network service
- *
- * @param nsInstanceId The NS instance id
- * @param segInput input parameters for current node from http request
- * @return
- * @since ONAP Amsterdam Release
- */
- public RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput)
- throws ApplicationException {
- // Call the NFVO or SDNO service to instantiate service
- LOGGER.info("instantiate ns -> begin");
-
- // Step1: Prepare restful parameters and options
- NsInstantiateReq oRequest = new NsInstantiateReq();
- oRequest.setNsInstanceId(nsInstanceId);
- NsParameters nsParameters = segInput.getNsParameters();
- oRequest.setLocationConstraints(nsParameters.getLocationConstraints());
- oRequest.setAdditionalParamForNs(nsParameters.getAdditionalParamForNs());
- String instReq = JsonUtil.marshal(oRequest);
- // Step2: prepare url and
- String url = getUrl(nsInstanceId, CommonConstant.Step.INSTANTIATE);
- String methodType = CommonConstant.MethodType.POST;
-
- RestfulResponse instRsp = restfulUtil.send(url, methodType, instReq);
- ResourceOperationStatus status = new ResourceOperationStatus(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");
- status.setStatus(RequestsDbConstant.Status.ERROR);
- status.setErrorCode(String.valueOf(instRsp.getStatus()));
- status.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED);
+ /**
+ * delete network service
+ *
+ * @param nsOperationKey The operation key of the NS resource
+ * @param nsInstanceId The NS instance id
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ public RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId) throws ApplicationException {
+ LOGGER.info("delete ns -> begin");
+ // Step1: prepare url and methodType
+ String url = getUrl(nsInstanceId, CommonConstant.Step.DELETE);
+ String methodType = CommonConstant.MethodType.DELETE;
+
+ // Step2: prepare restful parameters and options
+ RestfulResponse deleteRsp = restfulUtil.send(url, methodType, "");
+ ValidateUtil.assertObjectNotNull(deleteRsp);
+ LOGGER.info("delete ns response status is : {}", deleteRsp.getStatus());
+ LOGGER.info("delete ns response content is : {}", deleteRsp.getResponseContent());
+ LOGGER.info("delete ns -> end");
+
+ ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(),
+ nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
+ if (!HttpCode.isSucess(deleteRsp.getStatus())) {
+ LOGGER.error("fail to delete ns");
+
+ status.setStatus(RequestsDbConstant.Status.ERROR);
+ status.setErrorCode(String.valueOf(deleteRsp.getStatus()));
+ status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
+ resourceOperationStatusRepository.save(status);
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, 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
+ status.setStatus(RequestsDbConstant.Status.FINISHED);
+ status.setErrorCode(String.valueOf(deleteRsp.getStatus()));
+ status.setProgress("100");
+ status.setStatusDescription("VFC resource deletion finished");
resourceOperationStatusRepository.save(status);
- 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());
- @SuppressWarnings("unchecked")
- Map rsp = JsonUtil.unMarshal(instRsp.getResponseContent(), Map.class);
- String jobId = rsp.get(CommonConstant.JOB_ID);
- if (ValidateUtil.isStrEmpty(jobId)) {
- LOGGER.error("Invalid jobId from instantiate operation");
- status.setStatus(RequestsDbConstant.Status.ERROR);
- status.setErrorCode(String.valueOf(instRsp.getStatus()));
- status.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED);
- resourceOperationStatusRepository.save(status);
- throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
- DriverExceptionID.INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION);
- }
- LOGGER.info("instantiate ns -> end");
- // Step 3: update segment operation job id
- LOGGER.info("update resource operation status job id -> begin");
- status.setJobId(jobId);
- status.setProgress("100");
- status.setStatusDescription("NS initiation completed.");
- resourceOperationStatusRepository.save(status);
- LOGGER.info("update segment operation job id -> end");
-
- return instRsp;
- }
-
- /**
- * terminate network service
- *
- * @param nsOperationKey The operation key for NS resource
- * @param nsInstanceId The NS instance id
- * @return
- * @since ONAP Amsterdam Release
- */
- public RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId)
- throws ApplicationException {
- // Step1: save segment operation info for delete process
- LOGGER.info("save segment operation for delete process");
- ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(), nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
- status.setStatus(RequestsDbConstant.Status.PROCESSING);
- resourceOperationStatusRepository.save(status);
-
- LOGGER.info("terminate ns -> begin");
- // Step2: prepare url and method type
- String url = getUrl(nsInstanceId, CommonConstant.Step.TERMINATE);
- String methodType = CommonConstant.MethodType.POST;
-
- // Step3: prepare restful parameters and options
- Map reqBody = new HashMap<>();
- reqBody.put("nsInstanceId", nsInstanceId);
- reqBody.put("terminationType", "graceful");
- reqBody.put("gracefulTerminationTimeout", "60");
-
- // Step4: Call the NFVO or SDNO service to terminate service
- RestfulResponse terminateRsp = restfulUtil.send(url, methodType, JsonUtil.marshal(reqBody));
- 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");
- status.setStatus(RequestsDbConstant.Status.ERROR);
- status.setErrorCode(String.valueOf(terminateRsp.getStatus()));
- status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
- resourceOperationStatusRepository.save(status);
-
- throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
- DriverExceptionID.FAIL_TO_TERMINATE_NS);
- }
- @SuppressWarnings("unchecked")
- Map rsp = JsonUtil.unMarshal(terminateRsp.getResponseContent(), Map.class);
- String jobId = rsp.get(CommonConstant.JOB_ID);
- if (ValidateUtil.isStrEmpty(jobId)) {
- LOGGER.error("Invalid jobId from terminate operation");
- status.setStatus(RequestsDbConstant.Status.ERROR);
- status.setErrorCode(String.valueOf(terminateRsp.getStatus()));
- status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
- resourceOperationStatusRepository.save(status);
- throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
- DriverExceptionID.INVALID_RESPONSE_FROM_TERMINATE_OPERATION);
+ LOGGER.info("update segment operaton status for delete -> end");
+
+ return deleteRsp;
+
}
- LOGGER.info("terminate ns -> end");
-
- LOGGER.info("update segment job id -> begin");
- status.setProgress("60");
- status.setStatusDescription("NS is termination completed");
- status.setJobId(jobId);
- resourceOperationStatusRepository.save(status);
- LOGGER.info("update segment job id -> end");
-
- return terminateRsp;
- }
-
- /**
- * get ns progress by job Id
- *
- * @param nsOperationKey The OperationKey for NS resource
- * @param jobId the job id
- * @return
- * @since ONAP Amsterdam Release
- */
- public RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId)
- throws ApplicationException {
-
- ValidateUtil.assertObjectNotNull(jobId);
- // Step 1: query the current resource operation status
- ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(), nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
- status = resourceOperationStatusRepository.findOne(Example.of(status))
- .orElseThrow( () -> new ApplicationException(404,"Cannot Find Operation Status"));
- // Step 2: start query
- LOGGER.info("query ns status -> begin");
- String url = getUrl(jobId, CommonConstant.Step.QUERY);
- String methodType = CommonConstant.MethodType.GET;
- // prepare restful parameters and options
- RestfulResponse rsp = restfulUtil.send(url, methodType, "");
- ValidateUtil.assertObjectNotNull(rsp);
- LOGGER.info("query ns progress response status is : {}", rsp.getStatus());
- LOGGER.info("query ns progress response content is : {}", rsp.getResponseContent());
- // Step 3:check the response staus
- if (!HttpCode.isSucess(rsp.getStatus())) {
- LOGGER.info("fail to query job status");
- status.setErrorCode(String.valueOf(rsp.getStatus()));
- status.setStatus(RequestsDbConstant.Status.ERROR);
- status.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED);
- resourceOperationStatusRepository.save(status);
- throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
- DriverExceptionID.FAIL_TO_QUERY_JOB_STATUS);
+
+ /**
+ * instantiate network service
+ *
+ * @param nsInstanceId The NS instance id
+ * @param segInput input parameters for current node from http request
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ public RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput)
+ throws ApplicationException {
+ // Call the NFVO or SDNO service to instantiate service
+ LOGGER.info("instantiate ns -> begin");
+
+ // Step1: Prepare restful parameters and options
+ NsInstantiateReq oRequest = new NsInstantiateReq();
+ oRequest.setNsInstanceId(nsInstanceId);
+ NsParameters nsParameters = segInput.getNsParameters();
+ oRequest.setLocationConstraints(nsParameters.getLocationConstraints());
+ oRequest.setAdditionalParamForNs(nsParameters.getAdditionalParamForNs());
+ String instReq = JsonUtil.marshal(oRequest);
+ // Step2: prepare url and
+ String url = getUrl(nsInstanceId, CommonConstant.Step.INSTANTIATE);
+ String methodType = CommonConstant.MethodType.POST;
+
+ RestfulResponse instRsp = restfulUtil.send(url, methodType, instReq);
+ ResourceOperationStatus status = new ResourceOperationStatus(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");
+ status.setStatus(RequestsDbConstant.Status.ERROR);
+ status.setErrorCode(String.valueOf(instRsp.getStatus()));
+ status.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED);
+ resourceOperationStatusRepository.save(status);
+ 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());
+ @SuppressWarnings("unchecked")
+ Map rsp = JsonUtil.unMarshal(instRsp.getResponseContent(), Map.class);
+ String jobId = rsp.get(CommonConstant.JOB_ID);
+ if (ValidateUtil.isStrEmpty(jobId)) {
+ LOGGER.error("Invalid jobId from instantiate operation");
+ status.setStatus(RequestsDbConstant.Status.ERROR);
+ status.setErrorCode(String.valueOf(instRsp.getStatus()));
+ status.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED);
+ resourceOperationStatusRepository.save(status);
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
+ DriverExceptionID.INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION);
+ }
+ LOGGER.info("instantiate ns -> end");
+ // Step 3: update segment operation job id
+ LOGGER.info("update resource operation status job id -> begin");
+ status.setJobId(jobId);
+ status.setProgress("100");
+ status.setStatusDescription("NS initiation completed.");
+ resourceOperationStatusRepository.save(status);
+ LOGGER.info("update segment operation job id -> end");
+
+ return instRsp;
}
- // Step 4: Process Network Service Instantiate Response
- NsProgressStatus nsProgress =
- JsonUtil.unMarshal(rsp.getResponseContent(), NsProgressStatus.class);
- ResponseDescriptor rspDesc = nsProgress.getResponseDescriptor();
- // Step 5: update segment operation progress
-
- status.setProgress(rspDesc.getProgress());
- status.setStatusDescription(rspDesc.getStatusDescription());
- resourceOperationStatusRepository.save(status);
-
- // Step 6: update segment operation status
- if (RequestsDbConstant.Progress.ONE_HUNDRED.equals(rspDesc.getProgress())
- && RequestsDbConstant.Status.FINISHED.equals(rspDesc.getStatus())) {
- LOGGER.info("job result is succeeded, operType is {}", status.getOperType());
- status.setErrorCode(String.valueOf(rsp.getStatus()));
- status.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED);
-
- if(RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase(status.getOperType()) || "createInstance".equalsIgnoreCase (status.getOperType())) {
- status.setStatus(RequestsDbConstant.Status.FINISHED);
- }
- resourceOperationStatusRepository.save(status);
- } else if (RequestsDbConstant.Status.ERROR.equals(rspDesc.getStatus())) {
- LOGGER.error("job result is failed, operType is {}", status.getOperType());
- status.setErrorCode(String.valueOf(rsp.getStatus()));
- status.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED);
- status.setStatus(RequestsDbConstant.Status.ERROR);
- resourceOperationStatusRepository.save(status);
- throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
- DriverExceptionID.JOB_STATUS_ERROR);
- } else {
- LOGGER.error("unexcepted response status");
+
+ /**
+ * terminate network service
+ *
+ * @param nsOperationKey The operation key for NS resource
+ * @param nsInstanceId The NS instance id
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ public RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId) throws ApplicationException {
+ // Step1: save segment operation info for delete process
+ LOGGER.info("save segment operation for delete process");
+ ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(),
+ nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
+ status.setStatus(RequestsDbConstant.Status.PROCESSING);
+ resourceOperationStatusRepository.save(status);
+
+ LOGGER.info("terminate ns -> begin");
+ // Step2: prepare url and method type
+ String url = getUrl(nsInstanceId, CommonConstant.Step.TERMINATE);
+ String methodType = CommonConstant.MethodType.POST;
+
+ // Step3: prepare restful parameters and options
+ Map reqBody = new HashMap<>();
+ reqBody.put("nsInstanceId", nsInstanceId);
+ reqBody.put("terminationType", "graceful");
+ reqBody.put("gracefulTerminationTimeout", "60");
+
+ // Step4: Call the NFVO or SDNO service to terminate service
+ RestfulResponse terminateRsp = restfulUtil.send(url, methodType, JsonUtil.marshal(reqBody));
+ 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");
+ status.setStatus(RequestsDbConstant.Status.ERROR);
+ status.setErrorCode(String.valueOf(terminateRsp.getStatus()));
+ status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
+ resourceOperationStatusRepository.save(status);
+
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_TERMINATE_NS);
+ }
+ @SuppressWarnings("unchecked")
+ Map rsp = JsonUtil.unMarshal(terminateRsp.getResponseContent(), Map.class);
+ String jobId = rsp.get(CommonConstant.JOB_ID);
+ if (ValidateUtil.isStrEmpty(jobId)) {
+ LOGGER.error("Invalid jobId from terminate operation");
+ status.setStatus(RequestsDbConstant.Status.ERROR);
+ status.setErrorCode(String.valueOf(terminateRsp.getStatus()));
+ status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
+ resourceOperationStatusRepository.save(status);
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
+ DriverExceptionID.INVALID_RESPONSE_FROM_TERMINATE_OPERATION);
+ }
+ LOGGER.info("terminate ns -> end");
+
+ LOGGER.info("update segment job id -> begin");
+ status.setProgress("60");
+ status.setStatusDescription("NS is termination completed");
+ status.setJobId(jobId);
+ resourceOperationStatusRepository.save(status);
+ LOGGER.info("update segment job id -> end");
+
+ return terminateRsp;
}
- LOGGER.info("query ns status -> end");
- return rsp;
- }
+ /**
+ * get ns progress by job Id
+ *
+ * @param nsOperationKey The OperationKey for NS resource
+ * @param jobId the job id
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ public RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId) throws ApplicationException {
+
+ ValidateUtil.assertObjectNotNull(jobId);
+ // Step 1: query the current resource operation status
+ ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(),
+ nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
+ status = resourceOperationStatusRepository.findOne(Example.of(status))
+ .orElseThrow(() -> new ApplicationException(404, "Cannot Find Operation Status"));
+ // Step 2: start query
+ LOGGER.info("query ns status -> begin");
+ String url = getUrl(jobId, CommonConstant.Step.QUERY);
+ String methodType = CommonConstant.MethodType.GET;
+ // prepare restful parameters and options
+ RestfulResponse rsp = restfulUtil.send(url, methodType, "");
+ ValidateUtil.assertObjectNotNull(rsp);
+ LOGGER.info("query ns progress response status is : {}", rsp.getStatus());
+ LOGGER.info("query ns progress response content is : {}", rsp.getResponseContent());
+ // Step 3:check the response staus
+ if (!HttpCode.isSucess(rsp.getStatus())) {
+ LOGGER.info("fail to query job status");
+ status.setErrorCode(String.valueOf(rsp.getStatus()));
+ status.setStatus(RequestsDbConstant.Status.ERROR);
+ status.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED);
+ resourceOperationStatusRepository.save(status);
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_QUERY_JOB_STATUS);
+ }
+ // Step 4: Process Network Service Instantiate Response
+ NsProgressStatus nsProgress = JsonUtil.unMarshal(rsp.getResponseContent(), NsProgressStatus.class);
+ ResponseDescriptor rspDesc = nsProgress.getResponseDescriptor();
+ // Step 5: update segment operation progress
+
+ status.setProgress(rspDesc.getProgress());
+ status.setStatusDescription(rspDesc.getStatusDescription());
+ resourceOperationStatusRepository.save(status);
+
+ // Step 6: update segment operation status
+ if (RequestsDbConstant.Progress.ONE_HUNDRED.equals(rspDesc.getProgress())
+ && RequestsDbConstant.Status.FINISHED.equals(rspDesc.getStatus())) {
+ LOGGER.info("job result is succeeded, operType is {}", status.getOperType());
+ status.setErrorCode(String.valueOf(rsp.getStatus()));
+ status.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED);
+
+ if (RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase(status.getOperType())
+ || "createInstance".equalsIgnoreCase(status.getOperType())) {
+ status.setStatus(RequestsDbConstant.Status.FINISHED);
+ }
+ resourceOperationStatusRepository.save(status);
+ } else if (RequestsDbConstant.Status.ERROR.equals(rspDesc.getStatus())) {
+ LOGGER.error("job result is failed, operType is {}", status.getOperType());
+ status.setErrorCode(String.valueOf(rsp.getStatus()));
+ status.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED);
+ status.setStatus(RequestsDbConstant.Status.ERROR);
+ resourceOperationStatusRepository.save(status);
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.JOB_STATUS_ERROR);
+ } else {
+ LOGGER.error("unexcepted response status");
+ }
+ LOGGER.info("query ns status -> end");
+
+ return rsp;
+ }
/**
- * Scale NS instance
- *
+ * Scale NS instance
*
* @param nsInstanceId The NS instance id
* @param segInput input parameters for current node from http request
* @return
* @since ONAP Amsterdam Release
*/
- public RestfulResponse scaleNs(String nsInstanceId, NSResourceInputParameter segInput)
- throws ApplicationException {
- // Call the NFVO to scale service
+ public RestfulResponse scaleNs(String nsInstanceId, NSResourceInputParameter segInput) throws ApplicationException {
+ // Call the NFVO to scale service
LOGGER.info("scale ns -> begin");
// Step1: Prepare restful parameters and options
@@ -430,19 +423,20 @@ public class VfcManager {
oRequest.setScaleType(nsScaleParameters.getScaleType());
oRequest.setScaleNsData(nsScaleParameters.getScaleNsByStepsData());
String scaleReq = JsonUtil.marshal(oRequest);
-
+
// Step2: prepare url and method type
String url = getUrl(nsInstanceId, CommonConstant.Step.SCALE);
String methodType = CommonConstant.MethodType.POST;
LOGGER.info("scale ns request is {}", scaleReq);
// Step3: Call NFVO lcm to scale ns
RestfulResponse scaleRsp = restfulUtil.send(url, methodType, scaleReq);
-
- ResourceOperationStatus status = new ResourceOperationStatus(segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(), segInput.getNsOperationKey().getNodeTemplateUUID());
+
+ ResourceOperationStatus status = new ResourceOperationStatus(segInput.getNsOperationKey().getServiceId(),
+ segInput.getNsOperationKey().getOperationId(), segInput.getNsOperationKey().getNodeTemplateUUID());
ResourceOperationStatus nsOperInfo = resourceOperationStatusRepository.findOne(Example.of(status))
- .orElseThrow( () -> new ApplicationException(404,"Cannot Find Operation Status"));
+ .orElseThrow(() -> new ApplicationException(404, "Cannot Find Operation Status"));
ValidateUtil.assertObjectNotNull(scaleRsp);
- if(!HttpCode.isSucess(scaleRsp.getStatus())) {
+ if (!HttpCode.isSucess(scaleRsp.getStatus())) {
LOGGER.error("update segment operation status : fail to scale ns");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setErrorCode(String.valueOf(scaleRsp.getStatus()));
@@ -457,7 +451,7 @@ public class VfcManager {
@SuppressWarnings("unchecked")
Map rsp = JsonUtil.unMarshal(scaleRsp.getResponseContent(), Map.class);
String jobId = rsp.get(CommonConstant.JOB_ID);
- if(ValidateUtil.isStrEmpty(jobId)) {
+ if (ValidateUtil.isStrEmpty(jobId)) {
LOGGER.error("Invalid jobId from scale operation");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setErrorCode(String.valueOf(scaleRsp.getStatus()));
@@ -473,26 +467,26 @@ public class VfcManager {
resourceOperationStatusRepository.save(nsOperInfo);
LOGGER.info("update segment operation job id -> end");
LOGGER.info("scale ns -> end");
-
+
return scaleRsp;
}
-
- /**
- * get url for the operation
- *
- * @param variable variable should be put in the url
- * @param step step of the operation (terminate,query,delete)
- * @return
- * @since ONAP Amsterdam Release
- */
- private String getUrl(String variable, String step) {
-
- String url;
- String originalUrl;
- originalUrl = nfvoUrlMap.get(step);
- url = String.format(originalUrl, variable);
- return url;
-
- }
+
+ /**
+ * get url for the operation
+ *
+ * @param variable variable should be put in the url
+ * @param step step of the operation (terminate,query,delete)
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ private String getUrl(String variable, String step) {
+
+ String url;
+ String originalUrl;
+ originalUrl = nfvoUrlMap.get(step);
+ url = String.format(originalUrl, variable);
+ return url;
+
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java
index 2c1155ca6f..cefaadbb63 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java
@@ -24,12 +24,10 @@
package org.onap.so.adapters.vfc.util;
import java.io.IOException;
-
import org.onap.so.adapters.vfc.constant.HttpCode;
import org.onap.so.adapters.vfc.exceptions.ApplicationException;
import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
-
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -47,93 +45,92 @@ import org.slf4j.LoggerFactory;
*/
public class JsonUtil {
- /**
- * Log service
- */
- private static final Logger logger = LoggerFactory.getLogger(JsonUtil.class);
+ /**
+ * Log service
+ */
+ private static final Logger logger = LoggerFactory.getLogger(JsonUtil.class);
- /**
- * Mapper.
- */
- private static final ObjectMapper MAPPER = new ObjectMapper();
- private static final String UNMARSHAL_FAIL_MSG="fail to unMarshal json";
- static {
- MAPPER.setConfig(MAPPER.getDeserializationConfig().without(
- DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
- MAPPER.setSerializationInclusion(Include.NON_NULL);
- }
+ /**
+ * Mapper.
+ */
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+ private static final String UNMARSHAL_FAIL_MSG = "fail to unMarshal json";
+ static {
+ MAPPER.setConfig(MAPPER.getDeserializationConfig().without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
+ MAPPER.setSerializationInclusion(Include.NON_NULL);
+ }
- /**
- * Constructor
- *
- *
- *
- * @since ONAP Amsterdam Release 2017-9-6
- */
- private JsonUtil() {
+ /**
+ * Constructor
+ *
+ *
+ *
+ * @since ONAP Amsterdam Release 2017-9-6
+ */
+ private JsonUtil() {
- }
+ }
- /**
- * Parse the string in form of json.
- *
- * @param jsonstr json string.
- * @param type that convert json string to
- * @return model object
- * @since ONAP Amsterdam Release 2017-9-6
- */
- public static T unMarshal(String jsonstr, Class type) throws ApplicationException {
- try {
- return MAPPER.readValue(jsonstr, type);
- } catch (IOException e) {
- logger.error("{} {} {}", MessageEnum.RA_NS_EXC.toString(), ErrorCode.BusinessProcesssError.getValue(),
- UNMARSHAL_FAIL_MSG, e);
- throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG);
+ /**
+ * Parse the string in form of json.
+ *
+ * @param jsonstr json string.
+ * @param type that convert json string to
+ * @return model object
+ * @since ONAP Amsterdam Release 2017-9-6
+ */
+ public static T unMarshal(String jsonstr, Class type) throws ApplicationException {
+ try {
+ return MAPPER.readValue(jsonstr, type);
+ } catch (IOException e) {
+ logger.error("{} {} {}", MessageEnum.RA_NS_EXC.toString(), ErrorCode.BusinessProcesssError.getValue(),
+ UNMARSHAL_FAIL_MSG, e);
+ throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG);
+ }
}
- }
- /**
- * Parse the string in form of json.
- *
- * @param jsonstr json string.
- * @param type that convert json string to
- * @return model object
- * @since ONAP Amsterdam Release 2017-9-6
- */
- public static T unMarshal(String jsonstr, TypeReference type) throws ApplicationException {
- try {
- return MAPPER.readValue(jsonstr, type);
- } catch (IOException e) {
- logger.error("{} {} {}", MessageEnum.RA_NS_EXC.toString(), ErrorCode.BusinessProcesssError.getValue(),
- UNMARSHAL_FAIL_MSG, e);
- throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG);
+ /**
+ * Parse the string in form of json.
+ *
+ * @param jsonstr json string.
+ * @param type that convert json string to
+ * @return model object
+ * @since ONAP Amsterdam Release 2017-9-6
+ */
+ public static T unMarshal(String jsonstr, TypeReference type) throws ApplicationException {
+ try {
+ return MAPPER.readValue(jsonstr, type);
+ } catch (IOException e) {
+ logger.error("{} {} {}", MessageEnum.RA_NS_EXC.toString(), ErrorCode.BusinessProcesssError.getValue(),
+ UNMARSHAL_FAIL_MSG, e);
+ throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG);
+ }
}
- }
- /**
- * Convert object to json string.
- *
- * @param srcObj data object
- * @return json string
- * @since ONAP Amsterdam Release 2017-9-6
- */
- public static String marshal(Object srcObj) throws ApplicationException {
- try {
- return MAPPER.writeValueAsString(srcObj);
- } catch (IOException e) {
- logger.error("{} {} {}", MessageEnum.RA_NS_EXC.toString(), ErrorCode.BusinessProcesssError.getValue(),
- "fail to marshal json", e);
- throw new ApplicationException(HttpCode.BAD_REQUEST, "srcObj marshal failed!");
+ /**
+ * Convert object to json string.
+ *
+ * @param srcObj data object
+ * @return json string
+ * @since ONAP Amsterdam Release 2017-9-6
+ */
+ public static String marshal(Object srcObj) throws ApplicationException {
+ try {
+ return MAPPER.writeValueAsString(srcObj);
+ } catch (IOException e) {
+ logger.error("{} {} {}", MessageEnum.RA_NS_EXC.toString(), ErrorCode.BusinessProcesssError.getValue(),
+ "fail to marshal json", e);
+ throw new ApplicationException(HttpCode.BAD_REQUEST, "srcObj marshal failed!");
+ }
}
- }
- /**
- * Get mapper.
- *
- * @return mapper
- * @since ONAP Amsterdam Release 2017-9-6
- */
- public static ObjectMapper getMapper() {
- return MAPPER;
- }
+ /**
+ * Get mapper.
+ *
+ * @return mapper
+ * @since ONAP Amsterdam Release 2017-9-6
+ */
+ public static ObjectMapper getMapper() {
+ return MAPPER;
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java
index a51564eef8..3419e6d20c 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java
@@ -26,9 +26,7 @@ package org.onap.so.adapters.vfc.util;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
-
import javax.ws.rs.core.UriBuilder;
-
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
@@ -71,29 +69,29 @@ public class RestfulUtil {
private static final int DEFAULT_TIME_OUT = 60000;
private static final String ONAP_IP = "ONAP_IP";
-
+
private static final String DEFAULT_MSB_IP = "127.0.0.1";
private static final Integer DEFAULT_MSB_PORT = 80;
-
- private static final String VFC_ADAPTER="VFC Adapter";
- @Autowired
- private Environment env;
+ private static final String VFC_ADAPTER = "VFC Adapter";
+
+ @Autowired
+ private Environment env;
public String getMsbHost() {
- // MSB_IP will be set as ONAP_IP environment parameter in install flow.
- String msbIp = System.getenv().get(ONAP_IP);
- // if ONAP IP is not set. get it from config file.
- if (null == msbIp || msbIp.isEmpty()) {
- msbIp = env.getProperty("mso.msb-ip", DEFAULT_MSB_IP);
- }
- Integer msbPort = env.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT);
-
- String msbEndpoint = UriBuilder.fromPath("").host(msbIp).port(msbPort).scheme("http").build().toString();
- logger.debug("msbEndpoint in vfc adapter: {}", msbEndpoint);
-
- return msbEndpoint;
+ // MSB_IP will be set as ONAP_IP environment parameter in install flow.
+ String msbIp = System.getenv().get(ONAP_IP);
+ // if ONAP IP is not set. get it from config file.
+ if (null == msbIp || msbIp.isEmpty()) {
+ msbIp = env.getProperty("mso.msb-ip", DEFAULT_MSB_IP);
+ }
+ Integer msbPort = env.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT);
+
+ String msbEndpoint = UriBuilder.fromPath("").host(msbIp).port(msbPort).scheme("http").build().toString();
+ logger.debug("msbEndpoint in vfc adapter: {}", msbEndpoint);
+
+ return msbEndpoint;
}
private RestfulUtil() {
@@ -115,21 +113,21 @@ public class RestfulUtil {
HttpClient client = HttpClientBuilder.create().build();
- if("POST".equalsIgnoreCase(methodType)) {
+ if ("POST".equalsIgnoreCase(methodType)) {
HttpPost httpPost = new HttpPost(msbUrl);
httpPost.setConfig(requestConfig);
httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
method = httpPost;
- } else if("PUT".equalsIgnoreCase(methodType)) {
+ } else if ("PUT".equalsIgnoreCase(methodType)) {
HttpPut httpPut = new HttpPut(msbUrl);
httpPut.setConfig(requestConfig);
httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
method = httpPut;
- } else if("GET".equalsIgnoreCase(methodType)) {
+ } else if ("GET".equalsIgnoreCase(methodType)) {
HttpGet httpGet = new HttpGet(msbUrl);
httpGet.setConfig(requestConfig);
method = httpGet;
- } else if("DELETE".equalsIgnoreCase(methodType)) {
+ } else if ("DELETE".equalsIgnoreCase(methodType)) {
HttpDelete httpDelete = new HttpDelete(msbUrl);
httpDelete.setConfig(requestConfig);
method = httpDelete;
@@ -138,17 +136,17 @@ public class RestfulUtil {
httpResponse = client.execute(method);
String responseContent = null;
- if(httpResponse.getEntity() != 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));
+ logger.debug("VFC Response: {} {}", statusCode,
+ statusMessage + (responseContent == null ? "" : System.lineSeparator() + responseContent));
- if(httpResponse.getStatusLine().getStatusCode() >= 300) {
+ if (httpResponse.getStatusLine().getStatusCode() >= 300) {
String errMsg = "VFC returned " + statusCode + " " + statusMessage;
logError(errMsg);
return createResponse(statusCode, errMsg);
@@ -156,7 +154,7 @@ public class RestfulUtil {
httpResponse = null;
- if(null != method) {
+ if (null != method) {
method.reset();
} else {
logger.debug("method is NULL:");
@@ -165,29 +163,29 @@ public class RestfulUtil {
method = null;
return createResponse(statusCode, responseContent);
- } catch(SocketTimeoutException | ConnectTimeoutException e) {
+ } catch (SocketTimeoutException | ConnectTimeoutException e) {
String errMsg = "Request to VFC timed out";
logError(errMsg, e);
return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg);
- } catch(Exception e) {
+ } catch (Exception e) {
String errMsg = "Error processing request to VFC";
logError(errMsg, e);
return createResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg);
} finally {
- if(httpResponse != null) {
+ if (httpResponse != null) {
try {
EntityUtils.consume(httpResponse.getEntity());
- } catch(Exception e) {
+ } catch (Exception e) {
logger.debug("Exception :", e);
}
}
- if(method != null) {
+ if (method != null) {
try {
method.reset();
- } catch(Exception e) {
+ } catch (Exception e) {
logger.debug("Exception :", e);
}
}
@@ -196,12 +194,12 @@ public class RestfulUtil {
private static void logError(String errMsg, Throwable t) {
logger.error("{} {} {} {}", MessageEnum.RA_NS_EXC.toString(), VFC_ADAPTER,
- ErrorCode.AvailabilityError.getValue(), errMsg, t);
+ ErrorCode.AvailabilityError.getValue(), errMsg, t);
}
private static void logError(String errMsg) {
logger.error("{} {} {} {}", MessageEnum.RA_NS_EXC.toString(), VFC_ADAPTER,
- ErrorCode.AvailabilityError.toString(), errMsg);
+ ErrorCode.AvailabilityError.toString(), errMsg);
}
private static RestfulResponse createResponse(int statusCode, String content) {
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/ValidateUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/ValidateUtil.java
index d920dbea36..f56f5af05b 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/ValidateUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/ValidateUtil.java
@@ -27,61 +27,60 @@ import org.slf4j.LoggerFactory;
public class ValidateUtil {
- /**
- * Log server.
- */
- private static final Logger LOGGER = LoggerFactory.getLogger(ValidateUtil.class);
+ /**
+ * Log server.
+ */
+ private static final Logger LOGGER = LoggerFactory.getLogger(ValidateUtil.class);
- /**
- * Constructor
- *
- *
- *
- * @since ONAP Amsterdam Release 2017-9-6
- */
- private ValidateUtil() {
+ /**
+ * Constructor
+ *
+ *
+ *
+ * @since ONAP Amsterdam Release 2017-9-6
+ */
+ private ValidateUtil() {
- }
-
- /**
- * Assert String parameter.
- *
- * @param paramValue parameter data
- * @param paramName parameter name
- * @since ONAP Amsterdam Release 2017-9-6
- */
- public static void assertStringNotNull(String paramValue, String paramName)
- throws ApplicationException {
- if (null != paramValue && !paramValue.isEmpty()) {
- return;
}
- LOGGER.error(paramName + ": Parameter is null or empty.");
- throw new ApplicationException(HttpCode.BAD_REQUEST, paramName + ": Invalid parameter.");
- }
+ /**
+ * Assert String parameter.
+ *
+ * @param paramValue parameter data
+ * @param paramName parameter name
+ * @since ONAP Amsterdam Release 2017-9-6
+ */
+ public static void assertStringNotNull(String paramValue, String paramName) throws ApplicationException {
+ if (null != paramValue && !paramValue.isEmpty()) {
+ return;
+ }
- /**
- * Assert object is null.
- *
- * @param object data object
- * @since ONAP Amsterdam Release 2017-9-6
- */
- public static void assertObjectNotNull(Object object) throws ApplicationException {
- if (null == object) {
- LOGGER.error("Object is null.");
- throw new ApplicationException(HttpCode.BAD_REQUEST, "Object is null.");
+ LOGGER.error(paramName + ": Parameter is null or empty.");
+ throw new ApplicationException(HttpCode.BAD_REQUEST, paramName + ": Invalid parameter.");
}
- }
+ /**
+ * Assert object is null.
+ *
+ * @param object data object
+ * @since ONAP Amsterdam Release 2017-9-6
+ */
+ public static void assertObjectNotNull(Object object) throws ApplicationException {
+ if (null == object) {
+ LOGGER.error("Object is null.");
+ throw new ApplicationException(HttpCode.BAD_REQUEST, "Object is null.");
+ }
+
+ }
- /**
- *
- *
- * @param str
- * @return
- * @since ONAP Amsterdam Release
- */
- public static boolean isStrEmpty(String str) {
- return null == str || str.isEmpty();
- }
+ /**
+ *
+ *
+ * @param str
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ public static boolean isStrEmpty(String str) {
+ return null == str || str.isEmpty();
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java
index efd3359821..c0305f18de 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java
@@ -1,42 +1,36 @@
/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright (C) 2018 TechMahindra
+ * ================================================================================ 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
+ * 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.
+ * 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.onap.so.adapters.vfc.exceptions;
import static org.junit.Assert.*;
-
import org.junit.Test;
public class ApplicationExceptionTest {
- private ApplicationException application = new ApplicationException(500,null);
-
- @Test
- public void testApplicationException() {
- application.setErrorCode(500);
- application.setErrorMsg("ErrorMsg");
- assertEquals(application.getErrorCode(), 500);
- assertEquals(application.getErrorMsg(), "ErrorMsg");
- }
-
- @Test
- public void testbuildErrorResponse(){
- assert(application.buildErrorResponse()!=null);
- }
+ private ApplicationException application = new ApplicationException(500, null);
+
+ @Test
+ public void testApplicationException() {
+ application.setErrorCode(500);
+ application.setErrorMsg("ErrorMsg");
+ assertEquals(application.getErrorCode(), 500);
+ assertEquals(application.getErrorMsg(), "ErrorMsg");
+ }
+
+ @Test
+ public void testbuildErrorResponse() {
+ assert (application.buildErrorResponse() != null);
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java
index 2acd6c25ad..548d8b3645 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java
@@ -46,4 +46,4 @@ public class CustomerModelTest {
customerModel.setServiceType("service");
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java
index ef5eb2617e..2b217469e5 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java
@@ -46,4 +46,4 @@ public class LocationConstraintTest {
locationConstraint.setLocationConstraints(new VimLocation());
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java
index 2e720e47ad..082d4e69f4 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java
@@ -66,4 +66,4 @@ public class NSResourceInputParameterTest {
nsResourceInputParameter.setNsOperationKey(new NsOperationKey());
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java
index caf2d7e164..c2e6b583af 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java
@@ -66,4 +66,4 @@ public class NsCreateReqTest {
nsCreateReq.setDescription("desc");
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java
index 330e34d0cc..70e54a1c09 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java
@@ -36,4 +36,4 @@ public class NsInstantiateReqTest {
nsInstantiateReq.setNsInstanceId("test");
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java
index e315eefbcc..a8939f8996 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java
@@ -76,4 +76,4 @@ public class NsOperationKeyTest {
nsOperationKey.setNodeTemplateUUID("nodeTemplateid");
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java
index 852bac29a1..45c46edd0d 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java
@@ -20,7 +20,6 @@
package org.onap.so.adapters.vfc.model;
import org.junit.Test;
-
import java.util.Collections;
import java.util.HashMap;
@@ -49,4 +48,4 @@ public class NsParametersTest {
nsParameters.setAdditionalParamForNs(new HashMap<>());
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java
index e99d9aef38..b1040ef463 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java
@@ -20,7 +20,6 @@
package org.onap.so.adapters.vfc.model;
import org.junit.Test;
-
import java.util.Arrays;
public class NsProgressStatusTest {
@@ -58,4 +57,4 @@ public class NsProgressStatusTest {
nsProgressStatus.setResponseHistoryList(Arrays.asList(new ResponseDescriptor()));
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java
index a9f2f4ce3c..3f2f73531c 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java
@@ -76,4 +76,4 @@ public class ResponseDescriptorTest {
responseDescriptor.setResponseId(1);
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java
index 61ddac2707..64f8da65b4 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java
@@ -20,7 +20,6 @@
package org.onap.so.adapters.vfc.model;
import org.junit.Test;
-
import java.util.HashMap;
public class RestfulResponseTest {
@@ -73,4 +72,4 @@ public class RestfulResponseTest {
restfulResponse.setResponseContent("responseString");
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java
index e9b250717d..85d3a136af 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java
@@ -36,4 +36,4 @@ public class VimLocationTest {
vimLocation.setVimId("vimid");
}
-}
\ No newline at end of file
+}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java
index 50bf3f97b0..feb40f73e0 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java
@@ -19,10 +19,10 @@
*/
package org.onap.so.adapters.vfc.rest;
+
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
-
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
@@ -37,17 +37,14 @@ import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
-
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
@Profile({"test"})
@EnableTransactionManagement
-@EnableJpaRepositories(
- entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager",
- basePackages = { "org.onap.so.db.request.data.repository"}
- )
+@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory",
+ transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"})
public class EmbeddedMariaDbConfig {
@Bean
@@ -56,47 +53,34 @@ public class EmbeddedMariaDbConfig {
}
@Primary
- @Bean(name = "requestDataSource")
- @ConfigurationProperties(prefix = "spring.datasource")
+ @Bean(name = "requestDataSource")
+ @ConfigurationProperties(prefix = "spring.datasource")
DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
- @Value("${mariaDB4j.databaseName}") String databaseName,
- @Value("${spring.datasource.username}") String datasourceUsername,
- @Value("${spring.datasource.password}") String datasourcePassword,
- @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
- //Create our database with default root user and no password
+ @Value("${mariaDB4j.databaseName}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ // Create our database with default root user and no password
mariaDB4jSpringService.getDB().createDB(databaseName);
DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
- return DataSourceBuilder
- .create()
- .username(datasourceUsername)
- .password(datasourcePassword)
- .url(config.getURL(databaseName))
- .driverClassName(datasourceDriver)
- .build();
+ return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword)
+ .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build();
}
- @Primary
- @Bean(name = "requestEntityManagerFactory")
- public LocalContainerEntityManagerFactoryBean
- entityManagerFactory(
- EntityManagerFactoryBuilder builder,
- @Qualifier("requestDataSource") DataSource dataSource
- ) {
- return builder
- .dataSource(dataSource)
- .packages("org.onap.so.db.request.beans")
- .persistenceUnit("requestDB")
- .build();
- }
+ @Primary
+ @Bean(name = "requestEntityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
+ @Qualifier("requestDataSource") DataSource dataSource) {
+ return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB")
+ .build();
+ }
- @Primary
- @Bean(name = "requestTransactionManager")
- public PlatformTransactionManager transactionManager(
- @Qualifier("requestEntityManagerFactory") EntityManagerFactory
- entityManagerFactory
- ) {
- return new JpaTransactionManager(entityManagerFactory);
- }
+ @Primary
+ @Bean(name = "requestTransactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java
index 02922db007..fe2bd0bb98 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java
@@ -21,11 +21,7 @@
package org.onap.so.adapters.vfc.rest;
import static org.junit.Assert.*;
-
-
-
import javax.ws.rs.core.Response;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.vfc.MSOVfcApplication;
@@ -45,28 +41,27 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest(classes = MSOVfcApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
public class HealthCheckHandlerTest {
-
- @LocalServerPort
- private int port;
- TestRestTemplate restTemplate = new TestRestTemplate();
+ @LocalServerPort
+ private int port;
+
+ TestRestTemplate restTemplate = new TestRestTemplate();
+
+ HttpHeaders headers = new HttpHeaders();
+
+
+ @Test
+ public void testHealthcheck() throws JSONException {
- HttpHeaders headers = new HttpHeaders();
+ HttpEntity entity = new HttpEntity(null, headers);
-
- @Test
- public void testHealthcheck() throws JSONException {
+ ResponseEntity response =
+ restTemplate.exchange(createURLWithPort("manage/health"), HttpMethod.GET, entity, String.class);
- HttpEntity entity = new HttpEntity(null, headers);
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+ }
- ResponseEntity response = restTemplate.exchange(
- createURLWithPort("manage/health"),
- HttpMethod.GET, entity, String.class);
-
- assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
- }
-
- private String createURLWithPort(String uri) {
- return "http://localhost:" + port + uri;
- }
+ private String createURLWithPort(String uri) {
+ return "http://localhost:" + port + uri;
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java
index 22e6def28d..08fe6187ea 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java
@@ -36,7 +36,6 @@ import org.onap.so.adapters.vfc.util.RestfulUtil;
import org.onap.so.db.request.beans.ResourceOperationStatus;
import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
import org.springframework.http.HttpStatus;
-
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -122,12 +121,12 @@ public class VfcManagerTest {
RestfulResponse restfulResponse = new RestfulResponse();
restfulResponse.setStatus(HttpStatus.OK.value());
- restfulResponse
- .setResponseContent("{\"" + CommonConstant.JOB_ID + "\": \"someJobId\", " + "\"responseDescriptor\" : {}}");
+ restfulResponse.setResponseContent(
+ "{\"" + CommonConstant.JOB_ID + "\": \"someJobId\", " + "\"responseDescriptor\" : {}}");
when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse);
when(resourceOperationStatusRepository.findOne(any()))
- .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus));
+ .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus));
RestfulResponse response = vfcManager.getNsProgress(nsOperationKey, "someJobId");
assertEquals(HttpStatus.OK.value(), response.getStatus());
@@ -148,7 +147,7 @@ public class VfcManagerTest {
when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse);
when(resourceOperationStatusRepository.findOne(any()))
- .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus));
+ .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus));
RestfulResponse response = vfcManager.scaleNs("someNsInstanceId", segInput);
assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus());
--
cgit 1.2.3-korg