216f9bd38056958131c8cc4df5002bc5635286b2
[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  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.ccsdk.features.sdnr.northbound.a1Adapter;
23
24 import java.util.Properties;
25
26 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
27 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
28 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
29 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.*;
30
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34 public class A1AdapterClient {
35
36         private static final Logger LOG = LoggerFactory.getLogger(A1AdapterClient.class);
37
38         private SvcLogicService svcLogicService = null;
39
40         public A1AdapterClient(final SvcLogicService svcLogicService) {
41                 this.svcLogicService = svcLogicService;
42         }
43
44         public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
45         {
46                 return svcLogicService.hasGraph(module, rpc, version, mode);
47         }
48
49 // Client for GetNearRTRICs
50
51 public Properties execute(String module, String rpc, String version, String mode, GetNearRTRICsOutputBuilder serviceData)
52                 throws SvcLogicException {
53
54         Properties parms = new Properties();
55
56         return execute(module,rpc,version, mode,serviceData,parms);
57 }
58
59 public Properties execute(String module, String rpc, String version, String mode, GetNearRTRICsOutputBuilder serviceData, Properties parms)
60                         throws SvcLogicException {
61                         Properties localProp;
62                         localProp = MdsalHelper.toProperties(parms, serviceData);
63
64         if (LOG.isDebugEnabled())
65         {
66                 LOG.debug("Parameters passed to SLI");
67
68                 for (Object key : localProp.keySet()) {
69                         String parmName = (String) key;
70                         String parmValue = localProp.getProperty(parmName);
71
72                         LOG.debug(parmName+" = "+parmValue);
73
74                 }
75         }
76
77         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
78
79         if (LOG.isDebugEnabled())
80         {
81                 LOG.debug("Parameters returned by SLI");
82
83                 for (Object key : respProps.keySet()) {
84                         String parmName = (String) key;
85                         String parmValue = respProps.getProperty(parmName);
86
87                         LOG.debug(parmName+" = "+parmValue);
88
89                 }
90         }
91         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
92                 return respProps;
93         }
94
95         MdsalHelper.toBuilder(respProps, serviceData);
96
97         return respProps;
98 }
99
100 // Client for GetHealthCheck
101
102         public Properties execute(String module, String rpc, String version, String mode, GetHealthCheckOutputBuilder serviceData)
103                         throws SvcLogicException {
104
105                 Properties parms = new Properties();
106
107                 return execute(module,rpc,version, mode,serviceData,parms);
108         }
109
110         public Properties execute(String module, String rpc, String version, String mode, GetHealthCheckOutputBuilder serviceData, Properties parms)
111                                 throws SvcLogicException {
112         Properties localProp;
113         localProp = MdsalHelper.toProperties(parms, serviceData);
114
115                 if (LOG.isDebugEnabled())
116                 {
117                         LOG.debug("Parameters passed to SLI");
118
119                         for (Object key : localProp.keySet()) {
120                                 String parmName = (String) key;
121                                 String parmValue = localProp.getProperty(parmName);
122
123                                 LOG.debug(parmName+" = "+parmValue);
124
125                         }
126                 }
127
128                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
129
130                 if (LOG.isDebugEnabled())
131                 {
132                         LOG.debug("Parameters returned by SLI");
133
134                         for (Object key : respProps.keySet()) {
135                                 String parmName = (String) key;
136                                 String parmValue = respProps.getProperty(parmName);
137
138                                 LOG.debug(parmName+" = "+parmValue);
139
140                         }
141                 }
142                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
143                         return respProps;
144                 }
145
146                 MdsalHelper.toBuilder(respProps, serviceData);
147
148                 return respProps;
149         }
150
151
152         // Client for  getPolicyTypes
153
154         public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypesOutputBuilder serviceData)
155                         throws SvcLogicException {
156
157                 Properties parms = new Properties();
158
159                 return execute(module,rpc,version, mode,serviceData,parms);
160         }
161
162         public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypesOutputBuilder serviceData, Properties parms)
163                                 throws SvcLogicException {
164         Properties localProp;
165         localProp = MdsalHelper.toProperties(parms, serviceData);
166
167                 if (LOG.isDebugEnabled())
168                 {
169                         LOG.debug("Parameters passed to SLI");
170
171                         for (Object key : localProp.keySet()) {
172                                 String parmName = (String) key;
173                                 String parmValue = localProp.getProperty(parmName);
174
175                                 LOG.debug(parmName+" = "+parmValue);
176
177                         }
178                 }
179
180                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
181
182                 if (LOG.isDebugEnabled())
183                 {
184                         LOG.debug("Parameters returned by SLI");
185
186                         for (Object key : respProps.keySet()) {
187                                 String parmName = (String) key;
188                                 String parmValue = respProps.getProperty(parmName);
189
190                                 LOG.debug(parmName+" = "+parmValue);
191
192                         }
193                 }
194                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
195                         return respProps;
196                 }
197
198                 MdsalHelper.toBuilder(respProps, serviceData);
199
200                 return respProps;
201         }
202
203
204         // Client for  createPolicyType
205
206
207         public Properties execute(String module, String rpc, String version, String mode, CreatePolicyTypeOutputBuilder serviceData)
208                         throws SvcLogicException {
209
210                 Properties parms = new Properties();
211
212                 return execute(module,rpc,version, mode,serviceData,parms);
213         }
214
215         public Properties execute(String module, String rpc, String version, String mode, CreatePolicyTypeOutputBuilder serviceData, Properties parms)
216                                 throws SvcLogicException {
217         Properties localProp;
218         localProp = MdsalHelper.toProperties(parms, serviceData);
219
220                 if (LOG.isDebugEnabled())
221                 {
222                         LOG.debug("Parameters passed to SLI");
223
224                         for (Object key : localProp.keySet()) {
225                                 String parmName = (String) key;
226                                 String parmValue = localProp.getProperty(parmName);
227
228                                 LOG.debug(parmName+" = "+parmValue);
229
230                         }
231                 }
232
233                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
234
235                 if (LOG.isDebugEnabled())
236                 {
237                         LOG.debug("Parameters returned by SLI");
238
239                         for (Object key : respProps.keySet()) {
240                                 String parmName = (String) key;
241                                 String parmValue = respProps.getProperty(parmName);
242
243                                 LOG.debug(parmName+" = "+parmValue);
244
245                         }
246                 }
247                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
248                         return respProps;
249                 }
250
251                 MdsalHelper.toBuilder(respProps, serviceData);
252
253                 return respProps;
254         }
255
256         // Client for  getPolicyType
257
258         public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypeOutputBuilder serviceData)
259                         throws SvcLogicException {
260
261                 Properties parms = new Properties();
262
263                 return execute(module,rpc,version, mode,serviceData,parms);
264         }
265
266         public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypeOutputBuilder serviceData, Properties parms)
267                                 throws SvcLogicException {
268         Properties localProp;
269         localProp = MdsalHelper.toProperties(parms, serviceData);
270
271                 if (LOG.isDebugEnabled())
272                 {
273                         LOG.debug("Parameters passed to SLI");
274
275                         for (Object key : localProp.keySet()) {
276                                 String parmName = (String) key;
277                                 String parmValue = localProp.getProperty(parmName);
278
279                                 LOG.debug(parmName+" = "+parmValue);
280
281                         }
282                 }
283
284                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
285
286                 if (LOG.isDebugEnabled())
287                 {
288                         LOG.debug("Parameters returned by SLI");
289
290                         for (Object key : respProps.keySet()) {
291                                 String parmName = (String) key;
292                                 String parmValue = respProps.getProperty(parmName);
293
294                                 LOG.debug(parmName+" = "+parmValue);
295
296                         }
297                 }
298                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
299                         return respProps;
300                 }
301
302                 MdsalHelper.toBuilder(respProps, serviceData);
303
304                 return respProps;
305         }
306
307
308         // Client for  deletePolicyType
309
310         public Properties execute(String module, String rpc, String version, String mode, DeletePolicyTypeOutputBuilder serviceData)
311                         throws SvcLogicException {
312
313                 Properties parms = new Properties();
314
315                 return execute(module,rpc,version, mode,serviceData,parms);
316         }
317
318         public Properties execute(String module, String rpc, String version, String mode, DeletePolicyTypeOutputBuilder serviceData, Properties parms)
319                                 throws SvcLogicException {
320         Properties localProp;
321         localProp = MdsalHelper.toProperties(parms, serviceData);
322
323                 if (LOG.isDebugEnabled())
324                 {
325                         LOG.debug("Parameters passed to SLI");
326
327                         for (Object key : localProp.keySet()) {
328                                 String parmName = (String) key;
329                                 String parmValue = localProp.getProperty(parmName);
330
331                                 LOG.debug(parmName+" = "+parmValue);
332
333                         }
334                 }
335
336                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
337
338                 if (LOG.isDebugEnabled())
339                 {
340                         LOG.debug("Parameters returned by SLI");
341
342                         for (Object key : respProps.keySet()) {
343                                 String parmName = (String) key;
344                                 String parmValue = respProps.getProperty(parmName);
345
346                                 LOG.debug(parmName+" = "+parmValue);
347
348                         }
349                 }
350                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
351                         return respProps;
352                 }
353
354                 MdsalHelper.toBuilder(respProps, serviceData);
355
356                 return respProps;
357         }
358
359
360         // Client for  getPolicyInstances
361
362         public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstancesOutputBuilder serviceData)
363                         throws SvcLogicException {
364
365                 Properties parms = new Properties();
366
367                 return execute(module,rpc,version, mode,serviceData,parms);
368         }
369
370         public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstancesOutputBuilder serviceData, Properties parms)
371                                 throws SvcLogicException {
372         Properties localProp;
373         localProp = MdsalHelper.toProperties(parms, serviceData);
374
375                 if (LOG.isDebugEnabled())
376                 {
377                         LOG.debug("Parameters passed to SLI");
378
379                         for (Object key : localProp.keySet()) {
380                                 String parmName = (String) key;
381                                 String parmValue = localProp.getProperty(parmName);
382
383                                 LOG.debug(parmName+" = "+parmValue);
384
385                         }
386                 }
387
388                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
389
390                 if (LOG.isDebugEnabled())
391                 {
392                         LOG.debug("Parameters returned by SLI");
393
394                         for (Object key : respProps.keySet()) {
395                                 String parmName = (String) key;
396                                 String parmValue = respProps.getProperty(parmName);
397
398                                 LOG.debug(parmName+" = "+parmValue);
399
400                         }
401                 }
402                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
403                         return respProps;
404                 }
405
406                 MdsalHelper.toBuilder(respProps, serviceData);
407
408                 return respProps;
409         }
410
411
412
413         // Client for  createPolicyInstance
414
415         public Properties execute(String module, String rpc, String version, String mode, CreatePolicyInstanceOutputBuilder serviceData)
416                         throws SvcLogicException {
417
418                 Properties parms = new Properties();
419
420                 return execute(module,rpc,version, mode,serviceData,parms);
421         }
422
423         public Properties execute(String module, String rpc, String version, String mode, CreatePolicyInstanceOutputBuilder serviceData, Properties parms)
424                                 throws SvcLogicException {
425         Properties localProp;
426         localProp = MdsalHelper.toProperties(parms, serviceData);
427
428                 if (LOG.isDebugEnabled())
429                 {
430                         LOG.debug("Parameters passed to SLI");
431
432                         for (Object key : localProp.keySet()) {
433                                 String parmName = (String) key;
434                                 String parmValue = localProp.getProperty(parmName);
435
436                                 LOG.debug(parmName+" = "+parmValue);
437
438                         }
439                 }
440
441                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
442
443                 if (LOG.isDebugEnabled())
444                 {
445                         LOG.debug("Parameters returned by SLI");
446
447                         for (Object key : respProps.keySet()) {
448                                 String parmName = (String) key;
449                                 String parmValue = respProps.getProperty(parmName);
450
451                                 LOG.debug(parmName+" = "+parmValue);
452
453                         }
454                 }
455                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
456                         return respProps;
457                 }
458
459                 MdsalHelper.toBuilder(respProps, serviceData);
460
461                 return respProps;
462         }
463
464
465         // Client for  getPolicyInstance
466
467         public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstanceOutputBuilder serviceData)
468                         throws SvcLogicException {
469
470                 Properties parms = new Properties();
471
472                 return execute(module,rpc,version, mode,serviceData,parms);
473         }
474
475         public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstanceOutputBuilder serviceData, Properties parms)
476                                 throws SvcLogicException {
477         Properties localProp;
478         localProp = MdsalHelper.toProperties(parms, serviceData);
479
480                 if (LOG.isDebugEnabled())
481                 {
482                         LOG.debug("Parameters passed to SLI");
483
484                         for (Object key : localProp.keySet()) {
485                                 String parmName = (String) key;
486                                 String parmValue = localProp.getProperty(parmName);
487
488                                 LOG.debug(parmName+" = "+parmValue);
489
490                         }
491                 }
492
493                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
494
495                 if (LOG.isDebugEnabled())
496                 {
497                         LOG.debug("Parameters returned by SLI");
498
499                         for (Object key : respProps.keySet()) {
500                                 String parmName = (String) key;
501                                 String parmValue = respProps.getProperty(parmName);
502
503                                 LOG.debug(parmName+" = "+parmValue);
504
505                         }
506                 }
507                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
508                         return respProps;
509                 }
510
511                 MdsalHelper.toBuilder(respProps, serviceData);
512
513                 return respProps;
514         }
515
516         // Client for  deletePolicyInstance
517
518         public Properties execute(String module, String rpc, String version, String mode, DeletePolicyInstanceOutputBuilder serviceData)
519                         throws SvcLogicException {
520
521                 Properties parms = new Properties();
522
523                 return execute(module,rpc,version, mode,serviceData,parms);
524         }
525
526         public Properties execute(String module, String rpc, String version, String mode, DeletePolicyInstanceOutputBuilder serviceData, Properties parms)
527                                 throws SvcLogicException {
528         Properties localProp;
529         localProp = MdsalHelper.toProperties(parms, serviceData);
530
531                 if (LOG.isDebugEnabled())
532                 {
533                         LOG.debug("Parameters passed to SLI");
534
535                         for (Object key : localProp.keySet()) {
536                                 String parmName = (String) key;
537                                 String parmValue = localProp.getProperty(parmName);
538
539                                 LOG.debug(parmName+" = "+parmValue);
540
541                         }
542                 }
543
544                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
545
546                 if (LOG.isDebugEnabled())
547                 {
548                         LOG.debug("Parameters returned by SLI");
549
550                         for (Object key : respProps.keySet()) {
551                                 String parmName = (String) key;
552                                 String parmValue = respProps.getProperty(parmName);
553
554                                 LOG.debug(parmName+" = "+parmValue);
555
556                         }
557                 }
558                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
559                         return respProps;
560                 }
561
562                 MdsalHelper.toBuilder(respProps, serviceData);
563
564                 return respProps;
565         }
566
567         // Client for  getStatus
568
569
570         public Properties execute(String module, String rpc, String version, String mode, GetStatusOutputBuilder serviceData)
571                         throws SvcLogicException {
572
573                 Properties parms = new Properties();
574
575                 return execute(module,rpc,version, mode,serviceData,parms);
576         }
577
578         public Properties execute(String module, String rpc, String version, String mode, GetStatusOutputBuilder serviceData, Properties parms)
579                                 throws SvcLogicException {
580         Properties localProp;
581         localProp = MdsalHelper.toProperties(parms, serviceData);
582
583                 if (LOG.isDebugEnabled())
584                 {
585                         LOG.debug("Parameters passed to SLI");
586
587                         for (Object key : localProp.keySet()) {
588                                 String parmName = (String) key;
589                                 String parmValue = localProp.getProperty(parmName);
590
591                                 LOG.debug(parmName+" = "+parmValue);
592
593                         }
594                 }
595
596                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
597
598                 if (LOG.isDebugEnabled())
599                 {
600                         LOG.debug("Parameters returned by SLI");
601
602                         for (Object key : respProps.keySet()) {
603                                 String parmName = (String) key;
604                                 String parmValue = respProps.getProperty(parmName);
605
606                                 LOG.debug(parmName+" = "+parmValue);
607
608                         }
609                 }
610                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
611                         return respProps;
612                 }
613
614                 MdsalHelper.toBuilder(respProps, serviceData);
615
616                 return respProps;
617         }
618
619
620
621
622
623
624 }