2 * ============LICENSE_START========================================================================
3 * ONAP : tr-069-adapter
4 * =================================================================================================
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
6 * =================================================================================================
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
9 * may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14 * either express or implied. See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ===============LICENSE_END=======================================================================
19 package org.commscope.tr069adapter.mapper.acs;
21 import org.commscope.tr069adapter.acs.common.DeviceRPCRequest;
22 import org.commscope.tr069adapter.acs.common.utils.ConnectionStatusPOJO;
23 import org.commscope.tr069adapter.mapper.MapperConfigProperties;
24 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.http.HttpEntity;
26 import org.springframework.http.HttpHeaders;
27 import org.springframework.http.MediaType;
28 import org.springframework.stereotype.Component;
29 import org.springframework.web.client.RestTemplate;
32 public class ACSRequestSender {
34 private RestTemplate restTemplate = new RestTemplate();
37 MapperConfigProperties config;
39 public Long sendRequest(DeviceRPCRequest deviceRPCRequest) {
40 String uri = getUri();
41 return restTemplate.postForObject(uri, deviceRPCRequest, Long.class);
44 public ConnectionStatusPOJO sendConnectionStatusReq(String deviceId) {
45 HttpHeaders headers = new HttpHeaders();
46 headers.setContentType(MediaType.APPLICATION_JSON);
47 HttpEntity<String> entity = new HttpEntity<>(deviceId, headers);
48 return restTemplate.postForObject(getUriForConnStatus(), entity, ConnectionStatusPOJO.class);
51 private String getUri() {
52 return config.getSbiUri();
55 private String getUriForConnStatus() {
56 return config.getConnStatusUri();