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