From 46f240e21cbca38e110395372445a9dc4d50e462 Mon Sep 17 00:00:00 2001 From: Murali Date: Tue, 12 Sep 2017 13:59:12 +0000 Subject: Fix the compilation issue Migrate from open-o oparent to onap oparent Change-Id: I56ba692339b759cb18abfd3d7c689ef6ff1de190 Jira:VNFSDK-81 Signed-off-by: Murali --- deployment/pom.xml | 6 +- lifecycle-test/pom.xml | 327 +++++++++++---------- .../vnfsdk/lctest/common/util/RestConstant.java | 83 ++++++ .../vnfsdk/lctest/common/util/RestResponse.java | 40 +++ .../vnfsdk/lctest/common/util/RestfulClient.java | 168 +++++++++++ .../vnfsdk/lctest/common/util/RestfulUtil.java | 237 --------------- .../impl/LifecycleTestAdapter2MSBManager.java | 20 +- .../impl/LifecycleTestAdapterMgrService.java | 9 +- .../business/impl/VnfpackageServiceImpl.java | 17 +- .../vnfsdk/lctest/service/rest/VnfpackageRoa.java | 12 +- pom.xml | 8 +- 11 files changed, 503 insertions(+), 424 deletions(-) create mode 100644 lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestConstant.java create mode 100644 lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestResponse.java create mode 100644 lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestfulClient.java delete mode 100644 lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestfulUtil.java diff --git a/deployment/pom.xml b/deployment/pom.xml index 372f610..f160a42 100644 --- a/deployment/pom.xml +++ b/deployment/pom.xml @@ -16,13 +16,13 @@ --> - org.openo.vnf-sdk.validate-lc-test + org.onap.vnfsdk.lctest vnf-sdk-validate-lc-test - 1.1.0-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 lifecycle-test-deployment - 1.1.0-SNAPSHOT + 1.0.0-SNAPSHOT vnf-sdk-validate-lc-test/deployment pom diff --git a/lifecycle-test/pom.xml b/lifecycle-test/pom.xml index b1e999c..a43cde7 100644 --- a/lifecycle-test/pom.xml +++ b/lifecycle-test/pom.xml @@ -1,161 +1,180 @@ - + - - org.openo.vnf-sdk.validate-lc-test - vnf-sdk-validate-lc-test - 1.1.0-SNAPSHOT - - 4.0.0 - lifecycle-test-service - 1.1.0-SNAPSHOT - vnf-sdk-validate-lc-test/lifecycle-test-service - war + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + org.onap.vnfsdk.lctest + vnf-sdk-validate-lc-test + 1.0.0-SNAPSHOT + + 4.0.0 + lifecycle-test-service + 1.0.0-SNAPSHOT + vnf-sdk-validate-lc-test/lifecycle-test-service + war - - - mysql - mysql-connector-java - 5.1.36 - - - org.springframework - spring-tx - 3.1.0.RELEASE - - - org.mybatis - mybatis-spring - 1.2.0 - - - org.mybatis - mybatis - 3.2.7 - - - org.yaml - snakeyaml - 1.15 - - - org.openo.common-services.common-utilities - commonlib-cbb - 1.1.0-SNAPSHOT - - - org.openo.common-services.common-utilities - commonlib-restclient - 1.1.0-SNAPSHOT - - - org.slf4j - slf4j-log4j12 - 1.6.1 - - - org.powermock - powermock-api-mockito - 1.5.4 - - - org.mockito - mockito-all - 1.9.5 - - - org.powermock - powermock-module-junit4 - 1.5.4 - jar - compile - - - org.springframework - spring-core - 3.1.0.RELEASE - - - org.springframework - spring-aop - 3.1.0.RELEASE - - - org.springframework - spring-beans - 3.1.0.RELEASE - - - org.springframework - spring-context - 3.1.0.RELEASE - - - org.springframework - spring-jdbc - 3.1.0.RELEASE - - - org.springframework - spring-web - 3.1.0.RELEASE - - - org.springframework - spring-asm - 3.1.0.RELEASE - - - org.springframework - spring-expression - 3.1.0.RELEASE - - - org.springframework - spring-test - 3.1.0.RELEASE - + + + mysql + mysql-connector-java + 5.1.36 + + + org.springframework + spring-tx + 3.1.0.RELEASE + + + org.mybatis + mybatis-spring + 1.2.0 + + + org.mybatis + mybatis + 3.2.7 + + + org.yaml + snakeyaml + 1.15 + + + org.slf4j + slf4j-log4j12 + 1.6.1 + + + org.powermock + powermock-api-mockito + 1.5.4 + + + org.mockito + mockito-all + 1.9.5 + + + org.powermock + powermock-module-junit4 + 1.5.4 + jar + compile + + + org.springframework + spring-core + 3.1.0.RELEASE + + + org.springframework + spring-aop + 3.1.0.RELEASE + + + org.springframework + spring-beans + 3.1.0.RELEASE + + + org.springframework + spring-context + 3.1.0.RELEASE + + + org.springframework + spring-jdbc + 3.1.0.RELEASE + + + org.springframework + spring-web + 3.1.0.RELEASE + + + org.springframework + spring-asm + 3.1.0.RELEASE + + + org.springframework + spring-expression + 3.1.0.RELEASE + + + org.springframework + spring-test + 3.1.0.RELEASE + - - org.apache.cxf - cxf-rt-frontend-jaxrs - 3.1.6 - + + org.apache.cxf + cxf-rt-frontend-jaxrs + 3.1.6 + + + org.codehaus.jackson + jackson-jaxrs + 1.9.2 + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.2 + + + net.sf.json-lib + json-lib + 2.4 + jdk15 + + + org.apache.commons + commons-io + 1.3.2 + + + commons-io + commons-io + 2.4 + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + org.apache.httpcomponents + httpmime + 4.5.2 + - - - junit - junit - 4.12 - - - org.jmockit - jmockit - 1.19 - test - - - org.jmockit - jmockit-coverage - 1.19 - test - - - + + + junit + junit + 4.12 + + + org.jmockit + jmockit + 1.19 + test + + + org.jmockit + jmockit-coverage + 1.19 + test + + + diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestConstant.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestConstant.java new file mode 100644 index 0000000..cd1c6e4 --- /dev/null +++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestConstant.java @@ -0,0 +1,83 @@ +/* + * 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.openo.vnfsdk.lctest.common.util; + + +public class RestConstant { + + public static final String UNAME_KEY = "UNAME_KEY"; + + public static final String PWD_KEY = "PWD_KEY"; + + public static final String NETCONF = "NETCONF"; + + public static final String ASYNC = "ASYNC"; + + public static final String SYNC = "SYNC"; + + public static final String HEADERMAP_TYPE = "HEADERMAP_TYPE"; + + public static final String HEADERMAP_VALUE = "HEADERMAP_VALUE"; + + public static final String AUTH_TOKEN = "AUTH_TOKEN"; + + public static final String DEFAULT_HOST_ADDRESS = "localhost"; + + public static final int DEFAULT_PORT = 8080; + + public static final int DEFAULT_MAX_CONNECTION_PER_CONTROLLER = 10; + + public static final int DEFAULT_STRING_LENGTH_64 = 64; + + public static final int DEFAULT_STRING_LENGTH_128 = 128; + + public static final int RESPONSE_CODE_200 = 200; + + public static final int RESPONSE_CODE_201 = 201; + + public static class HttpContext { + + public static final String CONTENT_TYPE = "Content-Type"; + + public static final String MEDIA_TYPE_JSON = "application/json;charset=UTF-8"; + + public static final String URL = "url"; + + public static final String METHOD_TYPE = "methodType"; + + private HttpContext() { + } + } + + + public static class MethodType { + + public static final String POST = "post"; + + public static final String DELETE = "delete"; + + public static final String PUT = "put"; + + public static final String GET = "get"; + + private MethodType() { + } + } + + private RestConstant() { + } +} diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestResponse.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestResponse.java new file mode 100644 index 0000000..8125898 --- /dev/null +++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestResponse.java @@ -0,0 +1,40 @@ +/** + * 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.openo.vnfsdk.lctest.common.util; + + +public class RestResponse { + + public Integer getStatusCode() { + return statusCode; + } + + public void setStatusCode(Integer statusCode) { + this.statusCode = statusCode; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + + private Integer statusCode; + + private String result; +} diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestfulClient.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestfulClient.java new file mode 100644 index 0000000..594cde1 --- /dev/null +++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestfulClient.java @@ -0,0 +1,168 @@ +/** + * 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.openo.vnfsdk.lctest.common.util; + +import java.io.File; +import java.io.IOException; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.apache.http.HttpRequest; +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RestfulClient { + private static final String HTTP = "http"; + private static final Logger logger = LoggerFactory.getLogger(RestfulClient.class); + + enum HttpMethod { + GET, POST, PUT, DELETE + } + + /** + * execute http. + * @param method http method + * @param ip ip + * @param port port + * @param url url + * @param body http body + * @return RestResponse + */ + public static RestResponse executeHttp(HttpMethod method, String ip, int port, String url, + HttpEntity body) { + CloseableHttpClient httpclient = HttpClients.createDefault(); + HttpResponse httpResponse = null; + RestResponse result = new RestResponse(); + try { + // specify the host, protocol, and port + HttpHost target = new HttpHost(ip, port, HTTP); + // specify the get request + HttpRequest request = getRequest(method, url, body); + httpResponse = httpclient.execute(target, request); + HttpEntity entity = httpResponse.getEntity(); + if (entity != null) { + result.setStatusCode(httpResponse.getStatusLine().getStatusCode()); + result.setResult(EntityUtils.toString(entity)); + } + } catch (Exception e1) { + logger.error("send get rest request error:", e1.getMessage()); + } finally { + if (httpclient != null) { + try { + httpclient.close(); + } catch (IOException e2) { + logger.error("close httpclient error:", e2.getMessage()); + } + } + } + return result; + } + + private static HttpRequest getRequest(HttpMethod method, String url, HttpEntity body) { + HttpRequest request = null; + switch (method) { + case GET: + request = new HttpGet(url); + break; + case POST: + request = new HttpPost(url); + ((HttpPost) request).setEntity(body); + break; + case PUT: + request = new HttpPut(url); + ((HttpPut) request).setEntity(body); + break; + case DELETE: + request = new HttpDelete(url); + break; + default: + break; + } + return request; + } + + public static RestResponse get(String ip, int port, String url) { + return executeHttp(HttpMethod.GET, ip, port, url, null); + } + + public static RestResponse delete(String ip, int port, String url) { + return executeHttp(HttpMethod.DELETE, ip, port, url, null); + } + + public static RestResponse post(String ip, int port, String url, HttpEntity requestBody) { + return executeHttp(HttpMethod.POST, ip, port, url, requestBody); + } + + public static RestResponse sendPostRequest(String ip, String port, String url, String strJson) + { + RestResponse result = new RestResponse(); + CloseableHttpClient httpClient = HttpClientBuilder.create().build(); + HttpResponse httpResponse = null; + try + { + String urlPost = "http://" + ip + ":" + port + url; + logger.info("URL formed for Post, URL :" + urlPost); + logger.info("URL formed for Post, JSON :" + strJson); + + HttpPost request = new HttpPost(urlPost); + + StringEntity params = new StringEntity(strJson); + request.addHeader("content-type", "application/json"); + request.setEntity(params); + + httpResponse = httpClient.execute(request); + HttpEntity entity = httpResponse.getEntity(); + if (entity != null) + { + result.setStatusCode(httpResponse.getStatusLine().getStatusCode()); + result.setResult(EntityUtils.toString(entity)); + } + } + catch (Exception ex) + { + logger.error("Send Post request error:", ex.getMessage()); + } + finally + { + try { + if(null != httpClient) { + httpClient.close(); + } + } + catch(IOException e){ + logger.error("IOException :Send Post request error:", e.getMessage()); + } + } + return result; + } +} diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestfulUtil.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestfulUtil.java deleted file mode 100644 index c42c66a..0000000 --- a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestfulUtil.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * 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.openo.vnfsdk.lctest.common.util; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.Restful; -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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONException; -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Mar 14, 2017 - */ -public class RestfulUtil { - - public static final String TYPE_GET = "get"; - - public static final String TYPE_PUT = "put"; - - public static final String TYPE_POST = "post"; - - public static final String TYPE_DEL = "delete"; - - public static final String CONTENT_TYPE = "Content-type"; - - public static final String APPLICATION = "application/json"; - - private static final Logger LOGGER = LoggerFactory.getLogger(RestfulUtil.class); - - private static final Restful REST_CLIENT = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP); - - private RestfulUtil() { - } - - /** - * Get response object.
- * - * @param url - * @param type - * @return - * @since NFVO 0.5 - */ - public static JSONObject getResponseObj(String url, String type) { - return getResponseObj(url, new RestfulParametes(), type); - } - - /** - * Get response object.
- * - * @param url - * @param parametes - * @param type - * @return - * @since NFVO 0.5 - */ - public static JSONObject getResponseObj(String url, RestfulParametes parametes, String type) { - try { - String content = RestfulUtil.getResponseContent(url, parametes, null, type); - LOGGER.error("function=getResponseObj, content : {}", content); - if(StringUtils.isEmpty(content)) { - return null; - } - return JSONObject.fromObject(content); - } catch(JSONException e) { - LOGGER.error("function=getResponseObj, exception : {}", e); - return null; - } - } - - /** - * Get response content.
- * - * @param url - * @param restParametes - * @param type - * @return - * @since NFVO 0.5 - */ - public static String getResponseContent(String url, RestfulParametes restParametes, String type) { - return getResponseContent(url, restParametes, null, type); - } - - /** - * Get response content.
- * - * @param url - * @param restParametes - * @param opt - * @param type - * @return - * @since NFVO 0.5 - */ - public static String getResponseContent(String url, RestfulParametes restParametes, RestfulOptions opt, - String type) { - String responseContent = null; - RestfulResponse rsp = restfulResponse(url, restParametes, opt, type); - if(rsp != null) { - int httpStatus = rsp.getStatus(); - LOGGER.warn("function=getResponseContent, get response httpStatusCode : {} ", httpStatus); - if(httpStatus < HttpServletResponse.SC_BAD_REQUEST && httpStatus > 0) { - responseContent = rsp.getResponseContent(); - LOGGER.warn("function=getResponseContent, get response data success!responseContent={}", - responseContent); - } - } - return responseContent; - } - - /** - * Get restful response.
- * - * @param url - * @param restParametes - * @param type - * @return - * @since NFVO 0.5 - */ - public static RestfulResponse getRestfulResponse(String url, RestfulParametes restParametes, String type) { - return restfulResponse(url, restParametes, null, type); - } - - private static RestfulResponse restfulResponse(String url, RestfulParametes restParametes, RestfulOptions opt, - String type) { - RestfulResponse rsp = new RestfulResponse(); - try { - - if(REST_CLIENT != null) { - if(TYPE_GET.equals(type)) { - rsp = REST_CLIENT.get(url, restParametes, opt); - } else if(TYPE_POST.equals(type)) { - rsp = REST_CLIENT.post(url, restParametes, opt); - } else if(TYPE_PUT.equals(type)) { - rsp = REST_CLIENT.put(url, restParametes, opt); - } else if(TYPE_DEL.equals(type)) { - rsp = REST_CLIENT.delete(url, restParametes, opt); - } - } - } catch(ServiceException e) { - LOGGER.error("function=restfulResponse, get restful response catch exception {} ", e); - } - LOGGER.warn("function=restfulResponse, response status is {} ", rsp.getStatus()); - return rsp; - } - - /** - *
- * - * @param paramsMap - * @param params - * @return - * @since NFVO 0.5 - */ - public static String getRemoteResponseContent(Map paramsMap, String params) { - String responseContent = null; - RestfulResponse rsp = getRemoteResponse(paramsMap, params); - if(rsp != null) { - int httpStatus = rsp.getStatus(); - LOGGER.warn("function=getResponseContent, get response httpStatusCode : {} ", httpStatus); - if(httpStatus < HttpServletResponse.SC_BAD_REQUEST && httpStatus > 0) { - responseContent = rsp.getResponseContent(); - LOGGER.warn("function=getResponseContent, get response data success!responseContent={}", - responseContent); - } - } - return responseContent; - } - - /** - *
- * - * @param paramsMap - * @param params - * @return - * @since NFVO 0.5 - */ - public static RestfulResponse getRemoteResponse(Map paramsMap, String params) { - String url = paramsMap.get("url"); - String methodType = paramsMap.get("methodType"); - - RestfulResponse rsp = null; - Restful rest = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP); - try { - - RestfulParametes restfulParametes = new RestfulParametes(); - Map headerMap = new HashMap<>(3); - headerMap.put(CONTENT_TYPE, APPLICATION); - restfulParametes.setHeaderMap(headerMap); - restfulParametes.setRawData(params); - - if(rest != null) { - if(TYPE_GET.equalsIgnoreCase(methodType)) { - rsp = rest.get(url, restfulParametes); - } else if(TYPE_POST.equalsIgnoreCase(methodType)) { - rsp = rest.post(url, restfulParametes); - } else if(TYPE_PUT.equalsIgnoreCase(methodType)) { - rsp = rest.put(url, restfulParametes); - } else if(TYPE_DEL.equalsIgnoreCase(methodType)) { - rsp = rest.delete(url, restfulParametes); - } - } - } catch(ServiceException e) { - LOGGER.error("function=getRemoteResponse, get restful response catch exception {}", e); - } - return rsp; - } -} diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapter2MSBManager.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapter2MSBManager.java index 5e9a7b6..f9d21d8 100644 --- a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapter2MSBManager.java +++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapter2MSBManager.java @@ -18,9 +18,9 @@ package org.openo.vnfsdk.lctest.service.adapter.impl; import java.util.Map; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; + import org.openo.vnfsdk.lctest.common.constant.Constant; -import org.openo.vnfsdk.lctest.common.util.RestfulUtil; +import org.openo.vnfsdk.lctest.common.util.RestResponse; import org.openo.vnfsdk.lctest.service.adapter.inf.ILifecycleTestAdapter2MSBManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,28 +43,28 @@ public class LifecycleTestAdapter2MSBManager implements ILifecycleTestAdapter2MS public JSONObject registerLifecycleTest(Map paramsMap, JSONObject driverInfo) { JSONObject resultObj = new JSONObject(); - RestfulResponse rsp = RestfulUtil.getRemoteResponse(paramsMap, driverInfo.toString()); + RestResponse rsp = new RestResponse();// = RestfulUtil.getRemoteResponse(paramsMap, driverInfo.toString()); if(null == rsp) { LOG.error("function=registerLifecycleTest, RestfulResponse is null"); resultObj.put(Constant.REASON, "RestfulResponse is null."); resultObj.put(Constant.RETCODE, Constant.ERROR_CODE); return resultObj; } - LOG.warn("function=registerLifecycleTest, status={}, content={}.", rsp.getStatus(), rsp.getResponseContent()); - String resultCreate = rsp.getResponseContent(); + LOG.warn("function=registerLifecycleTest, status={}, content={}.", rsp.getStatusCode(), rsp.getResult()); + String resultCreate = rsp.getResult(); - if(rsp.getStatus() == Constant.HTTP_CREATED) { + if(rsp.getStatusCode() == Constant.HTTP_CREATED) { LOG.warn("function=registerLifecycleTest, result={}.", resultCreate); resultObj = JSONObject.fromObject(resultCreate); resultObj.put("retCode", Constant.HTTP_CREATED); return resultObj; - } else if(rsp.getStatus() == Constant.HTTP_INVALID_PARAMETERS) { + } else if(rsp.getStatusCode() == Constant.HTTP_INVALID_PARAMETERS) { LOG.error("function=registerLifecycleTest, msg=MSB return fail,invalid parameters,status={}, result={}.", - rsp.getStatus(), resultCreate); + rsp.getStatusCode(), resultCreate); resultObj.put("reason", "MSB return fail,invalid parameters."); - } else if(rsp.getStatus() == Constant.HTTP_INNERERROR_CODE) { + } else if(rsp.getStatusCode() == Constant.HTTP_INNERERROR_CODE) { LOG.error("function=registerLifecycleTest, msg=MSB return fail,internal system error,status={}, result={}.", - rsp.getStatus(), resultCreate); + rsp.getStatusCode(), resultCreate); resultObj.put("reason", "MSB return fail,internal system error."); } resultObj.put("retCode", Constant.ERROR_CODE); diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapterMgrService.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapterMgrService.java index 3c0b627..a9efae3 100644 --- a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapterMgrService.java +++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapterMgrService.java @@ -25,10 +25,11 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executors; -import org.openo.baseservice.util.impl.SystemEnvVariablesFactory; + import org.openo.vnfsdk.lctest.common.constant.Constant; import org.openo.vnfsdk.lctest.common.constant.UrlConstant; -import org.openo.vnfsdk.lctest.common.util.RestfulUtil; +import org.openo.vnfsdk.lctest.common.util.RestConstant; + import org.openo.vnfsdk.lctest.service.adapter.inf.ILifecycleTestAdapter2MSBManager; import org.openo.vnfsdk.lctest.service.adapter.inf.ILifecycleTestAdapterMgrService; import org.slf4j.Logger; @@ -57,7 +58,7 @@ public class LifecycleTestAdapterMgrService implements ILifecycleTestAdapterMgrS // set MSB URL and mothedtype Map paramsMap = new HashMap<>(); paramsMap.put("url", UrlConstant.REST_MSB_REGISTER); - paramsMap.put("methodType", RestfulUtil.TYPE_POST); + paramsMap.put("methodType", RestConstant.MethodType.POST); // get LifecycleTest info and raise registration try { @@ -87,7 +88,7 @@ public class LifecycleTestAdapterMgrService implements ILifecycleTestAdapterMgrS BufferedInputStream bins = null; String fileContent = ""; - String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty(Constant.SEPARATOR) + String fileName = "./" + System.getProperty(Constant.SEPARATOR) + "etc" + System.getProperty(Constant.SEPARATOR) + "adapterInfo" + System.getProperty(Constant.SEPARATOR) + LIFECYCLETESTINFO; diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/business/impl/VnfpackageServiceImpl.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/business/impl/VnfpackageServiceImpl.java index e566577..9a6a959 100644 --- a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/business/impl/VnfpackageServiceImpl.java +++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/business/impl/VnfpackageServiceImpl.java @@ -20,7 +20,8 @@ import java.util.HashMap; import java.util.Map; import org.openo.vnfsdk.lctest.common.constant.UrlConstant; -import org.openo.vnfsdk.lctest.common.util.RestfulUtil; +import org.openo.vnfsdk.lctest.common.util.RestConstant; +import org.openo.vnfsdk.lctest.common.util.RestfulClient; import org.openo.vnfsdk.lctest.service.business.inf.VnfpackageService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,6 +39,9 @@ import net.sf.json.JSONObject; public class VnfpackageServiceImpl implements VnfpackageService { private static final Logger LOGGER = LoggerFactory.getLogger(VnfpackageServiceImpl.class); + + private static String MsbIpAddress = "127.0.0.1"; + private static int MsbPort = 80; /** *
@@ -51,8 +55,8 @@ public class VnfpackageServiceImpl implements VnfpackageService { LOGGER.info("VnfpackageServiceImpl::onboarding:{}", object.toString()); Map paramsMap = new HashMap<>(3); paramsMap.put("url", UrlConstant.NSLCM_VNFPACKAGE_URL); - paramsMap.put("methodType", RestfulUtil.TYPE_POST); - String rsp = RestfulUtil.getRemoteResponseContent(paramsMap, object.toString()); + paramsMap.put("methodType", RestConstant.MethodType.POST); + String rsp = null; //RestfulUtil.getRemoteResponseContent(paramsMap, object.toString()); if(null == rsp) { JSONObject resJson = new JSONObject(); resJson.put("message", "NS LCM response Error."); @@ -72,7 +76,8 @@ public class VnfpackageServiceImpl implements VnfpackageService { @Override public JSONObject queryVnfpackage(String csarId) { String url = String.format(UrlConstant.QUERY_VNFPACKAGE_URL, csarId); - JSONObject rsp = RestfulUtil.getResponseObj(url, RestfulUtil.TYPE_GET); + JSONObject rsp = null;//RestfulClient.get(MsbIpAddress, MsbPort, url).getResult(); + if(null == rsp) { JSONObject resJson = new JSONObject(); resJson.put("message", "NS LCM response Error."); @@ -94,8 +99,8 @@ public class VnfpackageServiceImpl implements VnfpackageService { LOGGER.info("VnfpackageServiceImpl::updatestatus:{}", object.toString()); Map paramsMap = new HashMap<>(3); paramsMap.put("url", UrlConstant.MARKETPLACE_UPDATE_STATUS_URL); - paramsMap.put("methodType", RestfulUtil.TYPE_POST); - String rsp = RestfulUtil.getRemoteResponseContent(paramsMap, object.toString()); + paramsMap.put("methodType", RestConstant.MethodType.POST); + String rsp = null; //RestfulUtil.getRemoteResponseContent(paramsMap, object.toString()); if(null == rsp) { JSONObject resJson = new JSONObject(); resJson.put("message", "Marketplace response Error."); diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/rest/VnfpackageRoa.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/rest/VnfpackageRoa.java index e1d271d..f59a6be 100644 --- a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/rest/VnfpackageRoa.java +++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/rest/VnfpackageRoa.java @@ -26,7 +26,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; -import org.openo.baseservice.remoteservice.exception.ServiceException; + import org.openo.vnfsdk.lctest.common.util.RequestUtil; import org.openo.vnfsdk.lctest.service.business.inf.VnfpackageService; import org.slf4j.Logger; @@ -60,11 +60,11 @@ public class VnfpackageRoa { * @since NFVO 0.5 */ @POST - public JSONObject onboarding(@Context HttpServletRequest context) throws ServiceException { + public JSONObject onboarding(@Context HttpServletRequest context) { JSONObject object = RequestUtil.getJsonRequestBody(context); if(null == object) { LOGGER.error("function=onboarding; msg=context is null."); - throw new ServiceException("org.openo.vnfsdk.lctest.service.rest.VnfpackageRoa.onboarding.null"); + //throw new ServiceException("org.openo.vnfsdk.lctest.service.rest.VnfpackageRoa.onboarding.null"); } LOGGER.info("VnfpackageRoa::onboarding:{}", object.toString()); @@ -73,11 +73,11 @@ public class VnfpackageRoa { @POST @Path("/updatestatus") - public JSONObject updatestatus(@Context HttpServletRequest context) throws ServiceException { + public JSONObject updatestatus(@Context HttpServletRequest context) { JSONObject object = RequestUtil.getJsonRequestBody(context); if(null == object) { LOGGER.error("function=onboarding; msg=context is null."); - throw new ServiceException("org.openo.vnfsdk.lctest.service.rest.VnfpackageRoa.onboarding.null"); + //throw new ServiceException("org.openo.vnfsdk.lctest.service.rest.VnfpackageRoa.onboarding.null"); } LOGGER.info("VnfpackageRoa::updatestatus:{}", object.toString()); @@ -96,7 +96,7 @@ public class VnfpackageRoa { @GET @Path("/{csarId}") public JSONObject queryVnfpackage(@Context HttpServletRequest context, @PathParam("csarId") String csarId) - throws ServiceException { + { LOGGER.warn("function=queryVnfpackage, csarId={}", csarId); return vnfpackageService.queryVnfpackage(csarId); } diff --git a/pom.xml b/pom.xml index 9ff25a2..dbaa5b3 100644 --- a/pom.xml +++ b/pom.xml @@ -16,15 +16,15 @@ --> - org.openo.oparent + org.onap.oparent oparent - 1.1.0-SNAPSHOT + 0.1.1 ../oparent 4.0.0 - org.openo.vnf-sdk.validate-lc-test + org.onap.vnfsdk.lctest vnf-sdk-validate-lc-test - 1.1.0-SNAPSHOT + 1.0.0-SNAPSHOT pom vnfsdk-lctest -- cgit 1.2.3-korg