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.nbi.impl;
\r
21 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.MAPPER_SERVICE_QUALILFIER;
\r
22 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.TR069_NBI_REQUEST_Q;
\r
24 import org.commscope.tr069adapter.acs.common.DeviceRPCRequest;
\r
25 import org.commscope.tr069adapter.acs.common.exception.MapperServiceException;
\r
26 import org.commscope.tr069adapter.acs.common.mapper.ACSServiceAPI;
\r
27 import org.commscope.tr069adapter.acs.nbi.util.OperationIdGenerator;
\r
28 import org.slf4j.Logger;
\r
29 import org.slf4j.LoggerFactory;
\r
30 import org.slf4j.MDC;
\r
31 import org.springframework.beans.factory.annotation.Autowired;
\r
32 import org.springframework.jms.core.JmsTemplate;
\r
33 import org.springframework.stereotype.Component;
\r
35 @Component(MAPPER_SERVICE_QUALILFIER)
\r
36 public class ACSServiceAPIImpl implements ACSServiceAPI {
\r
38 private static final Logger logger = LoggerFactory.getLogger(ACSServiceAPIImpl.class);
\r
40 private static final String CLIENT_STR = "client";
\r
43 private OperationIdGenerator opIdGenerator;
\r
46 private JmsTemplate jmsTemplate;
\r
51 * @see org.commscope.tr069adapter.acs.mapper.ACSServiceAPI#performDeviceOperation(org.commscope.
\r
52 * tr069adapter.acs.DeviceRPCRequest)
\r
55 public long performDeviceOperation(DeviceRPCRequest deviceRPCRequest)
\r
56 throws MapperServiceException {
\r
60 if (deviceRPCRequest != null && deviceRPCRequest.getDeviceDetails() != null) {
\r
61 MDC.put(CLIENT_STR, deviceRPCRequest.getDeviceDetails().getDeviceId());
\r
64 // validate the request and reject if not valid.
\r
65 if (null == deviceRPCRequest) {
\r
66 logger.error("Received null Mapper Request.");
\r
67 throw new MapperServiceException("Received null Mapper Request.");
\r
68 } else if (null == deviceRPCRequest.getOpDetails()) {
\r
69 logger.error("Received null operation details.");
\r
70 throw new MapperServiceException("Received null operation details.");
\r
71 } else if (null == deviceRPCRequest.getOpDetails().getOpCode()) {
\r
72 logger.error("Received null operation code.");
\r
73 throw new MapperServiceException("Received null operation code.");
\r
76 logger.info("Received request to perform device operation. OperationCode: {}",
\r
77 deviceRPCRequest.getOpDetails().getOpCode());
\r
78 opId = opIdGenerator.generateOpId();
\r
79 logger.debug("The operation ID generated for processing the Device RPC request is - {}",
\r
81 // set opId and forward the request
\r
82 deviceRPCRequest.setOperationId(opId);
\r
83 jmsTemplate.convertAndSend(TR069_NBI_REQUEST_Q, deviceRPCRequest);
\r
86 "Successfully posted the Mapper Request to Queue with OperationId : {} OperationCode : {}",
\r
87 deviceRPCRequest.getOperationId(), deviceRPCRequest.getOpDetails().getOpCode());
\r
88 } catch (Exception ex) {
\r
89 MapperServiceException mapperEx =
\r
90 new MapperServiceException("ACS Internal Error. Unknown Exception. Details :", ex);
\r
91 logger.error(mapperEx.getMessage());
\r
94 MDC.remove(CLIENT_STR);
\r