diff options
author | Rich Tabedzki <richard.tabedzki@att.com> | 2017-04-05 13:15:15 +0000 |
---|---|---|
committer | Rich Tabedzki <richard.tabedzki@att.com> | 2017-04-05 13:15:52 +0000 |
commit | f2f129f56c057854517394cc5680b02418fece7d (patch) | |
tree | 43632d50bff51aa214713357b313a875e3e6d5c5 /aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/NamedQueryRequest.java | |
parent | c11f9ffaa0d9f43371f6f85a20cd1f09c6595dfb (diff) |
[SDNC-5] summary
Synchronized source code with 17.07 after cleaning up deprecated code
Change-Id: Ieabd58d25bb405ad15ad255e1cf40797e91d937f
Signed-off-by: Rich Tabedzki <richard.tabedzki@att.com>
Diffstat (limited to 'aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/NamedQueryRequest.java')
-rw-r--r-- | aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/NamedQueryRequest.java | 76 |
1 files changed, 67 insertions, 9 deletions
diff --git a/aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/NamedQueryRequest.java b/aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/NamedQueryRequest.java index 6271b1d..46421b6 100644 --- a/aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/NamedQueryRequest.java +++ b/aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/NamedQueryRequest.java @@ -24,26 +24,32 @@ package org.openecomp.sdnc.sli.aai; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import java.util.Properties; import org.openecomp.sdnc.sli.aai.data.AAIDatum; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.AnnotationIntrospector; import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; -import org.openecomp.aai.inventory.v8.InventoryResponseItems; +import org.openecomp.aai.inventory.v10.InventoryResponseItems; public class NamedQueryRequest extends AAIRequest { public static final String NAMED_SEARCH_PATH = "org.openecomp.sdnc.sli.aai.query.named"; - + private final String named_search_path; - + public static final String NAMED_QUERY_UUID = "named-query-uuid"; public static final String PREFIX = "prefix"; @@ -65,19 +71,23 @@ public class NamedQueryRequest extends AAIRequest { URL http_req_url = new URL(request_url); aaiService.LOGwriteFirstTrace(method, http_req_url.toString()); - + return http_req_url; } - + @Override - public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException { + public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException { return getRequestUrl(method, null); } @Override public String toJSONString() { - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = AAIService.getObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + mapper.setSerializationInclusion(Include.NON_EMPTY); + mapper.setSerializationInclusion(Include.NON_DEFAULT); + AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotationIntrospector secondary = new JacksonAnnotationIntrospector(); mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(introspector, secondary)); @@ -86,6 +96,54 @@ public class NamedQueryRequest extends AAIRequest { AAIDatum tenant = (AAIDatum)requestDatum; String json_text = null; try { + ObjectNode node = mapper.valueToTree(tenant); + Iterator<JsonNode> it = node.elements(); + while(it.hasNext()){ + JsonNode jn = it.next(); + JsonNode child = jn.get("instance-filter"); + if(child != null) { + child = child.get(0); + if(child.has("l3-network")) { + JsonNode innerChild = child.get("l3-network"); + if(innerChild != null) { + if(innerChild instanceof ObjectNode) { + ObjectNode on = ObjectNode.class.cast(innerChild); + List<String> namesToDelete = new ArrayList<String>(); + Iterator<String> names = on.fieldNames(); + while(names.hasNext()) { + String name = names.next(); + if(name != null && name.startsWith("is-")) { + namesToDelete.add(name); + } + } + for(String nameToDelete : namesToDelete) { + on.remove(nameToDelete); + } + } + } + } else if(child.has("pnf")) { + JsonNode innerChild = child.get("pnf"); + if(innerChild != null) { + if(innerChild instanceof ObjectNode) { + ObjectNode on = ObjectNode.class.cast(innerChild); + List<String> namesToDelete = new ArrayList<String>(); + Iterator<String> names = on.fieldNames(); + while(names.hasNext()) { + String name = names.next(); + if(name != null && name.startsWith("in-maint")) { + namesToDelete.add(name); + } + } + for(String nameToDelete : namesToDelete) { + on.remove(nameToDelete); + } + } + } + } + } + } + json_text = node.toString(); + if(json_text == null) json_text = mapper.writeValueAsString(tenant); } catch (JsonProcessingException exc) { handleException(this, exc); @@ -113,7 +171,7 @@ public class NamedQueryRequest extends AAIRequest { String encoded_vnf ; String key = NAMED_QUERY_UUID; - + if(requestProperties.containsKey(key)) { encoded_vnf = encodeQuery(requestProperties.getProperty(key)); request_url = request_url.replace("{named-query-uuid}", encoded_vnf) ; @@ -121,7 +179,7 @@ public class NamedQueryRequest extends AAIRequest { } key = PREFIX; - + if(requestProperties.containsKey(key)) { encoded_vnf = encodeQuery(requestProperties.getProperty(key)); request_url = request_url.replace("{prefix}", encoded_vnf) ; |