2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.instar.interfaceImpl;
27 import com.att.eelf.configuration.EELFLogger;
28 import com.att.eelf.configuration.EELFManager;
29 import java.util.HashMap;
30 import java.util.List;
31 import org.onap.appc.instar.interfaces.ResponseHandlerInterface;
32 import org.onap.appc.instar.interfaces.RestClientInterface;
33 import org.onap.appc.instar.interfaces.RuleHandlerInterface;
34 import org.onap.appc.instar.utils.InstarClientConstant;
35 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
36 import org.onap.sdnc.config.params.data.Parameter;
37 import org.onap.sdnc.config.params.data.ResponseKey;
39 public class InterfaceIpAddressImpl implements RuleHandlerInterface {
41 private static final EELFLogger log = EELFManager.getInstance().getLogger(InterfaceIpAddressImpl.class);
42 private Parameter parameters;
43 private SvcLogicContext context;
45 public InterfaceIpAddressImpl(Parameter params, SvcLogicContext ctx) {
46 this.parameters = params;
51 public void processRule() throws Exception {
53 String fn = "InterfaceIpAddressHandler.processRule";
54 log.info(fn + "Processing rule :" + parameters.getRuleType());
57 RestClientInterface restClient = null;
58 ResponseHandlerInterface responseHandler = null;
60 List<ResponseKey> responseKeyList = parameters.getResponseKeys();
61 if (responseKeyList != null && responseKeyList.size() > 0) {
62 for (ResponseKey filterKeys : responseKeyList) {
63 //response.setUniqueKeyValue(response.getUniqueKeyValue()+ context.getAttribute(InstarClientConstant.VNF_NAME));
64 switch (parameters.getSource()) {
65 case InstarClientConstant.SOURCE_SYSTEM_INSTAR:
66 restClient = new InstarRestClientImpl(createInstarRequestData(context));
67 responseHandler = new InstarResponseHandlerImpl(filterKeys, context);
68 operationName = "getIpAddressByVnf";
71 throw new Exception("No Client registered for : " + parameters.getSource());
74 responseHandler.processResponse(restClient.sendRequest(operationName), parameters.getName());
77 throw new Exception("NO response Keys set for : " + parameters.getRuleType());
81 private HashMap<String, String> createInstarRequestData(SvcLogicContext ctxt) {
82 HashMap<String, String> requestParams = new HashMap<String, String>();
83 requestParams.put(InstarClientConstant.VNF_NAME, ctxt.getAttribute(InstarClientConstant.VNF_NAME));