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.design.xinterface;
26 import java.util.HashMap;
28 import org.onap.appc.design.services.util.DesignServiceConstants;
29 import org.onap.appc.instar.dme2client.Dme2Client;
31 import com.att.eelf.configuration.EELFLogger;
32 import com.att.eelf.configuration.EELFManager;
33 import com.fasterxml.jackson.databind.JsonNode;
34 import com.fasterxml.jackson.databind.ObjectMapper;
36 public class XResponseProcessor {
38 private final EELFLogger log = EELFManager.getInstance().getLogger(XInterfaceService.class);
39 Dme2Client dme2Client;
41 public String parseResponse(String execute, String action) throws Exception {
42 ObjectMapper objectMapper = new ObjectMapper();
43 JsonNode payloadObject = objectMapper.readTree(execute);
44 log.info("payloadObject " + payloadObject);
46 //String queryParam = null;
47 String instarResponse = null;
48 HashMap<String, String> payload = null;
49 String ipAddress = null;
54 // check the payload whether its having ipaddr along with subnet
55 ipAddress = payloadObject.get(DesignServiceConstants.INSTAR_V4_ADDRESS) != null
56 ? payloadObject.get(DesignServiceConstants.INSTAR_V4_ADDRESS).textValue()
57 : (payloadObject.get(DesignServiceConstants.INSTAR_V6_ADDRESS) !=null)
58 ?payloadObject.get(DesignServiceConstants.INSTAR_V6_ADDRESS).textValue().toUpperCase()
61 mask = payloadObject.get(DesignServiceConstants.INSTAR_V4_MASK) != null
62 ? payloadObject.get(DesignServiceConstants.INSTAR_V4_MASK).textValue()
63 : (payloadObject.get(DesignServiceConstants.INSTAR_V6_MASK) != null)
64 ? payloadObject.get(DesignServiceConstants.INSTAR_V6_MASK).textValue().toUpperCase()
70 queryParam = ipAddress + "," +mask ;
71 log.info("Calling Instar with IpAddress "+ ipAddress + " Mask value: "+ mask );
73 queryParam = "ipAddress "+ipAddress ;
74 log.info("Calling Instar with IpAddress "+ ipAddress);
77 payload = new HashMap<String, String>();
78 payload.put("ipAddress", ipAddress);
79 payload.put("mask", mask);
80 log.info("Calling Instar with IpAddress "+ ipAddress + " Mask value: "+ mask );
81 dme2Client = new Dme2Client("getVnfbyIpadress", "payload", payload);
83 instarResponse = dme2Client.send();
85 log.debug("Resposne from Instar = " + instarResponse);
86 if (instarResponse == null || instarResponse.length() < 0)
87 throw new Exception("No Data received from Instar for this action " + action);
88 } catch (Exception e) {
92 return instarResponse;