Updating AAI service adaptor to use version 21 (v21) of the schema model.
[ccsdk/sli/adaptors.git] / aai-service / provider / src / main / java / org / onap / ccsdk / sli / adaptors / aai / AAIDeclarations.java
index aa16ef3..6765e15 100755 (executable)
@@ -2,9 +2,11 @@
  * ============LICENSE_START=======================================================
  * openECOMP : SDN-C
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
  *             reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 IBM.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * ============LICENSE_END=========================================================
  */
 
+/**
+ * @author Rich Tabedzki
+ *
+ */
 package org.onap.ccsdk.sli.adaptors.aai;
 
 import java.io.IOException;
@@ -27,6 +33,8 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.NoSuchMethodException;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -49,33 +57,23 @@ import javax.xml.bind.annotation.XmlType;
 import org.apache.commons.lang.StringUtils;
 import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
 import org.onap.ccsdk.sli.adaptors.aai.query.FormattedQueryResultList;
-import org.onap.ccsdk.sli.adaptors.aai.query.InstanceFilter;
-import org.onap.ccsdk.sli.adaptors.aai.query.InstanceFilters;
-import org.onap.ccsdk.sli.adaptors.aai.query.NamedQuery;
-import org.onap.ccsdk.sli.adaptors.aai.query.NamedQueryData;
-import org.onap.ccsdk.sli.adaptors.aai.query.QueryParameters;
 import org.onap.ccsdk.sli.adaptors.aai.query.Result;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.aai.inventory.v14.GenericVnf;
