aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-vfc-adapter
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-vfc-adapter')
-rw-r--r--adapters/mso-vfc-adapter/.springBeans2
-rw-r--r--adapters/mso-vfc-adapter/pom.xml5
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java2
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/MSOVfcApplication.java6
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java27
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java12
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java10
-rw-r--r--adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java2
-rw-r--r--adapters/mso-vfc-adapter/src/test/resources/application-test.yaml4
9 files changed, 43 insertions, 27 deletions
diff --git a/adapters/mso-vfc-adapter/.springBeans b/adapters/mso-vfc-adapter/.springBeans
index 1310366fc4..7f46cc45af 100644
--- a/adapters/mso-vfc-adapter/.springBeans
+++ b/adapters/mso-vfc-adapter/.springBeans
@@ -13,4 +13,4 @@
</autoconfigs>
<configSets>
</configSets>
-</beansProjectDescription>
+</beansProjectDescription> \ No newline at end of file
diff --git a/adapters/mso-vfc-adapter/pom.xml b/adapters/mso-vfc-adapter/pom.xml
index d416c8e1e2..4d1c612018 100644
--- a/adapters/mso-vfc-adapter/pom.xml
+++ b/adapters/mso-vfc-adapter/pom.xml
@@ -97,6 +97,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>mso-requests-db-repositories</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
</dependency>
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 3034cbcac3..031bc2edc5 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
@@ -32,7 +32,7 @@ import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.onap.so.adapters.vfc.rest.HealthCheckHandler;
import org.onap.so.adapters.vfc.rest.VfcAdapterRest;
-import org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging;
+import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/MSOVfcApplication.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/MSOVfcApplication.java
index 5bb83a7c1b..62234f910d 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/MSOVfcApplication.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/MSOVfcApplication.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* 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
@@ -23,9 +25,6 @@ package org.onap.so.adapters.vfc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@@ -35,5 +34,4 @@ public class MSOVfcApplication {
public static void main(String... args) {
SpringApplication.run(MSOVfcApplication.class, args);
}
-
}
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 9489ef14f5..0f0a14c8f5 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
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* 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
@@ -51,7 +53,8 @@ import org.springframework.stereotype.Component;
public class VfcAdapterRest {
private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, VfcAdapterRest.class);
-
+ private static final String REQUEST_DEBUG_MSG="body from request is {}";
+ private static final String APPLICATION_EXCEPTION="ApplicationException: ";
@Autowired
private VfcManager driverMgr ;
@@ -73,12 +76,12 @@ public class VfcAdapterRest {
public Response createNfvoNs(String data) {
try {
ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug("body from request is {}" + data);
+ LOGGER.debug(REQUEST_DEBUG_MSG + data);
NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class);
RestfulResponse rsp = driverMgr.createNs(nsInput);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug("ApplicationException: ", e);
+ LOGGER.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
@@ -99,12 +102,12 @@ public class VfcAdapterRest {
try {
ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug("body from request is {}" + data);
+ LOGGER.debug(REQUEST_DEBUG_MSG + data);
NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug("ApplicationException: ", e);
+ LOGGER.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
@@ -124,12 +127,12 @@ public class VfcAdapterRest {
public Response queryNfvoJobStatus(String data, @PathParam("jobId") String jobId) {
try {
ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug("body from request is {}" + data);
+ LOGGER.debug(REQUEST_DEBUG_MSG + data);
NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug("ApplicationException: ", e);
+ LOGGER.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
@@ -149,12 +152,12 @@ public class VfcAdapterRest {
public Response instantiateNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) {
try {
ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug("body from request is {}" + data);
+ LOGGER.debug(REQUEST_DEBUG_MSG + data);
NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class);
RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug("ApplicationException: ", e);
+ LOGGER.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
@@ -174,12 +177,12 @@ public class VfcAdapterRest {
public Response terminateNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) {
try {
ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug("body from request is {}" + data);
+ LOGGER.debug(REQUEST_DEBUG_MSG + data);
NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug("ApplicationException: ", e);
+ LOGGER.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
@@ -205,7 +208,7 @@ public class VfcAdapterRest {
RestfulResponse rsp = driverMgr.scaleNs(nsInstanceId, nsInput);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug("ApplicationException: ", e);
+ LOGGER.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
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 c12cd7da05..64032e25f5 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
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* 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
@@ -51,7 +53,7 @@ public class JsonUtil {
* 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));
@@ -82,8 +84,8 @@ public class JsonUtil {
return MAPPER.readValue(jsonstr, type);
} catch (IOException e) {
LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
- "fail to unMarshal json", e);
- throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json");
+ UNMARSHAL_FAIL_MSG, e);
+ throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG);
}
}
@@ -100,8 +102,8 @@ public class JsonUtil {
return MAPPER.readValue(jsonstr, type);
} catch (IOException e) {
LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
- "fail to unMarshal json", e);
- throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json");
+ UNMARSHAL_FAIL_MSG, e);
+ throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG);
}
}
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 5b8779a67d..0536dd3560 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
@@ -5,6 +5,8 @@
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018.
+ * ================================================================================
* 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
@@ -73,6 +75,8 @@ public class RestfulUtil {
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;
@@ -95,7 +99,7 @@ public class RestfulUtil {
public RestfulResponse send(String url, String methodType, String content) {
String msbUrl = getMsbHost() + url;
- LOGGER.info(MessageEnum.RA_NS_EXC, "Begin to sent message " + methodType +": " + msbUrl, "org.onap.so.adapters.vfc.util.RestfulUtil","VFC Adapter");
+ LOGGER.info(MessageEnum.RA_NS_EXC, "Begin to sent message " + methodType +": " + msbUrl, "org.onap.so.adapters.vfc.util.RestfulUtil",VFC_ADAPTER);
HttpRequestBase method = null;
HttpResponse httpResponse = null;
@@ -196,12 +200,12 @@ public class RestfulUtil {
}
private static void logError(String errMsg, Throwable t) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "VFC Adapter", "", MsoLogger.ErrorCode.AvailabilityError, errMsg, t);
+ LOGGER.error(MessageEnum.RA_NS_EXC, VFC_ADAPTER, "", MsoLogger.ErrorCode.AvailabilityError, errMsg, t);
ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg);
}
private static void logError(String errMsg) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "VFC Adapter", "", MsoLogger.ErrorCode.AvailabilityError, errMsg);
+ LOGGER.error(MessageEnum.RA_NS_EXC, VFC_ADAPTER, "", MsoLogger.ErrorCode.AvailabilityError, errMsg);
ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg);
}
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 10fa02a1d1..d53e467865 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
@@ -26,10 +26,10 @@ import static org.junit.Assert.*;
import javax.ws.rs.core.Response;
-import org.json.JSONException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.vfc.MSOVfcApplication;
+import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
diff --git a/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml b/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml
index 64de62c2d6..d558d247d7 100644
--- a/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml
+++ b/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml
@@ -5,6 +5,10 @@ server:
max-threads: 50
ssl-enable: false
mso:
+ adapters:
+ requestDb:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ endpoint: http://localhost:8081
logPath: logs
site-name: localSite
infra-requests: