diff options
62 files changed, 2751 insertions, 145 deletions
diff --git a/huawei/pom.xml b/huawei/pom.xml new file mode 100644 index 00000000..6f826766 --- /dev/null +++ b/huawei/pom.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- + Copyright 2017 ZTE Corporation. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm</groupId> + <artifactId>vfc-nfvo-driver-vnfm-svnfm</artifactId> + <version>1.0.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.huawei</groupId> + <artifactId>vfc-nfvo-driver-vnfm-svnfm-huawei</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>pom</packaging> + <name>vfc/nfvo/driver/vnfm/svnfm/huawei</name> + <description>vfc-nfvo-driver-vnfm-svnfm-huawei</description> + <modules> + <module>vnfmadapter</module> + </modules> +</project> diff --git a/huawei/vnfmadapter/VnfmadapterService/service/pom.xml b/huawei/vnfmadapter/VnfmadapterService/service/pom.xml index 72ebd09f..dfd285b4 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/pom.xml +++ b/huawei/vnfmadapter/VnfmadapterService/service/pom.xml @@ -26,14 +26,6 @@ <name>vfc/nfvo/drivers/vnfm/svnfm/huawei/vnfmadapter/VnfmadapterService/service</name> <packaging>war</packaging> - <repositories> - <repository> - <id>open-o</id> - <name>OPEN-O repository</name> - <url>https://nexus.open-o.org/content/repositories/public/</url> - </repository> - </repositories> - <dependencies> <dependency> <groupId>org.powermock</groupId> @@ -51,6 +43,53 @@ <version>1.5.4</version> </dependency> <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>com.springsource.org.apache.commons.lang</artifactId> + <version>2.5.0</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.1</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>com.springsource.org.apache.commons.logging</artifactId> + <version>1.1.1</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>com.springsource.org.apache.commons.codec</artifactId> + <version>1.3.0</version> + </dependency> + <dependency> + <groupId>net.sf.json-lib</groupId> + <artifactId>json-lib</artifactId> + <version>2.4</version> + <classifier>jdk15</classifier> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.6.1</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.orbit</groupId> + <artifactId>javax.servlet</artifactId> + <version>3.0.0.v201112011016</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.aggregate</groupId> + <artifactId>jetty-all</artifactId> + <version>8.1.16.v20140903</version> + </dependency> + <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.36</version> @@ -61,16 +100,6 @@ <version>3.1.6</version> </dependency> <dependency> - <groupId>org.openo.common-services.common-utilities</groupId> - <artifactId>commonlib-cbb</artifactId> - <version>2.0.0</version> - </dependency> - <dependency> - <groupId>org.openo.common-services.common-utilities</groupId> - <artifactId>commonlib-restclient</artifactId> - <version>2.0.0</version> - </dependency> - <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.0</version> diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITAuthRoaFail.java b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITAuthRoaFail.java index 14469b29..4ffc6fce 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITAuthRoaFail.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITAuthRoaFail.java @@ -21,7 +21,7 @@ import java.io.File; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.openo.nfvo.vnfmadapter.mocoserver.VnfmAdapterSuccessServer; import org.openo.nfvo.vnfmadapter.util.AddSuccessChecker; import org.openo.nfvo.vnfmadapter.util.FailureChecker; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITAuthRoaSuccess.java b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITAuthRoaSuccess.java index 0393571e..f5283cdf 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITAuthRoaSuccess.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITAuthRoaSuccess.java @@ -21,7 +21,7 @@ import java.io.File; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.openo.nfvo.vnfmadapter.mocoserver.VnfmAdapterSuccessServer; import org.openo.nfvo.vnfmadapter.util.AddSuccessChecker; import org.openo.nfvo.vnfmadapter.util.GetSuccessChecker; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfAdapterResourceRoaFail.java b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfAdapterResourceRoaFail.java index 8ef66b03..77c13329 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfAdapterResourceRoaFail.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfAdapterResourceRoaFail.java @@ -21,7 +21,7 @@ import java.io.File; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.openo.nfvo.vnfmadapter.mocoserver.VnfmAdapterSuccessServer; import org.openo.nfvo.vnfmadapter.util.FailureChecker; import org.openo.nfvo.vnfmadapter.util.GetSuccessChecker; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfAdapterResourceRoaSuccess.java b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfAdapterResourceRoaSuccess.java index 64ad1275..15d134eb 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfAdapterResourceRoaSuccess.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfAdapterResourceRoaSuccess.java @@ -21,7 +21,7 @@ import java.io.File; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.openo.nfvo.vnfmadapter.mocoserver.VnfmAdapterSuccessServer; import org.openo.nfvo.vnfmadapter.util.GetSuccessChecker; import org.openo.nfvo.vnfmadapter.util.MyTestManager; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfResourceRoaFail.java b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfResourceRoaFail.java index 25aeaa67..3ae4b591 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfResourceRoaFail.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfResourceRoaFail.java @@ -21,7 +21,7 @@ import java.io.File; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.openo.nfvo.vnfmadapter.mocoserver.VnfmAdapterSuccessServer; import org.openo.nfvo.vnfmadapter.util.FailureChecker; import org.openo.nfvo.vnfmadapter.util.GetSuccessChecker; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfResourceRoaSuccess.java b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfResourceRoaSuccess.java index 549ae1ca..f87a024d 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfResourceRoaSuccess.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfResourceRoaSuccess.java @@ -21,7 +21,7 @@ import java.io.File; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.openo.nfvo.vnfmadapter.mocoserver.VnfmAdapterSuccessServer; import org.openo.nfvo.vnfmadapter.util.GetSuccessChecker; import org.openo.nfvo.vnfmadapter.util.MyTestManager; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfRoaFail.java b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfRoaFail.java index 784aa9df..eb77b2a3 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfRoaFail.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfRoaFail.java @@ -21,7 +21,7 @@ import java.io.File; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.openo.nfvo.vnfmadapter.mocoserver.VnfmAdapterSuccessServer; import org.openo.nfvo.vnfmadapter.util.FailureChecker; import org.openo.nfvo.vnfmadapter.util.MyTestManager; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfRoaSuccess.java b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfRoaSuccess.java index b2109e1f..b95829fc 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfRoaSuccess.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/test/ITVnfRoaSuccess.java @@ -21,7 +21,7 @@ import java.io.File; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.openo.nfvo.vnfmadapter.mocoserver.VnfmAdapterSuccessServer; import org.openo.nfvo.vnfmadapter.util.GetSuccessChecker; import org.openo.nfvo.vnfmadapter.util.MyTestManager; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/util/MyTestManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/util/MyTestManager.java index aa866bb3..324a2444 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/util/MyTestManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/integration-test/java/org/openo/nfvo/vnfmadapter/util/MyTestManager.java @@ -21,9 +21,9 @@ import java.util.Iterator; import java.util.Map; import org.junit.Assert; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulParametes; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.openo.sdno.testframework.checker.DefaultChecker; import org.openo.sdno.testframework.http.model.HttpModelUtils; import org.openo.sdno.testframework.http.model.HttpRequest; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/AsyncCallback.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/AsyncCallback.java index 556789d1..cab780e1 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/AsyncCallback.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/AsyncCallback.java @@ -16,8 +16,8 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common; -import org.openo.baseservice.roa.util.restclient.RestfulAsyncCallback; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulAsyncCallback; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtil.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtil.java index 49d17fe3..57491007 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtil.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtil.java @@ -16,10 +16,10 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VnfmRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.ParamConstants; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,7 +31,7 @@ import net.sf.json.JSONObject; * <br/> * * @author - * @version NFVO 0.5 Aug 25, 2016 + * @version NFVO 0.5 Aug 25, 2016 */ public final class VnfmUtil { @@ -47,7 +47,7 @@ public final class VnfmUtil { * * @param vnfmId * @return - * @since NFVO 0.5 + * @since NFVO 0.5 */ public static JSONObject getVnfmById(String vnfmId) { RestfulResponse rsp = VnfmRestfulUtil.getRemoteResponse(String.format(ParamConstants.ESR_GET_VNFM_URL, vnfmId), @@ -59,10 +59,11 @@ public final class VnfmUtil { return JSONObject.fromObject(rsp.getResponseContent()); } - public static JSONObject mockForTest(String vnfmId){ - String vInfo = "{\"vnfmId\":\"1234\", \"name\":\"vnfm\", \"type\":\"Tacker\", \"vimId\":\"\", \"vendor\":\"huawei\", \"version\":\"v1.0\", \"description\":\"vnfm\", \"certificateUrl\":\"\", \"url\":\"https://192.168.44.126:30001\", \"userName\":\"manoadmin\", \"password\":\"User@12345\", \"createTime\":\"2016-07-06 15:33:18\"}"; + public static JSONObject mockForTest(String vnfmId) { + String vInfo = + "{\"vnfmId\":\"1234\", \"name\":\"vnfm\", \"type\":\"Tacker\", \"vimId\":\"\", \"vendor\":\"huawei\", \"version\":\"v1.0\", \"description\":\"vnfm\", \"certificateUrl\":\"\", \"url\":\"https://192.168.44.126:30001\", \"userName\":\"manoadmin\", \"password\":\"User@12345\", \"createTime\":\"2016-07-06 15:33:18\"}"; JSONObject json = JSONObject.fromObject(vInfo); - json.put("vnfmId",vnfmId); + json.put("vnfmId", vnfmId); return json; } @@ -72,7 +73,7 @@ public final class VnfmUtil { * * @param ip * @return - * @since NFVO 0.5 + * @since NFVO 0.5 */ public static String getVnfmIdByIp(String ip) { RestfulResponse rsp = diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/DefaultAsyncCallback.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/DefaultAsyncCallback.java new file mode 100644 index 00000000..a1e7822d --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/DefaultAsyncCallback.java @@ -0,0 +1,38 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +/** + * Restful Asynchronous call back implentation.<br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public class DefaultAsyncCallback implements RestfulAsyncCallback { + + @Override + public void callback(final RestfulResponse response) { + // default implementation. + } + + @Override + public void handleExcepion(final Throwable e) { + // default implementation + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ExceptionArgs.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ExceptionArgs.java new file mode 100644 index 00000000..49e9500f --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ExceptionArgs.java @@ -0,0 +1,111 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +/** + * ROA exception handling parameters. + * <br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public class ExceptionArgs { + + /** + * Exception descriptions. + */ + private String[] descArgs = null; + + /** + * Exception reasons. + */ + private String[] reasonArgs = null; + + /** + * Exception detals. + */ + private String[] detailArgs = null; + + /** + * Exception advices. + */ + private String[] adviceArgs = null; + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + */ + public ExceptionArgs() { + // default constructor. + } + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + * @param descArgs: descriptions. + * @param reasonArgs: reasons. + * @param detailArgs: details. + * @param adviceArgs: advices. + */ + public ExceptionArgs(final String[] descArgs, final String[] reasonArgs, final String[] detailArgs, + final String[] adviceArgs) { + this.descArgs = descArgs; + this.reasonArgs = reasonArgs; + this.detailArgs = detailArgs; + this.adviceArgs = adviceArgs; + } + + public String[] getDescArgs() { + return descArgs; + } + + public void setDescArgs(final String[] descArgs) { + this.descArgs = descArgs; + } + + public String[] getReasonArgs() { + return reasonArgs; + } + + public void setReasonArgs(final String[] reasonArgs) { + this.reasonArgs = reasonArgs; + } + + public String[] getDetailArgs() { + return detailArgs; + } + + public void setDetailArgs(final String[] detailArgs) { + this.detailArgs = detailArgs; + } + + public String[] getAdviceArgs() { + return adviceArgs; + } + + public void setAdviceArgs(final String[] adviceArgs) { + this.adviceArgs = adviceArgs; + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/HttpBaseRest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/HttpBaseRest.java new file mode 100644 index 00000000..45e1c753 --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/HttpBaseRest.java @@ -0,0 +1,272 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +import org.eclipse.jetty.client.Address; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.HttpExchange; +import org.eclipse.jetty.http.HttpMethods; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version Aug 9, 2016 + */ +public abstract class HttpBaseRest implements Restful { + + private static final Logger LOG = LoggerFactory.getLogger(HttpRest.class); + + final AtomicInteger requestId = new AtomicInteger(0); + + protected HttpClient client = null; + + private static final String LOCAL_HOST = "127.0.0.1"; + + static final String HTTP_PATCH = "PATCH"; + + String defaultIP = LOCAL_HOST; + + int defaultPort = -10000; + + int defaultTimeout = 30000; + + final String procenameRouteID = "RouteID-" + System.currentTimeMillis() + "-"; + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + */ + public HttpBaseRest() { + super(); + } + + protected void createHttpClient() { + client = new HttpClient(); + } + + protected RestHttpContentExchange createRestHttpContentExchange(final RestfulAsyncCallback callback) { + final RestHttpContentExchange exchange = new RestHttpContentExchange(true, callback); + exchange.setScheme("http"); + return exchange; + } + + private String encodeParams(final RestfulParametes restParametes) throws ServiceException { + final Map<String, String> parm = restParametes.getParamMap(); + String value = null; + boolean bHasParma = false; + final StringBuilder builder = new StringBuilder(); + try { + for(final String key : parm.keySet()) { + value = parm.get(key); + if(value == null) { + value = ""; + } + String str; + if(bHasParma) { + str = String.format("&%s=%s", URLEncoder.encode(key, RestfulClientConst.ENCODING), + URLEncoder.encode(value, RestfulClientConst.ENCODING)); + } else { + bHasParma = true; + str = String.format("%s=%s", URLEncoder.encode(key, RestfulClientConst.ENCODING), + URLEncoder.encode(value, RestfulClientConst.ENCODING)); + } + builder.append(str); + } + } catch(final UnsupportedEncodingException ex) { + LOG.error("unsupported encoding: ", ex); + throw new ServiceException("Broken VM does not support UTF-8"); + } + return builder.toString(); + } + + private void processHeader(final RestHttpContentExchange contentExchange, final Map<String, String> headerMap) { + for(final String key : headerMap.keySet()) { + final String value = headerMap.get(key); + contentExchange.addRequestHeader(key, value); + } + + } + + private void setContentExchangeParams(final RestHttpContentExchange contentExchange) { + final String contentType = contentExchange.getRequestFields().getStringField("Content-Type"); + if(null == contentType || contentType.isEmpty()) { + // application/json;charset=utf-8 + contentExchange.setRequestContentType(RestfulClientConst.APPLICATION_FORM_URLENCODED); + } + final String encoding = contentExchange.getRequestFields().getStringField("Accept-Encoding"); + if(null == encoding || encoding.isEmpty()) { + // compress,gzip + contentExchange.setRequestHeader("Accept-Encoding", "*/*"); + } + contentExchange.setVersion(11); + } + + /** + * <br/> + * + * @param method + * @param servicePath + * @param restParametes + * @param options + * @param callback + * @return + * @throws ServiceException + * @since + */ + protected RestfulResponse sendHttpRequest(final String method, final String servicePath, + final RestfulParametes restParametes, final RestfulOptions options, final RestfulAsyncCallback callback) + throws ServiceException { + final RestHttpContentExchange contentExchange = createRestHttpContentExchange(callback); + if(null == restParametes) { + return new RestfulResponse(); + } + final String requestTrace = this.getReuqestIdString(); + restParametes.putHttpContextHeader(RestfulClientConst.REQUEST_ID, requestTrace); + + RestfulResponse rsp = null; + try { + contentExchange.setMethod(method); + final String str = encodeParams(restParametes); + final StringBuilder builder = new StringBuilder(); + builder.append(servicePath); + if(str.length() > 0 && (method.equals(HttpMethods.GET) || method.equals(HttpMethods.DELETE) + || method.equals(HttpMethods.HEAD))) { + builder.append('?'); + builder.append(str); + } + setDefaultUrl(contentExchange, options, builder); + processHeader(contentExchange, restParametes.getHeaderMap()); + setContentExchangeParams(contentExchange); + + setPostPutParam(method, restParametes, contentExchange, str); + setTimeout(options, contentExchange); + + client.send(contentExchange); + rsp = callbackExecute(callback, contentExchange); + } catch(final Exception e) { + LOG.error("request reply message have exception:status is " + + RestHttpContentExchange.toState(contentExchange.getStatus())); + throw new ServiceException(e); + } + return rsp; + } + + private void setDefaultUrl(final RestHttpContentExchange contentExchange, final RestfulOptions options, + final StringBuilder url) { + // server + if(url.toString().startsWith("http")) { + contentExchange.setURL(url.toString()); + } else { + String host = defaultIP; + int iPort = defaultPort; + if(options != null) { + host = options.getHost(); + if(host.isEmpty()) { + host = defaultIP; + } + iPort = options.getPort(); + if(iPort == 0) { + iPort = defaultPort; + } + } + // Integer.getInteger(".http.client.maxThread",30) + contentExchange.setAddress(new Address(host, iPort)); + contentExchange.setRequestURI(url.toString()); + } + } + + private String getReuqestIdString() { + if(this.requestId.get() == 0x7FFFFFFF) { + this.requestId.set(1); + } + final int reqId = this.requestId.getAndIncrement(); + final StringBuilder builder = new StringBuilder(this.procenameRouteID); + // time + final SimpleDateFormat dateFormate = new SimpleDateFormat("yyMMdd"); + final SimpleDateFormat timeFormate = new SimpleDateFormat("HHmmss"); + final Date date = Calendar.getInstance().getTime(); + builder.append(dateFormate.format(date) + timeFormate.format(date)); + builder.append('-'); + builder.append(reqId); + return builder.toString(); + } + + private void setPostPutParam(final String method, final RestfulParametes restParametes, + final RestHttpContentExchange contentExchange, final String str) throws UnsupportedEncodingException { + if(HttpMethods.POST.equals(method) || HttpMethods.PUT.equals(method) || HTTP_PATCH.equals(method)) { + ByteArrayInputStream buff; + final String tmpRaw = restParametes.getRawData(); + if(tmpRaw == null) { + buff = new ByteArrayInputStream(str.getBytes(RestfulClientConst.ENCODING)); + } else { + buff = new ByteArrayInputStream(tmpRaw.getBytes(RestfulClientConst.ENCODING)); + } + final int len = buff.available(); + contentExchange.setRequestContentSource(buff); + contentExchange.setRequestHeader("content-length", String.valueOf(len)); + } + } + + private void setTimeout(final RestfulOptions options, final RestHttpContentExchange contentExchange) { + if(options != null) { + final long timeout = options.getRestTimeout(); + if(timeout != 0) { + contentExchange.setTimeout(timeout); + } else { + contentExchange.setTimeout(defaultTimeout); + } + } else { + contentExchange.setTimeout(defaultTimeout); + } + } + + private RestfulResponse callbackExecute(final RestfulAsyncCallback callback, + final RestHttpContentExchange contentExchange) throws InterruptedException, IOException, ServiceException { + if(callback == null) { + final int exchangeState = contentExchange.waitForDone(); + if(exchangeState == HttpExchange.STATUS_COMPLETED) { + return contentExchange.getResponse(); + } else if(exchangeState == HttpExchange.STATUS_EXCEPTED) { + throw new ServiceException( + "request is exception: " + RestHttpContentExchange.toState(HttpExchange.STATUS_EXCEPTED)); + } else if(exchangeState == HttpExchange.STATUS_EXPIRED) { + throw new ServiceException( + "request is expierd: " + RestHttpContentExchange.toState(HttpExchange.STATUS_EXPIRED)); + } + } + return null; + } + +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/HttpRest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/HttpRest.java new file mode 100644 index 00000000..7215424d --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/HttpRest.java @@ -0,0 +1,253 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.http.HttpMethods; +import org.eclipse.jetty.util.thread.QueuedThreadPool; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version Aug 9, 2016 + */ +public class HttpRest extends HttpBaseRest { + + private static final Logger LOG = LoggerFactory.getLogger(HttpRest.class); + + /** + * Initializing Rest options.<br/> + * + * @param options: rest options. + * @throws ServiceException + * @since + */ + public void initHttpRest(final RestfulOptions option) throws ServiceException { + if(option == null) { + client = null; + throw new ServiceException("option is null."); + } + createHttpClient(); + try { + int iValue; + iValue = option.getIntOption(RestfulClientConst.MAX_CONN_PER_ADDR_KEY_NAME); + // max 200 concurrent,connections to every address + client.setMaxConnectionsPerAddress(iValue); + + iValue = option.getIntOption(RestfulClientConst.THREAD_KEY_NAME); + // max threads + client.setThreadPool(new QueuedThreadPool(iValue)); + iValue = option.getIntOption(RestfulClientConst.CONN_TIMEOUT_KEY_NAME); + client.setConnectTimeout(iValue); + iValue = option.getRestTimeout(); + defaultTimeout = iValue; + client.setTimeout(iValue); + + iValue = option.getIntOption(RestfulClientConst.IDLE_TIMEOUT_KEY_NAME); + client.setIdleTimeout(iValue); + iValue = option.getIntOption(RestfulClientConst.MAX_RESPONSE_HEADER_SIZE); + client.setResponseHeaderSize(iValue); + iValue = option.getIntOption(RestfulClientConst.MAX_REQUEST_HEADER_SIZE); + client.setRequestHeaderSize(iValue); + // HttpClient.CONNECTOR_SOCKET + client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + client.start(); + defaultIP = option.getStringOption(RestfulClientConst.HOST_KEY_NAME); + defaultPort = option.getIntOption(RestfulClientConst.PORT_KEY_NAME); + } catch(final Exception e) { + LOG.error("start httpclient error", e); + client = null; + throw new ServiceException("http client init failed."); + } + } + + @Override + public RestfulResponse get(final String servicePath, final RestfulParametes restParametes) throws ServiceException { + return this.sendHttpRequest(HttpMethods.GET, servicePath, restParametes, null, null); + } + + @Override + public RestfulResponse get(final String servicePath, final RestfulParametes restParametes, + final RestfulOptions option) throws ServiceException { + return this.sendHttpRequest(HttpMethods.GET, servicePath, restParametes, option, null); + } + + @Override + public RestfulResponse head(final String servicePath, final RestfulParametes restParametes) + throws ServiceException { + return this.sendHttpRequest(HttpMethods.HEAD, servicePath, restParametes, null, null); + } + + @Override + public RestfulResponse head(final String servicePath, final RestfulParametes restParametes, + final RestfulOptions option) throws ServiceException { + return this.sendHttpRequest(HttpMethods.HEAD, servicePath, restParametes, option, null); + } + + @Override + public void asyncGet(final String servicePath, final RestfulParametes restParametes, + final RestfulAsyncCallback callback) throws ServiceException { + if(callback == null) { + this.sendHttpRequest(HttpMethods.GET, servicePath, restParametes, null, new DefaultAsyncCallback()); + } else { + this.sendHttpRequest(HttpMethods.GET, servicePath, restParametes, null, callback); + } + } + + @Override + public void asyncGet(final String servicePath, final RestfulParametes restParametes, final RestfulOptions option, + final RestfulAsyncCallback callback) throws ServiceException { + if(callback == null) { + this.sendHttpRequest(HttpMethods.GET, servicePath, restParametes, option, new DefaultAsyncCallback()); + } else { + this.sendHttpRequest(HttpMethods.GET, servicePath, restParametes, option, callback); + } + } + + @Override + public RestfulResponse put(final String servicePath, final RestfulParametes restParametes) throws ServiceException { + return this.sendHttpRequest(HttpMethods.PUT, servicePath, restParametes, null, null); + } + + @Override + public RestfulResponse put(final String servicePath, final RestfulParametes restParametes, + final RestfulOptions option) throws ServiceException { + return this.sendHttpRequest(HttpMethods.PUT, servicePath, restParametes, option, null); + } + + @Override + public void asyncPut(final String servicePath, final RestfulParametes restParametes, + final RestfulAsyncCallback callback) throws ServiceException { + if(callback == null) { + this.sendHttpRequest(HttpMethods.PUT, servicePath, restParametes, null, new DefaultAsyncCallback()); + } else { + this.sendHttpRequest(HttpMethods.PUT, servicePath, restParametes, null, callback); + } + } + + @Override + public void asyncPut(final String servicePath, final RestfulParametes restParametes, final RestfulOptions option, + final RestfulAsyncCallback callback) throws ServiceException { + if(callback == null) { + this.sendHttpRequest(HttpMethods.PUT, servicePath, restParametes, option, new DefaultAsyncCallback()); + } else { + this.sendHttpRequest(HttpMethods.PUT, servicePath, restParametes, option, callback); + } + } + + @Override + public RestfulResponse post(final String servicePath, final RestfulParametes restParametes) + throws ServiceException { + return this.sendHttpRequest(HttpMethods.POST, servicePath, restParametes, null, null); + } + + @Override + public RestfulResponse post(final String servicePath, final RestfulParametes restParametes, + final RestfulOptions option) throws ServiceException { + return this.sendHttpRequest(HttpMethods.POST, servicePath, restParametes, option, null); + } + + @Override + public void asyncPost(final String servicePath, final RestfulParametes restParametes, + final RestfulAsyncCallback callback) throws ServiceException { + if(callback == null) { + this.sendHttpRequest(HttpMethods.POST, servicePath, restParametes, null, new DefaultAsyncCallback()); + } else { + this.sendHttpRequest(HttpMethods.POST, servicePath, restParametes, null, callback); + } + } + + @Override + public void asyncPost(final String servicePath, final RestfulParametes restParametes, final RestfulOptions option, + final RestfulAsyncCallback callback) throws ServiceException { + if(callback == null) { + this.sendHttpRequest(HttpMethods.POST, servicePath, restParametes, option, new DefaultAsyncCallback()); + } else { + this.sendHttpRequest(HttpMethods.POST, servicePath, restParametes, option, callback); + } + } + + @Override + public RestfulResponse delete(final String servicePath, final RestfulParametes restParametes) + throws ServiceException { + return this.sendHttpRequest(HttpMethods.DELETE, servicePath, restParametes, null, null); + } + + @Override + public RestfulResponse delete(final String servicePath, final RestfulParametes restParametes, + final RestfulOptions option) throws ServiceException { + return this.sendHttpRequest(HttpMethods.DELETE, servicePath, restParametes, option, null); + } + + @Override + public void asyncDelete(final String servicePath, final RestfulParametes restParametes, + final RestfulAsyncCallback callback) throws ServiceException { + if(callback == null) { + this.sendHttpRequest(HttpMethods.DELETE, servicePath, restParametes, null, new DefaultAsyncCallback()); + } else { + this.sendHttpRequest(HttpMethods.DELETE, servicePath, restParametes, null, callback); + } + } + + @Override + public void asyncDelete(final String servicePath, final RestfulParametes restParametes, final RestfulOptions option, + final RestfulAsyncCallback callback) throws ServiceException { + if(callback == null) { + this.sendHttpRequest(HttpMethods.DELETE, servicePath, restParametes, option, new DefaultAsyncCallback()); + } else { + this.sendHttpRequest(HttpMethods.DELETE, servicePath, restParametes, option, callback); + } + } + + @Override + public RestfulResponse patch(final String servicePath, final RestfulParametes restParametes) + throws ServiceException { + return this.sendHttpRequest(HTTP_PATCH, servicePath, restParametes, null, null); + } + + @Override + public RestfulResponse patch(final String servicePath, final RestfulParametes restParametes, + final RestfulOptions option) throws ServiceException { + return this.sendHttpRequest(HTTP_PATCH, servicePath, restParametes, option, null); + } + + @Override + public void asyncPatch(final String servicePath, final RestfulParametes restParametes, + final RestfulAsyncCallback callback) throws ServiceException { + if(callback == null) { + this.sendHttpRequest(HTTP_PATCH, servicePath, restParametes, null, new DefaultAsyncCallback()); + } else { + this.sendHttpRequest(HTTP_PATCH, servicePath, restParametes, null, callback); + } + } + + @Override + public void asyncPatch(final String servicePath, final RestfulParametes restParametes, final RestfulOptions option, + final RestfulAsyncCallback callback) throws ServiceException { + if(callback == null) { + this.sendHttpRequest(HTTP_PATCH, servicePath, restParametes, option, new DefaultAsyncCallback()); + } else { + this.sendHttpRequest(HTTP_PATCH, servicePath, restParametes, option, callback); + } + } + +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ReaderHelper.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ReaderHelper.java new file mode 100644 index 00000000..4ceab83d --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ReaderHelper.java @@ -0,0 +1,62 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import java.io.Reader; + +import org.apache.commons.io.LineIterator; + +/** + * Helper for read line.<br/> + * <p> + * </p> + * + * @author + * @version 31-May-2016 + */ +public class ReaderHelper { + + private LineIterator ite = null; + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + * @param reader + */ + public ReaderHelper(final Reader reader) { + if(reader != null) { + ite = new LineIterator(reader); + } + + } + + /** + * Gets the next line.<br/> + * + * @return line if present else null. + * @since + */ + public String getLine() { + if(ite != null && ite.hasNext()) { + return ite.nextLine(); + } + return null; + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestHttpContentExchange.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestHttpContentExchange.java new file mode 100644 index 00000000..076b5793 --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestHttpContentExchange.java @@ -0,0 +1,233 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.zip.GZIPInputStream; + +import org.apache.commons.lang.StringUtils; +import org.eclipse.jetty.client.ContentExchange; +import org.eclipse.jetty.client.HttpDestination; +import org.eclipse.jetty.http.HttpFields; +import org.eclipse.jetty.http.HttpHeaders; +import org.eclipse.jetty.io.Buffer; +import org.eclipse.jetty.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * ContentExchange implementation classe to provide access to response. + * <br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public class RestHttpContentExchange extends ContentExchange { + + private static final Logger LOGGER = LoggerFactory.getLogger(RestHttpContentExchange.class); + + private boolean gzip = false; + + private RestfulAsyncCallback callback = null; + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + * @param cacheFields whether to cache response header. + * @param asyncCallback callback method. + */ + RestHttpContentExchange(final boolean cacheFields, final RestfulAsyncCallback asyncCallback) { + super(cacheFields); + this.callback = asyncCallback; + } + + /** + * Extract message. + * <br/> + * + * @param data GZipped data. + * @return Uncompressed data. + * @throws IOException + * @since + */ + public String decompressGzipToStr(final byte[] data) throws IOException { + if(data == null) { + return ""; + } + ByteArrayInputStream input = null; + GZIPInputStream gzis = null; + InputStreamReader reader = null; + final StringBuilder out = new StringBuilder(); + try { + input = new ByteArrayInputStream(data); + gzis = new GZIPInputStream(input); + reader = new InputStreamReader(gzis, Charset.forName(RestfulClientConst.ENCODING)); + final char[] buff = new char[1024]; + for(int n; (n = reader.read(buff)) != -1;) { + out.append(new String(buff, 0, n)); + } + } finally { + if(reader != null) { + try { + reader.close(); + } catch(final IOException e) { + LOGGER.error("decompress Gzip reader exception:", e); + } + } + if(gzis != null) { + try { + gzis.close(); + } catch(final IOException e) { + LOGGER.error("decompress Gzip exception:", e); + } + } + if(input != null) { + try { + input.close(); + } catch(final IOException e) { + LOGGER.error("decompress Gzip input exception:", e); + } + } + } + return out.toString(); + + } + + /** + * View response headers Content-Encoding values if you need to extract data.<br/> + * + * @param name buffer + * @param value value + * @throws IOException + * @since + */ + @Override + protected synchronized void onResponseHeader(final Buffer name, final Buffer value) throws IOException { + super.onResponseHeader(name, value); + final int header = HttpHeaders.CACHE.getOrdinal(name); + if(header == HttpHeaders.CONTENT_ENCODING_ORDINAL) { + final String encoding = StringUtil.asciiToLowerCase(value.toString()); + gzip = encoding != null && StringUtils.contains(encoding, "gzip"); + } + + } + + @Override + protected void onResponseComplete() throws IOException { + if(LOGGER.isInfoEnabled()) { + LOGGER.info("Response has Complete:" + "path:" + this.getRequestURI().replace("\n", "0x0A")); + } + super.onResponseComplete(); + if(callback != null) { + final RestfulResponse rsp = getResponse(); + callback.callback(rsp); + } + } + + @Override + protected void onRequestCommitted() throws IOException { + if(LOGGER.isInfoEnabled()) { + LOGGER.info("Request Header has been send:" + "path:" + this.getRequestURI().replace("\n", "0x0A")); + } + super.onRequestCommitted(); + } + + @Override + protected void onRequestComplete() throws IOException { + if(LOGGER.isInfoEnabled()) { + LOGGER.info("Request has bend send complete:" + "path:" + this.getRequestURI().replace("\n", "0x0A")); + } + super.onRequestComplete(); + } + + @Override + protected void onException(final Throwable x) { + LOGGER.warn("onException:", x); + super.onException(x); + if(callback != null) { + callback.handleExcepion(x); + } + } + + @Override + protected void onConnectionFailed(final Throwable x) { + LOGGER.warn("onConnectionFailed:", x); + super.onConnectionFailed(x); + if(callback != null) { + callback.handleExcepion(x); + } + + } + + @Override + protected void expire(final HttpDestination destination) { + super.expire(destination); + if(callback != null) { + callback.handleExcepion(new ServiceException("request is expired, status:" + toState(getStatus()))); + } + } + + public boolean isGzip() { + return gzip; + } + + /** + * Get the response as RestfulResponse. + * <br/> + * + * @return response object. + * @throws IOException + * @since + */ + public RestfulResponse getResponse() throws IOException { + final RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(this.getResponseStatus()); + if(isGzip()) { + final String responseString = decompressGzipToStr(getResponseContentBytes()); + rsp.setResponseJson(responseString); + } else { + rsp.setResponseJson(this.getResponseContent()); + } + + final HttpFields field = this.getResponseFields(); + if(field != null) { + final Map<String, String> header = new HashMap<>(); + + final Enumeration<String> names = field.getFieldNames(); + for(final Enumeration<String> e = names; e.hasMoreElements();) { + final String fieldName = e.nextElement(); + final String fieldValue = field.getStringField(fieldName); + header.put(fieldName, fieldValue); + } + + rsp.setRespHeaderMap(header); + } + return rsp; + } + +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/Restful.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/Restful.java new file mode 100644 index 00000000..a5deb2e5 --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/Restful.java @@ -0,0 +1,297 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +/** + * ReSTful method interface.<br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public interface Restful { + + /** + * Http GET method.<br/> + * + * @param servicePath: request path. + * @param restParametes: query parameters. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse get(String servicePath, RestfulParametes restParametes) throws ServiceException; + + /** + * Http HEAD method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse head(String servicePath, RestfulParametes restParametes, RestfulOptions options) + throws ServiceException; + + /** + * Http HEAD method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse head(String servicePath, RestfulParametes restParametes) throws ServiceException; + + /** + * Http GET method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse get(String servicePath, RestfulParametes restParametes, RestfulOptions options) + throws ServiceException; + + /** + * Asynchronouse GET request.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param callback: response callback method. + * @throws ServiceException + * @since + */ + void asyncGet(String servicePath, RestfulParametes restParametes, RestfulAsyncCallback callback) + throws ServiceException; + + /** + * Asynchronouse GET request.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @param callback: response callback method. + * @throws ServiceException + * @since + */ + void asyncGet(String servicePath, RestfulParametes restParametes, RestfulOptions options, + RestfulAsyncCallback callback) throws ServiceException; + + /** + * Http PUT method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse put(String servicePath, RestfulParametes restParametes) throws ServiceException; + + /** + * Http PUT method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse put(String servicePath, RestfulParametes restParametes, RestfulOptions options) + throws ServiceException; + + /** + * Asynchronouse PUT request.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param callback: response callback method. + * @throws ServiceException + * @since + */ + void asyncPut(String servicePath, RestfulParametes restParametes, RestfulAsyncCallback callback) + throws ServiceException; + + /** + * Asynchronouse PUT request.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @param callback: response callback method. + * @throws ServiceException + * @since + */ + void asyncPut(String servicePath, RestfulParametes restParametes, RestfulOptions options, + RestfulAsyncCallback callback) throws ServiceException; + + /** + * Http POST method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse post(String servicePath, RestfulParametes restParametes) throws ServiceException; + + /** + * Http POST method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse post(String servicePath, RestfulParametes restParametes, RestfulOptions options) + throws ServiceException; + + /** + * Asynchronouse POST request.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param callback: response callback method. + * @throws ServiceException + * @since + */ + void asyncPost(String servicePath, RestfulParametes restParametes, RestfulAsyncCallback callback) + throws ServiceException; + + /** + * Asynchronouse POST request.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @param callback: response callback method. + * @throws ServiceException + * @since + */ + void asyncPost(String servicePath, RestfulParametes restParametes, RestfulOptions options, + RestfulAsyncCallback callback) throws ServiceException; + + /** + * Http DELETE method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse delete(String servicePath, RestfulParametes restParametes) throws ServiceException; + + /** + * Http DELETE method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse delete(String servicePath, RestfulParametes restParametes, RestfulOptions options) + throws ServiceException; + + /** + * Asynchronouse DELETE request.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param callback: response callback method. + * @throws ServiceException + * @since + */ + void asyncDelete(String servicePath, RestfulParametes restParametes, RestfulAsyncCallback callback) + throws ServiceException; + + /** + * Asynchronouse DELETE request.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @param callback: response callback method. + * @throws ServiceException + * @since + */ + void asyncDelete(String servicePath, RestfulParametes restParametes, RestfulOptions options, + RestfulAsyncCallback callback) throws ServiceException; + + /** + * Http PATCH method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse patch(String servicePath, RestfulParametes restParametes) throws ServiceException; + + /** + * Http PATCH method.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @return response. + * @throws ServiceException + * @since + */ + RestfulResponse patch(String servicePath, RestfulParametes restParametes, RestfulOptions options) + throws ServiceException; + + /** + * Asynchronouse PATCH request.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param callback: response callback method. + * @throws ServiceException + * @since + */ + void asyncPatch(String servicePath, RestfulParametes restParametes, RestfulAsyncCallback callback) + throws ServiceException; + + /** + * Asynchronouse PATCH request.<br/> + * + * @param servicePath: request path. + * @param restParametes: request parameters. + * @param options: request options. + * @param callback: response callback method. + * @throws ServiceException + * @since + */ + void asyncPatch(String servicePath, RestfulParametes restParametes, RestfulOptions options, + RestfulAsyncCallback callback) throws ServiceException; +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulAsyncCallback.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulAsyncCallback.java new file mode 100644 index 00000000..e2f2a09a --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulAsyncCallback.java @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +/** + * Callback interface for ReST calls.<br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public interface RestfulAsyncCallback { + + /** + * Response callback.<br/> + * + * @param response: response of ReST call. + * @since + */ + void callback(RestfulResponse response); + + /** + * Exceptoin callback.<br/> + * + * @param e: ReST call exception. + * @since + */ + void handleExcepion(Throwable e); +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulClientConst.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulClientConst.java new file mode 100644 index 00000000..34594925 --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulClientConst.java @@ -0,0 +1,64 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +/** + * Constants for ReST client.<br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public class RestfulClientConst { + + /** -- json Ecode -- **/ + public static final String APPLICATION_FORM_JSON_EBCIDED = "application/json"; + + /** + * urlencode + */ + public static final String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded; charset=UTF-8"; + + public static final String ENCODING = "UTF-8"; + + public static final String SERVER_KEY_NAME = "defaultServer"; + + public static final String HOST_KEY_NAME = "host"; + + public static final String PORT_KEY_NAME = "port"; + + public static final String CONN_TIMEOUT_KEY_NAME = "ConnectTimeout"; + + public static final String THREAD_KEY_NAME = "thread"; + + public static final String IDLE_TIMEOUT_KEY_NAME = "idletimeout"; + + public static final String TIMEOUT_KEY_NAME = "timeout"; + + public static final String MAX_CONN_PER_ADDR_KEY_NAME = "maxConnectionPerAddr"; + + public static final String REQUEST_ID = "x-request-id"; + + public static final String MAX_RESPONSE_HEADER_SIZE = "responseHeaderSize"; + + public static final String MAX_REQUEST_HEADER_SIZE = "requestHeaderSize"; + + private RestfulClientConst() { + + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulConfigure.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulConfigure.java new file mode 100644 index 00000000..8b71941e --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulConfigure.java @@ -0,0 +1,161 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * Rest client options.<br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public class RestfulConfigure { + + private static final Logger LOG = LoggerFactory.getLogger(RestfulConfigure.class); + + private RestfulOptions options = null; + + /** + * Constructor<br/> + * <p> + * Use the default path initialization http Rest options. + * </p> + * + * @since + */ + public RestfulConfigure() { + final String config = "/etc/conf/restclient.json"; + final String approot = SystemEnvVariablesFactory.getInstance().getAppRoot(); + final StringBuilder extendSetting = new StringBuilder(); + + if(approot != null) { + extendSetting.append(approot); + extendSetting.append(config); + } else { + extendSetting.append(System.getProperty("user.dir")); + extendSetting.append(config); + } + + final String configfile = extendSetting.toString(); + initRestConf(configfile); + } + + /** + * Constructor<br/> + * <p> + * Use the specified file to initialize http Rest options. + * </p> + * + * @since + * @param configfile + */ + public RestfulConfigure(final String configfile) { + initRestConf(configfile); + } + + public RestfulOptions getOptions() { + return options; + } + + private void initRestConf(final String configfile) { + options = getDefaultOptions(); + + final JSONObject obj = loadJsonFromFile(configfile); + if(obj != null) { + if(obj.has(RestfulClientConst.SERVER_KEY_NAME)) { + final JSONObject server = obj.getJSONObject(RestfulClientConst.SERVER_KEY_NAME); + setStringOption(server, RestfulClientConst.HOST_KEY_NAME); + setIntOption(server, RestfulClientConst.PORT_KEY_NAME); + } + setIntOption(obj, RestfulClientConst.CONN_TIMEOUT_KEY_NAME); + setIntOption(obj, RestfulClientConst.THREAD_KEY_NAME); + setIntOption(obj, RestfulClientConst.IDLE_TIMEOUT_KEY_NAME); + setIntOption(obj, RestfulClientConst.TIMEOUT_KEY_NAME); + setIntOption(obj, RestfulClientConst.MAX_CONN_PER_ADDR_KEY_NAME); + setIntOption(obj, RestfulClientConst.MAX_RESPONSE_HEADER_SIZE); + setIntOption(obj, RestfulClientConst.MAX_REQUEST_HEADER_SIZE); + } else { + LOG.error("failed to load json from " + configfile); + } + } + + private void setStringOption(final JSONObject json, final String key) { + if(json.has(key)) { + options.setOption(key, json.getString(key)); + } + } + + private void setIntOption(final JSONObject json, final String key) { + if(json.has(key)) { + options.setOption(key, json.getInt(key)); + } + } + + private RestfulOptions getDefaultOptions() { + options = new RestfulOptions(); + options.setOption(RestfulClientConst.CONN_TIMEOUT_KEY_NAME, 3000); + options.setOption(RestfulClientConst.THREAD_KEY_NAME, 200); + options.setOption(RestfulClientConst.IDLE_TIMEOUT_KEY_NAME, 30000); + options.setOption(RestfulClientConst.TIMEOUT_KEY_NAME, 30000); + options.setOption(RestfulClientConst.MAX_CONN_PER_ADDR_KEY_NAME, 50); + options.setOption(RestfulClientConst.MAX_RESPONSE_HEADER_SIZE, 20 * 1024); + options.setOption(RestfulClientConst.MAX_REQUEST_HEADER_SIZE, 20 * 1024); + return options; + } + + private JSONObject loadJsonFromFile(final String filePath) { + final File file = new File(filePath); + if((!file.exists()) || (!file.isFile())) { + LOG.error(filePath + "isn't exist."); + return null; + } + BufferedReader reader = null; + final StringBuilder jsonstr = new StringBuilder(); + JSONObject jo = null; + try { + reader = new BufferedReader(new FileReader(file)); + final ReaderHelper rHelpper = new ReaderHelper(reader); + String tempString = null; + while((tempString = rHelpper.getLine()) != null) { + jsonstr.append(tempString); + } + jo = JSONObject.fromObject(jsonstr.toString()); + } catch(final IOException e) { + LOG.error("load file exception:" + e); + } finally { + if(reader != null) { + try { + reader.close(); + } catch(final IOException e) { + LOG.error("close error.", e); + } + } + } + return jo; + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulFactory.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulFactory.java new file mode 100644 index 00000000..801648c7 --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulFactory.java @@ -0,0 +1,94 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * RestFul instance factory. <br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public class RestfulFactory { + + /** + * https protocol. + */ + public static final String PROTO_HTTPS = "https"; + + /** + * http protocol. + */ + public static final String PROTO_HTTP = "http"; + + private static final Logger LOG = LoggerFactory.getLogger(RestfulFactory.class); + + private static final Map<String, Restful> INSTANCES = new HashMap<>(2); + + private RestfulFactory() { + + } + + /** + * Get RESTful instance. This method returns a singleton instance. + * <br/> + * + * @param protocol protocol. currently only support 'http'. + * @return restful instance. + * @since + */ + public static synchronized Restful getRestInstance(final String protocol) { + Restful rest = INSTANCES.get(protocol); + if(rest != null) { + return rest; + } + if(PROTO_HTTP.equals(protocol)) { + rest = createHttpRest(); + INSTANCES.put(protocol, rest); + } + return rest; + } + + private static Restful createHttpRest() { + final HttpRest rest = new HttpRest(); + setRestOption(rest, null); + return rest; + } + + private static void setRestOption(final HttpRest rest, final String restoptionfile) { + try { + RestfulConfigure config; + if(restoptionfile == null || restoptionfile.isEmpty()) { + config = new RestfulConfigure(); + } else { + config = new RestfulConfigure(restoptionfile); + } + + final RestfulOptions option = config.getOptions(); + rest.initHttpRest(option); + } catch(final ServiceException e) { + LOG.error("init http client exception: ", e); + } + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulOptions.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulOptions.java new file mode 100644 index 00000000..bbbfbce4 --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulOptions.java @@ -0,0 +1,171 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import java.util.HashMap; +import java.util.Map; + +/** + * Options for Rest communication.<br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public class RestfulOptions { + + public static final String REST_OPTIONS_NAME_TIMEOUT = "timeout"; + + public static final int REST_OPTIONS_TIMEOUT_MAXTIMEOUT = 1800000; + + private final Map<String, Object> optionsMap = new HashMap<>(); + + /** + * Get port.<br/> + * + * @return port. + * @since + */ + public int getPort() { + final Object obj = this.getOption(RestfulClientConst.PORT_KEY_NAME); + if(null == obj) { + return 0; + } + return ((Integer)obj).intValue(); + } + + /** + * Set port.<br/> + * + * @param port port to set. + * @return + * @since + */ + public boolean setPort(final int port) { + this.setOption(RestfulClientConst.PORT_KEY_NAME, port); + return true; + } + + /** + * Get host.<br/> + * + * @return the host. + * @since + */ + public String getHost() { + final Object obj = this.getOption(RestfulClientConst.HOST_KEY_NAME); + if(null == obj) { + return ""; + } + return (String)obj; + } + + /** + * Set host.<br/> + * + * @param host host to set. + * @return + * @since + */ + public boolean setHost(final String host) { + this.setOption(RestfulClientConst.HOST_KEY_NAME, host); + return true; + } + + /** + * Set rest time-out.<br/> + * + * @param timeout time-out to set in seconds. + * @return + * @since + */ + public boolean setRestTimeout(final int timeout) { + if(0 < timeout && REST_OPTIONS_TIMEOUT_MAXTIMEOUT >= timeout) { + this.setOption(REST_OPTIONS_NAME_TIMEOUT, timeout); + return true; + } + return false; + } + + /** + * Get time-out.<br/> + * + * @return time-out in seconds. + * @since + */ + public int getRestTimeout() { + final Object obj = this.getOption(REST_OPTIONS_NAME_TIMEOUT); + if(null == obj) { + return 0; + } + return ((Integer)obj).intValue(); + } + + /** + * Get specified option.<br/> + * + * @param optionName option name. + * @return option + * @since + */ + public Object getOption(final String optionName) { + return optionsMap.get(optionName); + } + + /** + * Get option value as integer.<br/> + * + * @param optionName option name. + * @return option value as int. + * @since + */ + public int getIntOption(final String optionName) { + final Object obj = this.getOption(optionName); + if(null == obj) { + return 0; + } + return ((Integer)obj).intValue(); + } + + /** + * Get option value as string.<br/> + * + * @param optionName option name. + * @return option value as string. + * @since + */ + public String getStringOption(final String optionName) { + final Object obj = this.getOption(optionName); + if(null == obj) { + return ""; + } + return (String)obj; + } + + /** + * Set option.<br/> + * + * @param option option name. + * @param optionsValue option value. + * @return + * @since + */ + public Object setOption(final String option, final Object optionsValue) { + return optionsMap.put(option, optionsValue); + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulParametes.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulParametes.java new file mode 100644 index 00000000..1075f02e --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulParametes.java @@ -0,0 +1,155 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import java.util.HashMap; +import java.util.Map; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version Aug 9, 2016 + */ +public class RestfulParametes { + + private Map<String, String> paramMap = new HashMap<>(); + + private Map<String, String> headerMap = new HashMap<>(); + + private String rawData = null; + + /** + * <br/> + * + * @param key + * @return + * @since + */ + public String get(final String key) { + return paramMap.get(key); + } + + /** + * <br/> + * + * @param data + * @since + */ + public void setRawData(final String data) { + this.rawData = data; + } + + /** + * <br/> + * + * @return + * @since + */ + public String getRawData() { + return this.rawData; + } + + /** + * <br/> + * + * @param key + * @param value + * @return + * @since + */ + public String put(final String key, final String value) { + return paramMap.put(key, value); + } + + /** + * <br/> + * + * @param key + * @param value + * @return + * @since + */ + public String putHttpContextHeader(final String key, final String value) { + return headerMap.put(key, value); + } + + /** + * <br/> + * + * @param key + * @param value + * @return + * @since + */ + public String putHttpContextHeader(final String key, final int value) { + return this.putHttpContextHeader(key, String.valueOf(value)); + } + + /** + * <br/> + * + * @param key + * @return + * @since + */ + public String getHttpContextHeader(final String key) { + return headerMap.get(key); + } + + /** + * <br/> + * + * @return + * @since + */ + public Map<String, String> getParamMap() { + return paramMap; + } + + /** + * <br/> + * + * @param paramMap + * @since + */ + public void setParamMap(final Map<String, String> paramMap) { + this.paramMap = paramMap; + } + + /** + * <br/> + * + * @return + * @since + */ + public Map<String, String> getHeaderMap() { + return this.headerMap; + } + + /** + * <br/> + * + * @param headerMap + * @since + */ + public void setHeaderMap(final Map<String, String> headerMap) { + this.headerMap = headerMap; + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulResponse.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulResponse.java new file mode 100644 index 00000000..322b0cec --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestfulResponse.java @@ -0,0 +1,144 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import java.util.Map; + +/** + * Response for RestFul requests.<br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public class RestfulResponse { + + private String responseContent; + + private int status = -1; + + private Map<String, String> respHeaderMap = null; + + /** + * <br/> + * + * @return + * @since + */ + public int getStatus() { + return status; + } + + /** + * <br/> + * + * @param status + * @since + */ + public void setStatus(final int status) { + this.status = status; + } + + /** + * <br/> + * + * @return + * @since + */ + public Map<String, String> getRespHeaderMap() { + return respHeaderMap; + } + + /** + * <br/> + * + * @param header + * @since + */ + public void setRespHeaderMap(final Map<String, String> header) { + this.respHeaderMap = header; + } + + /** + * Get response header value as integer.<br/> + * + * @param key header param name. + * @return header param value as integer. (-1 if error) + * @since + */ + public int getRespHeaderInt(final String key) { + if(respHeaderMap != null) { + final String result = respHeaderMap.get(key); + if(result != null) { + return Integer.parseInt(result); + } + } + return -1; + } + + /** + * Get response header value as long.<br/> + * + * @param key header param name. + * @return value as long. -1 if no value. + * @since + */ + public long getRespHeaderLong(final String key) { + if(respHeaderMap != null) { + final String result = respHeaderMap.get(key); + if(result != null) { + return Long.parseLong(result); + } + } + return -1; + } + + /** + * Get http header as string.<br/> + * + * @param key header name. + * @return header value. + * @since + */ + public String getRespHeaderStr(final String key) { + if(respHeaderMap != null) { + return respHeaderMap.get(key); + } + return null; + } + + /** + * <br/> + * + * @return + * @since + */ + public String getResponseContent() { + return responseContent; + } + + /** + * <br/> + * + * @param responseString + * @since + */ + public void setResponseJson(final String responseString) { + this.responseContent = responseString; + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ServiceException.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ServiceException.java new file mode 100644 index 00000000..af8086b7 --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ServiceException.java @@ -0,0 +1,270 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import java.text.MessageFormat; + +/** + * The base class for all common exception.<br/> + * <p> + * </p> + * + * @author + * @version 28-May-2016 + */ +public class ServiceException extends Exception { + + /** + * default exception id. + */ + public static final String DEFAULT_ID = "framwork.remote.SystemError"; + + /** + * Serial number. + */ + private static final long serialVersionUID = 5703294364555144738L; + + /** + * Exception id. + */ + private String id = DEFAULT_ID; + + private Object[] args = null; + + private int httpCode = 500; + + private ExceptionArgs exceptionArgs = null; + + /** + * The default constructor<br/> + * <p> + * This method is only used as deserialized, in other cases, use parameterized constructor. + * </p> + * + * @since + */ + public ServiceException() { + super(""); + } + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + * @param id: details. + * @param cause: reason. + */ + public ServiceException(final String id, final Throwable cause) { + super(cause); + this.setId(id); + } + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + * @param message: details. + */ + public ServiceException(final String message) { + super(message); + } + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + * @param id: exception id. + * @param message: details. + */ + public ServiceException(final String id, final String message) { + super(message); + this.setId(id); + } + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + * @param id: exception id. + * @param httpCode: http status code. + */ + public ServiceException(final String id, final int httpCode) { + super(); + this.setId(id); + this.setHttpCode(httpCode); + } + + /** + * Constructor<br/> + * <p> + * the exception include the httpcode and message. + * </p> + * + * @since + * @param httpCode http code. + * @param message details. + */ + public ServiceException(final int httpCode, final String message) { + super(message); + this.setHttpCode(httpCode); + } + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + * @param id: exception id. + * @param httpCode: http code. + * @param exceptionArgs: Exception handling frame parameters. + */ + public ServiceException(final String id, final int httpCode, final ExceptionArgs exceptionArgs) { + super(); + this.setId(id); + this.setHttpCode(httpCode); + this.setExceptionArgs(exceptionArgs); + } + + /** + * Constructor<br/> + * <p> + * Have a placeholder exception, use args formatted message. + * </p> + * + * @since + * @param id: exception id. + * @param message: details. + * @param args: Placeholders for parameters + */ + public ServiceException(final String id, final String message, final Object... args) { + super(MessageFormat.format(message, args)); + this.setId(id); + this.args = args; + } + + /** + * Constructor<br/> + * <p> + * Have a placeholder exception, use args formatted message + * </p> + * + * @since + * @param id: exception id. + * @param message: details. + * @param cause: reason. + * @param args: placeholder for parameters + */ + public ServiceException(final String id, final String message, final Throwable cause, final Object... args) { + super(MessageFormat.format(message, args), cause); + this.setId(id); + this.args = args; + } + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + * @param id: exception id. + * @param message: details. + * @param cause: reason. + */ + public ServiceException(final String id, final String message, final Throwable cause) { + super(message, cause); + this.setId(id); + } + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + * @param cause: reason. + */ + public ServiceException(final Throwable cause) { + super(cause); + } + + /** + * Get exceptoin id.<br/> + * + * @return + * @since + */ + public String getId() { + if(id == null || id.isEmpty()) { + return DEFAULT_ID; + } + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public int getHttpCode() { + return this.httpCode; + } + + public void setHttpCode(final int httpCode) { + this.httpCode = httpCode; + } + + /** + * Obtain the ROA exception handling framework parameters<br/> + * + * @return exception args. + * @since + */ + public ExceptionArgs getExceptionArgs() { + return exceptionArgs; + } + + public void setExceptionArgs(final ExceptionArgs exceptionArgs) { + this.exceptionArgs = exceptionArgs; + } + + /** + * Gets the parameter information<br/> + * + * @return parameter list. + * @since + */ + protected Object[] getArgs() { + if(args == null || args.length == 0 || DEFAULT_ID.equals(getId())) { + return new Object[] {}; + } + return args; + } + + @Override + public String toString() { + return "exception.id: " + getId() + "; " + super.toString(); + } + +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/SystemEnvVariables.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/SystemEnvVariables.java new file mode 100644 index 00000000..c5e35b06 --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/SystemEnvVariables.java @@ -0,0 +1,36 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +/** + * Dependency the system env<br/> + * <p> + * </p> + * + * @author + * @version 31-May-2016 + */ +public interface SystemEnvVariables { + + /** + * Get application root path <br/> + * + * @return application root path. + * @since + */ + String getAppRoot(); +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/SystemEnvVariablesDefImpl.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/SystemEnvVariablesDefImpl.java new file mode 100644 index 00000000..40e489be --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/SystemEnvVariablesDefImpl.java @@ -0,0 +1,67 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import java.io.File; +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * System environment variable helper implementation.<br/> + * <p> + * </p> + * + * @author + * @version 24-Jun-2016 + */ +public class SystemEnvVariablesDefImpl implements SystemEnvVariables { + + private static final Logger LOG = LoggerFactory.getLogger(SystemEnvVariablesDefImpl.class); + + @Override + public String getAppRoot() { + String appRoot = null; + appRoot = System.getProperty("catalina.base"); + if(appRoot != null) { + appRoot = getCanonicalPath(appRoot); + } + return appRoot; + } + + /** + * Gets the canonical path<br/> + * + * @param inPath input path + * @return the canonical path. + * @since + */ + private String getCanonicalPath(final String inPath) { + String path = null; + try { + if(inPath != null) { + final File file = new File(inPath); + path = file.getCanonicalPath(); + } + } catch(final IOException e) { + LOG.error("file.getCanonicalPath() IOException:", e); + } + return path; + } + +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/SystemEnvVariablesFactory.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/SystemEnvVariablesFactory.java new file mode 100644 index 00000000..1f8c07c6 --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/SystemEnvVariablesFactory.java @@ -0,0 +1,53 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +/** + * SystemEnvVariables factory class + * <br/> + * <p> + * </p> + * + * @author + * @version + */ +public class SystemEnvVariablesFactory { + + private static SystemEnvVariables systemEnvVariablesInstance = new SystemEnvVariablesDefImpl(); + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since + */ + private SystemEnvVariablesFactory() { + + } + + /** + * get the SystemEnvVariables instance + * <br/> + * + * @return SystemEnvVariables instance + * @since + */ + public static SystemEnvVariables getInstance() { + return systemEnvVariablesInstance; + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/HttpRestfulHelp.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/HttpRestfulHelp.java index 6bac7633..3fcbce93 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/HttpRestfulHelp.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/HttpRestfulHelp.java @@ -19,8 +19,8 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken; import java.util.HashMap; import java.util.Map; -import org.openo.baseservice.roa.util.restclient.HttpRest; -import org.openo.baseservice.roa.util.restclient.Restful; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.HttpRest; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.Restful; /** * HTTP Restful helper. diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtil.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtil.java index 1b405648..eb21caa1 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtil.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtil.java @@ -24,13 +24,13 @@ import java.util.Map; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmException; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.Restful; -import org.openo.baseservice.roa.util.restclient.RestfulAsyncCallback; -import org.openo.baseservice.roa.util.restclient.RestfulFactory; -import org.openo.baseservice.roa.util.restclient.RestfulOptions; -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.Restful; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulAsyncCallback; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulFactory; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulOptions; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulParametes; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtil.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtil.java index b694d573..924b2489 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtil.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtil.java @@ -24,13 +24,13 @@ import java.util.Map; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmException; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.Restful; -import org.openo.baseservice.roa.util.restclient.RestfulAsyncCallback; -import org.openo.baseservice.roa.util.restclient.RestfulFactory; -import org.openo.baseservice.roa.util.restclient.RestfulOptions; -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.Restful; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulAsyncCallback; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulFactory; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulOptions; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulParametes; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java index 5b9d0774..a6062404 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java @@ -28,14 +28,14 @@ import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpStatus; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.DownloadCsarManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.SystemEnvVariablesFactory; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VNFRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.inf.IResourceManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.UrlConstant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect.ConnectMgrVnfm; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect.HttpRequests; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; -import org.openo.baseservice.util.impl.SystemEnvVariablesFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManager.java index 689ee2fe..8f482b6b 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManager.java @@ -21,7 +21,7 @@ import java.util.Map; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VNFRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.inf.IDriver2MSBManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManager.java index d6831b9c..39bb9fb0 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManager.java @@ -21,7 +21,7 @@ import java.util.Map; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VNFRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.inf.IVnfmAdapter2DriverManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java index be0f5acc..9da10093 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java @@ -25,12 +25,12 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executors; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.SystemEnvVariablesFactory; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl.VnfmAdapter2DriverManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.inf.IVnfmAdapter2DriverManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.api.internalsvc.inf.IVnfmAdapter2DriverMgrService; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.UrlConstant; -import org.openo.baseservice.util.impl.SystemEnvVariablesFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java index 9bcde8ab..e754fa27 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java @@ -25,12 +25,12 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executors; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.SystemEnvVariablesFactory; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl.Driver2MSBManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.inf.IDriver2MSBManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.api.internalsvc.inf.IVnfmAdapterMgrService; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.UrlConstant; -import org.openo.baseservice.util.impl.SystemEnvVariablesFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -76,10 +76,11 @@ public class VnfmAdapterMgrService implements IVnfmAdapterMgrService { /** * Retrieve VIM driver information. + * * @return * @throws IOException */ - public String readVnfmAdapterInfoFromJson() throws IOException { + public String readVnfmAdapterInfoFromJson() throws IOException { InputStream ins = null; BufferedInputStream bins = null; String fileContent = ""; @@ -101,10 +102,10 @@ public class VnfmAdapterMgrService implements IVnfmAdapterMgrService { } catch(FileNotFoundException e) { LOG.error(fileName + "is not found!", e); } finally { - if (ins != null) { + if(ins != null) { ins.close(); } - if (bins != null) { + if(bins != null) { bins.close(); } } @@ -175,7 +176,7 @@ public class VnfmAdapterMgrService implements IVnfmAdapterMgrService { @Override public void unregister() { - //unregister + // unregister } } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/AbstractSslContext.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/AbstractSslContext.java index 255bdb72..f10c2ac5 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/AbstractSslContext.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/AbstractSslContext.java @@ -16,32 +16,43 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect; -import net.sf.json.JSONObject; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; -import org.openo.baseservice.util.impl.SystemEnvVariablesFactory; +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; + +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; + +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.SystemEnvVariablesFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.http.HttpRequest; -import java.io.*; -import java.security.*; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -import javax.net.ssl.*; +import net.sf.json.JSONObject; /** * SSL context * .</br> * * @author - * @version NFVO 0.5 Sep 14, 2016 + * @version NFVO 0.5 Sep 14, 2016 */ public class AbstractSslContext { + private static final Logger LOG = LoggerFactory.getLogger(AbstractSslContext.class); - protected AbstractSslContext(){ - //constructor + + protected AbstractSslContext() { + // constructor } private static SSLContext getSSLContext() throws NoSuchAlgorithmException { @@ -53,81 +64,85 @@ public class AbstractSslContext { sslContext.init(null, new TrustManager[] {new TrustAnyTrustManager()}, new SecureRandom()); return sslContext; } + protected static SSLContext getCertificateSSLContext() throws GeneralSecurityException { SSLContext sslContext = getSSLContext(); - JSONObject sslConf = null; + JSONObject sslConf = null; try { - sslConf = readSSLConfToJson(); - } catch (Exception e) { - LOG.error("readSSLConfToJson error",e); + sslConf = readSSLConfToJson(); + } catch(Exception e) { + LOG.error("readSSLConfToJson error", e); } sslContext.init(createKeyManager(sslConf), createTrustManager(sslConf), new SecureRandom()); return sslContext; } - protected static KeyManager[] createKeyManager(JSONObject sslConf) { + protected static KeyManager[] createKeyManager(JSONObject sslConf) { KeyManager[] kms = null; try { - String CERT_STORE="etc/conf/server.p12"; - String CERT_STORE_PASSWORD="Changeme_123"; + String CERT_STORE = "etc/conf/server.p12"; + String CERT_STORE_PASSWORD = "Changeme_123"; String KEY_STORE_TYPE = "PKCS12"; - if(sslConf != null){ + if(sslConf != null) { CERT_STORE = sslConf.getString("keyStore"); CERT_STORE_PASSWORD = sslConf.getString("keyStorePass"); KEY_STORE_TYPE = sslConf.getString("keyStoreType"); } // load jks file - FileInputStream f_certStore=new FileInputStream(CERT_STORE); + FileInputStream f_certStore = new FileInputStream(CERT_STORE); KeyStore ks = KeyStore.getInstance(KEY_STORE_TYPE); ks.load(f_certStore, CERT_STORE_PASSWORD.toCharArray()); f_certStore.close(); // init and create - String alg= KeyManagerFactory.getDefaultAlgorithm(); + String alg = KeyManagerFactory.getDefaultAlgorithm(); KeyManagerFactory kmFact = KeyManagerFactory.getInstance(alg); kmFact.init(ks, CERT_STORE_PASSWORD.toCharArray()); kms = kmFact.getKeyManagers(); - } catch (Exception e) { - LOG.error("create KeyManager fail!",e); + } catch(Exception e) { + LOG.error("create KeyManager fail!", e); } return kms; } - protected static TrustManager[] createTrustManager(JSONObject sslConf){ + + protected static TrustManager[] createTrustManager(JSONObject sslConf) { TrustManager[] tms = null; try { - String TRUST_STORE="etc/conf/trust.jks"; - String TRUST_STORE_PASSWORD="Changeme_123"; - String TRUST_STORE_TYPE = "jks"; - if(sslConf != null){ - TRUST_STORE = sslConf.getString("trustStore"); - TRUST_STORE_PASSWORD = sslConf.getString("trustStorePass"); - TRUST_STORE_TYPE = sslConf.getString("trustStoreType"); - } - FileInputStream f_trustStore=new FileInputStream(TRUST_STORE); - KeyStore ks = KeyStore.getInstance(TRUST_STORE_TYPE); - ks.load(f_trustStore, TRUST_STORE_PASSWORD.toCharArray()); - f_trustStore.close(); - - String alg=TrustManagerFactory.getDefaultAlgorithm(); - TrustManagerFactory tmFact=TrustManagerFactory.getInstance(alg); - tmFact.init(ks); - tms=tmFact.getTrustManagers(); - - } catch (Exception e){ - LOG.error("create TrustManager fail!",e); + String TRUST_STORE = "etc/conf/trust.jks"; + String TRUST_STORE_PASSWORD = "Changeme_123"; + String TRUST_STORE_TYPE = "jks"; + if(sslConf != null) { + TRUST_STORE = sslConf.getString("trustStore"); + TRUST_STORE_PASSWORD = sslConf.getString("trustStorePass"); + TRUST_STORE_TYPE = sslConf.getString("trustStoreType"); + } + FileInputStream f_trustStore = new FileInputStream(TRUST_STORE); + KeyStore ks = KeyStore.getInstance(TRUST_STORE_TYPE); + ks.load(f_trustStore, TRUST_STORE_PASSWORD.toCharArray()); + f_trustStore.close(); + + String alg = TrustManagerFactory.getDefaultAlgorithm(); + TrustManagerFactory tmFact = TrustManagerFactory.getInstance(alg); + tmFact.init(ks); + tms = tmFact.getTrustManagers(); + + } catch(Exception e) { + LOG.error("create TrustManager fail!", e); } - return tms; + return tms; } - /**readSSLConfToJson + /** + * readSSLConfToJson + * * @return * @throws IOException * @since NFVO 0.5 */ public static JSONObject readSSLConfToJson() throws IOException { - JSONObject sslJson= null; + JSONObject sslJson = null; InputStream ins = null; BufferedInputStream bins = null; String fileContent = ""; @@ -149,9 +164,9 @@ public class AbstractSslContext { sslJson = JSONObject.fromObject(fileContent); } catch(FileNotFoundException e) { LOG.error(fileName + "is not found!", e); - } catch (Exception e){ + } catch(Exception e) { LOG.error("read sslconf file fail.please check if the 'sslconf.json' is exist."); - }finally { + } finally { if(ins != null) { ins.close(); } @@ -162,6 +177,7 @@ public class AbstractSslContext { return sslJson; } + private static class TrustAnyTrustManager implements X509TrustManager { @Override @@ -171,12 +187,12 @@ public class AbstractSslContext { @Override public void checkServerTrusted(X509Certificate[] certs, String authType) { - //NOSONAR + // NOSONAR } @Override public void checkClientTrusted(X509Certificate[] certs, String authType) { - //NOSONAR + // NOSONAR } } } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/impl/VnfmDaoImpl.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/impl/VnfmDaoImpl.java index 83db166e..caf153a6 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/impl/VnfmDaoImpl.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/impl/VnfmDaoImpl.java @@ -22,7 +22,7 @@ import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.dao.inf.AbstractDao; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.dao.inf.VnfmDao; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.entity.Vnfm; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.mapper.VnfmMapper; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; /** * VNFM DAO diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/inf/VnfmDao.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/inf/VnfmDao.java index e1fdc2d2..af43d6a5 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/inf/VnfmDao.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/inf/VnfmDao.java @@ -19,7 +19,7 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.dao.inf; import java.util.List; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.entity.Vnfm; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; /** * VNFM DAO diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgr.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgr.java index c0d7b0f4..49c722f8 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgr.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgr.java @@ -22,7 +22,7 @@ import java.util.Map; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.RegisterConfigInfo; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VnfmRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.ParamConstants; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgr.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgr.java index 3d34b8cb..96d76ca6 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgr.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgr.java @@ -23,7 +23,7 @@ import org.apache.commons.lang.StringUtils; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VnfmRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.ParamConstants; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java index 870875c4..20a02d6c 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java @@ -35,9 +35,9 @@ import javax.ws.rs.core.MediaType; import org.apache.commons.collections.map.UnmodifiableMap; import org.apache.commons.lang3.StringUtils; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmJsonUtil; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process.VnfMgr; -import org.openo.baseservice.remoteservice.exception.ServiceException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -277,11 +277,11 @@ public class VnfRoa { * * @param context * { - * “action”: “vmReset”, - * “affectedvm”: { - * “vmid”: “804cca71 - 9ae9 - 4511 - 8e30 - d1387718caff”, - * “vduid”: “vdu_100”, - * “vmname”: “ZTE_SSS_111_PP_2_L” + * �action�: �vmReset�, + * �affectedvm�: { + * �vmid�: �804cca71 - 9ae9 - 4511 - 8e30 - d1387718caff�, + * �vduid�: �vdu_100�, + * �vmname�: �ZTE_SSS_111_PP_2_L� * } * } * @param resp diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapper.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapper.java index b38088d2..2ee864d6 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapper.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapper.java @@ -21,7 +21,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; /** * ServiceException response provider.<br> diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtilTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtilTest.java index d3f773e9..e95e9578 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtilTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtilTest.java @@ -21,7 +21,7 @@ import static org.junit.Assert.*; import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VnfmRestfulUtil; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/HttpRestfulHelpTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/HttpRestfulHelpTest.java index 62f3f212..5f2410ab 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/HttpRestfulHelpTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/HttpRestfulHelpTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertNotNull; import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.HttpRestfulHelp; -import org.openo.baseservice.roa.util.restclient.Restful; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.Restful; /** * <br/> diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtilTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtilTest.java index cd6c0df2..9691a077 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtilTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtilTest.java @@ -27,7 +27,7 @@ import java.util.Map; import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VNFRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.testutils.JsonUtil; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java index 6c19feaa..fec98449 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java @@ -26,7 +26,7 @@ import java.util.Map; import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VnfmRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java index e6e0b23f..95727339 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java @@ -29,7 +29,7 @@ import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.DownloadCsarManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VNFRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl.AdapterResourceManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.testutils.JsonUtil; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManagerTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManagerTest.java index dc76d846..4855a548 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManagerTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManagerTest.java @@ -27,7 +27,7 @@ import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VNFRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl.Driver2MSBManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.testutils.JsonUtil; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManagerTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManagerTest.java index 761b7e16..fd36b438 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManagerTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManagerTest.java @@ -27,7 +27,7 @@ import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VNFRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl.VnfmAdapter2DriverManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.testutils.JsonUtil; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/impl/VnfmDaoImplTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/impl/VnfmDaoImplTest.java index 6a2604d5..59ecbf90 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/impl/VnfmDaoImplTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/dao/impl/VnfmDaoImplTest.java @@ -19,7 +19,7 @@ import junit.framework.Assert; import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.dao.impl.VnfmDaoImpl; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.entity.Vnfm; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; /** * Created by QuanZhong on 2017/3/17. diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgrTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgrTest.java index d19889cd..83961f8c 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgrTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgrTest.java @@ -22,7 +22,7 @@ import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VnfmRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process.AuthMgr; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgrTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgrTest.java index 7273878c..e8c842be 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgrTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgrTest.java @@ -19,7 +19,7 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process; import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VnfmRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process.RegisterMgr; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgrTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgrTest.java index 60d11b0b..7ef0460d 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgrTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgrTest.java @@ -31,7 +31,7 @@ import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.dao.impl.VnfmDaoImpl; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.dao.inf.VnfmDao; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.entity.Vnfm; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process.VnfMgr; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgrTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgrTest.java index eb5719e1..cccc441a 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgrTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgrTest.java @@ -22,7 +22,7 @@ import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VnfmRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process.VnfResourceMgr; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoaTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoaTest.java index 411e6adc..b9ab83a8 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoaTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoaTest.java @@ -29,7 +29,7 @@ import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmJsonUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process.VnfMgr; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.rest.VnfRoa; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import mockit.Mock; import mockit.MockUp; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapperTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapperTest.java index cf4c56e9..8a187bde 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapperTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapperTest.java @@ -22,7 +22,7 @@ import javax.ws.rs.core.Response; import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.rest.exceptionmapper.ServiceExceptionMapper; -import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; /** * <br> diff --git a/huawei/vnfmadapter/pom.xml b/huawei/vnfmadapter/pom.xml index 4eac272e..48ae5700 100644 --- a/huawei/vnfmadapter/pom.xml +++ b/huawei/vnfmadapter/pom.xml @@ -16,8 +16,8 @@ --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> - <groupId>org.onap.oparent</groupId> - <artifactId>oparent</artifactId> + <groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.huawei</groupId> + <artifactId>vfc-nfvo-driver-vnfm-svnfm-huawei</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> @@ -29,5 +29,6 @@ <description>vfc-nfvo-driver-vnfm-svnfm</description> <modules> <module>zte</module> + <module>huawei</module> </modules> </project> |