2 * ============LICENSE_START========================================================================
\r
3 * ONAP : tr-069-adapter
\r
4 * =================================================================================================
\r
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
\r
6 * =================================================================================================
\r
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
\r
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
\r
9 * may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
\r
14 * either express or implied. See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
16 * ===============LICENSE_END=======================================================================
\r
19 package org.commscope.tr069adapter.acs.requestprocessor.custom;
\r
21 import org.commscope.tr069adapter.acs.common.DeviceRPCRequest;
\r
22 import org.commscope.tr069adapter.acs.common.DeviceRPCResponse;
\r
23 import org.commscope.tr069adapter.acs.common.OperationResponse;
\r
24 import org.commscope.tr069adapter.acs.common.dto.TR069DeviceDetails;
\r
25 import org.commscope.tr069adapter.acs.common.dto.TR069OperationCode;
\r
26 import org.commscope.tr069adapter.acs.common.exception.TR069EventProcessingException;
\r
27 import org.commscope.tr069adapter.acs.requestprocessor.dao.DeviceRPCRequestRepositoryHelper;
\r
28 import org.commscope.tr069adapter.acs.requestprocessor.dto.CustomOperationData;
\r
29 import org.commscope.tr069adapter.acs.requestprocessor.impl.TR069EventNotificationService;
\r
30 import org.commscope.tr069adapter.acs.requestprocessor.impl.TR069RequestProcessEngine;
\r
31 import org.slf4j.Logger;
\r
32 import org.slf4j.LoggerFactory;
\r
33 import org.springframework.beans.factory.annotation.Autowired;
\r
34 import org.springframework.stereotype.Component;
\r
36 @Component("CheckDeviceAvailability")
\r
37 public class CheckDeviceAvailability implements CustomOperation {
\r
39 private static final Logger logger = LoggerFactory.getLogger(CheckDeviceAvailability.class);
\r
42 protected DeviceRPCRequestRepositoryHelper deviceRPCRequestRepositoryHelper;
\r
45 TR069RequestProcessEngine tr069RequestProcessEngine;
\r
48 TR069EventNotificationService eventNotificationService;
\r
51 public CustomOperationData executeCustomLogic(CustomOperationData customOperationData)
\r
52 throws TR069EventProcessingException {
\r
54 TR069DeviceDetails deviceDetails = customOperationData.getDeviceDetails();
\r
55 DeviceRPCRequest deviceRPCRequest = customOperationData.getDeviceRPCRequest();
\r
57 logger.debug("Started processing Check device availability");
\r
59 DeviceRPCResponse deviceRPCResponse = new DeviceRPCResponse();
\r
60 OperationResponse operationResponse = new OperationResponse();
\r
61 operationResponse.setOperationCode(TR069OperationCode.INITIATE_CR);
\r
62 Long operationId = deviceRPCRequest.getOperationId();
\r
63 deviceRPCResponse.setDeviceDetails(deviceDetails);
\r
64 deviceRPCResponse.setOperationId(operationId);
\r
65 deviceRPCResponse.setOperationResponse(operationResponse);
\r
67 logger.debug("Marking as processed the corresponding NBI Operation request record");
\r
68 deviceRPCRequestRepositoryHelper.markDeviceRPCRequestAsProcessed(deviceDetails.getDeviceId(),
\r
71 logger.debug("Sending the operation response for check device availability");
\r
72 // Sending the operation response to NBI
\r
73 eventNotificationService.sendOperationResultToNBI(deviceRPCResponse);
\r
74 customOperationData.setDeviceRPCResponse(null);
\r
75 customOperationData.setDeviceRPCRequest(null);
\r
77 logger.debug("Stopping request timer if any running for operation ID : {}", operationId);
\r
78 tr069RequestProcessEngine.stopDeviceRPCRequestTimer(deviceDetails.getDeviceId(),
\r
79 deviceRPCRequest.getOperationId());
\r
80 logger.debug("Finished processing Check device availability");
\r
81 return customOperationData;
\r