-import org.onap.aai.inventory.v14.Image;
-import org.onap.aai.inventory.v14.InventoryResponseItem;
-import org.onap.aai.inventory.v14.InventoryResponseItems;
-import org.onap.aai.inventory.v14.L3Network;
-import org.onap.aai.inventory.v14.LogicalLink;
-import org.onap.aai.inventory.v14.Metadata;
-import org.onap.aai.inventory.v14.Metadatum;
-import org.onap.aai.inventory.v14.Pnf;
-import org.onap.aai.inventory.v14.RelatedToProperty;
-import org.onap.aai.inventory.v14.Relationship;
-import org.onap.aai.inventory.v14.RelationshipData;
-import org.onap.aai.inventory.v14.RelationshipList;
-import org.onap.aai.inventory.v14.ResultData;
-import org.onap.aai.inventory.v14.SearchResults;
-import org.onap.aai.inventory.v14.ServiceInstance;
-import org.onap.aai.inventory.v14.Vlan;
-import org.onap.aai.inventory.v14.Vlans;
-import org.onap.aai.inventory.v14.Vserver;
+import org.onap.aai.inventory.v21.GenericVnf;
+import org.onap.aai.inventory.v21.Image;
+import org.onap.aai.inventory.v21.Metadata;
+import org.onap.aai.inventory.v21.Metadatum;
+import org.onap.aai.inventory.v21.RelatedToProperty;
+import org.onap.aai.inventory.v21.Relationship;
+import org.onap.aai.inventory.v21.RelationshipData;
+import org.onap.aai.inventory.v21.RelationshipList;
+import org.onap.aai.inventory.v21.ResultData;
+import org.onap.aai.inventory.v21.SearchResults;
+import org.onap.aai.inventory.v21.ServiceInstance;
+import org.onap.aai.inventory.v21.Vlan;
+import org.onap.aai.inventory.v21.Vlans;
+import org.onap.aai.inventory.v21.Vserver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -130,9 +128,6 @@ public abstract class AAIDeclarations implements AAIClient {
     //Service
     public static final String SERVICE_PATH              = "org.onap.ccsdk.sli.adaptors.aai.path.service";
 
-    // P-Interfaces
-    public static final String P_INTERFACE_PATH       = "org.onap.ccsdk.sli.adaptors.aai.path.pserver.pinterface";
-
     // site-pair-sets
     public static final String SITE_PAIR_SET_PATH     = "org.onap.ccsdk.sli.adaptors.aai.path.site.pair.set";
 
@@ -141,14 +136,17 @@ public abstract class AAIDeclarations implements AAIClient {
 
     private static final String VERSION_PATTERN = "/v$/";
 
+    private static final String AAI_SERVICE_EXCEPTION = "AAI Service Exception";
 
     protected abstract Logger getLogger();
     public abstract AAIExecutorInterface getExecutor();
 
+    private static final String RELATIONSHIP_DATA= "Retrofitting relationship data: ";
+
 
     @Override
     public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, String orderBy, SvcLogicContext ctx)
-        throws SvcLogicException {
+            throws SvcLogicException {
 
         getLogger().debug("AAIService.query \tresource = "+resource);
 
@@ -242,17 +240,17 @@ public abstract class AAIDeclarations implements AAIClient {
                         } catch (AAIServiceException exc) {
                             int errorCode = exc.getReturnCode();
                             switch(errorCode) {
-                            case 400:
-                            case 404:
-                            case 412:
-                                break;
-                            default:
-                                getLogger().warn("Caught exception trying to refresh generic VNF", exc);
+                                case 400:
+                                case 404:
+                                case 412:
+                                    break;
+                                default:
+                                    getLogger().warn("Caught exception trying to refresh generic VNF", exc);
                             }
                             ctx.setAttribute(prefix + ".error.message", exc.getMessage());
                             if(errorCode >= 300) {
                                 ctx.setAttribute(prefix + ".error.http.response-code",
-                                                 Integer.toString(exc.getReturnCode()));
+                                        Integer.toString(exc.getReturnCode()));
                             }
                             return QueryStatus.FAILURE;
                         }
@@ -280,57 +278,59 @@ public abstract class AAIDeclarations implements AAIClient {
                     if(vserverId != null) vserverId = vserverId.trim().replace("'", "").replace("$", "").replace("'", "");
                     if(tenantId != null) tenantId = tenantId.trim().replace("'", "").replace("$", "").replace("'", "");
 
-                if (vserverName != null) {
-                    URL vserverUrl = null;
-                    try {
-                        vserverUrl = this.requestVserverURLNodeQuery(vserverName);
-                    } catch (AAIServiceException aaiexc) {
-                        ctx.setAttribute(prefix + ".error.message", aaiexc.getMessage());
-                        if (aaiexc.getReturnCode() >= 300) {
-                            ctx.setAttribute(prefix + ".error.http" + "" + ".response-code", Integer.toString(aaiexc.getReturnCode()));
-                        }
+                    if (vserverName != null) {
+                        URL vserverUrl = null;
+                        try {
+                            vserverUrl = this.requestVserverURLNodeQuery(vserverName);
+                        } catch (AAIServiceException aaiexc) {
+                            getLogger().warn(AAI_SERVICE_EXCEPTION, aaiexc);
+                            ctx.setAttribute(prefix + ".error.message", aaiexc.getMessage());
+                            if (aaiexc.getReturnCode() >= 300) {
+                                ctx.setAttribute(prefix + ".error.http" + "" + ".response-code", Integer.toString(aaiexc.getReturnCode()));
+                            }
 
-                        if (aaiexc.getReturnCode() == 404)
+                            if (aaiexc.getReturnCode() == 404)
+                                return QueryStatus.NOT_FOUND;
+                            else
+                                return QueryStatus.FAILURE;
+                        }
+                        if (vserverUrl == null) {
                             return QueryStatus.NOT_FOUND;
-                        else
-                            return QueryStatus.FAILURE;
-                    }
-                    if (vserverUrl == null) {
-                        return QueryStatus.NOT_FOUND;
-                    }
+                        }
 
-                    tenantId = getTenantIdFromVserverUrl(vserverUrl);
-                            String cloudOwner = getCloudOwnerFromVserverUrl(vserverUrl);
-                            String cloudRegionId = getCloudRegionFromVserverUrl(vserverUrl);
+                        tenantId = getTenantIdFromVserverUrl(vserverUrl);
+                        String cloudOwner = getCloudOwnerFromVserverUrl(vserverUrl);
+                        String cloudRegionId = getCloudRegionFromVserverUrl(vserverUrl);
 
-                    Vserver vserver = null;
-                    try {
-                        vserver = this.requestVServerDataByURL(vserverUrl);
-                    } catch (AAIServiceException aaiexc) {
-                        ctx.setAttribute(prefix + ".error.message", aaiexc.getMessage());
-                        if (aaiexc.getReturnCode() >= 300) {
-                            ctx.setAttribute(prefix + ".error.http" + ".response-code", Integer.toString(aaiexc.getReturnCode()));
-                        }
+                        Vserver vserver = null;
+                        try {
+                            vserver = this.requestVServerDataByURL(vserverUrl);
+                        } catch (AAIServiceException aaiexc) {
+                            getLogger().warn(AAI_SERVICE_EXCEPTION, aaiexc);
+                            ctx.setAttribute(prefix + ".error.message", aaiexc.getMessage());
+                            if (aaiexc.getReturnCode() >= 300) {
+                                ctx.setAttribute(prefix + ".error.http" + ".response-code", Integer.toString(aaiexc.getReturnCode()));
+                            }
 
-                        if (aaiexc.getReturnCode() == 404)
+                            if (aaiexc.getReturnCode() == 404)
+                                return QueryStatus.NOT_FOUND;
+                            else
+                                return QueryStatus.FAILURE;
+                        }
+                        if (vserver == null) {
                             return QueryStatus.NOT_FOUND;
-                        else
-                            return QueryStatus.FAILURE;
-                    }
-                    if (vserver == null) {
-                        return QueryStatus.NOT_FOUND;
-                    }
-                    attributes = mapper.convertValue(vserver, attributes.getClass());
-                    if (!attributes.containsKey("tenant-id") && tenantId != null) {
-                        attributes.put("tenant-id", tenantId);
-                    }
-                    if (!attributes.containsKey("cloud-owner") && cloudOwner != null) {
-                        attributes.put("cloud-owner", cloudOwner);
-                    }
-                    if (!attributes.containsKey("cloud-region-id") && cloudRegionId != null) {
-                        attributes.put("cloud-region-id", cloudRegionId);
-                    }
-                } else if (vserverId != null && tenantId != null) {
+                        }
+                        attributes = mapper.convertValue(vserver, attributes.getClass());
+                        if (!attributes.containsKey("tenant-id") && tenantId != null) {
+                            attributes.put("tenant-id", tenantId);
+                        }
+                        if (!attributes.containsKey("cloud-owner") && cloudOwner != null) {
+                            attributes.put("cloud-owner", cloudOwner);
+                        }
+                        if (!attributes.containsKey("cloud-region-id") && cloudRegionId != null) {
+                            attributes.put("cloud-region-id", cloudRegionId);
+                        }
+                    } else if (vserverId != null && tenantId != null) {
                         Vserver vserver = this.requestVServerData(tenantId, vserverId, "att-aic", "AAIAIC25");
                         if(vserver == null) {
                             return QueryStatus.NOT_FOUND;
@@ -425,7 +425,7 @@ public abstract class AAIDeclarations implements AAIClient {
             if(entity instanceof Map) {
                 writeMap( (Map<String, Object>)entity,  prefix + "[" + i + "]",  ctx);
             } else
-                if(entity instanceof String ||  entity instanceof Long || entity instanceof Integer || entity instanceof Boolean) {
+            if(entity instanceof String ||  entity instanceof Long || entity instanceof Integer || entity instanceof Boolean) {
                 ctx.setAttribute(prefix, entity.toString());
                 getLogger().debug(prefix  + " : " + entity.toString());
             }
@@ -484,6 +484,7 @@ public abstract class AAIDeclarations implements AAIClient {
                     path = request.getRequestUrl("GET", null);
                     params.put("vserver-selflink", path.toString());
                 } catch (UnsupportedEncodingException | MalformedURLException | URISyntaxException e) {
+                    getLogger().warn("URL error Exception", e);
                     params.put("vserver-selflink", "/vserver");
                 }
             }
@@ -598,6 +599,7 @@ public abstract class AAIDeclarations implements AAIClient {
             request.processRequestPathValues(nameValues);
             getExecutor().patch(request, resourceVersion);
         } catch(AAIServiceException aaiexc) {
+            getLogger().warn(AAI_SERVICE_EXCEPTION, aaiexc);
             if(aaiexc.getReturnCode() == 404)
                 return QueryStatus.NOT_FOUND;
             else
@@ -670,6 +672,7 @@ public abstract class AAIDeclarations implements AAIClient {
                         return QueryStatus.SUCCESS;
                     }
                 } catch(AAIServiceException aaiexc) {
+                    getLogger().warn(AAI_SERVICE_EXCEPTION, aaiexc);
                     if(aaiexc.getReturnCode() == 404)
                         return QueryStatus.NOT_FOUND;
                     else
@@ -758,7 +761,7 @@ public abstract class AAIDeclarations implements AAIClient {
         throw new SvcLogicException("Method AAIService.notify() has not been implemented yet");
     }
 
-//    @Override
+    //    @Override
     public QueryStatus newModelQuery(String resource, boolean localOnly, String select, String key, String prefix, String orderBy, SvcLogicContext ctx) {
 
         QueryStatus retval = QueryStatus.SUCCESS;
@@ -783,14 +786,13 @@ public abstract class AAIDeclarations implements AAIClient {
                 if(!tmpParams.isEmpty()) {
                     params.putAll(tmpParams);
                 }
-                if("named-query".equals(resource))
-                    request.setRequestObject(extractNamedQueryDataFromQueryPrefix(nameValues, params));
             }
             String rv = getExecutor().get(request);
 
             retval = processResponseData(rv, resource, request, prefix,  ctx, nameValues, modifier);
 
         } catch(AAIServiceException aaiexc) {
+            getLogger().warn(AAI_SERVICE_EXCEPTION, aaiexc);
             int errorCode = aaiexc.getReturnCode();
             ctx.setAttribute(prefix + ".error.message", aaiexc.getMessage());
             if(errorCode >= 300) {
@@ -815,53 +817,45 @@ public abstract class AAIDeclarations implements AAIClient {
     {
         Object response;
 
+        if(rv == null) {
+            return QueryStatus.NOT_FOUND;
+        }
+
+        response = request.jsonStringToObject(rv);
+        if(response == null) {
+            return QueryStatus.NOT_FOUND;
+        }
+
+        if("generic-query".equals(resource)) {
+            SearchResults rd = SearchResults.class.cast(response);
+            List<ResultData> rdList = rd.getResultData();
+            if(rdList == null || rdList.isEmpty()) {
+                return QueryStatus.NOT_FOUND;
+            }
+            ResultData rDatum = rdList.get(0);
+            nameValues.put("selflink", rDatum.getResourceLink());
+            AAIRequest req2 = AAIRequest.createRequest(rDatum.getResourceType(), nameValues);
+            req2.processRequestPathValues(nameValues);
+            rv = getExecutor().get(req2);
             if(rv == null) {
                 return QueryStatus.NOT_FOUND;
             }
 
-            response = request.jsonStringToObject(rv);
+            response = req2.jsonStringToObject(rv);
             if(response == null) {
                 return QueryStatus.NOT_FOUND;
             }
+        }
 
-            if("generic-query".equals(resource)) {
-                SearchResults rd = SearchResults.class.cast(response);
-                List<ResultData> rdList = rd.getResultData();
-                if(rdList == null || rdList.isEmpty()) {
-                    return QueryStatus.NOT_FOUND;
-                }
-                ResultData rDatum = rdList.get(0);
-                nameValues.put("selflink", rDatum.getResourceLink());
-                AAIRequest req2 = AAIRequest.createRequest(rDatum.getResourceType(), nameValues);
-                req2.processRequestPathValues(nameValues);
-                rv = getExecutor().get(req2);
-                if(rv == null) {
-                    return QueryStatus.NOT_FOUND;
-                }
-
-                response = req2.jsonStringToObject(rv);
-                if(response == null) {
-                    return QueryStatus.NOT_FOUND;
-                }
-            }
-
-            if("named-query".equals(resource)) {
-                InventoryResponseItems rd = InventoryResponseItems.class.cast(response);
-                List<InventoryResponseItem> iRIlist = rd.getInventoryResponseItem();
-                if(iRIlist == null || iRIlist.isEmpty()) {
-                    return QueryStatus.NOT_FOUND;
-                }
-            }
-
-            if("nodes-query".equals(resource)) {
-                SearchResults rd = SearchResults.class.cast(response);
-                List<ResultData> rdList = rd.getResultData();
-                if(rdList == null || rdList.isEmpty()) {
-                    return QueryStatus.NOT_FOUND;
-                }
-                ResultData rDatum = rdList.get(0);
-                response = rDatum;
+        if("nodes-query".equals(resource)) {
+            SearchResults rd = SearchResults.class.cast(response);
+            List<ResultData> rdList = rd.getResultData();
+            if(rdList == null || rdList.isEmpty()) {
+                return QueryStatus.NOT_FOUND;
             }
+            ResultData rDatum = rdList.get(0);
+            response = rDatum;
+        }
 
         if("formatted-query".equals(resource) || "custom-query".equals(resource)) {
             FormattedQueryResultList rd = FormattedQueryResultList.class.cast(response);
@@ -882,93 +876,93 @@ public abstract class AAIDeclarations implements AAIClient {
                 AAIServiceUtils.populateRelationshipDataFromPath(list);
             }
         } catch(Exception exc) {
-            getLogger().debug("Retrofiting relationship data: " + exc.getMessage());
+            getLogger().debug(RELATIONSHIP_DATA + exc.getMessage());
         }
 
-            String preFix;
-            if(prefix == null || prefix.isEmpty()) {
-                preFix = "";
-            } else {
-                preFix = prefix + ".";
-            }
-
-            Map<String,Object> props = objectToProperties(response);
-            Set<String> keys = props.keySet();
-            for(String theKey: keys) {
-                if(getLogger().isTraceEnabled())
-                    getLogger().trace(theKey);
-
-                Object value = props.get(theKey);
-                if(value == null)
-                    continue;
-                Object type = value.getClass();
-                if(value instanceof String) {
-                    ctx.setAttribute(preFix + theKey, value.toString());
-                    continue;
-                }
-                if(value instanceof Boolean) {
-                    ctx.setAttribute(preFix + theKey, value.toString());
-                    continue;
-                }
-                if(value instanceof Integer) {
-                    ctx.setAttribute(preFix + theKey, value.toString());
-                    continue;
-                }
-                if(value instanceof Long) {
-                    ctx.setAttribute(preFix + theKey, value.toString());
-                    continue;
-                }
+        String preFix;
+        if(prefix == null || prefix.isEmpty()) {
+            preFix = "";
+        } else {
+            preFix = prefix + ".";
+        }
 
-                if(value instanceof ArrayList) {
-                    ArrayList<?> array = ArrayList.class.cast(value);
-                    for(int i = 0; i < array.size(); i++) {
-                        writeList(array, String.format("%s.%s", prefix, theKey), ctx);
-                    }
-                    continue;
+        Map<String,Object> props = objectToProperties(response);
+        Set<String> keys = props.keySet();
+        for(String theKey: keys) {
+            if(getLogger().isTraceEnabled())
+                getLogger().trace(theKey);
+
+            Object value = props.get(theKey);
+            if(value == null)
+                continue;
+            Object type = value.getClass();
+            if(value instanceof String) {
+                ctx.setAttribute(preFix + theKey, value.toString());
+                continue;
+            }
+            if(value instanceof Boolean) {
+                ctx.setAttribute(preFix + theKey, value.toString());
+                continue;
+            }
+            if(value instanceof Integer) {
+                ctx.setAttribute(preFix + theKey, value.toString());
+                continue;
+            }
+            if(value instanceof Long) {
+                ctx.setAttribute(preFix + theKey, value.toString());
+                continue;
+            }
+
+            if(value instanceof ArrayList) {
+                ArrayList<?> array = ArrayList.class.cast(value);
+                for(int i = 0; i < array.size(); i++) {
+                    writeList(array, String.format("%s.%s", prefix, theKey), ctx);
                 }
+                continue;
+            }
 
-                if("relationship-list".equals(theKey)){
-                    Map<String, Object> relationshipList = (Map<String, Object>)value;
-                    // we are interested in seeing just the selected relationship
-                    if(theKey.equals(modifier)) {
-                        List<?> relationships = (List<?>)relationshipList.get("relationship");
-                        if(relationships != null && !relationships.isEmpty()) {
-
-                            List newRelationships = new LinkedList();
-                            newRelationships.addAll(relationships);
-
-                            for(Object obj : newRelationships){
-                                if(obj instanceof Map<?, ?>) {
-                                    Map<?, ?> relProperties = (Map<?, ?>)obj;
-                                    if(relProperties.containsKey("related-to")) {
-                                        Object relPropsRelatedTo = relProperties.get("related-to");
-
-                                        String relatedTo = nameValues.get("related_to");
-                                        if(relatedTo != null) {
-                                            relatedTo = relatedTo.trim().replace("'", "").replace("$", "").replace("'", "");
-                                            if(!relatedTo.equals(relPropsRelatedTo)) {
-                                                relationships.remove(relProperties);
-                                            }
-                                            continue;
-                                        } else {
-                                            continue;
+            if("relationship-list".equals(theKey)){
+                Map<String, Object> relationshipList = (Map<String, Object>)value;
+                // we are interested in seeing just the selected relationship
+                if(theKey.equals(modifier)) {
+                    List<?> relationships = (List<?>)relationshipList.get("relationship");
+                    if(relationships != null && !relationships.isEmpty()) {
+
+                        List newRelationships = new LinkedList();
+                        newRelationships.addAll(relationships);
+
+                        for(Object obj : newRelationships){
+                            if(obj instanceof Map<?, ?>) {
+                                Map<?, ?> relProperties = (Map<?, ?>)obj;
+                                if(relProperties.containsKey("related-to")) {
+                                    Object relPropsRelatedTo = relProperties.get("related-to");
+
+                                    String relatedTo = nameValues.get("related_to");
+                                    if(relatedTo != null) {
+                                        relatedTo = relatedTo.trim().replace("'", "").replace("$", "").replace("'", "");
+                                        if(!relatedTo.equals(relPropsRelatedTo)) {
+                                            relationships.remove(relProperties);
                                         }
+                                        continue;
+                                    } else {
+                                        continue;
                                     }
                                 }
                             }
                         }
                     }
-                    writeMap(relationshipList, String.format("%s.%s", prefix, theKey), ctx);
-                    continue;
-                }
-
-                if(value instanceof Map) {
-                    Map<String, Object> subnetsList = (Map<String, Object>)value;
-                    writeMap(subnetsList, String.format("%s.%s", prefix, theKey), ctx);
-                    continue;
                 }
+                writeMap(relationshipList, String.format("%s.%s", prefix, theKey), ctx);
+                continue;
+            }
 
+            if(value instanceof Map) {
+                Map<String, Object> subnetsList = (Map<String, Object>)value;
+                writeMap(subnetsList, String.format("%s.%s", prefix, theKey), ctx);
+                continue;
             }
+
+        }
         return QueryStatus.SUCCESS;
     }
 
@@ -1003,6 +997,7 @@ public abstract class AAIDeclarations implements AAIClient {
             String rv = getExecutor().get(request);
             ctx.setAttribute(prefix, rv);
         } catch(AAIServiceException aaiexc) {
+            getLogger().warn(AAI_SERVICE_EXCEPTION, aaiexc);
             if(aaiexc.getReturnCode() == 404)
                 return QueryStatus.NOT_FOUND;
 
@@ -1081,11 +1076,11 @@ public abstract class AAIDeclarations implements AAIClient {
                             String id = AAIServiceUtils.camelCaseToDashedString(value);
                             Field field = resourceClass.getDeclaredField(value);
                             Class<?> type = field.getType();
-                            Method setter = null;
+
                             try {
-                                setter = resourceClass.getMethod("set"+StringUtils.capitalize(value), type);
                                 if(type.getName().startsWith("java.lang") || "boolean".equals(type.getName()) || "long".equals(type.getName()) || "int".equals(type.getName())) {
                                     try {
+                                        Method setter = resourceClass.getMethod("set"+StringUtils.capitalize(value), type);
                                         Object arglist[] = new Object[1];
                                         arglist[0] = params.get(id);
 
@@ -1133,15 +1128,30 @@ public abstract class AAIDeclarations implements AAIClient {
                                             newValues.add(tmpValue);
                                         }
                                         if(!newValues.isEmpty()) {
-                                            Object o = setter.invoke(instance, newValues);
+                                            Method setter = findSetterFor(resourceClass, value);
+                                            if(setter != null) {
+                                                Object o = setter.invoke(instance, newValues);
+                                            } else {
+                                            try {
+                                                Method listGetter = resourceClass.getMethod("get"+StringUtils.capitalize(value));
+                                                Object o = listGetter.invoke(instance);
+                                                if(o != null && o instanceof java.util.List ) {
+                                                    List innerList = List.class.cast(o);
+                                                    innerList.addAll(newValues);
+                                                }
+                                            } catch(NoSuchMethodException nsme) {
+                                                getLogger().warn(AAI_SERVICE_EXCEPTION, nsme);
+                                            }
+                                        }
                                         }
                                     }
                                     set.remove(id);
                                 } else {
+                                    Method setter = resourceClass.getMethod("set"+StringUtils.capitalize(value), type);
                                     setters.put(id, setter);
                                 }
                             } catch(Exception exc) {
-
+                                getLogger().warn(AAI_SERVICE_EXCEPTION, exc);
                             }
 
                             Method getter;
@@ -1150,8 +1160,19 @@ public abstract class AAIDeclarations implements AAIClient {
                                 if(!type.getName().equals("java.lang.String")) {
                                     getters.put(id, getter);
                                 }
+                            } catch(NoSuchMethodException exc) {
+                                try {
+                                    if(type.getName().equals("java.lang.Boolean")) {
+                                       getter = resourceClass.getMethod("is"+StringUtils.capitalize(value));
+                                        getters.put(id, getter);
+                                    } else {
+                                        getLogger().warn(AAI_SERVICE_EXCEPTION, exc);
+                                    }
+                                 } catch(Exception iexc) {
+                                     getLogger().warn(AAI_SERVICE_EXCEPTION, iexc);
+                                 }
                             } catch(Exception exc) {
-
+                                getLogger().warn(AAI_SERVICE_EXCEPTION, exc);
                             }
 
                         }
@@ -1194,7 +1215,6 @@ public abstract class AAIDeclarations implements AAIClient {
                             Object o = method.invoke(instance, arglist);
                             if(o instanceof ArrayList) {
                                 ArrayList<String> values = (ArrayList<String>)o;
-//                                getLogger().debug(String.format("Processing %s with parameter %s", types[0].getName(), value));
                                 value = value.replace("[", "").replace("]", "");
                                 List<String> items = Arrays.asList(value.split("\\s*,\\s*"));
                                 for(String s : items) {
@@ -1215,9 +1235,9 @@ public abstract class AAIDeclarations implements AAIClient {
                 Object obj = null;
                 Method getRelationshipListMethod = null;
                 try {
-                     getRelationshipListMethod = resourceClass.getMethod("getRelationshipList");
+                    getRelationshipListMethod = resourceClass.getMethod("getRelationshipList");
                 } catch(Exception exc) {
-                    getLogger().debug("Retrofiting relationship data: " + exc.getMessage());
+                    getLogger().debug(RELATIONSHIP_DATA + exc.getMessage());
                 }
 
                 if(getRelationshipListMethod != null){
@@ -1268,7 +1288,7 @@ public abstract class AAIDeclarations implements AAIClient {
                     getLogger().debug("About to process related link of {}", relatedLink);
                     if(relatedLink != null) {
                         if(relatedLink.contains("v$"))
-                            relatedLink = relatedLink.replace(VERSION_PATTERN, "/v14/");
+                            relatedLink = relatedLink.replace(VERSION_PATTERN, "/v21/");
                         relationship.setRelatedLink(relatedLink);
                     } else {
                         Map<String, String> relParams = new HashMap<>();
@@ -1276,10 +1296,10 @@ public abstract class AAIDeclarations implements AAIClient {
                         while(true) {
                             String searchRelationshipKey = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-key";
                             String searchRelationshipValue = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-value";
-                                if(!params.containsKey(searchRelationshipKey))
+                            if(!params.containsKey(searchRelationshipKey))
                                 break;
 
-                                relParams.put(params.get(searchRelationshipKey), params.get(searchRelationshipValue));
+                            relParams.put(params.get(searchRelationshipKey), params.get(searchRelationshipValue));
                             j++;
                         }
                         AAIRequest rlRequest = AAIRequest.createRequest(relatedTo, relParams);
@@ -1358,18 +1378,18 @@ public abstract class AAIDeclarations implements AAIClient {
                     vlan.setVlanInterface(vlanInterface);
 
                     if(vlanIdInner != null) {
-                    Long iVlanIdInner = Long.parseLong(vlanIdInner);
-                    vlan.setVlanIdInner(iVlanIdInner);
+                        Long iVlanIdInner = Long.parseLong(vlanIdInner);
+                        vlan.setVlanIdInner(iVlanIdInner);
                     }
 
                     if(vlanIdOute != null) {
                         Long iVlanIdOuter = Long.parseLong(vlanIdOute);
-                    vlan.setVlanIdOuter(iVlanIdOuter);
+                        vlan.setVlanIdOuter(iVlanIdOuter);
                     }
 
                     if(speedValue != null) {
-                    vlan.setSpeedValue(speedValue);
-                    vlan.setSpeedUnits(speedUnits);
+                        vlan.setSpeedValue(speedValue);
+                        vlan.setSpeedUnits(speedUnits);
                     }
 
                     vlanList.getVlan().add(vlan);
@@ -1439,15 +1459,15 @@ public abstract class AAIDeclarations implements AAIClient {
 
             request.processRequestPathValues(nameValues);
             request.setRequestObject(instance);
-                Object response = getExecutor().post(request);
-                if(request.expectsDataFromPUTRequest()){
-                    if(response != null && response instanceof String) {
-                        String rv = response.toString();
-                        QueryStatus retval = processResponseData(rv, resource, request, prefix,  ctx, nameValues, null);
-                        getLogger().debug("newModelSave - returning " + retval.toString());
-                        return retval;
-                    }
+            Object response = getExecutor().post(request);
+            if(request.expectsDataFromPUTRequest()){
+                if(response != null && response instanceof String) {
+                    String rv = response.toString();
+                    QueryStatus retval = processResponseData(rv, resource, request, prefix,  ctx, nameValues, null);
+                    getLogger().debug("newModelSave - returning " + retval.toString());
+                    return retval;
                 }
+            }
 
         } catch(AAIServiceException exc){
             ctx.setAttribute(prefix + ".error.message", exc.getMessage());
@@ -1475,6 +1495,21 @@ public abstract class AAIDeclarations implements AAIClient {
         return QueryStatus.SUCCESS;
     }
 
+    private Method findSetterFor(Class<? extends AAIDatum> resourceClass, String value) {
+        try {
+            String setterName = "set"+StringUtils.capitalize(value);
+            for (Method method : resourceClass.getDeclaredMethods()) {
+                int modifiers = method.getModifiers();
+                if (Modifier.isPublic(modifiers) && setterName.contentEquals(method.getName())) {
+                    return method;
+                }
+            }
+        } catch(Exception exc) {
+             getLogger().warn("findSetterFor()", exc);
+        }
+        return null;
+    }
+
     private QueryStatus newModelProcessRelationshipList(Object instance, Map<String, String> params, String prefix, SvcLogicContext ctx) throws Exception {
 
         Class resourceClass = instance.getClass();
@@ -1498,9 +1533,9 @@ public abstract class AAIDeclarations implements AAIClient {
             Object obj = null;
             Method getRelationshipListMethod = null;
             try {
-                 getRelationshipListMethod = resourceClass.getMethod("getRelationshipList");
+                getRelationshipListMethod = resourceClass.getMethod("getRelationshipList");
             } catch(Exception exc) {
-                getLogger().debug("Retrofiting relationship data: " + exc.getMessage());
+                getLogger().debug(RELATIONSHIP_DATA + exc.getMessage());
             }
             if(getRelationshipListMethod != null){
                 try {
@@ -1621,7 +1656,7 @@ public abstract class AAIDeclarations implements AAIClient {
         }
 
         Class resourceClass = instance.getClass();
-        Set<String> metadataKeys = new TreeSet<String>();
+        Set<String> metadataKeys = new TreeSet<>();
         Set<String> set = params.keySet();
         for(String attribute : set) {
             if(attribute.startsWith("metadata")) {
@@ -1787,9 +1822,9 @@ public abstract class AAIDeclarations implements AAIClient {
             Object obj = null;
             Method getRelationshipListMethod = null;
             try {
-                 getRelationshipListMethod = resourceClass.getMethod("getRelationshipList");
+                getRelationshipListMethod = resourceClass.getMethod("getRelationshipList");
             } catch(Exception exc) {
-                getLogger().debug("Retrofiting relationship data: " + exc.getMessage());
+                getLogger().debug(RELATIONSHIP_DATA + exc.getMessage());
             }
             if(getRelationshipListMethod != null){
                 try {
@@ -1832,14 +1867,14 @@ public abstract class AAIDeclarations implements AAIClient {
                             if(localRelatedLink.endsWith(relatedLink)) {
                                 getLogger().debug(String.format("Found relationship of '%s' to keyword '%s'", relationship.getRelatedTo(),  relatedTo));
                                 relationshipsToDelete.add(relationship);
+                            }
                         }
-                    }
                     } else {
-                    getLogger().debug(String.format("Found relationship of '%s' to keyword '%s'", relationship.getRelatedTo(),  relatedTo));
-                    relationshipsToDelete.add(relationship);
+                        getLogger().debug(String.format("Found relationship of '%s' to keyword '%s'", relationship.getRelatedTo(),  relatedTo));
+                        relationshipsToDelete.add(relationship);
+                    }
                 }
             }
-            }
             if(relationshipsToDelete == null || relationshipsToDelete.isEmpty()) {
                 getLogger().info(String.format("Relationship has not been found for %s", key));
                 return QueryStatus.NOT_FOUND;
@@ -2001,114 +2036,6 @@ public abstract class AAIDeclarations implements AAIClient {
         return prefixMap;
     }
 
-    /**
-    */
-    protected NamedQueryData extractNamedQueryDataFromQueryPrefix(HashMap<String, String> nameValues, Map<String, String> parms) {
-        if(parms.isEmpty()) {
-            return null;
-        }
-
-        NamedQueryData data = new NamedQueryData();
-
-        // query parameters
-        if(data.getQueryParameters() == null) {
-            data.setQueryParameters(new QueryParameters());
-        }
-        String namedQueryUuid = nameValues.get("named-query-uuid".replaceAll("-", "_"));
-        if(namedQueryUuid == null) {
-            namedQueryUuid = parms.get("query-parameters.named-query.named-query-uuid");
-        }
-        NamedQuery namedQuery = new NamedQuery();
-        namedQuery.setNamedQueryUuid(namedQueryUuid);
-        data.getQueryParameters().setNamedQuery(namedQuery);
-
-        // instance filters
-        if(data.getInstanceFilters() == null) {
-            data.setInstanceFilters(new InstanceFilters());
-        }
-
-
-        String quantity = parms.get("instance-filters.instance-filter_length");
-        if(quantity != null && StringUtils.isNumeric(quantity)) {
-            int max = Integer.parseInt(quantity);
-            for(int i = 0; i < max; i++) {
-                String keyPattern = String.format("instance-filters.instance-filter[%d].", i);
-                Set<String> keys = parms.keySet();
-                for(String key: keys) {
-                    if(key.startsWith(keyPattern)){
-                        String value = parms.get(key);
-                        String remainder = key.substring(keyPattern.length());
-                        String[] split = remainder.split("\\.");
-                        getLogger().debug(String.format("%s", remainder));
-                        if("logical-link".equals(split[0])) {
-                            InstanceFilter insf = null;
-                            if(data.getInstanceFilters().getInstanceFilter().isEmpty()) {
-                                insf = new InstanceFilter();
-                                data.getInstanceFilters().getInstanceFilter().add(insf);
-                            } else {
-                                insf = data.getInstanceFilters().getInstanceFilter().get(0);
-                            }
-                            LogicalLink logicalLink = insf.getLogicalLink();
-                            if(logicalLink == null) {
-                                logicalLink = new LogicalLink();
-                                insf.setLogicalLink(logicalLink);
-                            }
-
-                            switch(split[1]) {
-                            case "link-name":
-                                logicalLink.setLinkName(value);
-                                break;
-                            case "link-type":
-                                logicalLink.setLinkType(value);
-                                break;
-                            case "operational-state":
-                                logicalLink.setOperationalStatus(value);
-                                break;
-                            }
-
-                        } else if("pnf".equals(split[0])) {
-                            Pnf pnf = new Pnf();
-                            pnf.setPnfName(value);
-
-                            InstanceFilter insf = new InstanceFilter();
-                            insf.setPnf(pnf);
-                            data.getInstanceFilters().getInstanceFilter().add(insf);
-
-                        } else if("service-instance".equals(split[0])) {
-                            ServiceInstance serviceInstance = new ServiceInstance();
-                            serviceInstance.setServiceInstanceId(value);
-
-                            InstanceFilter insf = new InstanceFilter();
-                            insf.setServiceInstance(serviceInstance);
-                            data.getInstanceFilters().getInstanceFilter().add(insf);
-
-                        } else if("l3-network".equals(split[0])) {
-                            L3Network l3Network = new L3Network();
-                            if("network-role".equals(split[1])) {
-                                l3Network.setNetworkRole(value);
-                            }
-
-                            InstanceFilter insf = new InstanceFilter();
-                            insf.setL3Network(l3Network);
-                            data.getInstanceFilters().getInstanceFilter().add(insf);
-                        } else if("generic-vnf".equals(split[0])) {
-                            GenericVnf vnf = new GenericVnf();
-                            if("vnf-id".equals(split[1])) {
-                                vnf.setVnfId(value);
-                            }
-
-                            InstanceFilter insf = new InstanceFilter();
-                            insf.setGenericVnf(vnf);
-                            data.getInstanceFilters().getInstanceFilter().add(insf);
-                        }
-                    }
-                }
-            }
-        }
-
-        return data;
-    }
-
     public abstract <T> T getResource(String key, Class<T> type) throws AAIServiceException ;
     protected abstract boolean deleteList(URL url, String caller) throws AAIServiceException;
 }