fix bug for readResource in AAI 02/77802/7
authorNeha Sood <ns189k@att.com>
Mon, 4 Feb 2019 17:24:37 +0000 (12:24 -0500)
committerPatrick Brady <patrick.brady@att.com>
Wed, 6 Feb 2019 21:33:32 +0000 (21:33 +0000)
fix bug for readResource in AaiService

Change-Id: I20a6564f3bbc16ab5deb3e0e40a75a105343965d
Issue-ID: APPC-1379
Signed-off-by: Neha Sood <ns189k@att.com>
appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java
appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java
appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/MockAaiService.java

index a25013f..4e1da8a 100644 (file)
@@ -644,8 +644,10 @@ public class AaiService {
         SvcLogicResource.QueryStatus response =
             aaiClient.query(resourceType, false, null, query, prefix, null, resourceContext);
         log.info("AAIResponse: " + response.toString());
-        if (!SvcLogicResource.QueryStatus.SUCCESS.equals(response)) {
-            throw new AaiServiceInternalException("Error Retrieving " + resourceType + " from A&AI");
+        if (resourceType==null || !resourceType.equals("cloud-region")) {
+            if (!SvcLogicResource.QueryStatus.SUCCESS.equals(response)) {
+                throw new AaiServiceInternalException("Error Retrieving " + resourceType + " from A&AI");
+            }
         }
         return resourceContext;
     }
@@ -781,6 +783,7 @@ public class AaiService {
         String resourceType = "cloud-region";
         SvcLogicContext urlCtx = readResource(resourceKey, queryPrefix, resourceType);
         log.info("IdentityUrl: "+urlCtx.getAttribute("urlInfo.identity-url"));
+        log.info("Prefix for getIdentityUrl: "+prefix+"cloud-region.identity-url");
         ctx.setAttribute(prefix+"cloud-region.identity-url", urlCtx.getAttribute("urlInfo.identity-url"));
  
     }
index 5a95e6e..da44f34 100644 (file)
@@ -86,6 +86,7 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
 
             log.debug("Cloud Owner" + cloudOwnerValue);
             log.debug("CloudRegionId" + cloudOwnerValue);
+            SvcLogicContext cloudCtx = new SvcLogicContext();
             Map<String, String> paramsCloud = new HashMap<>();
             paramsCloud.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
                     inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
@@ -156,11 +157,11 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
                 vserverMap.put("tenant-id", ctx.getAttribute(responsePrefix + "vm[" + i + STR_TENANT_ID));
                 vserverMap.put("cloud-owner", ctx.getAttribute(responsePrefix + "vm[" + i + STR_CLOUD_OWNER));
                 vserverMap.put("cloud-region-id", ctx.getAttribute(responsePrefix + "vm[" + i + STR_CLOUD_REGION_ID));
-
+                
                 // Parameters returned by getVMInfo
                 vserverMap.put(PARAM_VSERVER_NAME, vmServerCtx.getAttribute(responsePrefix + "vm.vserver-name"));
                 vserverMap.put("vf-module-id", vmServerCtx.getAttribute(responsePrefix + "vm.vf-module-id"));
-                vserverMap.put(PARAM_VSERVER_SELFLINK, vmServerCtx.getAttribute(responsePrefix + "vm.vserver-selflink"));
+                vserverMap.put("vserver-selflink", vmServerCtx.getAttribute(responsePrefix + "vm.vserver-selflink"));
 
                 log.info("VSERVER-LINK VALUE:" + vmServerCtx.getAttribute(responsePrefix + "vm.vserver-selflink"));
 
@@ -512,7 +513,7 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
         return params;
     }
 
-    public void getVfModuleModelInfo(Map<String, String> inParams, SvcLogicContext ctx) {
+    public void getVfModuleModelInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
         log.info("vfModuleInfo()::Retrieving vf-module information :" + inParams.toString());
         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
         try {
@@ -572,7 +573,7 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
 
     }
 
-    public void getFormattedValue(Map<String, String> inParams, SvcLogicContext ctx) {
+    public void getFormattedValue(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
         log.info("getFormattedValue()::Formatting values :" + inParams.toString());
         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
         try {
index 1f6cd65..9a4adef 100644 (file)
@@ -31,14 +31,12 @@ import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.onap.appc.aai.client.AppcAaiClientConstant;
-//import org.onap.appc.aai.client.aai.AAIClientMock;
 import org.onap.appc.aai.client.aai.AaiService;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
 import org.onap.ccsdk.sli.adaptors.aai.AAIClient;
 
 public class MockAaiService extends AaiService {