2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.instar.interfaceImpl;
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
28 import java.io.IOException;
29 import java.util.HashMap;
30 import java.util.List;
32 import org.onap.appc.instar.interfaces.ResponseHandlerInterface;
33 import org.onap.appc.instar.interfaces.RestClientInterface;
34 import org.onap.appc.system.interfaces.RuleHandlerInterface;
35 import org.onap.appc.instar.utils.InstarClientConstant;
36 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
37 import org.onap.sdnc.config.params.data.Parameter;
38 import org.onap.sdnc.config.params.data.ResponseKey;
40 public class InterfaceIpAddressImpl implements RuleHandlerInterface {
42 private static final EELFLogger log = EELFManager.getInstance().getLogger(InterfaceIpAddressImpl.class);
43 private Parameter parameters;
44 private SvcLogicContext context;
46 public InterfaceIpAddressImpl(Parameter params, SvcLogicContext ctx) {
47 this.parameters = params;
52 public void processRule() throws InstarResponseException, IOException {
54 String fn = "InterfaceIpAddressHandler.processRule";
55 log.info(fn + "Processing rule :" + parameters.getRuleType());
58 RestClientInterface restClient;
59 ResponseHandlerInterface responseHandler;
61 List<ResponseKey> responseKeyList = parameters.getResponseKeys();
62 if (responseKeyList != null && !responseKeyList.isEmpty()) {
63 for (ResponseKey filterKeys : responseKeyList) {
64 if (parameters.getSource().equals(InstarClientConstant.SOURCE_SYSTEM_INSTAR)) {
65 restClient = new InstarRestClientImpl(createInstarRequestData(context));
66 responseHandler = new InstarResponseHandlerImpl(filterKeys, context);
67 operationName = "getIpAddressByVnf";
70 throw new InstarResponseException("No Client registered for : " + parameters.getSource());
72 responseHandler.processResponse(restClient.sendRequest(operationName), parameters.getName());
75 throw new InstarResponseException("NO response Keys set for : " + parameters.getRuleType());
79 private Map<String, String> createInstarRequestData(SvcLogicContext ctxt) {
80 HashMap<String, String> requestParams = new HashMap<>();
81 requestParams.put(InstarClientConstant.VNF_NAME, ctxt.getAttribute(InstarClientConstant.VNF_NAME));