summaryrefslogtreecommitdiffstats
path: root/appc-provider/appc-provider-bundle/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorprashank <prashant.kumar1@amdocs.com>2017-11-07 17:37:57 +0530
committerPatrick Brady <pb071s@att.com>2017-11-20 18:38:45 +0000
commit0f08ee5a5334a9e4581719f8f3ca2042e9e84edc (patch)
tree314d4def45c83d813de1a0609204d1d3ef5f2326 /appc-provider/appc-provider-bundle/src/main/java/org/openecomp
parent52d9122c0e36a2b7488eff2d8eaa8f9edaf84338 (diff)
Actionlevel used to identify valid requestHandler
Change-Id: I7fbcf10321a5f2c169ebf018a60be1a44b719bf8 Issue-Id: APPC-312 Signed-off-by: prashank <prashant.kumar1@amdocs.com>
Diffstat (limited to 'appc-provider/appc-provider-bundle/src/main/java/org/openecomp')
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java33
1 files changed, 21 insertions, 12 deletions
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java
index 7d321989f..0ce877838 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java
@@ -122,6 +122,7 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.openecomp.appc.Constants;
import org.openecomp.appc.configuration.Configuration;
import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.domainmodel.lcm.ActionLevel;
import org.openecomp.appc.domainmodel.lcm.ResponseContext;
import org.openecomp.appc.exceptions.APPCException;
import org.openecomp.appc.executor.objects.LCMCommandStatus;
@@ -136,12 +137,14 @@ import org.openecomp.appc.requesthandler.objects.RequestHandlerInput;
import org.openecomp.appc.requesthandler.objects.RequestHandlerOutput;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import java.text.ParseException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import java.util.Collection;
public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
@@ -528,19 +531,25 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
return requestHandlerOutput;
}
- private RequestHandler getRequestHandler(){
+ private RequestHandler getRequestHandler(ActionLevel actionLevel){
final BundleContext context = FrameworkUtil.getBundle(RequestHandler.class).getBundleContext();
- if (context == null) {
- return null;
- }
-
- final ServiceReference reference = context.getServiceReference(RequestHandler.class.getName());
- if (reference == null) {
- logger.error("Cannot find service reference for " + RequestHandler.class.getName());
- throw new RuntimeException();
+ if (context != null) {
+ String filter = null;
+ try {
+ filter = "(level=" + actionLevel.name() + ")";
+ Collection<ServiceReference<RequestHandler>> serviceReferences = context.getServiceReferences(RequestHandler.class, filter);
+ if (serviceReferences.size() != 1) {
+ logger.error("Cannot find service reference for " + RequestHandler.class.getName());
+ throw new RuntimeException();
+ }
+ ServiceReference<RequestHandler> serviceReference = serviceReferences.iterator().next();
+ return context.getService(serviceReference);
+ } catch (InvalidSyntaxException e) {
+ logger.error("Cannot find service reference for " + RequestHandler.class.getName() + ": Invalid Syntax " + filter, e);
+ throw new RuntimeException(e);
+ }
}
-
- return (RequestHandler) context.getService(reference);
+ return null;
}
@Override
@@ -1179,7 +1188,7 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
}
RequestHandlerOutput executeRequest(RequestHandlerInput request){
- RequestHandler handler = getRequestHandler();
+ RequestHandler handler = getRequestHandler(request.getRequestContext().getActionLevel());
RequestHandlerOutput requestHandlerOutput;
if (handler != null) {
try {