2 * Copyright © 2017-2018 AT&T Intellectual Property.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
\r
5 * in compliance with the License. You may obtain a copy of the License at
\r
7 * http://www.apache.org/licenses/LICENSE-2.0
\r
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
\r
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
\r
11 * or implied. See the License for the specific language governing permissions and limitations under
\r
15 package org.onap.ccsdk.config.data.adaptor.service;
\r
17 import java.util.Map;
\r
18 import org.apache.commons.lang3.StringUtils;
\r
19 import org.onap.ccsdk.config.data.adaptor.DataAdaptorConstants;
\r
20 import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;
\r
21 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
\r
22 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
\r
23 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
\r
25 public class ConfigResourceNode implements SvcLogicJavaPlugin {
\r
27 private ConfigResourceService configResourceService;
\r
29 public ConfigResourceNode(ConfigResourceService configResourceService) {
\r
30 this.configResourceService = configResourceService;
\r
33 public void saveConfigTransactionLog(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
\r
34 String responsePrefix = inParams.get(DataAdaptorConstants.INPUT_PARAM_RESPONSE_PRIFIX);
\r
36 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
\r
38 String messageType = inParams.get(DataAdaptorConstants.INPUT_PARAM_MESSAGE_TYPE);
\r
39 String message = inParams.get(DataAdaptorConstants.INPUT_PARAM_MESSAGE);
\r
40 String requestId = ctx.getAttribute("request-id");
\r
42 TransactionLog transactionLog = new TransactionLog();
\r
44 transactionLog.setMessage(message);
\r
45 transactionLog.setMessageType(messageType);
\r
46 transactionLog.setRequestId(requestId);
\r
48 configResourceService.save(transactionLog);
\r
50 } catch (Exception e) {
\r
51 ctx.setAttribute(responsePrefix + DataAdaptorConstants.OUTPUT_PARAM_STATUS,
\r
52 DataAdaptorConstants.OUTPUT_STATUS_FAILURE);
\r
53 ctx.setAttribute(responsePrefix + DataAdaptorConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
\r
54 throw new SvcLogicException("Failed in saveConfigTransactionLog :" + e.getMessage());
\r