9e6e59391b140fe138744dc6f84f6d8fa308586d
[ccsdk/features.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                      reserved.
7  * Modifications Copyright (C) 2020 Nordix Foundation.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.ccsdk.features.sdnr.northbound.a1Adapter;
24
25 import com.google.common.util.concurrent.Futures;
26 import com.google.common.util.concurrent.ListenableFuture;
27 import java.util.Properties;
28 import java.util.concurrent.ExecutorService;
29 import java.util.concurrent.Executors;
30 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
31 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
32 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
33 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
34 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
35 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.A1ADAPTERAPIService;
36 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceInput;
37 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceInputBuilder;
38 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceOutput;
39 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceOutputBuilder;
40 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeInput;
41 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeInputBuilder;
42 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeOutput;
43 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeOutputBuilder;
44 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceInput;
45 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceInputBuilder;
46 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceOutput;
47 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceOutputBuilder;
48 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeInput;
49 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeInputBuilder;
50 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeOutput;
51 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeOutputBuilder;
52 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckInput;
53 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckInputBuilder;
54 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckOutput;
55 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckOutputBuilder;
56 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsInput;
57 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsInputBuilder;
58 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsOutput;
59 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsOutputBuilder;
60 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceInput;
61 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceInputBuilder;
62 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceOutput;
63 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceOutputBuilder;
64 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesInput;
65 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesInputBuilder;
66 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesOutput;
67 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesOutputBuilder;
68 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeInput;
69 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeInputBuilder;
70 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeOutput;
71 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeOutputBuilder;
72 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesInput;
73 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesInputBuilder;
74 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesOutput;
75 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesOutputBuilder;
76 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusInput;
77 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusInputBuilder;
78 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusOutput;
79 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusOutputBuilder;
80 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateInput;
81 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateInputBuilder;
82 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateOutput;
83 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateOutputBuilder;
84 import org.opendaylight.yangtools.concepts.Builder;
85 import org.opendaylight.yangtools.yang.common.RpcResult;
86 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
87 import org.slf4j.Logger;
88 import org.slf4j.LoggerFactory;
89
90 /**
91  * Defines a base implementation for your provider. This class extends from a helper class which
92  * provides storage for the most commonly used components of the MD-SAL. Additionally the base class
93  * provides some basic logging and initialization / clean up methods.
94  *
95  */
96 public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService {
97
98     private static final Logger LOG = LoggerFactory.getLogger(A1AdapterProvider.class);
99
100     private static final String APPLICATION_NAME = "a1Adapter-api";
101     private static final String GET_NEARRT_RICS = "getNearRT-RICs";
102     private static final String GET_HEALTH_CHECK = "getHealthCheck";
103     private static final String GET_POLICY_TYPES = "getPolicyTypes";
104     private static final String CREATE_POLICY_TYPE = "createPolicyType";
105     private static final String GET_POLICY_TYPE = "getPolicyType";
106     private static final String DELETE_POLICY_TYPE = "deletePolicyType";
107     private static final String GET_POLICY_INSTANCES = "getPolicyInstances";
108     private static final String CREATE_POLICY_INSTANCES = "createPolicyInstance";
109     private static final String GET_POLICY_INSTANCE = "getPolicyInstance";
110     private static final String DELETE_POLICY_INSTANCE = "deletePolicyInstance";
111     private static final String GET_STATUS = "getStatus";
112     private static final String NOTIFICATION_ENFORECEMENT = "notifyPolicyEnforcementUpdate";
113
114     private final ExecutorService executor;
115     protected DataBroker dataBroker;
116     protected NotificationPublishService notificationService;
117     protected RpcProviderRegistry rpcRegistry;
118     protected BindingAwareBroker.RpcRegistration<A1ADAPTERAPIService> rpcRegistration;
119     private final A1AdapterClient A1AdapterClient;
120
121     public A1AdapterProvider(final DataBroker dataBroker, final NotificationPublishService notificationPublishService,
122             final RpcProviderRegistry rpcProviderRegistry, final A1AdapterClient A1AdapterClient) {
123
124         LOG.info("Creating provider for {}", APPLICATION_NAME);
125         executor = Executors.newFixedThreadPool(1);
126         this.dataBroker = dataBroker;
127         this.notificationService = notificationPublishService;
128         this.rpcRegistry = rpcProviderRegistry;
129         this.A1AdapterClient = A1AdapterClient;
130         initialize();
131     }
132
133     public void initialize() {
134         LOG.info("Initializing provider for {}", APPLICATION_NAME);
135         rpcRegistration = rpcRegistry.addRpcImplementation(A1ADAPTERAPIService.class, this);
136         LOG.info("Initialization complete for {}", APPLICATION_NAME);
137     }
138
139     protected void initializeChild() {
140         // Override if you have custom initialization intelligence
141     }
142
143     @Override
144     public void close() throws Exception {
145         LOG.info("Closing provider for {}", APPLICATION_NAME);
146         executor.shutdown();
147         rpcRegistration.close();
148         LOG.info("Successfully closed provider for {}", APPLICATION_NAME);
149     }
150
151     // RPC getNearRT-RICs
152
153     @Override
154     public ListenableFuture<RpcResult<GetNearRTRICsOutput>> getNearRTRICs(GetNearRTRICsInput input) {
155         final String svcOperation = "getNearRT-RICs";
156
157         Properties parms = new Properties();
158         GetNearRTRICsOutputBuilder serviceDataBuilder = (GetNearRTRICsOutputBuilder) getServiceData(GET_NEARRT_RICS);
159
160         LOG.info("Reached RPC getNearRT-RICs");
161
162         LOG.info(svcOperation + " called.");
163
164         if (input == null) {
165             LOG.debug("exiting " + svcOperation + " because of invalid input");
166             serviceDataBuilder.setResponseCode("Input is null");
167             RpcResult<GetNearRTRICsOutput> rpcResult =
168                     RpcResultBuilder.<GetNearRTRICsOutput>status(true).withResult(serviceDataBuilder.build()).build();
169             return Futures.immediateFuture(rpcResult);
170         }
171
172         // add input to parms
173         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
174         GetNearRTRICsInputBuilder inputBuilder = new GetNearRTRICsInputBuilder(input);
175         MdsalHelper.toProperties(parms, inputBuilder.build());
176
177         LOG.info("Printing SLI parameters to be passed");
178
179         // iterate properties file to get key-value pairs
180         for (String key : parms.stringPropertyNames()) {
181             String value = parms.getProperty(key);
182             LOG.info("The SLI parameter in " + key + " is: " + value);
183         }
184
185         // Call SLI sync method
186         try {
187             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
188                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
189                 try {
190                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
191                 } catch (Exception e) {
192                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
193                     serviceDataBuilder.setResponseCode("500");
194                 }
195             } else {
196                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
197                 serviceDataBuilder.setResponseCode("503");
198             }
199         } catch (Exception e) {
200             LOG.error("Caught exception looking for service logic", e);
201             serviceDataBuilder.setResponseCode("500");
202         }
203
204         String errorCode = serviceDataBuilder.getResponseCode();
205
206         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
207             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
208         } else {
209             LOG.info("Returned SUCCESS for " + svcOperation + " ");
210             serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetNearRTRICs ");
211         }
212
213         RpcResult<GetNearRTRICsOutput> rpcResult =
214                 RpcResultBuilder.<GetNearRTRICsOutput>status(true).withResult(serviceDataBuilder.build()).build();
215
216         LOG.info("Successful exit from getNearRT-RICs ");
217
218         return Futures.immediateFuture(rpcResult);
219     }
220
221     // RPC getHealthCheck
222
223     @Override
224     public ListenableFuture<RpcResult<GetHealthCheckOutput>> getHealthCheck(GetHealthCheckInput input) {
225         final String svcOperation = "getHealthCheck";
226
227         Properties parms = new Properties();
228         GetHealthCheckOutputBuilder serviceDataBuilder = (GetHealthCheckOutputBuilder) getServiceData(GET_HEALTH_CHECK);
229
230         LOG.info("Reached RPC getHealthCheck");
231
232         LOG.info(svcOperation + " called.");
233
234         if (input == null) {
235             LOG.debug("exiting " + svcOperation + " because of invalid input");
236             serviceDataBuilder.setResponseCode("Input is null");
237             RpcResult<GetHealthCheckOutput> rpcResult =
238                     RpcResultBuilder.<GetHealthCheckOutput>status(true).withResult(serviceDataBuilder.build()).build();
239             return Futures.immediateFuture(rpcResult);
240         }
241
242         // add input to parms
243         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
244         GetHealthCheckInputBuilder inputBuilder = new GetHealthCheckInputBuilder(input);
245         MdsalHelper.toProperties(parms, inputBuilder.build());
246
247         LOG.info("Printing SLI parameters to be passed");
248
249         // iterate properties file to get key-value pairs
250         for (String key : parms.stringPropertyNames()) {
251             String value = parms.getProperty(key);
252             LOG.info("The SLI parameter in " + key + " is: " + value);
253         }
254
255         // Call SLI sync method
256         try {
257             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
258                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
259                 try {
260                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
261                 } catch (Exception e) {
262                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
263                     serviceDataBuilder.setResponseCode("500");
264                 }
265             } else {
266                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
267                 serviceDataBuilder.setResponseCode("503");
268             }
269         } catch (Exception e) {
270             LOG.error("Caught exception looking for service logic", e);
271             serviceDataBuilder.setResponseCode("500");
272         }
273
274         String errorCode = serviceDataBuilder.getResponseCode();
275
276         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
277             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
278         } else {
279             LOG.info("Returned SUCCESS for " + svcOperation + " ");
280             serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetHealthCheck. ");
281         }
282
283         RpcResult<GetHealthCheckOutput> rpcResult =
284                 RpcResultBuilder.<GetHealthCheckOutput>status(true).withResult(serviceDataBuilder.build()).build();
285
286         LOG.info("Successful exit from getHealthCheck ");
287
288         return Futures.immediateFuture(rpcResult);
289     }
290
291     // RPC getPolicyTypes
292
293     @Override
294     public ListenableFuture<RpcResult<GetPolicyTypesOutput>> getPolicyTypes(GetPolicyTypesInput input) {
295         final String svcOperation = "getPolicyTypes";
296
297         Properties parms = new Properties();
298         GetPolicyTypesOutputBuilder serviceDataBuilder = (GetPolicyTypesOutputBuilder) getServiceData(GET_POLICY_TYPES);
299
300         LOG.info("Reached RPC getPolicyTypes");
301
302         LOG.info(svcOperation + " called.");
303
304         if (input == null) {
305             LOG.debug("exiting " + svcOperation + " because of invalid input");
306             serviceDataBuilder.setResponseCode("Input is null");
307             RpcResult<GetPolicyTypesOutput> rpcResult =
308                     RpcResultBuilder.<GetPolicyTypesOutput>status(true).withResult(serviceDataBuilder.build()).build();
309             return Futures.immediateFuture(rpcResult);
310         }
311
312         // add input to parms
313         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
314         GetPolicyTypesInputBuilder inputBuilder = new GetPolicyTypesInputBuilder(input);
315         MdsalHelper.toProperties(parms, inputBuilder.build());
316
317         LOG.info("Printing SLI parameters to be passed");
318
319         // iterate properties file to get key-value pairs
320         for (String key : parms.stringPropertyNames()) {
321             String value = parms.getProperty(key);
322             LOG.info("The SLI parameter in " + key + " is: " + value);
323         }
324
325         // Call SLI sync method
326         try {
327             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
328                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
329                 try {
330                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
331                 } catch (Exception e) {
332                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
333                     serviceDataBuilder.setResponseCode("500");
334                 }
335             } else {
336                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
337                 serviceDataBuilder.setResponseCode("503");
338             }
339         } catch (Exception e) {
340             LOG.error("Caught exception looking for service logic", e);
341             serviceDataBuilder.setResponseCode("500");
342         }
343
344         String errorCode = serviceDataBuilder.getResponseCode();
345
346         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
347             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
348         } else {
349             LOG.info("Returned SUCCESS for " + svcOperation + " ");
350             serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyTypes ");
351         }
352
353         RpcResult<GetPolicyTypesOutput> rpcResult =
354                 RpcResultBuilder.<GetPolicyTypesOutput>status(true).withResult(serviceDataBuilder.build()).build();
355
356         LOG.info("Successful exit from getPolicyTypes ");
357
358         return Futures.immediateFuture(rpcResult);
359     }
360
361     // RPC createPolicyType
362
363     @Override
364     public ListenableFuture<RpcResult<CreatePolicyTypeOutput>> createPolicyType(CreatePolicyTypeInput input) {
365         final String svcOperation = "createPolicyType";
366
367         Properties parms = new Properties();
368         CreatePolicyTypeOutputBuilder serviceDataBuilder =
369                 (CreatePolicyTypeOutputBuilder) getServiceData(CREATE_POLICY_TYPE);
370
371         LOG.info("Reached RPC createPolicyType");
372
373         LOG.info(svcOperation + " called.");
374
375         if (input == null) {
376             LOG.debug("exiting " + svcOperation + " because of invalid input");
377             serviceDataBuilder.setResponseCode("Input is null");
378             RpcResult<CreatePolicyTypeOutput> rpcResult = RpcResultBuilder.<CreatePolicyTypeOutput>status(true)
379                     .withResult(serviceDataBuilder.build()).build();
380             return Futures.immediateFuture(rpcResult);
381         }
382
383         // add input to parms
384         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
385         CreatePolicyTypeInputBuilder inputBuilder = new CreatePolicyTypeInputBuilder(input);
386         MdsalHelper.toProperties(parms, inputBuilder.build());
387
388         LOG.info("Printing SLI parameters to be passed");
389
390         // iterate properties file to get key-value pairs
391         for (String key : parms.stringPropertyNames()) {
392             String value = parms.getProperty(key);
393             LOG.info("The SLI parameter in " + key + " is: " + value);
394         }
395
396         // Call SLI sync method
397         try {
398             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
399                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
400                 try {
401                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
402                 } catch (Exception e) {
403                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
404                     serviceDataBuilder.setResponseCode("500");
405                 }
406             } else {
407                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
408                 serviceDataBuilder.setResponseCode("503");
409             }
410         } catch (Exception e) {
411             LOG.error("Caught exception looking for service logic", e);
412             serviceDataBuilder.setResponseCode("500");
413         }
414
415         String errorCode = serviceDataBuilder.getResponseCode();
416
417         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
418             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
419         } else {
420             LOG.info("Returned SUCCESS for " + svcOperation + " ");
421             serviceDataBuilder.setResponseCode("A1 Adapter Executed for CreatePolicyType");
422         }
423
424         RpcResult<CreatePolicyTypeOutput> rpcResult =
425                 RpcResultBuilder.<CreatePolicyTypeOutput>status(true).withResult(serviceDataBuilder.build()).build();
426
427         LOG.info("Successful exit from createPolicyType ");
428
429         return Futures.immediateFuture(rpcResult);
430     }
431
432     // RPC getPolicyType
433
434     @Override
435     public ListenableFuture<RpcResult<GetPolicyTypeOutput>> getPolicyType(GetPolicyTypeInput input) {
436         final String svcOperation = "getPolicyType";
437
438         Properties parms = new Properties();
439         GetPolicyTypeOutputBuilder serviceDataBuilder = (GetPolicyTypeOutputBuilder) getServiceData(GET_POLICY_TYPE);
440
441         LOG.info("Reached RPC getPolicyType");
442
443         LOG.info(svcOperation + " called.");
444
445         if (input == null) {
446             LOG.debug("exiting " + svcOperation + " because of invalid input");
447             serviceDataBuilder.setResponseCode("Input is null");
448             RpcResult<GetPolicyTypeOutput> rpcResult =
449                     RpcResultBuilder.<GetPolicyTypeOutput>status(true).withResult(serviceDataBuilder.build()).build();
450             return Futures.immediateFuture(rpcResult);
451         }
452
453         // add input to parms
454         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
455         GetPolicyTypeInputBuilder inputBuilder = new GetPolicyTypeInputBuilder(input);
456         MdsalHelper.toProperties(parms, inputBuilder.build());
457
458         LOG.info("Printing SLI parameters to be passed");
459
460         // iterate properties file to get key-value pairs
461         for (String key : parms.stringPropertyNames()) {
462             String value = parms.getProperty(key);
463             LOG.info("The SLI parameter in " + key + " is: " + value);
464         }
465
466         // Call SLI sync method
467         try {
468             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
469                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
470                 try {
471                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
472                 } catch (Exception e) {
473                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
474                     serviceDataBuilder.setResponseCode("500");
475                 }
476             } else {
477                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
478                 serviceDataBuilder.setResponseCode("503");
479             }
480         } catch (Exception e) {
481             LOG.error("Caught exception looking for service logic", e);
482             serviceDataBuilder.setResponseCode("500");
483         }
484
485         String errorCode = serviceDataBuilder.getResponseCode();
486
487         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
488             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
489         } else {
490             LOG.info("Returned SUCCESS for " + svcOperation + " ");
491             serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyType. ");
492         }
493
494         RpcResult<GetPolicyTypeOutput> rpcResult =
495                 RpcResultBuilder.<GetPolicyTypeOutput>status(true).withResult(serviceDataBuilder.build()).build();
496
497         LOG.info("Successful exit from getPolicyType ");
498
499         return Futures.immediateFuture(rpcResult);
500     }
501
502     // RPC deletePolicyType
503
504     @Override
505     public ListenableFuture<RpcResult<DeletePolicyTypeOutput>> deletePolicyType(DeletePolicyTypeInput input) {
506         final String svcOperation = "deletePolicyType";
507
508         Properties parms = new Properties();
509         DeletePolicyTypeOutputBuilder serviceDataBuilder =
510                 (DeletePolicyTypeOutputBuilder) getServiceData(DELETE_POLICY_TYPE);
511
512         LOG.info("Reached RPC deletePolicyType");
513
514         LOG.info(svcOperation + " called.");
515
516         if (input == null) {
517             LOG.debug("exiting " + svcOperation + " because of invalid input");
518             serviceDataBuilder.setResponseCode("Input is null");
519             RpcResult<DeletePolicyTypeOutput> rpcResult = RpcResultBuilder.<DeletePolicyTypeOutput>status(true)
520                     .withResult(serviceDataBuilder.build()).build();
521             return Futures.immediateFuture(rpcResult);
522         }
523
524         // add input to parms
525         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
526         DeletePolicyTypeInputBuilder inputBuilder = new DeletePolicyTypeInputBuilder(input);
527         MdsalHelper.toProperties(parms, inputBuilder.build());
528
529         LOG.info("Printing SLI parameters to be passed");
530
531         // iterate properties file to get key-value pairs
532         for (String key : parms.stringPropertyNames()) {
533             String value = parms.getProperty(key);
534             LOG.info("The SLI parameter in " + key + " is: " + value);
535         }
536
537         // Call SLI sync method
538         try {
539             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
540                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
541                 try {
542                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
543                 } catch (Exception e) {
544                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
545                     serviceDataBuilder.setResponseCode("500");
546                 }
547             } else {
548                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
549                 serviceDataBuilder.setResponseCode("503");
550             }
551         } catch (Exception e) {
552             LOG.error("Caught exception looking for service logic", e);
553             serviceDataBuilder.setResponseCode("500");
554         }
555
556         String errorCode = serviceDataBuilder.getResponseCode();
557
558         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
559             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
560         } else {
561             LOG.info("Returned SUCCESS for " + svcOperation + " ");
562             serviceDataBuilder.setResponseCode("A1 Adapter Executed for DeletePolicyType ");
563         }
564
565         RpcResult<DeletePolicyTypeOutput> rpcResult =
566                 RpcResultBuilder.<DeletePolicyTypeOutput>status(true).withResult(serviceDataBuilder.build()).build();
567
568         LOG.info("Successful exit from deletePolicyType ");
569
570         return Futures.immediateFuture(rpcResult);
571     }
572
573     // RPC getPolicyInstances
574
575     @Override
576     public ListenableFuture<RpcResult<GetPolicyInstancesOutput>> getPolicyInstances(GetPolicyInstancesInput input) {
577         final String svcOperation = "getPolicyInstances";
578
579         Properties parms = new Properties();
580         GetPolicyInstancesOutputBuilder serviceDataBuilder =
581                 (GetPolicyInstancesOutputBuilder) getServiceData(GET_POLICY_INSTANCES);
582
583         LOG.info("Reached RPC getPolicyInstances");
584
585         LOG.info(svcOperation + " called.");
586
587         if (input == null) {
588             LOG.debug("exiting " + svcOperation + " because of invalid input");
589             serviceDataBuilder.setResponseCode("Input is null");
590             RpcResult<GetPolicyInstancesOutput> rpcResult = RpcResultBuilder.<GetPolicyInstancesOutput>status(true)
591                     .withResult(serviceDataBuilder.build()).build();
592             return Futures.immediateFuture(rpcResult);
593         }
594
595         // add input to parms
596         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
597         GetPolicyInstancesInputBuilder inputBuilder = new GetPolicyInstancesInputBuilder(input);
598         MdsalHelper.toProperties(parms, inputBuilder.build());
599
600         LOG.info("Printing SLI parameters to be passed");
601
602         // iterate properties file to get key-value pairs
603         for (String key : parms.stringPropertyNames()) {
604             String value = parms.getProperty(key);
605             LOG.info("The SLI parameter in " + key + " is: " + value);
606         }
607
608         // Call SLI sync method
609         try {
610             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
611                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
612                 try {
613                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
614                 } catch (Exception e) {
615                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
616                     serviceDataBuilder.setResponseCode("500");
617                 }
618             } else {
619                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
620                 serviceDataBuilder.setResponseCode("503");
621             }
622         } catch (Exception e) {
623             LOG.error("Caught exception looking for service logic", e);
624             serviceDataBuilder.setResponseCode("500");
625         }
626
627         String errorCode = serviceDataBuilder.getResponseCode();
628
629         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
630             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
631         } else {
632             LOG.info("Returned SUCCESS for " + svcOperation + " ");
633             serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyInstances ");
634         }
635
636         RpcResult<GetPolicyInstancesOutput> rpcResult =
637                 RpcResultBuilder.<GetPolicyInstancesOutput>status(true).withResult(serviceDataBuilder.build()).build();
638
639         LOG.info("Successful exit from getPolicyInstances ");
640
641         return Futures.immediateFuture(rpcResult);
642     }
643
644
645     // RPC createPolicyInstance
646
647     @Override
648     public ListenableFuture<RpcResult<CreatePolicyInstanceOutput>> createPolicyInstance(
649             CreatePolicyInstanceInput input) {
650         final String svcOperation = "createPolicyInstance";
651
652         Properties parms = new Properties();
653         CreatePolicyInstanceOutputBuilder serviceDataBuilder =
654                 (CreatePolicyInstanceOutputBuilder) getServiceData(CREATE_POLICY_INSTANCES);
655
656         LOG.info("Reached RPC createPolicyInstance");
657
658         LOG.info(svcOperation + " called.");
659
660         if (input == null) {
661             LOG.debug("exiting " + svcOperation + " because of invalid input");
662             serviceDataBuilder.setResponseCode("Input is null");
663             RpcResult<CreatePolicyInstanceOutput> rpcResult = RpcResultBuilder.<CreatePolicyInstanceOutput>status(true)
664                     .withResult(serviceDataBuilder.build()).build();
665             return Futures.immediateFuture(rpcResult);
666         }
667
668         // add input to parms
669         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
670         CreatePolicyInstanceInputBuilder inputBuilder = new CreatePolicyInstanceInputBuilder(input);
671         MdsalHelper.toProperties(parms, inputBuilder.build());
672
673         LOG.info("Printing SLI parameters to be passed");
674
675         // iterate properties file to get key-value pairs
676         for (String key : parms.stringPropertyNames()) {
677             String value = parms.getProperty(key);
678             LOG.info("The SLI parameter in " + key + " is: " + value);
679         }
680
681         // Call SLI sync method
682         try {
683             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
684                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
685                 try {
686                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
687                 } catch (Exception e) {
688                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
689                     serviceDataBuilder.setResponseCode("500");
690                 }
691             } else {
692                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
693                 serviceDataBuilder.setResponseCode("503");
694             }
695         } catch (Exception e) {
696             LOG.error("Caught exception looking for service logic", e);
697             serviceDataBuilder.setResponseCode("500");
698         }
699
700         String errorCode = serviceDataBuilder.getResponseCode();
701
702         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
703             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
704         } else {
705             LOG.info("Returned SUCCESS for " + svcOperation + " ");
706             serviceDataBuilder.setResponseCode("A1 Adapter Executed for CreatePolicyInstance. ");
707         }
708
709         RpcResult<CreatePolicyInstanceOutput> rpcResult = RpcResultBuilder.<CreatePolicyInstanceOutput>status(true)
710                 .withResult(serviceDataBuilder.build()).build();
711
712         LOG.info("Successful exit from createPolicyInstance ");
713
714         return Futures.immediateFuture(rpcResult);
715     }
716
717
718
719     // RPC getPolicyInstance
720
721     @Override
722     public ListenableFuture<RpcResult<GetPolicyInstanceOutput>> getPolicyInstance(GetPolicyInstanceInput input) {
723         final String svcOperation = "getPolicyInstance";
724
725         Properties parms = new Properties();
726         GetPolicyInstanceOutputBuilder serviceDataBuilder =
727                 (GetPolicyInstanceOutputBuilder) getServiceData(GET_POLICY_INSTANCE);
728
729         LOG.info("Reached RPC getPolicyInstance");
730
731         LOG.info(svcOperation + " called.");
732
733         if (input == null) {
734             LOG.debug("exiting " + svcOperation + " because of invalid input");
735             serviceDataBuilder.setResponseCode("Input is null");
736             RpcResult<GetPolicyInstanceOutput> rpcResult = RpcResultBuilder.<GetPolicyInstanceOutput>status(true)
737                     .withResult(serviceDataBuilder.build()).build();
738             return Futures.immediateFuture(rpcResult);
739         }
740
741         // add input to parms
742         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
743         GetPolicyInstanceInputBuilder inputBuilder = new GetPolicyInstanceInputBuilder(input);
744         MdsalHelper.toProperties(parms, inputBuilder.build());
745
746         LOG.info("Printing SLI parameters to be passed");
747
748         // iterate properties file to get key-value pairs
749         for (String key : parms.stringPropertyNames()) {
750             String value = parms.getProperty(key);
751             LOG.info("The SLI parameter in " + key + " is: " + value);
752         }
753
754         // Call SLI sync method
755         try {
756             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
757                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
758                 try {
759                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
760                 } catch (Exception e) {
761                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
762                     serviceDataBuilder.setResponseCode("500");
763                 }
764             } else {
765                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
766                 serviceDataBuilder.setResponseCode("503");
767             }
768         } catch (Exception e) {
769             LOG.error("Caught exception looking for service logic", e);
770             serviceDataBuilder.setResponseCode("500");
771         }
772
773         String errorCode = serviceDataBuilder.getResponseCode();
774
775         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
776             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
777         } else {
778             LOG.info("Returned SUCCESS for " + svcOperation + " ");
779             serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyInstance. ");
780         }
781
782         RpcResult<GetPolicyInstanceOutput> rpcResult =
783                 RpcResultBuilder.<GetPolicyInstanceOutput>status(true).withResult(serviceDataBuilder.build()).build();
784
785         LOG.info("Successful exit from getPolicyInstance ");
786
787         return Futures.immediateFuture(rpcResult);
788     }
789
790
791
792     // RPC deletePolicyInstance
793
794     @Override
795     public ListenableFuture<RpcResult<DeletePolicyInstanceOutput>> deletePolicyInstance(
796             DeletePolicyInstanceInput input) {
797         final String svcOperation = "deletePolicyInstance";
798
799         Properties parms = new Properties();
800         DeletePolicyInstanceOutputBuilder serviceDataBuilder =
801                 (DeletePolicyInstanceOutputBuilder) getServiceData(DELETE_POLICY_INSTANCE);
802
803         LOG.info("Reached RPC deletePolicyInstance");
804
805         LOG.info(svcOperation + " called.");
806
807         if (input == null) {
808             LOG.debug("exiting " + svcOperation + " because of invalid input");
809             serviceDataBuilder.setResponseCode("Input is null");
810             RpcResult<DeletePolicyInstanceOutput> rpcResult = RpcResultBuilder.<DeletePolicyInstanceOutput>status(true)
811                     .withResult(serviceDataBuilder.build()).build();
812             return Futures.immediateFuture(rpcResult);
813         }
814
815         // add input to parms
816         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
817         DeletePolicyInstanceInputBuilder inputBuilder = new DeletePolicyInstanceInputBuilder(input);
818         MdsalHelper.toProperties(parms, inputBuilder.build());
819
820         LOG.info("Printing SLI parameters to be passed");
821
822         // iterate properties file to get key-value pairs
823         for (String key : parms.stringPropertyNames()) {
824             String value = parms.getProperty(key);
825             LOG.info("The SLI parameter in " + key + " is: " + value);
826         }
827
828         // Call SLI sync method
829         try {
830             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
831                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
832                 try {
833                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
834                 } catch (Exception e) {
835                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
836                     serviceDataBuilder.setResponseCode("500");
837                 }
838             } else {
839                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
840                 serviceDataBuilder.setResponseCode("503");
841             }
842         } catch (Exception e) {
843             LOG.error("Caught exception looking for service logic", e);
844             serviceDataBuilder.setResponseCode("500");
845         }
846
847         String errorCode = serviceDataBuilder.getResponseCode();
848
849         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
850             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
851         } else {
852             LOG.info("Returned SUCCESS for " + svcOperation + " ");
853             serviceDataBuilder.setResponseCode("A1 Adapter Executed for DeletePolicyInstance. ");
854         }
855
856         RpcResult<DeletePolicyInstanceOutput> rpcResult = RpcResultBuilder.<DeletePolicyInstanceOutput>status(true)
857                 .withResult(serviceDataBuilder.build()).build();
858
859         LOG.info("Successful exit from deletePolicyInstance ");
860
861         return Futures.immediateFuture(rpcResult);
862     }
863
864
865
866     // RPC getStatus
867
868     @Override
869     public ListenableFuture<RpcResult<GetStatusOutput>> getStatus(GetStatusInput input) {
870         final String svcOperation = "getStatus";
871
872         Properties parms = new Properties();
873         GetStatusOutputBuilder serviceDataBuilder = (GetStatusOutputBuilder) getServiceData(GET_STATUS);
874
875         LOG.info("Reached RPC getStatus");
876
877         LOG.info(svcOperation + " called.");
878
879         if (input == null) {
880             LOG.debug("exiting " + svcOperation + " because of invalid input");
881             serviceDataBuilder.setResponseCode("Input is null");
882             RpcResult<GetStatusOutput> rpcResult =
883                     RpcResultBuilder.<GetStatusOutput>status(true).withResult(serviceDataBuilder.build()).build();
884             return Futures.immediateFuture(rpcResult);
885         }
886
887         // add input to parms
888         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
889         GetStatusInputBuilder inputBuilder = new GetStatusInputBuilder(input);
890         MdsalHelper.toProperties(parms, inputBuilder.build());
891
892         LOG.info("Printing SLI parameters to be passed");
893
894         // iterate properties file to get key-value pairs
895         for (String key : parms.stringPropertyNames()) {
896             String value = parms.getProperty(key);
897             LOG.info("The SLI parameter in " + key + " is: " + value);
898         }
899
900         // Call SLI sync method
901         try {
902             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
903                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
904                 try {
905                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
906                 } catch (Exception e) {
907                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
908                     serviceDataBuilder.setResponseCode("500");
909                 }
910             } else {
911                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
912                 serviceDataBuilder.setResponseCode("503");
913             }
914         } catch (Exception e) {
915             LOG.error("Caught exception looking for service logic", e);
916             serviceDataBuilder.setResponseCode("500");
917         }
918
919         String errorCode = serviceDataBuilder.getResponseCode();
920
921         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
922             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
923         } else {
924             LOG.info("Returned SUCCESS for " + svcOperation + " ");
925             serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetStatus. ");
926         }
927
928         RpcResult<GetStatusOutput> rpcResult =
929                 RpcResultBuilder.<GetStatusOutput>status(true).withResult(serviceDataBuilder.build()).build();
930
931         LOG.info("Successful exit from getStatus ");
932
933         return Futures.immediateFuture(rpcResult);
934     }
935
936
937     // RPC notifyPolicyEnforcementUpdate
938
939     @Override
940     public ListenableFuture<RpcResult<NotifyPolicyEnforcementUpdateOutput>> notifyPolicyEnforcementUpdate(
941             NotifyPolicyEnforcementUpdateInput input) {
942         final String svcOperation = "notifyPolicyEnforcementUpdate";
943
944         Properties parms = new Properties();
945         NotifyPolicyEnforcementUpdateOutputBuilder serviceDataBuilder =
946                 (NotifyPolicyEnforcementUpdateOutputBuilder) getServiceData(NOTIFICATION_ENFORECEMENT);
947
948         LOG.info("Reached RPC notifyPolicyEnforcementUpdate");
949
950         LOG.info(svcOperation + " called.");
951
952         if (input == null) {
953             LOG.debug("exiting " + svcOperation + " because of invalid input");
954             serviceDataBuilder.setResponseCode("Input is null");
955             RpcResult<NotifyPolicyEnforcementUpdateOutput> rpcResult = RpcResultBuilder
956                     .<NotifyPolicyEnforcementUpdateOutput>status(true).withResult(serviceDataBuilder.build()).build();
957             return Futures.immediateFuture(rpcResult);
958         }
959
960         // add input to parms
961         LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
962         NotifyPolicyEnforcementUpdateInputBuilder inputBuilder = new NotifyPolicyEnforcementUpdateInputBuilder(input);
963         MdsalHelper.toProperties(parms, inputBuilder.build());
964
965         LOG.info("Printing SLI parameters to be passed");
966
967         // iterate properties file to get key-value pairs
968         for (String key : parms.stringPropertyNames()) {
969             String value = parms.getProperty(key);
970             LOG.info("The SLI parameter in " + key + " is: " + value);
971         }
972
973         // Call SLI sync method
974         try {
975             if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
976                 LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
977                 try {
978                     A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
979                 } catch (Exception e) {
980                     LOG.error("Caught exception executing service logic for " + svcOperation, e);
981                     serviceDataBuilder.setResponseCode("500");
982                 }
983             } else {
984                 LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
985                 serviceDataBuilder.setResponseCode("503");
986             }
987         } catch (Exception e) {
988             LOG.error("Caught exception looking for service logic", e);
989             serviceDataBuilder.setResponseCode("500");
990         }
991
992         String errorCode = serviceDataBuilder.getResponseCode();
993
994         if (!("0".equals(errorCode) || "200".equals(errorCode))) {
995             LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
996         } else {
997             LOG.info("Returned SUCCESS for " + svcOperation + " ");
998             serviceDataBuilder.setResponseCode("A1 Adapter Executed for notifyPolicyEnforcementUpdate. ");
999         }
1000
1001         RpcResult<NotifyPolicyEnforcementUpdateOutput> rpcResult = RpcResultBuilder
1002                 .<NotifyPolicyEnforcementUpdateOutput>status(true).withResult(serviceDataBuilder.build()).build();
1003
1004         LOG.info("Successful exit from notifyPolicyEnforcementUpdate ");
1005
1006         return Futures.immediateFuture(rpcResult);
1007     }
1008
1009     protected Builder<?> getServiceData(String svcOperation) {
1010         switch (svcOperation) {
1011             case GET_NEARRT_RICS:
1012                 return new GetNearRTRICsOutputBuilder();
1013             case GET_HEALTH_CHECK:
1014                 return new GetHealthCheckOutputBuilder();
1015             case GET_POLICY_TYPES:
1016                 return new GetPolicyTypesOutputBuilder();
1017             case CREATE_POLICY_TYPE:
1018                 return new CreatePolicyTypeOutputBuilder();
1019             case GET_POLICY_TYPE:
1020                 return new GetPolicyTypeOutputBuilder();
1021             case DELETE_POLICY_TYPE:
1022                 return new DeletePolicyTypeOutputBuilder();
1023             case GET_POLICY_INSTANCES:
1024                 return new GetPolicyInstancesOutputBuilder();
1025             case CREATE_POLICY_INSTANCES:
1026                 return new CreatePolicyInstanceOutputBuilder();
1027             case GET_POLICY_INSTANCE:
1028                 return new GetPolicyInstanceOutputBuilder();
1029             case DELETE_POLICY_INSTANCE:
1030                 return new DeletePolicyInstanceOutputBuilder();
1031             case GET_STATUS:
1032                 return new GetStatusOutputBuilder();
1033             case NOTIFICATION_ENFORECEMENT:
1034                 return new NotifyPolicyEnforcementUpdateOutputBuilder();
1035         }
1036         return null;
1037     }
1038 }