aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/resources/clds/camel/routes/policy-flows.xml
blob: cc51a086e038df21554c9e2a9a75a393c4092c6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
<routes xmlns="http://camel.apache.org/schema/spring">
    <route id="verify-one-policy">
        <from uri="direct:verify-one-policy"/>
        <setProperty propertyName="raiseHttpExceptionFlag">
            <simple resultType="java.lang.Boolean">false</simple>
        </setProperty>
        <to uri="direct:get-policy"/>
        <when>
            <simple>${header.CamelHttpResponseCode} != 200</simple>
            <setProperty propertyName="policyFound">
                <simple resultType="java.lang.Boolean">false</simple>
            </setProperty>
            <log loggingLevel="WARN"
                 message="At least one policy has not been found on policy engine: ${exchangeProperty[policyName]}"/>
        </when>
        <setProperty propertyName="raiseHttpExceptionFlag">
            <simple resultType="java.lang.Boolean">false</simple>
        </setProperty>
        <to uri="direct:get-deployment-policy"/>
        <when>
            <simple>${header.CamelHttpResponseCode} != 200</simple>
            <setProperty propertyName="policyDeployed">
                <simple resultType="java.lang.Boolean">false</simple>
            </setProperty>
            <log loggingLevel="WARN"
                 message="At least one policy has not been deployed on policy engine: ${exchangeProperty[policyName]}"/>
        </when>
        <setProperty propertyName="newPolicyState">
            <simple>${exchangeProperty[policyComponent].computeState(*)}</simple>
        </setProperty>
    </route>

    <route id="get-policy">
        <from uri="direct:get-policy"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Getting Policy: ${exchangeProperty[policyName]}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Get Policy')"/>
            <setHeader headerName="CamelHttpMethod">
                <constant>GET</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to get policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/${exchangeProperty[policyTypeVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log>
            <toD
                    uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/${exchangeProperty[policyTypeVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
            <doCatch>
                <exception>java.lang.Exception</exception>
                <handled>
                    <constant>true</constant>
                </handled>

                <log loggingLevel="ERROR"
                     message="GET policy request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/>
                <to
                        uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('GET policy request failed, Error reported: ${exception.message}','ERROR',${exchangeProperty[loopObject]})"/>
            </doCatch>
            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
                <setProperty propertyName="logMessage">
                    <simple>${exchangeProperty[policyName]} GET
                        Policy status
                    </simple>
                </setProperty>
                <setProperty propertyName="logComponent">
                    <simple>POLICY</simple>
                </setProperty>
                <to uri="direct:dump-loop-log-http-response"/>
            </doFinally>
        </doTry>
    </route>

    <route id="get-deployment-policy">
        <from uri="direct:get-deployment-policy"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Getting the policy deployment in PDP: ${exchangeProperty[policyName]}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy deployment in PDP')"/>
            <setHeader headerName="CamelHttpMethod">
                <constant>GET</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to get policy deployment status: {{clamp.config.policy.pap.url}}/policy/pap/v1/policies/status/${exchangeProperty[policyPdpGroup]}/${exchangeProperty[policyName]}/1.0.0"></log>
            <toD
                    uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/policies/status/${exchangeProperty[policyPdpGroup]}/${exchangeProperty[policyName]}/1.0.0?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
            <doCatch>
                <exception>java.lang.Exception</exception>
                <handled>
                    <constant>true</constant>
                </handled>

                <log loggingLevel="ERROR"
                     message="GET policy request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/>
                <to
                        uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('GET policy request failed, Error reported: ${exception.message}','ERROR',${exchangeProperty[loopObject]})"/>
            </doCatch>
            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
                <setProperty propertyName="logMessage">
                    <simple>${exchangeProperty[policyName]} GET Policy deployment
                        status
                    </simple>
                </setProperty>
                <setProperty propertyName="logComponent">
                    <simple>POLICY</simple>
                </setProperty>
                <to uri="direct:dump-loop-log-http-response"/>
            </doFinally>
        </doTry>
    </route>

    <route id="create-policy-from-loop-object">
        <from uri="direct:create-policy-from-loop-object"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Creating Policy from loop object: ${exchangeProperty[policy].getName()}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Creating Policy from loop object')"/>
            <setBody>
                <simple>${exchangeProperty[policy].createPolicyPayload()}
                </simple>
            </setBody>
            <setProperty propertyName="policyModelType">
                <simple>${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}</simple>
            </setProperty>
            <setProperty propertyName="policyModelVersion">
                <simple>${exchangeProperty[policy].getPolicyModel().getVersion()}</simple>
            </setProperty>
            <to uri="direct:create-policy"/>
            <doFinally>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
                <setProperty propertyName="logMessage">
                    <simple>${exchangeProperty[policy].getName()} creation
                        status
                    </simple>
                </setProperty>
                <setProperty propertyName="logComponent">
                    <simple>POLICY</simple>
                </setProperty>
                <to uri="direct:dump-loop-log-http-response"/>
            </doFinally>
        </doTry>
    </route>

    <route id="delete-policy-from-loop-object">
        <from uri="direct:delete-policy-from-loop-object"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Deleting Policy in a loop: ${exchangeProperty[policy].getName()}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Policy in a loop')"/>
            <setProperty propertyName="policyModelType">
                <simple>${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}</simple>
            </setProperty>
            <setProperty propertyName="policyModelVersion">
                <simple>${exchangeProperty[policy].getPolicyModel().getVersion()}</simple>
            </setProperty>
            <setProperty propertyName="policyName">
                <simple>${exchangeProperty[policy].getName()}</simple>
            </setProperty>
            <setProperty propertyName="policyVersion">
                <simple>1.0.0</simple>
            </setProperty>
            <to uri="direct:delete-policy"/>
            <doFinally>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
                <setProperty propertyName="logMessage">
                    <simple>${exchangeProperty[policy].getName()} removal
                        status
                    </simple>
                </setProperty>
                <setProperty propertyName="logComponent">
                    <simple>POLICY</simple>
                </setProperty>
                <to uri="direct:dump-loop-log-http-response"/>
            </doFinally>
        </doTry>
    </route>

    <route id="add-policies-from-loop-to-pdp-group">
        <from uri="direct:add-policies-from-loop-to-pdp-group"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Adding loop policies to PDP Group: ${exchangeProperty[loopObject].getName()}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Add policies to PDP group')"/>
            <setBody>
                <simple>
                    ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"POST")}
                </simple>
            </setBody>
            <to uri="direct:add-multiple-policies-to-pdp-group"/>
            <doFinally>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
                <setProperty propertyName="logMessage">
                    <simple>PDP Group push ALL status</simple>
                </setProperty>
                <setProperty propertyName="logComponent">
                    <simple>POLICY</simple>
                </setProperty>
                <to uri="direct:dump-loop-log-http-response"/>
            </doFinally>
        </doTry>
    </route>

    <route id="remove-all-policy-from-active-pdp-group">
        <from uri="direct:remove-all-policy-from-active-pdp-group"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Removing loop policies from PDP Group: ${exchangeProperty[loopObject].getName()}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Remove policies from PDP group')"/>
            <setBody>
                <simple>
                    ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"DELETE")}
                </simple>
            </setBody>
            <setHeader headerName="CamelHttpMethod">
                <constant>POST</constant>
            </setHeader>
            <setHeader headerName="Content-Type">
                <constant>application/json</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to remove policies from PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch"></log>
            <toD
                    uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;useSystemProperties=true&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>

            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
                <setProperty propertyName="logMessage">
                    <simple>PDP Group remove ALL status</simple>
                </setProperty>
                <setProperty propertyName="logComponent">
                    <simple>POLICY</simple>
                </setProperty>
                <to uri="direct:dump-loop-log-http-response"/>
            </doFinally>
        </doTry>
    </route>

    <route id="remove-one-policy-from-active-pdp-group">
        <from uri="direct:remove-one-policy-from-active-pdp-group"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Removing policy from active PDP group for loop: ${exchangeProperty[loopObject].getName()}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Removing one policy PDP group')"/>
            <setProperty propertyName="policyVersion">
                <simple>1.0.0</simple>
            </setProperty>
            <to uri="direct:undeploy-one-policy-from-pap"/>
            <setProperty propertyName="logMessage">
                <simple>${exchangeProperty[policyName]} PDP Group removal status
                </simple>
            </setProperty>
            <setProperty propertyName="logComponent">
                <simple>POLICY</simple>
            </setProperty>
            <to uri="direct:dump-loop-log-http-response"/>
            <doCatch>
                <exception>java.lang.Exception</exception>
                <handled>
                    <constant>false</constant>
                </handled>
                <setProperty propertyName="logMessage">
                    <simple>PDP Group removal, Error reported: ${exception}</simple>
                </setProperty>
                <setProperty propertyName="logComponent">
                    <simple>POLICY</simple>
                </setProperty>
                <to uri="direct:dump-loop-log-http-response"/>
            </doCatch>
            <doFinally>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
            </doFinally>
        </doTry>
    </route>

    <!-- Camel routes not related to Loop context -->
    <route id="get-all-policy-models">
        <from uri="direct:get-all-policy-models"/>
        <doTry>
            <log loggingLevel="INFO" message="Getting all the policy models"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting all the policy models')"/>
            <setHeader headerName="CamelHttpMethod">
                <constant>GET</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to get all policy models: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes"></log>
            <toD
                    uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
            <convertBodyTo type="java.lang.String"/>
            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
            </doFinally>
        </doTry>
    </route>

    <route id="get-policy-tosca-model">
        <from uri="direct:get-policy-tosca-model"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Getting the policy tosca model: ${exchangeProperty[policyModelType]}/${exchangeProperty[policyModelVersion]}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy model')"/>
            <setHeader headerName="CamelHttpMethod">
                <constant>GET</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to get policy model: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}"></log>
            <toD
                    uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
            <convertBodyTo type="java.lang.String"/>
            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
            </doFinally>
        </doTry>
    </route>

    <route id="get-all-pdp-groups">
        <from uri="direct:get-all-pdp-groups"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Getting the list of PDP Groups"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the PDP Group list')"/>
            <setHeader headerName="CamelHttpMethod">
                <constant>GET</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to get policy model: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps"></log>
            <toD
                    uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
            <convertBodyTo type="java.lang.String"/>
            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
            </doFinally>
        </doTry>
    </route>

    <route id="get-all-policies">
        <from uri="direct:get-all-policies"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Getting the policies list"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policies list')"/>
            <setHeader headerName="CamelHttpMethod">
                <constant>GET</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to get policies list: {{clamp.config.policy.api.url}}/policy/api/v1/policies"></log>
            <toD
                    uri="{{clamp.config.policy.api.url}}/policy/api/v1/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
            <convertBodyTo type="java.lang.String"/>
            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
            </doFinally>
        </doTry>
    </route>
    <route id="add-multiple-policies-to-pdp-group">
        <from uri="direct:add-multiple-policies-to-pdp-group"/>
        <!-- Body should come from outside, expect a json describing the policy -->
        <doTry>
            <log loggingLevel="INFO"
                 message="Add policies to PDP group"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Add policies to PDP group')"/>
            <setHeader headerName="CamelHttpMethod">
                <constant>POST</constant>
            </setHeader>
            <setHeader headerName="Content-Type">
                <constant>application/json</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to add policies to PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch"></log>
            <toD
                    uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;useSystemProperties=true&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
            </doFinally>
        </doTry>
    </route>
    <route id="undeploy-one-policy-from-pap">
        <from uri="direct:undeploy-one-policy-from-pap"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Undeploy POLICY from PAP: ${exchangeProperty[policyName]}/${exchangeProperty[policyVersion]}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Undeploy POLICY from PAP')"/>
            <setBody>
                <constant>null</constant>
            </setBody>
            <setHeader headerName="CamelHttpMethod">
                <constant>DELETE</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to delete policy from PDP Group: {{clamp.config.policy.pap.url}}/pdps/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log>
            <toD
                    uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
            </doFinally>
        </doTry>
    </route>

    <route id="create-policy">
        <!-- Body should come from outside, expect a json describing the policy -->
        <from uri="direct:create-policy"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Create Policy from model ${exchangeProperty[policyModelType]}/${exchangeProperty[policyModelVersion]}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Policy')"/>
            <setHeader headerName="CamelHttpMethod">
                <constant>POST</constant>
            </setHeader>
            <setHeader headerName="Content-Type">
                <constant>application/json</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to create policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}/policies"></log>
            <toD
                    uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
            </doFinally>
        </doTry>
    </route>
    <route id="delete-policy">
        <from uri="direct:delete-policy"/>
        <doTry>
            <log loggingLevel="INFO"
                 message="Deleting Policy: ${exchangeProperty[policyName]}"/>
            <to
                    uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Policy')"/>
            <setBody>
                <constant>null</constant>
            </setBody>
            <setHeader headerName="CamelHttpMethod">
                <constant>DELETE</constant>
            </setHeader>
            <setHeader headerName="X-ONAP-RequestID">
                <simple>${exchangeProperty[X-ONAP-RequestID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-InvocationID">
                <simple>${exchangeProperty[X-ONAP-InvocationID]}
                </simple>
            </setHeader>
            <setHeader headerName="X-ONAP-PartnerName">
                <simple>${exchangeProperty[X-ONAP-PartnerName]}
                </simple>
            </setHeader>
            <log loggingLevel="INFO"
                 message="Endpoint to delete policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log>
            <toD
                    uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>

            <doFinally>
                <to uri="direct:reset-raise-http-exception-flag"/>
                <to
                        uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
            </doFinally>
        </doTry>
    </route>
</routes>