Aharoni, Pavel (pa0916) | ca3cb01 | 2018-10-22 15:29:57 +0300 | [diff] [blame] | 1 | /*-
|
| 2 | * ============LICENSE_START=======================================================
|
| 3 | * OSAM Core
|
| 4 | * ================================================================================
|
| 5 | * Copyright (C) 2018 Netsia
|
| 6 | * ================================================================================
|
| 7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 | * you may not use this file except in compliance with the License.
|
| 9 | * You may obtain a copy of the License at
|
| 10 | *
|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 12 | *
|
| 13 | * Unless required by applicable law or agreed to in writing, software
|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 | * See the License for the specific language governing permissions and
|
| 17 | * limitations under the License.
|
| 18 | * ============LICENSE_END=========================================================
|
| 19 | */
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 | package org.onap.osam.controller;
|
| 24 |
|
| 25 | import lombok.extern.slf4j.Slf4j;
|
| 26 | import org.onap.osam.api.service.AccessPodService;
|
| 27 | import org.onap.osam.api.service.DeviceService;
|
Aharoni, Pavel (pa0916) | 0a8080c | 2018-11-22 15:45:19 +0200 | [diff] [blame] | 28 | import org.onap.osam.common.dto.AccessPodDTO;
|
Aharoni, Pavel (pa0916) | ca3cb01 | 2018-10-22 15:29:57 +0300 | [diff] [blame] | 29 | import org.onap.osam.helper.DTOMapper;
|
| 30 | import org.onap.osam.model.dao.AccessPod;
|
| 31 | import org.onap.osam.model.dao.Chassis;
|
| 32 | import org.springframework.beans.factory.annotation.Autowired;
|
| 33 | import org.springframework.http.ResponseEntity;
|
| 34 | import org.springframework.web.bind.annotation.GetMapping;
|
| 35 | import org.springframework.web.bind.annotation.PathVariable;
|
| 36 | import org.springframework.web.bind.annotation.RequestMapping;
|
| 37 | import org.springframework.web.bind.annotation.RestController;
|
| 38 |
|
| 39 | import java.util.List;
|
| 40 |
|
| 41 | /**
|
| 42 | * Created by cemturker on 03.10.2018.
|
| 43 | */
|
| 44 | @RestController
|
| 45 | @RequestMapping("topology")
|
| 46 | @Slf4j
|
| 47 | public class TopologyController extends AbstractController {
|
| 48 | private AccessPodService accessPodService;
|
| 49 | private DeviceService deviceService;
|
| 50 |
|
| 51 | @Autowired
|
| 52 | public TopologyController(AccessPodService accessPodService,
|
| 53 | DeviceService deviceService) {
|
| 54 | super(log);
|
| 55 | this.accessPodService = accessPodService;
|
| 56 | this.deviceService = deviceService;
|
| 57 | }
|
| 58 |
|
| 59 | @GetMapping("/accessPod/{pnfId}")
|
| 60 | public ResponseEntity<AccessPodDTO> getTopologyWithPnfId(@PathVariable("pnfId") String pnfId) {
|
| 61 | try{
|
| 62 | log.info("GetTopology with pnfId:{} is received.",pnfId);
|
| 63 | AccessPod accessPod = accessPodService.findByPnfId(pnfId);
|
| 64 | List<Chassis> chassisList = deviceService.getByPnfId(pnfId);
|
| 65 | return ResponseEntity.ok(DTOMapper.representTheAccessPod(chassisList,accessPod));
|
| 66 | }catch (Exception e) {
|
| 67 | return super.proceedException(e);
|
| 68 | }
|
| 69 | }
|
| 70 | }
|