NonRT-RIC A1 Northbound API
[nonrtric.git] / sdnc-a1-controller / oam / SdncReports / SdncReportsApi / src / main / java / com / onap / sdnc / reports / controller / ReportController.java
1 /*
2 * ============LICENSE_START=======================================================
3 * ONAP : SDNC-FEATURES
4 * ================================================================================
5 * Copyright 2018 TechMahindra
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 package com.onap.sdnc.reports.controller;
21
22 import java.util.Date;
23 import java.util.List;
24
25 import org.apache.logging.log4j.LogManager;
26 import org.apache.logging.log4j.Logger;
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.web.bind.annotation.PathVariable;
29 import org.springframework.web.bind.annotation.RequestMapping;
30 import org.springframework.web.bind.annotation.RequestMethod;
31 import org.springframework.web.bind.annotation.RestController;
32
33 import com.onap.sdnc.reports.rest.model.PreTestModel;
34 import com.onap.sdnc.reports.service.IReportService;
35
36 @RestController
37 public class ReportController {
38
39         private static final Logger logger = LogManager.getLogger(ReportController.class);
40         
41         @Autowired
42         IReportService reportService;
43         @RequestMapping(value="/findReportByDeviceIP/{startDate}/{endDate}/{deviceIP:.+}", produces = "application/json",method=RequestMethod.GET)
44         public List<PreTestModel> findReportByDeviceIP(@PathVariable("startDate") Date startDate,@PathVariable("endDate") Date endDate,@PathVariable("deviceIP") String deviceIP) {
45
46                 try{
47                         logger.info("findReportByDeviceIP Started Working..");
48                         if(logger.isDebugEnabled())
49                                 logger.debug("Received StartDate : "+startDate+" ,EndDate : "+endDate+"  ,DeviceIP : "+deviceIP);
50
51                         return reportService.findReportByDeviceIP(startDate,endDate,deviceIP);
52                 }
53                 catch(Exception ex)
54                 {
55                         logger.info("Exception Occured : "+ex.getLocalizedMessage());
56                         return java.util.Collections.emptyList();
57                 }               
58         }
59 }