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.vesagent.mapper;
\r
21 import java.util.concurrent.Future;
\r
23 import org.commscope.tr069adapter.acs.common.DeviceRPCRequest;
\r
24 import org.commscope.tr069adapter.acs.common.DeviceRPCResponse;
\r
25 import org.commscope.tr069adapter.vesagent.VesConfiguration;
\r
26 import org.commscope.tr069adapter.vesagent.async.WaitForNotifications;
\r
27 import org.slf4j.Logger;
\r
28 import org.slf4j.LoggerFactory;
\r
29 import org.springframework.beans.factory.annotation.Autowired;
\r
30 import org.springframework.scheduling.annotation.Async;
\r
31 import org.springframework.scheduling.annotation.AsyncResult;
\r
32 import org.springframework.stereotype.Component;
\r
33 import org.springframework.web.client.RestTemplate;
\r
37 public class MapperRequestSender {
\r
38 private static final Logger LOG = LoggerFactory.getLogger(MapperRequestSender.class);
\r
39 private RestTemplate restTemplate = new RestTemplate();
\r
42 VesConfiguration config;
\r
45 WaitForNotifications waitForNotifications;
\r
47 // public DeviceRPCResponse sendRequest(DeviceRPCRequest deviceRPCRequest) {
\r
48 // return restTemplate.postForObject(config.getMapperPath(), deviceRPCRequest,
\r
49 // DeviceRPCResponse.class);
\r
52 @Async("threadPoolTaskExecutor2")
\r
53 public Future<DeviceRPCResponse> sendRequest(DeviceRPCRequest deviceRPCRequest) {
\r
54 LOG.info("Sending device connectivity request to ACS for device {}",
\r
55 deviceRPCRequest.getDeviceDetails().getDeviceId());
\r
56 DeviceRPCResponse response = restTemplate.postForObject(config.getMapperPath(),
\r
57 deviceRPCRequest, DeviceRPCResponse.class);
\r
59 waitForNotifications.notifyResult(response);
\r
61 return new AsyncResult<>(response);
\r