2 * Copyright 2016-2017, Nokia Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
18 import com.nokia.cbam.lcm.v32.model.VnfLifecycleChangeNotification;
19 import javax.servlet.http.HttpServletResponse;
20 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManager;
21 import org.slf4j.Logger;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.stereotype.Controller;
24 import org.springframework.web.bind.annotation.RequestBody;
25 import org.springframework.web.bind.annotation.RequestMapping;
26 import org.springframework.web.bind.annotation.ResponseStatus;
28 import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.BASE_URL;
29 import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.LCN_URL;
30 import static org.slf4j.LoggerFactory.getLogger;
31 import static org.springframework.http.HttpStatus.NO_CONTENT;
32 import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
33 import static org.springframework.web.bind.annotation.RequestMethod.GET;
34 import static org.springframework.web.bind.annotation.RequestMethod.POST;
37 * Responsible for providing the Nokia CBAM REST API for recieving LCNs from CBAM
40 @RequestMapping(value = BASE_URL)
42 private static Logger logger = getLogger(LcnApi.class);
43 private final LifecycleChangeNotificationManager lcnManager;
46 LcnApi(LifecycleChangeNotificationManager lcnManager) {
47 this.lcnManager = lcnManager;
51 * Provides a probe for CBAM VNFM to test LCN registration
53 * @param httpResponse the HTTP response
55 @RequestMapping(value = LCN_URL, method = GET)
56 public void testLcnConnectivity(HttpServletResponse httpResponse) {
57 //used to test connectivity from CBAM to driver
61 * Handle the LCN sent by CBAM
63 * @param lcn the LCN notification
65 @RequestMapping(value = LCN_URL, method = POST, consumes = APPLICATION_JSON_VALUE)
66 @ResponseStatus(code = NO_CONTENT)
67 public void handleLcn(@RequestBody VnfLifecycleChangeNotification lcn) {
68 logger.info("REST: handle LCN");
69 lcnManager.handleLcn(lcn);