aboutsummaryrefslogtreecommitdiffstats
path: root/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfcomparsion/controller/VnfComparisonController.java
blob: 2f83368c778a30ab7772f93c2f0956b4bd405f13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.onap.sdnc.vnfcomparsion.controller;

import java.util.List;

import org.apache.log4j.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.onap.sdnc.vnfconfigcomparsion.model.VnfCompareResponse;
import com.onap.sdnc.vnfconfigcomparsion.model.VnfConfigDetailsDB;
import com.onap.sdnc.vnfconfigcomparsion.service.VnfComparisonService;


@RestController
public class VnfComparisonController {
	
	private static final Logger logger = Logger.getLogger(VnfComparisonController.class);

	@Autowired
	VnfComparisonService vnfComparisonService;
	
	
	@RequestMapping(value="/getAllBackupVnfIds", method=RequestMethod.GET,produces="application/json")
	public List<VnfConfigDetailsDB>  getAllBackupVnfIds() {
		return vnfComparisonService.getAllBackupVnfIds();
	}
	
	
	@RequestMapping(value="/configcomparison/{vnfid}", method = RequestMethod.POST,produces="application/json")
	public VnfCompareResponse configComparison(@RequestBody String versionNames,@PathVariable("vnfid") String vnfId) {
		VnfCompareResponse vnfCompareResponse = null;
		try {
			JSONObject versionId = new JSONObject(versionNames);
			vnfCompareResponse = vnfComparisonService.getConfigurationDeatils(versionId,vnfId);
		
	} catch (JSONException e1) {
		logger.error("exception occered"+e1);
	}
	
	return vnfCompareResponse;
}
	
	@RequestMapping(value="/configDetailsByIdVersion/{vnfid}", method = RequestMethod.POST,produces="application/json")
	public VnfCompareResponse getVnfDetailsOfVersionsAndVnfID(@RequestBody String versionNames,@PathVariable("vnfid") String vnfId) {
		VnfCompareResponse vnfCompareResponse = null;
		try {
			JSONObject versionId = new JSONObject(versionNames);
			vnfCompareResponse = vnfComparisonService.getConfigDeatilsByVnfIdVnfVersion(versionId,vnfId);
		
	} catch (JSONException e1) {
		logger.error("exception occered"+e1);
	}
	
	return vnfCompareResponse;
}
	
	@RequestMapping(value="/configDetailsById/{vnfid}", method = RequestMethod.GET,produces="application/json")
	public List<VnfConfigDetailsDB> getVnfDetailsOfVnfID(@PathVariable("vnfid") String vnfId) {
		List<VnfConfigDetailsDB> vnfConfigDetails = null;
		vnfConfigDetails = vnfComparisonService.getConfigurationDeatils(vnfId);
	return vnfConfigDetails;
}
}