aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java
blob: 2735efbc2da9beb1cbb185198d2b994373eaa1d7 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
 * Copyright 2016-2017 ZTE Corporation.
 *
 * 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.onap.usecaseui.server.controller.lcm;

import org.onap.usecaseui.server.service.lcm.CustomerService;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;

import java.util.List;

@Controller
@CrossOrigin(origins="*")
@org.springframework.context.annotation.Configuration
@EnableAspectJAutoProxy
public class CustomerController {

    @Resource(name="CustomerService")
    private CustomerService customerService;

    public void setCustomerService(CustomerService customerService) {
        this.customerService = customerService;
    }

    @ResponseBody
    @GetMapping(value = {"/uui-lcm/customers"} , produces = "application/json")
    public List<AAICustomer> getCustomers(){
        return customerService.listCustomer();
    }
    
    @ResponseBody
    @PutMapping(value={"/uui-lcm/customers/{customerId}"},produces="application/json")
    public JSONObject createOrUpdateCustomer(HttpServletRequest request,@PathVariable String customerId){
    	return customerService.createOrUpdateCustomer(request, customerId);
    }
    
    @ResponseBody
    @GetMapping(value={"/uui-lcm/customers/{customerId}"},produces="application/json")
    public JSONObject getCustomerById(@PathVariable String customerId){
    	return customerService.getCustomerById(customerId);
    }
    
    @ResponseBody
    @DeleteMapping(value={"/uui-lcm/customers"},produces="application/json")
    public JSONObject deleteCustomer(@RequestParam String customerId,@RequestParam String resourceVersion){
    	return customerService.deleteCustomer(customerId,resourceVersion);
    }
    
    @ResponseBody
    @GetMapping(value = {"/uui-lcm/customers/{customerId}/service-subscriptions"} , produces = "application/json")
    public List<AAIServiceSubscription> getServiceSubscriptions(@PathVariable(value="customerId") String customerId){
        return customerService.listServiceSubscriptions(customerId);
    }
    
    @ResponseBody
    @PutMapping(value={"/uui-lcm/customers/{customerId}/service-subscriptions/{serviceType}"},produces="application/json")
    public JSONObject createOrUpdateServiceType(HttpServletRequest request,@PathVariable String serviceType,@PathVariable String customerId){
    	return customerService.createOrUpdateServiceType(request, serviceType,customerId);
    }
    
    @ResponseBody
    @DeleteMapping(value={"/uui-lcm/customers/{customerId}/service-subscriptions/{serviceType}"},produces="application/json")
    public JSONObject deleteServiceType(@PathVariable String customerId,@PathVariable String serviceType,@RequestParam String resourceVersion){
    	return customerService.deleteServiceType(customerId,serviceType,resourceVersion);
    }
    
    @ResponseBody
    @GetMapping(value={"/uui-lcm/customers/{customerId}/service-subscriptions/{serviceType}"}, produces="application/json")
    public JSONObject getServiceTypeById(@PathVariable String customerId,@PathVariable String serviceType){
    	return customerService.getServiceTypeById(customerId,serviceType);
    }
}