summaryrefslogtreecommitdiffstats
path: root/lifecycle-test/src/main
diff options
context:
space:
mode:
authorluxin <luxin7@huawei.com>2017-03-15 16:49:25 +0800
committerluxin <luxin7@huawei.com>2017-03-15 16:49:25 +0800
commit7b63090190459364e2c4be3edf49ebb6256f6dab (patch)
tree5002435abdbbbb7307b69155d982abf9564e7270 /lifecycle-test/src/main
parent7709f7cfdc7d19032fe590547a24678de04dbe97 (diff)
Onboarding Interface
Validate&Lifecycle Test Onboarding Interface VNFSDK-78 Change-Id: Ic59ffb6d2b2ddbb128fa5634307ad16c5bb4f319 Signed-off-by: luxin <luxin7@huawei.com>
Diffstat (limited to 'lifecycle-test/src/main')
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/constant/Constant.java86
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/constant/UrlConstant.java45
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RequestUtil.java128
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestfulUtil.java237
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/resources/LifecycleResource.java47
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/activator/LifecycleTestPostProcessor.java60
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapter2MSBManager.java79
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapterMgrService.java184
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/inf/ILifecycleTestAdapter2MSBManager.java52
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/inf/ILifecycleTestAdapterMgrService.java39
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/business/impl/VnfpackageServiceImpl.java83
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/business/inf/VnfpackageService.java49
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/rest/SwaggerRoa.java53
-rw-r--r--lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/rest/VnfpackageRoa.java94
-rw-r--r--lifecycle-test/src/main/resources/log4j.properties27
-rw-r--r--lifecycle-test/src/main/resources/spring/services.xml62
-rw-r--r--lifecycle-test/src/main/resources/spring/svc_register.xml42
-rw-r--r--lifecycle-test/src/main/resources/swagger.json146
-rw-r--r--lifecycle-test/src/main/webapp/WEB-INF/web.xml47
19 files changed, 1513 insertions, 47 deletions
diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/constant/Constant.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/constant/Constant.java
new file mode 100644
index 0000000..732818e
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/constant/Constant.java
@@ -0,0 +1,86 @@
+/*
+ * 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.constant;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 14, 2017
+ */
+public class Constant {
+
+ private Constant() {
+ // private constants
+ }
+
+ public static final int OK_CODE = 1;
+
+ public static final int ERROR_CODE = -1;
+
+ public static final String SEPARATOR = "file.separator";
+
+ public static final String REASON = "reason";
+
+ public static final String RETCODE = "retCode";
+
+ public static final int REPEAT_REG_TIME = 60 * 1000;
+
+ public static final int HTTP_OK = 200;
+
+ public static final int HTTP_CREATED = 201;
+
+ public static final int HTTP_ACCEPTED = 202;
+
+ public static final int HTTP_NOCONTENT = 204;
+
+ public static final int HTTP_UNAUTHORIZED = 401;
+
+ public static final int HTTP_BAD_REQUEST = 400;
+
+ public static final int HTTP_NOTFOUND_CODE = 404;
+
+ public static final int HTTP_CONFLICT_CODE = 409;
+
+ public static final int HTTP_INVALID_PARAMETERS = 415;
+
+ public static final int HTTP_INNERERROR_CODE = 500;
+
+ public static final int INTERNAL_EXCEPTION_CODE = 600;
+
+ public static final int TOKEN_HEAD_NULL_CODE = 601;
+
+ public static final int TOKEN_USER_NULL_CODE = 602;
+
+ public static final int SERVICE_URL_ERROR_CODE = 603;
+
+ public static final int ACCESS_OBJ_NULL_CODE = 604;
+
+ public static final int CONNECT_NOT_FOUND_CODE = 605;
+
+ public static final int VCENTER_PARA_ERROR_CODE = 606;
+
+ public static final int TYPE_PARA_ERROR_CODE = 607;
+
+ public static final int CONNECT_FAIL_CODE = 608;
+
+ public static final int DIS_CONNECT_FAIL_CODE = 609;
+
+ public static final int HANDSHAKE_FAIL_CODE = 610;
+}
diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/constant/UrlConstant.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/constant/UrlConstant.java
new file mode 100644
index 0000000..4acf225
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/constant/UrlConstant.java
@@ -0,0 +1,45 @@
+/*
+ * 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.constant;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 14, 2017
+ */
+public class UrlConstant {
+
+ private UrlConstant() {
+ // private constructor
+ }
+
+ /**
+ * MSB register url.
+ */
+ public static final String REST_MSB_REGISTER = "/openoapi/microservices/v1/services";
+
+ /**
+ * NSLCM VNF package onboarding url.
+ */
+ public static final String NSLCM_VNFPACKAGE_URL = "/openoapi/nslcm/v1/vnfpackage";
+
+ public static final String QUERY_VNFPACKAGE_URL = "/openoapi/nslcm/v1/vnfpackage/%s";
+
+}
diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RequestUtil.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RequestUtil.java
new file mode 100644
index 0000000..788d904
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RequestUtil.java
@@ -0,0 +1,128 @@
+/*
+ * 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.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONException;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 14, 2017
+ */
+public class RequestUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(RequestUtil.class);
+
+ /**
+ * Constructor<br/>
+ * <p>
+ * </p>
+ *
+ * @since NFVO 0.5
+ */
+ private RequestUtil() {
+ }
+
+ /**
+ * Get context string from HttpServletRequest context
+ *
+ * @param context
+ * HttpServletRequest context
+ * @return the needed string in HttpServletRequest context
+ */
+ public static String getStringRequestBody(HttpServletRequest context) {
+ try {
+ InputStream input = context.getInputStream();
+ return IOUtils.toString(input);
+ } catch(IOException e) {
+ LOGGER.error("function=getStringRequestBody, get httpservletrequest body exception: {}", e);
+ return null;
+ }
+ }
+
+ /**
+ * Get json parameter from HttpServletRequest context
+ *
+ * @param context
+ * HttpServletRequest context
+ * @return JSONObject
+ */
+ public static JSONObject getJsonRequestBody(HttpServletRequest context) {
+ try {
+ String bodyStr = getStringRequestBody(context);
+ return JSONObject.fromObject(bodyStr);
+ } catch(JSONException e) {
+ LOGGER.error("function=getJsonRequestBody, maybe request param is not a jsonobject exception: {}", e);
+ return null;
+ }
+ }
+
+ /**
+ * Get the body of all request in json format<br/>
+ *
+ * @param context
+ * The HttpServletRequest context
+ * @return JSONObject The body of all request in json format
+ * @since NFVO 0.5
+ */
+ public static JSONObject getAllJsonRequestBody(HttpServletRequest context) {
+ JSONObject requestBody = getJsonRequestBody(context);
+ if(null == requestBody) {
+ LOGGER.error("get httpservletrequest body exception");
+ requestBody = new JSONObject();
+ }
+ LOGGER.warn("function=getAllJsonRequestBody; msg=get request data is:[{}]", requestBody.toString());
+ requestBody.put("header", getContextHeader(context));
+ return requestBody;
+ }
+
+ /**
+ * Get the context header<br/>
+ *
+ * @param context
+ * The http context
+ * @return Map context header
+ * @since NFVO 0.5
+ */
+ @SuppressWarnings("unchecked")
+ private static Map<String, String> getContextHeader(HttpServletRequest context) {
+ Map<String, String> header = new HashMap<String, String>();
+ Enumeration<String> headerNames = context.getHeaderNames();
+ while(headerNames.hasMoreElements()) {
+ String headerName = headerNames.nextElement();
+ String value = context.getHeader(headerName);
+ header.put(headerName, value);
+ }
+ return header;
+ }
+}
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
new file mode 100644
index 0000000..c42c66a
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/common/util/RestfulUtil.java
@@ -0,0 +1,237 @@
+/*
+ * 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;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @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.<br>
+ *
+ * @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.<br>
+ *
+ * @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.<br>
+ *
+ * @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.<br>
+ *
+ * @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.<br>
+ *
+ * @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;
+ }
+
+ /**
+ * <br>
+ *
+ * @param paramsMap
+ * @param params
+ * @return
+ * @since NFVO 0.5
+ */
+ public static String getRemoteResponseContent(Map<String, String> 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;
+ }
+
+ /**
+ * <br>
+ *
+ * @param paramsMap
+ * @param params
+ * @return
+ * @since NFVO 0.5
+ */
+ public static RestfulResponse getRemoteResponse(Map<String, String> 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<String, String> 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/resources/LifecycleResource.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/resources/LifecycleResource.java
deleted file mode 100644
index 4d60213..0000000
--- a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/resources/LifecycleResource.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2016-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.resources;
-
-import java.io.InputStream;
-
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-
-
-
-
-/**
- * csar package test service.
- * <p>
- * </p>
- *
- * @author 71221
- */
-@Path("/")
-public class LifecycleResource {
-
- @Path("/csars")
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- public Response lctest(InputStream uploadedInputStream) {
- //TODO code to be added for lctest , csar will be input in stream
- return Response.ok().build();
- }
-}
diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/activator/LifecycleTestPostProcessor.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/activator/LifecycleTestPostProcessor.java
new file mode 100644
index 0000000..f4eff0f
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/activator/LifecycleTestPostProcessor.java
@@ -0,0 +1,60 @@
+/*
+ * 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.service.activator;
+
+import org.openo.vnfsdk.lctest.service.adapter.inf.ILifecycleTestAdapterMgrService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 14, 2017
+ */
+public class LifecycleTestPostProcessor implements DestructionAwareBeanPostProcessor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(LifecycleTestPostProcessor.class);
+
+ @Override
+ public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
+ if(bean instanceof ILifecycleTestAdapterMgrService) {
+ LOG.warn("Register to Microservice BUS!");
+ ILifecycleTestAdapterMgrService lifecycleTestAdapterSvc = (ILifecycleTestAdapterMgrService)bean;
+ lifecycleTestAdapterSvc.register();
+ }
+
+ return bean;
+ }
+
+ @Override
+ public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
+ // TODO Auto-generated method stub
+ return bean;
+ }
+
+ @Override
+ public void postProcessBeforeDestruction(Object bean, String name) throws BeansException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
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
new file mode 100644
index 0000000..5e9a7b6
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapter2MSBManager.java
@@ -0,0 +1,79 @@
+/*
+ * 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.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.service.adapter.inf.ILifecycleTestAdapter2MSBManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 22, 2016
+ */
+public class LifecycleTestAdapter2MSBManager implements ILifecycleTestAdapter2MSBManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(LifecycleTestAdapter2MSBManager.class);
+
+ @Override
+ public JSONObject registerLifecycleTest(Map<String, String> paramsMap, JSONObject driverInfo) {
+ JSONObject resultObj = new JSONObject();
+
+ RestfulResponse rsp = 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();
+
+ if(rsp.getStatus() == 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) {
+ LOG.error("function=registerLifecycleTest, msg=MSB return fail,invalid parameters,status={}, result={}.",
+ rsp.getStatus(), resultCreate);
+ resultObj.put("reason", "MSB return fail,invalid parameters.");
+ } else if(rsp.getStatus() == Constant.HTTP_INNERERROR_CODE) {
+ LOG.error("function=registerLifecycleTest, msg=MSB return fail,internal system error,status={}, result={}.",
+ rsp.getStatus(), resultCreate);
+ resultObj.put("reason", "MSB return fail,internal system error.");
+ }
+ resultObj.put("retCode", Constant.ERROR_CODE);
+ return resultObj;
+ }
+
+ @Override
+ public JSONObject unregisterLifecycleTest(Map<String, String> paramsMap) {
+ return new JSONObject();
+ }
+
+}
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
new file mode 100644
index 0000000..3c0b627
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/impl/LifecycleTestAdapterMgrService.java
@@ -0,0 +1,184 @@
+/*
+ * 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.service.adapter.impl;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+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.service.adapter.inf.ILifecycleTestAdapter2MSBManager;
+import org.openo.vnfsdk.lctest.service.adapter.inf.ILifecycleTestAdapterMgrService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 22, 2016
+ */
+@Service
+public class LifecycleTestAdapterMgrService implements ILifecycleTestAdapterMgrService {
+
+ private static final Logger LOG = LoggerFactory.getLogger(LifecycleTestAdapterMgrService.class);
+
+ public static final String LIFECYCLETESTINFO = "lifecycletestinfo.json";
+
+ @Override
+ public void register() {
+ // set MSB URL and mothedtype
+ Map<String, String> paramsMap = new HashMap<>();
+ paramsMap.put("url", UrlConstant.REST_MSB_REGISTER);
+ paramsMap.put("methodType", RestfulUtil.TYPE_POST);
+
+ // get LifecycleTest info and raise registration
+ try {
+ String lifecycleTest = readAdapterInfoFromJson();
+ if(!"".equals(lifecycleTest)) {
+ JSONObject adapterObject = JSONObject.fromObject(lifecycleTest);
+ RegisterThread registerThread = new RegisterThread(paramsMap, adapterObject);
+ Executors.newSingleThreadExecutor().submit(registerThread);
+ } else {
+ LOG.error("LifecycleTest info is null,please check!");
+ }
+
+ } catch(IOException e) {
+ LOG.error("Failed to read LifecycleTest info! " + e.getMessage(), e);
+ }
+
+ }
+
+ /**
+ * Retrieve lifecycleTest information.
+ *
+ * @return
+ * @throws IOException
+ */
+ public static String readAdapterInfoFromJson() throws IOException {
+ InputStream ins = null;
+ BufferedInputStream bins = null;
+ String fileContent = "";
+
+ String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty(Constant.SEPARATOR)
+ + "etc" + System.getProperty(Constant.SEPARATOR) + "adapterInfo"
+ + System.getProperty(Constant.SEPARATOR) + LIFECYCLETESTINFO;
+
+ try {
+ ins = new FileInputStream(fileName);
+ bins = new BufferedInputStream(ins);
+
+ byte[] contentByte = new byte[ins.available()];
+ int num = bins.read(contentByte);
+
+ if(num > 0) {
+ fileContent = new String(contentByte);
+ }
+ } catch(FileNotFoundException e) {
+ LOG.error(fileName + "is not found!", e);
+ } finally {
+ if(ins != null) {
+ ins.close();
+ }
+ if(bins != null) {
+ bins.close();
+ }
+ }
+
+ return fileContent;
+ }
+
+ private static class RegisterThread implements Runnable {
+
+ // Thread lock Object
+ private final Object lockObject = new Object();
+
+ private ILifecycleTestAdapter2MSBManager adapter2MSBMgr = new LifecycleTestAdapter2MSBManager();
+
+ // url and mothedtype
+ private Map<String, String> paramsMap;
+
+ // driver body
+ private JSONObject adapterInfo;
+
+ public RegisterThread(Map<String, String> paramsMap, JSONObject adapterInfo) {
+ this.paramsMap = paramsMap;
+ this.adapterInfo = adapterInfo;
+ }
+
+ @Override
+ public void run() {
+ LOG.info("start register lifecycleTest", RegisterThread.class);
+
+ if(paramsMap == null || adapterInfo == null) {
+ LOG.error("parameter is null,please check!", RegisterThread.class);
+ return;
+ }
+
+ // catch Runtime Exception
+ try {
+ sendRequest(paramsMap, adapterInfo);
+ } catch(RuntimeException e) {
+ LOG.error(e.getMessage(), e);
+ }
+
+ }
+
+ private void sendRequest(Map<String, String> paramsMap, JSONObject driverInfo) {
+ JSONObject resultObj = adapter2MSBMgr.registerLifecycleTest(paramsMap, driverInfo);
+
+ if(Integer.valueOf(resultObj.get("retCode").toString()) == Constant.HTTP_CREATED) {
+ LOG.info("LifecycleTest has now Successfully Registered to the Microservice BUS!");
+ } else {
+ LOG.error("LifecycleTest failed to Register to the Microservice BUS! Reason:"
+ + resultObj.get("reason").toString() + " retCode:" + resultObj.get("retCode").toString());
+
+ // if registration fails,wait one minute and try again
+ try {
+ synchronized(lockObject) {
+ lockObject.wait(Constant.REPEAT_REG_TIME);
+ }
+ } catch(InterruptedException e) {
+ LOG.error(e.getMessage(), e);
+ }
+
+ sendRequest(this.paramsMap, this.adapterInfo);
+ }
+
+ }
+
+ }
+
+ @Override
+ public void unregister() {
+ // unregister
+ }
+
+}
diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/inf/ILifecycleTestAdapter2MSBManager.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/inf/ILifecycleTestAdapter2MSBManager.java
new file mode 100644
index 0000000..ef1090a
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/inf/ILifecycleTestAdapter2MSBManager.java
@@ -0,0 +1,52 @@
+/*
+ * 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.service.adapter.inf;
+
+import java.util.Map;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 14, 2017
+ */
+public interface ILifecycleTestAdapter2MSBManager {
+
+ /**
+ * <br>
+ *
+ * @param paramsMap
+ * @param driverInfo
+ * @return
+ * @since NFVO 0.5
+ */
+ JSONObject registerLifecycleTest(Map<String, String> paramsMap, JSONObject driverInfo);
+
+ /**
+ * <br>
+ *
+ * @param paramsMap
+ * @return
+ * @since NFVO 0.5
+ */
+ JSONObject unregisterLifecycleTest(Map<String, String> paramsMap);
+
+}
diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/inf/ILifecycleTestAdapterMgrService.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/inf/ILifecycleTestAdapterMgrService.java
new file mode 100644
index 0000000..399bb65
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/adapter/inf/ILifecycleTestAdapterMgrService.java
@@ -0,0 +1,39 @@
+/*
+ * 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.service.adapter.inf;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 14, 2017
+ */
+public interface ILifecycleTestAdapterMgrService {
+
+ /**
+ * Lifecycle-test register interface.
+ */
+ void register();
+
+ /**
+ * Lifecycle-test unregister interface.
+ */
+ void unregister();
+
+}
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
new file mode 100644
index 0000000..43c418b
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/business/impl/VnfpackageServiceImpl.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.service.business.impl;
+
+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.service.business.inf.VnfpackageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 14, 2017
+ */
+public class VnfpackageServiceImpl implements VnfpackageService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VnfpackageServiceImpl.class);
+
+ /**
+ * <br>
+ *
+ * @param object
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public JSONObject onboarding(JSONObject object) {
+ LOGGER.info("VnfpackageServiceImpl::onboarding:{}", object.toString());
+ Map<String, String> paramsMap = new HashMap<>(3);
+ paramsMap.put("url", UrlConstant.NSLCM_VNFPACKAGE_URL);
+ paramsMap.put("methodType", RestfulUtil.TYPE_POST);
+ String rsp = RestfulUtil.getRemoteResponseContent(paramsMap, object.toString());
+ if(null == rsp) {
+ JSONObject resJson = new JSONObject();
+ resJson.put("message", "NS LCM response Error.");
+ return resJson;
+ }
+ return JSONObject.fromObject(rsp);
+ }
+
+ /**
+ * <br>
+ *
+ * @param csarId
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public JSONObject queryVnfpackage(String csarId) {
+ String url = String.format(UrlConstant.QUERY_VNFPACKAGE_URL, csarId);
+ JSONObject rsp = RestfulUtil.getResponseObj(url, RestfulUtil.TYPE_GET);
+ if(null == rsp) {
+ JSONObject resJson = new JSONObject();
+ resJson.put("message", "NS LCM response Error.");
+ return resJson;
+ }
+ return rsp;
+ }
+
+}
diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/business/inf/VnfpackageService.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/business/inf/VnfpackageService.java
new file mode 100644
index 0000000..f7977ad
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/business/inf/VnfpackageService.java
@@ -0,0 +1,49 @@
+/*
+ * 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.service.business.inf;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 14, 2017
+ */
+public interface VnfpackageService {
+
+ /**
+ * <br>
+ *
+ * @param object
+ * @return
+ * @since NFVO 0.5
+ */
+ JSONObject onboarding(JSONObject object);
+
+ /**
+ * <br>
+ *
+ * @param csarId
+ * @return
+ * @since NFVO 0.5
+ */
+ JSONObject queryVnfpackage(String csarId);
+
+}
diff --git a/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/rest/SwaggerRoa.java b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/rest/SwaggerRoa.java
new file mode 100644
index 0000000..2132d01
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/rest/SwaggerRoa.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.openo.vnfsdk.lctest.service.rest;
+
+import java.io.IOException;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.commons.io.IOUtils;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 14, 2017
+ */
+@Path("/v1")
+@Produces({MediaType.APPLICATION_JSON})
+public class SwaggerRoa {
+
+ /**
+ * API doc.
+ *
+ * @param filename
+ * @return
+ * @throws IOException
+ */
+ @GET
+ @Path("/swagger.json")
+ public String apidoc() throws IOException {
+ ClassLoader classLoader = getClass().getClassLoader();
+ return IOUtils.toString(classLoader.getResourceAsStream("swagger.json"));
+ }
+}
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
new file mode 100644
index 0000000..4c909bd
--- /dev/null
+++ b/lifecycle-test/src/main/java/org/openo/vnfsdk/lctest/service/rest/VnfpackageRoa.java
@@ -0,0 +1,94 @@
+/*
+ * 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.service.rest;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+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;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 14, 2017
+ */
+@Path("/v1/vnfpackage")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class VnfpackageRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VnfpackageRoa.class);
+
+ private VnfpackageService vnfpackageService;
+
+ /**
+ * <br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @POST
+ public JSONObject onboarding(@Context HttpServletRequest context) throws ServiceException {
+ 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");
+ }
+
+ LOGGER.info("VnfpackageRoa::onboarding:{}", object.toString());
+ return vnfpackageService.onboarding(object);
+ }
+
+ /**
+ * <br>
+ *
+ * @param context
+ * @param csarId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @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);
+ }
+
+ public void setVnfpackageService(VnfpackageService vnfpackageService) {
+ this.vnfpackageService = vnfpackageService;
+ }
+}
diff --git a/lifecycle-test/src/main/resources/log4j.properties b/lifecycle-test/src/main/resources/log4j.properties
new file mode 100644
index 0000000..8a86be9
--- /dev/null
+++ b/lifecycle-test/src/main/resources/log4j.properties
@@ -0,0 +1,27 @@
+###############################################################################
+# 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.
+###############################################################################
+log4j.rootLogger=INFO,root,stdout
+log4j.appender.root.Append=true
+log4j.appender.root.File=${catalina.base}/logs/lifecycle-test.log
+log4j.appender.root.layout.ConversionPattern=%d %-5p [%t][%X{moduleID}][%C %L] %m%n
+log4j.appender.root.layout=org.apache.log4j.PatternLayout
+log4j.appender.root.MaxBackupIndex=50
+log4j.appender.root.MaxFileSize=20MB
+log4j.appender.root=org.apache.log4j.RollingFileAppender
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t][%X{moduleID}][%C %L] %m%n \ No newline at end of file
diff --git a/lifecycle-test/src/main/resources/spring/services.xml b/lifecycle-test/src/main/resources/spring/services.xml
new file mode 100644
index 0000000..44acfd6
--- /dev/null
+++ b/lifecycle-test/src/main/resources/spring/services.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
+ xmlns:ctx="http://www.springframework.org/schema/context"
+ xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context.xsd
+ http://www.springframework.org/schema/osgi-compendium
+ http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
+ http://cxf.apache.org/jaxrs
+ http://cxf.apache.org/schemas/jaxrs.xsd
+ http://cxf.apache.org/transports/http/configuration
+ http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://www.springframework.org/schema/aop
+ http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
+
+ <!-- these are included in the dependency jar -->
+ <import resource="classpath:META-INF/cxf/cxf.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
+
+ <bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
+
+ <bean id="SwaggerRoa" class="org.openo.vnfsdk.lctest.service.rest.SwaggerRoa"></bean>
+
+ <bean id="vnfpackageService" class="org.openo.vnfsdk.lctest.service.business.impl.VnfpackageServiceImpl"></bean>
+ <bean id="VnfpackageRoa" class="org.openo.vnfsdk.lctest.service.rest.VnfpackageRoa">
+ <property name="vnfpackageService" ref="vnfpackageService"></property>
+ </bean>
+
+ <jaxrs:server id="restContainer" address="/">
+ <jaxrs:serviceBeans>
+ <ref bean="SwaggerRoa" />
+ <ref bean="VnfpackageRoa" />
+ </jaxrs:serviceBeans>
+ <jaxrs:providers>
+ <ref bean="jsonProvider" />
+ </jaxrs:providers>
+ </jaxrs:server>
+</beans>
diff --git a/lifecycle-test/src/main/resources/spring/svc_register.xml b/lifecycle-test/src/main/resources/spring/svc_register.xml
new file mode 100644
index 0000000..79f4f3e
--- /dev/null
+++ b/lifecycle-test/src/main/resources/spring/svc_register.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
+ xmlns:ctx="http://www.springframework.org/schema/context" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context.xsd
+ http://www.springframework.org/schema/osgi-compendium
+ http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
+ http://cxf.apache.org/jaxrs
+ http://cxf.apache.org/schemas/jaxrs.xsd
+ http://cxf.apache.org/transports/http/configuration
+ http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://www.springframework.org/schema/aop
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
+ http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
+ <bean class="org.openo.vnfsdk.lctest.service.activator.LifecycleTestPostProcessor"></bean>
+ <bean class="org.openo.vnfsdk.lctest.service.adapter.impl.LifecycleTestAdapterMgrService"></bean>
+</beans> \ No newline at end of file
diff --git a/lifecycle-test/src/main/resources/swagger.json b/lifecycle-test/src/main/resources/swagger.json
new file mode 100644
index 0000000..8b73adb
--- /dev/null
+++ b/lifecycle-test/src/main/resources/swagger.json
@@ -0,0 +1,146 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "title": "lifecycle-test API",
+ "description": "OPEN-O Interface provider.",
+ "version": "1.0.0"
+ },
+ "host": "openo.org",
+ "schemes": [
+ "https",
+ "http"
+ ],
+ "basePath": "/openoapi/vnfsdk/v1",
+ "paths": {
+ "/vnfpackage": {
+ "post": {
+ "summary": "Vnfpackage Onboarding",
+ "description": "Vnfpackage Onboarding",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "Vnfpackage",
+ "description": "Vnfpackage Onboarding.",
+ "schema": {
+ "$ref": "#/definitions/VnfpackageParam"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successfully Vnfpackage Onboarding",
+ "schema": {
+ "$ref": "#/definitions/VnfpackageOnboardingResponse"
+ }
+ },
+ "401": {
+ "description": "Unauthorized"
+ },
+ "404": {
+ "description": "Vnfpackage Onboarding Not Found"
+ },
+ "500": {
+ "description": "Vnfpackage Onboarding failed to process the request"
+ }
+ }
+ }
+ },
+ "/vnfpackage/{csarId}": {
+ "get": {
+ "summary": "Vnfpackage Query",
+ "description": "Vnfpackage Query",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "csarId",
+ "in": "path",
+ "description": "csarId",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successfully Vnfpackage Query",
+ "schema": {
+ "$ref": "#/definitions/VnfpackageQueryResponse"
+ }
+ },
+ "401": {
+ "description": "Unauthorized"
+ },
+ "404": {
+ "description": "Vnfpackage Onboarding Not Found"
+ },
+ "500": {
+ "description": "Vnfpackage Onboarding failed to process the request"
+ }
+ }
+ }
+ }
+ },
+ "definitions": {
+ "VnfpackageParam": {
+ "type": "object",
+ "description": "Vnfpackage Param.",
+ "required": [
+ "csarId",
+ "vimIds",
+ "labVimId"
+ ],
+ "properties": {
+ "csarId": {
+ "type": "string",
+ "description": "csarId"
+ },
+ "vimIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "labVimId": {
+ "type": "string",
+ "description": "labVimId"
+ }
+ }
+ },
+ "VnfpackageOnboardingResponse": {
+ "type": "object",
+ "description": "Vnfpackage Onboarding Response.",
+ "required": [
+ "jobId"
+ ],
+ "properties": {
+ "jobId": {
+ "type": "string",
+ "description": "jobId"
+ }
+ }
+ },
+ "VnfpackageQueryResponse": {
+ "type": "object",
+ "description": "Vnfpackage Onboarding Response.",
+ "required": [
+ "csarId"
+ ],
+ "properties": {
+ "csarId": {
+ "type": "string",
+ "description": "csarId"
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/lifecycle-test/src/main/webapp/WEB-INF/web.xml b/lifecycle-test/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..30750ca
--- /dev/null
+++ b/lifecycle-test/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>CXFServlet</servlet-name>
+ <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>CXFServlet</servlet-name>
+ <url-pattern>/openoapi/vnfsdk/*</url-pattern>
+ </servlet-mapping>
+
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>WEB-INF/classes/spring/*.xml
+ </param-value>
+ </context-param>
+
+ <session-config>
+ <session-timeout>10000000</session-timeout>
+ </session-config>
+
+ <display-name>lifecycle-test-service</display-name>
+
+</web-app> \ No newline at end of file