X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=appc-dg-util%2Fappc-dg-util-bundle%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Fdg%2Futil%2Fimpl%2FExecuteNodeActionImpl.java;h=d2aa68a149bacc7baa3c5303968a578eda5a3902;hb=ed13e1b0270932ba8bbfa7b51c84b4b88894e061;hp=9e21d75de827da69b4cc19add3a79bb6884a0fca;hpb=e35c3a0387e68bbeb3df8c5d614e0b99f5c4f743;p=appc.git diff --git a/appc-dg-util/appc-dg-util-bundle/src/main/java/org/onap/appc/dg/util/impl/ExecuteNodeActionImpl.java b/appc-dg-util/appc-dg-util-bundle/src/main/java/org/onap/appc/dg/util/impl/ExecuteNodeActionImpl.java index 9e21d75de..d2aa68a14 100644 --- a/appc-dg-util/appc-dg-util-bundle/src/main/java/org/onap/appc/dg/util/impl/ExecuteNodeActionImpl.java +++ b/appc-dg-util/appc-dg-util-bundle/src/main/java/org/onap/appc/dg/util/impl/ExecuteNodeActionImpl.java @@ -5,7 +5,9 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs - * ============================================================================= + * ================================================================================ + * Modifications Copyright (C) 2018 Nokia + * ================================================================================ * 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 @@ -35,14 +37,9 @@ import java.util.concurrent.ConcurrentHashMap; import org.onap.appc.dg.util.ExecuteNodeAction; import org.onap.appc.exceptions.APPCException; import org.onap.appc.i18n.Msg; -import org.onap.ccsdk.sli.adaptors.aai.AAIClient; -import org.onap.ccsdk.sli.adaptors.aai.AAIService; 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.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; public class ExecuteNodeActionImpl implements ExecuteNodeAction { @@ -63,30 +60,10 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction { private static final String RELATED_TO_PROPERTY_LEN_PARAM = "related-to-property_length"; public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message"; - private AAIService aaiService; - protected AAIClient client; - - public ExecuteNodeActionImpl() { /*default constructor*/} - - /** - * initialize the SDNC adapter (AAIService) by building the context. - */ - private void initialize() { - getAAIservice(); - } - - private void getAAIservice() { - BundleContext bctx = FrameworkUtil.getBundle(AAIService.class).getBundleContext(); - // Get AAIadapter reference - ServiceReference sref = bctx.getServiceReference(AAIService.class.getName()); - if (sref != null) { - logger.info("AAIService from bundlecontext"); - aaiService = (AAIService) bctx.getService(sref); + private AAIServiceFactory aaiServiceFactory; - } else { - logger.info("AAIService error from bundlecontext"); - logger.error(EELFResourceManager.format(Msg.AAI_CONNECTION_FAILED, "AAIService")); - } + public ExecuteNodeActionImpl(AAIServiceFactory aaiServiceFactory) { + this.aaiServiceFactory = aaiServiceFactory; } /** @@ -110,7 +87,6 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction { @Override public void getResource(Map params, SvcLogicContext ctx) throws APPCException { - initialize(); String resourceType = params.get(RESOURCE_TYPE_PARAM); String ctxPrefix = params.get(PREFIX_PARAM); String resourceKey = params.get(RESOURCE_KEY_PARAM); @@ -119,10 +95,10 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction { logger.debug("inside getResorce"); logger.debug("Retrieving " + resourceType + " details from A&AI for Key : " + resourceKey); } - client = aaiService; + try { SvcLogicResource.QueryStatus response = - client.query(resourceType, false, null, resourceKey, ctxPrefix, null, ctx); + aaiServiceFactory.getAAIService().query(resourceType, false, null, resourceKey, ctxPrefix, null, ctx); logger.info(AAI_RESPONSE_STR + response.toString()); ctx.setAttribute(GET_RESOURCE_RESULT, response.toString()); } catch (SvcLogicException e) { @@ -136,7 +112,6 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction { @Override public void postResource(Map params, SvcLogicContext ctx) throws APPCException { - initialize(); String resourceType = params.get(RESOURCE_TYPE_PARAM); String ctxPrefix = params.get(PREFIX_PARAM); String resourceKey = params.get(RESOURCE_KEY_PARAM); @@ -149,10 +124,10 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction { } Map data = new HashMap<>(); data.put(attName, attValue); - client = aaiService; try { - SvcLogicResource.QueryStatus response = client.update(resourceType, resourceKey, data, ctxPrefix, ctx); + SvcLogicResource.QueryStatus response = aaiServiceFactory.getAAIService() + .update(resourceType, resourceKey, data, ctxPrefix, ctx); logger.info(AAI_RESPONSE_STR + response.toString()); ctx.setAttribute("postResource_result", response.toString()); } catch (SvcLogicException e) { @@ -166,7 +141,6 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction { @Override public void deleteResource(Map params, SvcLogicContext ctx) throws APPCException { - initialize(); String resourceType = params.get(RESOURCE_TYPE_PARAM); String resourceKey = params.get(RESOURCE_KEY_PARAM); @@ -174,9 +148,10 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction { logger.debug("inside deleteResource"); logger.debug("Deleting " + resourceType + " details From A&AI for Key : " + resourceKey); } - client = aaiService; + try { - SvcLogicResource.QueryStatus response = client.delete(resourceType, resourceKey, ctx); + SvcLogicResource.QueryStatus response = aaiServiceFactory.getAAIService() + .delete(resourceType, resourceKey, ctx); logger.info(AAI_RESPONSE_STR + response.toString()); ctx.setAttribute("deleteResource_result", response.toString()); } catch (SvcLogicException e) { @@ -360,7 +335,7 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction { return 0; } - private void populateVnfcsDetailsinContext(Map> vnfcHierarchyMap, SvcLogicContext ctx) + void populateVnfcsDetailsinContext(Map> vnfcHierarchyMap, SvcLogicContext ctx) throws APPCException { SvcLogicContext vnfcCtx = new SvcLogicContext(); int vnfcCounter = 0;