2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.utils.rest;
23 import java.io.IOException;
24 import java.text.ParseException;
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.HashMap;
28 import java.util.Iterator;
29 import java.util.List;
31 import java.util.Optional;
33 import org.apache.commons.codec.binary.Base64;
34 import org.apache.log4j.Logger;
35 import org.codehaus.jackson.JsonParseException;
36 import org.codehaus.jackson.Version;
37 import org.codehaus.jackson.map.DeserializationConfig;
38 import org.codehaus.jackson.map.JsonDeserializer;
39 import org.codehaus.jackson.map.JsonMappingException;
40 import org.codehaus.jackson.map.ObjectMapper;
41 import org.codehaus.jackson.map.module.SimpleModule;
42 import org.json.JSONArray;
43 import org.json.JSONException;
44 import org.json.simple.JSONObject;
45 import org.json.simple.JSONValue;
46 import org.openecomp.sdc.be.model.ArtifactDefinition;
47 import org.openecomp.sdc.be.model.Component;
48 import org.openecomp.sdc.be.model.ComponentInstance;
49 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
50 import org.openecomp.sdc.be.model.Product;
51 import org.openecomp.sdc.be.model.PropertyConstraint;
52 import org.openecomp.sdc.be.model.Resource;
53 import org.openecomp.sdc.be.model.Service;
54 import org.openecomp.sdc.be.model.category.CategoryDefinition;
55 import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintJacksonDeserialiser;
56 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
57 import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure;
58 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
59 import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject;
60 import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus;
61 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
62 import org.openecomp.sdc.ci.tests.utils.Utils;
64 import com.fasterxml.jackson.databind.DeserializationFeature;
65 import com.google.gson.Gson;
66 import com.google.gson.JsonArray;
67 import com.google.gson.JsonElement;
68 import com.google.gson.JsonObject;
69 import com.google.gson.JsonParser;
71 public class ResponseParser {
73 // comment by Andrey, for test only
74 // public static void main(String[] args) {
76 // "{\"uniqueId\":\"52eb0139-a855-47b9-a0e6-c90f0a90b1d2\",\"resourceName\":\"importResource4test\",\"resourceVersion\":\"0.1\",\"creatorUserId\":\"jh0003\",\"creatorFullName\":\"Jimmy
77 // Hendrix\",\"lastUpdaterUserId\":\"jh0003\",\"lastUpdaterFullName\":\"Jimmy
78 // Hendrix\",\"creationDate\":1446742241514,\"lastUpdateDate\":1446742241514,\"description\":\"Represents
79 // a generic software component that can be managed and run by a Compute
81 // Type.\",\"icon\":\"defaulticon\",\"tags\":[\"importResource4test\"],\"category\":\"Generic/Infrastructure\",\"lifecycleState\":\"NOT_CERTIFIED_CHECKOUT\",\"derivedFrom\":[\"tosca.nodes.Root\"],\"artifacts\":{},\"deploymentArtifacts\":{},\"properties\":[{\"uniqueId\":\"52eb0139-a855-47b9-a0e6-c90f0a90b1d2.port\",\"type\":\"integer\",\"required\":false,\"description\":\"the
82 // port the DBMS service will listen to for data and
83 // requests\",\"password\":false,\"name\":\"port\",\"parentUniqueId\":\"52eb0139-a855-47b9-a0e6-c90f0a90b1d2\",\"definition\":true},{\"uniqueId\":\"52eb0139-a855-47b9-a0e6-c90f0a90b1d2.root_password\",\"type\":\"string\",\"required\":false,\"description\":\"the
84 // optional root password for the DBMS
85 // service\",\"password\":false,\"name\":\"root_password\",\"parentUniqueId\":\"52eb0139-a855-47b9-a0e6-c90f0a90b1d2\",\"definition\":true}],\"interfaces\":{\"standard\":{\"type\":\"tosca.interfaces.node.lifecycle.Standard\",\"uniqueId\":\"tosca.interfaces.node.lifecycle.standard\",\"operations\":{\"stop\":{\"uniqueId\":\"tosca.interfaces.node.lifecycle.standard.stop\",\"description\":\"Standard
87 // operation.\",\"definition\":false},\"start\":{\"uniqueId\":\"tosca.interfaces.node.lifecycle.standard.start\",\"description\":\"Standard
89 // operation.\",\"definition\":false},\"delete\":{\"uniqueId\":\"tosca.interfaces.node.lifecycle.standard.delete\",\"description\":\"Standard
91 // operation.\",\"definition\":false},\"create\":{\"uniqueId\":\"tosca.interfaces.node.lifecycle.standard.create\",\"description\":\"Standard
93 // operation.\",\"definition\":false},\"configure\":{\"uniqueId\":\"tosca.interfaces.node.lifecycle.standard.configure\",\"description\":\"Standard
94 // lifecycle configure
95 // operation.\",\"definition\":false}},\"definition\":false}},\"capabilities\":{\"feature\":{\"uniqueId\":\"capability.8313348e-3623-4f4a-9b8f-d2fbadaf9a31.feature\",\"type\":\"tosca.capabilities.Node\"},\"feature2\":{\"uniqueId\":\"capability.52eb0139-a855-47b9-a0e6-c90f0a90b1d2.feature2\",\"type\":\"tosca.capabilities.Node\"}},\"requirements\":{\"dependency\":{\"uniqueId\":\"8313348e-3623-4f4a-9b8f-d2fbadaf9a31.dependency\",\"capability\":\"tosca.capabilities.Node\",\"node\":\"tosca.nodes.Root\",\"relationship\":\"tosca.relationships.DependsOn\"},\"dependency2\":{\"uniqueId\":\"52eb0139-a855-47b9-a0e6-c90f0a90b1d2.dependency2\",\"capability\":\"tosca.capabilities.Node\",\"node\":\"tosca.nodes.importResource4test\",\"relationship\":\"tosca.relationships.DependsOn\"}},\"vendorName\":\"ATT
96 // (Tosca)\",\"vendorRelease\":\"1.0.0.wd03\",\"contactId\":\"jh0003\",\"systemName\":\"Importresource4test\",\"additionalInformation\":[{\"uniqueId\":\"52eb0139-a855-47b9-a0e6-c90f0a90b1d2.additionalinformation\",\"lastCreatedCounter\":0,\"parentUniqueId\":\"52eb0139-a855-47b9-a0e6-c90f0a90b1d2\",\"parameters\":[]}],\"allVersions\":{\"0.1\":\"52eb0139-a855-47b9-a0e6-c90f0a90b1d2\"},\"abstract\":false,\"highestVersion\":true,\"uuid\":\"2e91a2df-b066-49bb-abde-4c1c01e409db\"}";
97 // convertResourceResponseToJavaObject(response);
100 private static final String INVARIANT_UUID = "invariantUUID";
101 public static final String UNIQUE_ID = "uniqueId";
102 public static final String VERSION = "version";
103 public static final String UUID = "uuid";
104 public static final String NAME = "name";
105 public static final String ORIGIN_TYPE = "originType";
106 public static final String TOSCA_RESOURCE_NAME = "toscaResourceName";
108 static Logger logger = Logger.getLogger(ResponseParser.class.getName());
110 public static String getValueFromJsonResponse(String response, String fieldName) {
112 JSONObject jsonResp = (JSONObject) JSONValue.parse(response);
113 Object fieldValue = jsonResp.get(fieldName);
114 return fieldValue.toString();
116 } catch (Exception e) {
122 public static String getUniqueIdFromResponse(RestResponse response) {
123 return getValueFromJsonResponse(response.getResponse(), UNIQUE_ID);
126 public static String getInvariantUuid(RestResponse response) {
127 return getValueFromJsonResponse(response.getResponse(), INVARIANT_UUID);
130 public static String getUuidFromResponse(RestResponse response) {
131 return getValueFromJsonResponse(response.getResponse(), UUID);
134 public static String getNameFromResponse(RestResponse response) {
135 return getValueFromJsonResponse(response.getResponse(), NAME);
138 public static String getVersionFromResponse(RestResponse response) {
139 return ResponseParser.getValueFromJsonResponse(response.getResponse(), VERSION);
142 public static String getComponentTypeFromResponse(RestResponse response) {
143 return ResponseParser.getValueFromJsonResponse(response.getResponse(), ORIGIN_TYPE);
146 public static String getToscaResourceNameFromResponse(RestResponse response) {
147 return getValueFromJsonResponse(response.getResponse(), TOSCA_RESOURCE_NAME);
150 @SuppressWarnings("unchecked")
151 public static ResourceRespJavaObject parseJsonListReturnResourceDetailsObj(RestResponse restResponse,
152 String resourceType, String searchPattern, String expectedResult) throws Exception {
154 // Gson gson = new Gson;
156 JsonElement jElement = new JsonParser().parse(restResponse.getResponse());
157 JsonObject jObject = jElement.getAsJsonObject();
158 JsonArray arrayOfObjects = (JsonArray) jObject.get(resourceType);
159 Gson gson = new Gson();
160 Map<String, Object> map = new HashMap<String, Object>();
161 ResourceRespJavaObject jsonToJavaObject = new ResourceRespJavaObject();
163 for (int counter = 0; counter < arrayOfObjects.size(); counter++) {
164 JsonObject jHitObject = (JsonObject) arrayOfObjects.get(counter);
166 map = (Map<String, Object>) gson.fromJson(jHitObject.toString(), map.getClass());
167 if (map.get(searchPattern).toString().contains(expectedResult)) {
169 jsonToJavaObject = gson.fromJson(jObject, ResourceRespJavaObject.class);
173 return jsonToJavaObject;
177 public static Resource convertResourceResponseToJavaObject(String response) {
179 ObjectMapper mapper = new ObjectMapper();
180 final SimpleModule module = new SimpleModule("customerSerializationModule",
181 new Version(1, 0, 0, "static version"));
182 JsonDeserializer<PropertyConstraint> deserializer = new PropertyConstraintJacksonDeserialiser();
183 addDeserializer(module, PropertyConstraint.class, deserializer);
185 mapper.registerModule(module);
186 Resource resource = null;
188 // TODO Andrey L. uncomment line below in case to ignore on unknown properties, not recommended
189 // mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
190 resource = mapper.readValue(response, Resource.class);
192 logger.debug(resource.toString());
193 } catch (IOException e) {
195 List<Resource> resources = Arrays.asList(mapper.readValue(response.toString(), Resource[].class));
196 resource = resources.get(0);
197 } catch (Exception e1) {
198 // TODO Auto-generated catch block
199 e1.printStackTrace();
206 public static ComponentInstanceProperty convertPropertyResponseToJavaObject(String response) {
208 ObjectMapper mapper = new ObjectMapper();
209 final SimpleModule module = new SimpleModule("customerSerializationModule",
210 new Version(1, 0, 0, "static version"));
211 JsonDeserializer<PropertyConstraint> desrializer = new PropertyConstraintJacksonDeserialiser();
212 addDeserializer(module, PropertyConstraint.class, desrializer);
214 mapper.registerModule(module);
215 ComponentInstanceProperty propertyDefinition = null;
217 propertyDefinition = mapper.readValue(response, ComponentInstanceProperty.class);
218 logger.debug(propertyDefinition.toString());
219 } catch (IOException e) {
220 // TODO Auto-generated catch block
223 return propertyDefinition;
226 public static String toJson(Object object) {
227 Gson gson = new Gson();
228 return gson.toJson(object);
231 public static ArtifactDefinition convertArtifactDefinitionResponseToJavaObject(String response) {
232 ObjectMapper mapper = new ObjectMapper();
233 ArtifactDefinition artifactDefinition = null;
236 artifactDefinition = mapper.readValue(response, ArtifactDefinition.class);
237 logger.debug(artifactDefinition.toString());
238 } catch (IOException e) {
239 // TODO Auto-generated catch block
243 return artifactDefinition;
247 public static ArtifactReqDetails convertArtifactReqDetailsToJavaObject(String response) {
249 ArtifactReqDetails artifactReqDetails = null;
250 Gson gson = new Gson();
251 artifactReqDetails = gson.fromJson(response, ArtifactReqDetails.class);
252 return artifactReqDetails;
255 public static <T> T parseToObject(String json, Class<T> clazz) {
256 Gson gson = new Gson();
259 object = gson.fromJson(json, clazz);
260 } catch (Exception e) {
261 object = parseToObjectUsingMapper(json, clazz);
266 public static <T> T parseToObjectUsingMapper(String json, Class<T> clazz) {
268 ObjectMapper mapper = new ObjectMapper();
270 final SimpleModule module = new SimpleModule("customerSerializationModule",
271 new Version(1, 0, 0, "static version"));
272 JsonDeserializer<PropertyConstraint> desrializer = new PropertyConstraintJacksonDeserialiser();
273 addDeserializer(module, PropertyConstraint.class, desrializer);
274 mapper.registerModule(module);
276 object = mapper.readValue(json, clazz);
277 // System.out.println("Class: "+clazz.getSimpleName()+", json:
279 } catch (IOException e) {
280 // TODO Auto-generated catch block
287 public static ArtifactReqDetails convertArtifactDefinitionToArtifactReqDetailsObject(
288 ArtifactDefinition artifactDefinition) {
290 ArtifactReqDetails artifactReqDetails = null;
291 Gson gson = new Gson();
292 String artDef = gson.toJson(artifactDefinition);
293 artifactReqDetails = gson.fromJson(artDef, ArtifactReqDetails.class);
294 return artifactReqDetails;
297 public static <T> void addDeserializer(SimpleModule module, Class<T> clazz,
298 final JsonDeserializer<T> deserializer) {
299 module.addDeserializer(clazz, deserializer);
302 public static Service convertServiceResponseToJavaObject(String response) {
304 ObjectMapper mapper = new ObjectMapper();
305 final SimpleModule module = new SimpleModule("customerSerializationModule",
306 new Version(1, 0, 0, "static version"));
307 JsonDeserializer<PropertyConstraint> deserializer = new PropertyConstraintJacksonDeserialiser();
308 addDeserializer(module, PropertyConstraint.class, deserializer);
310 mapper.registerModule(module);
311 Service service = null;
313 service = mapper.readValue(response, Service.class);
314 logger.debug(service.toString());
315 } catch (IOException e) {
316 // TODO Auto-generated catch block
323 public static Product convertProductResponseToJavaObject(String response) {
325 ObjectMapper mapper = new ObjectMapper();
327 final SimpleModule module = new SimpleModule("customerSerializationModule",
328 new Version(1, 0, 0, "static version"));
329 JsonDeserializer<PropertyConstraint> desrializer = new PropertyConstraintJacksonDeserialiser();
330 addDeserializer(module, PropertyConstraint.class, desrializer);
332 mapper.registerModule(module);
334 Product product = null;
336 product = mapper.readValue(response, Product.class);
337 logger.debug(product.toString());
338 } catch (IOException e) {
339 // TODO Auto-generated catch block
346 public static ComponentInstance convertComponentInstanceResponseToJavaObject(String response) {
348 ObjectMapper mapper = new ObjectMapper();
349 final SimpleModule module = new SimpleModule("customerSerializationModule",
350 new Version(1, 0, 0, "static version"));
351 JsonDeserializer<PropertyConstraint> desrializer = new PropertyConstraintJacksonDeserialiser();
352 addDeserializer(module, PropertyConstraint.class, desrializer);
354 mapper.registerModule(module);
355 ComponentInstance componentInstance = null;
357 componentInstance = mapper.readValue(response, ComponentInstance.class);
358 logger.debug(componentInstance.toString());
359 } catch (IOException e) {
360 // TODO Auto-generated catch block
364 return componentInstance;
367 public static List<String> getValuesFromJsonArray(RestResponse message) throws Exception {
368 List<String> artifactTypesArrayFromApi = new ArrayList<String>();
370 org.json.JSONObject responseObject = new org.json.JSONObject(message.getResponse());
371 JSONArray jArr = responseObject.getJSONArray("artifactTypes");
373 for (int i = 0; i < jArr.length(); i++) {
374 org.json.JSONObject jObj = jArr.getJSONObject(i);
375 String value = jObj.get("name").toString();
377 artifactTypesArrayFromApi.add(value);
379 return artifactTypesArrayFromApi;
382 public static String calculateMD5Header(ArtifactReqDetails artifactDetails) {
383 Gson gson = new Gson();
384 String jsonBody = gson.toJson(artifactDetails);
385 // calculate MD5 for json body
386 return calculateMD5(jsonBody);
390 public static String calculateMD5(String data) {
391 String calculatedMd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(data);
392 // encode base-64 result
393 byte[] encodeBase64 = Base64.encodeBase64(calculatedMd5.getBytes());
394 String encodeBase64Str = new String(encodeBase64);
395 return encodeBase64Str;
399 public static List<Map<String, Object>> getAuditFromMessage(Map auditingMessage) {
400 List<Map<String, Object>> auditList = new ArrayList<Map<String, Object>>();
401 // JsonElement jElement = new JsonParser().parse(auditingMessage);
402 // JsonObject jObject = jElement.getAsJsonObject();
403 // JsonObject hitsObject = (JsonObject) jObject.get("hits");
404 // JsonArray hitsArray = (JsonArray) hitsObject.get("hits");
406 // Iterator<JsonElement> hitsIterator = hitsArray.iterator();
407 // while(hitsIterator.hasNext())
409 // JsonElement nextHit = hitsIterator.next();
410 // JsonObject jHitObject = nextHit.getAsJsonObject();
411 // JsonObject jSourceObject = (JsonObject) jHitObject.get("_source");
413 // Gson gson=new Gson();
414 // String auditUnparsed = jSourceObject.toString();
416 // Map<String,Object> map = new HashMap<String,Object>();
417 // map = (Map<String,Object>) gson.fromJson(auditUnparsed,
420 auditList.add(auditingMessage);
425 public static List<CategoryDefinition> parseCategories(RestResponse getAllCategoriesRest) {
427 List<CategoryDefinition> categories = new ArrayList<>();
429 JsonElement jElement = new JsonParser().parse(getAllCategoriesRest.getResponse());
430 JsonArray cagegories = jElement.getAsJsonArray();
431 Iterator<JsonElement> iter = cagegories.iterator();
432 while (iter.hasNext()) {
433 JsonElement next = iter.next();
434 CategoryDefinition category = ResponseParser.parseToObject(next.toString(), CategoryDefinition.class);
435 categories.add(category);
438 } catch (Exception e) {
445 public static JSONArray getListFromJson(RestResponse res, String field) throws JSONException {
446 String valueFromJsonResponse = getValueFromJsonResponse(res.getResponse(), field);
447 JSONArray jArr = new JSONArray(valueFromJsonResponse);
452 public static List<String> getDerivedListFromJson(RestResponse res) throws JSONException {
453 JSONArray listFromJson = getListFromJson(res, "derivedList");
454 List<String> lst = new ArrayList<String>();
455 for (int i = 0; i < listFromJson.length(); i++) {
456 lst.add(listFromJson.getString(i));
462 public static Map<String, Object> convertStringToMap(String obj) {
463 Map<String, Object> object = (Map<String, Object>) JSONValue.parse(obj);
467 public static List<Map<String, Object>> getListOfMapsFromJson(RestResponse res, String field) throws Exception {
468 List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
469 JSONArray listFromJson = getListFromJson(res, field);
470 for (int i = 0; i < listFromJson.length(); i++) {
471 Map<String, Object> convertStringToMap = convertStringToMap(listFromJson.getString(i));
472 list.add(convertStringToMap);
478 public static Map<String, Object> getJsonValueAsMap(RestResponse response, String key) {
479 String valueField = getValueFromJsonResponse(response.getResponse(), key);
480 Map<String, Object> convertToMap = convertStringToMap(valueField);
484 public static String getJsonObjectValueByKey(String metadata, String key) {
485 JsonElement jelement = new JsonParser().parse(metadata);
487 JsonObject jobject = jelement.getAsJsonObject();
488 Object obj = jobject.get(key);
492 return obj.toString();
496 public static Map<String, List<Component>> convertCatalogResponseToJavaObject(String response) {
498 // Map<String, ArrayList<Component>> map = new HashMap<String,
499 // ArrayList<Component>>();
500 Map<String, List<Component>> map = new HashMap<String, List<Component>>();
502 JsonElement jElement = new JsonParser().parse(response);
503 JsonObject jObject = jElement.getAsJsonObject();
504 JsonArray jArrReousrces = jObject.getAsJsonArray("resources");
505 JsonArray jArrServices = jObject.getAsJsonArray("services");
506 JsonArray jArrProducts = jObject.getAsJsonArray("products");
508 if (jArrReousrces != null && jArrServices != null && jArrProducts != null){
511 //////// RESOURCE/////////////////////////////
512 ArrayList<Component> restResponseArray = new ArrayList<>();
513 Component component = null;
514 for (int i = 0; i < jArrReousrces.size(); i++) {
515 String resourceString = (String) jArrReousrces.get(i).toString();
516 component = ResponseParser.convertResourceResponseToJavaObject(resourceString);
517 restResponseArray.add(component);
520 map.put("resources", restResponseArray);
522 ///////// SERVICE/////////////////////////////
524 restResponseArray = new ArrayList<>();
526 for (int i = 0; i < jArrServices.size(); i++) {
527 String resourceString = (String) jArrServices.get(i).toString();
528 component = ResponseParser.convertServiceResponseToJavaObject(resourceString);
529 restResponseArray.add(component);
532 map.put("services", restResponseArray);
534 ///////// PRODUCT/////////////////////////////
535 restResponseArray = new ArrayList<>();
537 for (int i = 0; i < jArrProducts.size(); i++) {
538 String resourceString = (String) jArrProducts.get(i).toString();
539 component = ResponseParser.convertProductResponseToJavaObject(resourceString);
540 restResponseArray.add(component);
543 map.put("products", restResponseArray);
547 map.put("resources", new ArrayList<>());
548 map.put("services", new ArrayList<>());
549 map.put("products", new ArrayList<>());
557 public static Map<Long, ServiceDistributionStatus> convertServiceDistributionStatusToObject(String response) throws ParseException {
559 Map<Long, ServiceDistributionStatus> serviceDistributionStatusMap = new HashMap<Long, ServiceDistributionStatus>();
560 ServiceDistributionStatus serviceDistributionStatusObject = null;
562 JsonElement jElement = new JsonParser().parse(response);
563 JsonObject jObject = jElement.getAsJsonObject();
564 JsonArray jDistrStatusArray = jObject.getAsJsonArray("distributionStatusOfServiceList");
566 for (int i = 0; i < jDistrStatusArray.size(); i++){
567 Gson gson = new Gson();
568 String servDistrStatus = gson.toJson(jDistrStatusArray.get(i));
569 serviceDistributionStatusObject = gson.fromJson(servDistrStatus, ServiceDistributionStatus.class);
570 serviceDistributionStatusMap.put(Utils.getEpochTimeFromUTC(serviceDistributionStatusObject.getTimestamp()), serviceDistributionStatusObject);
573 return serviceDistributionStatusMap;
577 public static Map<String, String> getPropertiesNameType(RestResponse restResponse)
578 throws JSONException {
579 Map<String, String> propertiesMap = new HashMap<String, String>();
580 JSONArray propertiesList = getListFromJson(restResponse, "properties");
581 for (int i = 0; i < propertiesList.length() ; i ++){
582 JSONObject prop = (JSONObject) JSONValue.parse(propertiesList.get(i).toString());
583 String propName = prop.get("name").toString();
584 String propType = prop.get("type").toString();
585 propertiesMap.put(propName, propType);
588 return propertiesMap;
591 public static ResourceAssetStructure getDataOutOfSearchExternalAPIResponseForResourceName(String response, String resourceName) {
592 Gson gson = new Gson();
593 JsonElement jsonElement = new JsonParser().parse(response);
594 JsonArray jsonArray = jsonElement.getAsJsonArray();
595 for(JsonElement jElement: jsonArray) {
596 ResourceAssetStructure parsedResponse = gson.fromJson(jElement, ResourceAssetStructure.class);
598 if(resourceName.contains(parsedResponse.getName()) && parsedResponse.getName().contains(resourceName)) {
599 return parsedResponse;