aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn
blob: 50600bd49f3a39266a62cb7210360e51f6a0c56b (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
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.14.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
  <bpmn2:process id="UpdateNetworkInstance" name="UpdateNetworkInstance" isExecutable="true">
    <bpmn2:startEvent id="createNetwork_startEvent" name="Start Flow">
      <bpmn2:outgoing>SequenceFlow_0lp2z7l</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:subProcess id="unexpectedErrors_SubProcess" name="Sub-process for UnexpectedErrors" triggeredByEvent="true">
      <bpmn2:scriptTask id="ScriptTask_1" name="Log / Print Unexpected Error" scriptFormat="groovy">
        <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing>
        <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.*
def networkMod = new UpdateNetworkInstance()
networkMod.processJavaException(execution)</bpmn2:script>
      </bpmn2:scriptTask>
      <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="ScriptTask_1" targetRef="EndEvent_1" />
      <bpmn2:startEvent id="StartEvent_1">
        <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing>
        <bpmn2:errorEventDefinition id="ErrorEventDefinition_2" errorRef="Error_1" />
      </bpmn2:startEvent>
      <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="StartEvent_1" targetRef="ScriptTask_1" />
      <bpmn2:endEvent id="EndEvent_1">
        <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming>
      </bpmn2:endEvent>
    </bpmn2:subProcess>
    <bpmn2:callActivity id="doUpdateNetworkInstance_CallActivity" name="DoUpdate Network Instance&#10;" calledElement="DoUpdateNetworkInstance">
      <bpmn2:extensionElements>
        <camunda:out source="WorkflowException" target="WorkflowException" />
        <camunda:in source="msoRequestId" target="msoRequestId" />
        <camunda:out source="rollbackData" target="rollbackData" />
        <camunda:in source="networkId" target="networkId" />
        <camunda:in source="networkName" target="networkName" />
        <camunda:in source="networkModelInfo" target="networkModelInfo" />
        <camunda:in source="cloudOwner" target="cloudOwner" />
        <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" />
        <camunda:in source="tenantId" target="tenantId" />
        <camunda:in source="productFamilyId" target="productFamilyId" />
        <camunda:in source="disableRollback" target="disableRollback" />
        <camunda:in source="serviceInstanceId" target="serviceInstanceId" />
        <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" />
        <camunda:in source="networkInputParams" target="networkInputParams" />
        <camunda:out source="rolledBack" target="rolledBack" />
        <camunda:out source="networkId" target="networkId" />
        <camunda:out source="networkName" target="networkName" />
        <camunda:out source="networkOutputParams" target="networkOutputParams" />
        <camunda:in source="bpmnRequest" target="bpmnRequest" />
        <camunda:in source="failIfExists" target="failIfExists" />
        <camunda:in source="sdncVersion" target="sdncVersion" />
        <camunda:in source="requestId" target="requestId" />
        <camunda:in source="serviceInstanceId" target="serviceInstanceId" />
        <camunda:in source="requestAction" target="requestAction" />
        <camunda:in source="mso-request-id" target="mso-request-id" />
        <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" />
        <camunda:in source="globalSubscriberId" target="globalSubscriberId" />
        <camunda:in source="serviceModelInfo" target="serviceModelInfo" />
      </bpmn2:extensionElements>
      <bpmn2:incoming>SequenceFlow_0eto8sn</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_1lj31zp</bpmn2:outgoing>
    </bpmn2:callActivity>
    <bpmn2:endEvent id="EndEvent_0o440av" name="End">
      <bpmn2:incoming>SequenceFlow_0x3znm5</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:scriptTask id="ScriptTask_09qt0pi" name="CreateNetwork&#10;PostProcess Success&#10;" scriptFormat="groovy">
      <bpmn2:incoming>SequenceFlow_095crcd</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_0x3znm5</bpmn2:outgoing>
      <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.*
def UpdateNetworkInstance = new  UpdateNetworkInstance()
UpdateNetworkInstance.postProcessResponse(execution)
</bpmn2:script>
    </bpmn2:scriptTask>
    <bpmn2:sequenceFlow id="SequenceFlow_1lj31zp" sourceRef="doUpdateNetworkInstance_CallActivity" targetRef="ScriptTask_0cihgpv" />
    <bpmn2:sequenceFlow id="SequenceFlow_0x3znm5" sourceRef="ScriptTask_09qt0pi" targetRef="EndEvent_0o440av" />
    <bpmn2:scriptTask id="ScriptTask_0pvcr6j" name="PreProcess Incoming Request" scriptFormat="groovy">
      <bpmn2:incoming>SequenceFlow_0lp2z7l</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_1ablr60</bpmn2:outgoing>
      <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.*
def preProcess = new UpdateNetworkInstance()
preProcess.preProcessRequest(execution)</bpmn2:script>
    </bpmn2:scriptTask>
    <bpmn2:sequenceFlow id="SequenceFlow_0lp2z7l" sourceRef="createNetwork_startEvent" targetRef="ScriptTask_0pvcr6j" />
    <bpmn2:sequenceFlow id="SequenceFlow_1ablr60" sourceRef="ScriptTask_0pvcr6j" targetRef="Task_19xbdbu" />
    <bpmn2:scriptTask id="ScriptTask_0cihgpv" name="Prepare Completion Request" scriptFormat="groovy">
      <bpmn2:incoming>SequenceFlow_1lj31zp</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_0xxvjxq</bpmn2:outgoing>
      <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.*
def UpdateNetworkInstance = new UpdateNetworkInstance()
UpdateNetworkInstance.prepareCompletion(execution)</bpmn2:script>
    </bpmn2:scriptTask>
    <bpmn2:callActivity id="CallActivity_0sevgre" name="Call CompleteMsoProcess" calledElement="CompleteMsoProcess">
      <bpmn2:extensionElements>
        <camunda:in source="UPDNI_CompleteMsoProcessRequest" target="CompleteMsoProcessRequest" />
        <camunda:in source="mso-request-id" target="mso-request-id" />
        <camunda:in source="mso-service-instance-id" target="mso-service-instance-id" />
        <camunda:out source="CMSO_ResponseCode" target="CMSO_ResponseCode" />
        <camunda:out source="CompleteMsoProcessResponse" target="CompleteMsoProcessResponse" />
        <camunda:out source="CMSO_ErrorResponse" target="CMSO_ErrorResponse" />
      </bpmn2:extensionElements>
      <bpmn2:incoming>SequenceFlow_0xxvjxq</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_095crcd</bpmn2:outgoing>
    </bpmn2:callActivity>
    <bpmn2:sequenceFlow id="SequenceFlow_0xxvjxq" sourceRef="ScriptTask_0cihgpv" targetRef="CallActivity_0sevgre" />
    <bpmn2:subProcess id="SubProcess_1k2112i" name="Sub-process for FalloutHandler" triggeredByEvent="true">
      <bpmn2:startEvent id="StartEvent_110xxgx">
        <bpmn2:outgoing>SequenceFlow_0n4umjf</bpmn2:outgoing>
        <bpmn2:errorEventDefinition errorRef="Error_2" />
      </bpmn2:startEvent>
      <bpmn2:endEvent id="EndEvent_1rqikib">
        <bpmn2:incoming>SequenceFlow_1ghqolv</bpmn2:incoming>
      </bpmn2:endEvent>
      <bpmn2:scriptTask id="ScriptTask_1hql91g" name="Prepare FalloutHandler" scriptFormat="groovy">
        <bpmn2:incoming>SequenceFlow_0n4umjf</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_1reso2f</bpmn2:outgoing>
        <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.*
def UpdateNetworkInstance = new UpdateNetworkInstance()
UpdateNetworkInstance.buildErrorResponse(execution)</bpmn2:script>
      </bpmn2:scriptTask>
      <bpmn2:callActivity id="CallActivity_1ksm1dz" name="Call FalloutHandlerV1" calledElement="FalloutHandler">
        <bpmn2:extensionElements>
          <camunda:in source="UPDNI_FalloutHandlerRequest" target="FalloutHandlerRequest" />
          <camunda:in source="mso-request-id" target="mso-request-id" />
          <camunda:in source="mso-service-instance-id" target="mso-service-instance-id" />
          <camunda:out source="FH_ResponseCode" target="FH_ResponseCode" />
          <camunda:out source="FalloutHandlerResponse" target="FalloutHandlerResponse" />
          <camunda:out source="FH_ErrorResponse" target="FH_ErrorResponse" />
        </bpmn2:extensionElements>
        <bpmn2:incoming>SequenceFlow_1reso2f</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_1ghqolv</bpmn2:outgoing>
      </bpmn2:callActivity>
      <bpmn2:sequenceFlow id="SequenceFlow_1reso2f" sourceRef="ScriptTask_1hql91g" targetRef="CallActivity_1ksm1dz" />
      <bpmn2:sequenceFlow id="SequenceFlow_1ghqolv" sourceRef="CallActivity_1ksm1dz" targetRef="EndEvent_1rqikib" />
      <bpmn2:sequenceFlow id="SequenceFlow_0n4umjf" sourceRef="StartEvent_110xxgx" targetRef="ScriptTask_1hql91g" />
    </bpmn2:subProcess>
    <bpmn2:sequenceFlow id="SequenceFlow_095crcd" sourceRef="CallActivity_0sevgre" targetRef="ScriptTask_09qt0pi" />
    <bpmn2:sequenceFlow id="SequenceFlow_0rt8wax" sourceRef="Task_19xbdbu" targetRef="Task_1nko5zz" />
    <bpmn2:sequenceFlow id="SequenceFlow_0eto8sn" sourceRef="Task_1nko5zz" targetRef="doUpdateNetworkInstance_CallActivity" />
    <bpmn2:scriptTask id="Task_19xbdbu" name="Get Network Model Info&#10;" scriptFormat="groovy">
      <bpmn2:incoming>SequenceFlow_1ablr60</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_0rt8wax</bpmn2:outgoing>
      <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.*
def UpdateNetworkInstance = new UpdateNetworkInstance()
UpdateNetworkInstance.getNetworkModelInfo(execution)</bpmn2:script>
    </bpmn2:scriptTask>
    <bpmn2:scriptTask id="Task_1nko5zz" name="Send Sync Ack Response" scriptFormat="groovy">
      <bpmn2:incoming>SequenceFlow_0rt8wax</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_0eto8sn</bpmn2:outgoing>
      <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.*
def UpdateNetworkInstance = new  UpdateNetworkInstance()
UpdateNetworkInstance.sendSyncResponse(execution)</bpmn2:script>
    </bpmn2:scriptTask>
  </bpmn2:process>
  <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
  <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="UpdateNetworkInstance">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_47" bpmnElement="createNetwork_startEvent">
        <dc:Bounds x="3" y="79" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="-3" y="120" width="48" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="_BPMNShape_SubProcess_28" bpmnElement="unexpectedErrors_SubProcess" isExpanded="true">
        <dc:Bounds x="370" y="734" width="394" height="188" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_71" bpmnElement="StartEvent_1">
        <dc:Bounds x="403" y="811" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="376" y="852" width="90" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_270" bpmnElement="ScriptTask_1">
        <dc:Bounds x="518" y="789" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="_BPMNShape_EndEvent_220" bpmnElement="EndEvent_1">
        <dc:Bounds x="679" y="811" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="652" y="852" width="90" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_StartEvent_71" targetElement="_BPMNShape_ScriptTask_270">
        <di:waypoint x="439" y="829" />
        <di:waypoint x="518" y="829" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="436" y="829" width="90" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_ScriptTask_270" targetElement="_BPMNShape_EndEvent_220">
        <di:waypoint x="618" y="829" />
        <di:waypoint x="679" y="829" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="608" y="829" width="90" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_CallActivity_72" bpmnElement="doUpdateNetworkInstance_CallActivity">
        <dc:Bounds x="692" y="57" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_0o440av_di" bpmnElement="EndEvent_0o440av">
        <dc:Bounds x="1408" y="79" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1419" y="115" width="19" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ScriptTask_09qt0pi_di" bpmnElement="ScriptTask_09qt0pi">
        <dc:Bounds x="1253" y="57" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1lj31zp_di" bpmnElement="SequenceFlow_1lj31zp">
        <di:waypoint x="792" y="97" />
        <di:waypoint x="907" y="97" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="850" y="82" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_0x3znm5_di" bpmnElement="SequenceFlow_0x3znm5">
        <di:waypoint x="1353" y="97" />
        <di:waypoint x="1408" y="97" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1381" y="82" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="ScriptTask_0pvcr6j_di" bpmnElement="ScriptTask_0pvcr6j">
        <dc:Bounds x="139" y="57" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_0lp2z7l_di" bpmnElement="SequenceFlow_0lp2z7l">
        <di:waypoint x="39" y="97" />
        <di:waypoint x="89" y="97" />
        <di:waypoint x="89" y="97" />
        <di:waypoint x="139" y="97" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="104" y="97" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_1ablr60_di" bpmnElement="SequenceFlow_1ablr60">
        <di:waypoint x="239" y="97" />
        <di:waypoint x="306" y="97" />
        <di:waypoint x="306" y="97" />
        <di:waypoint x="372" y="97" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="321" y="97" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="ScriptTask_0cihgpv_di" bpmnElement="ScriptTask_0cihgpv">
        <dc:Bounds x="907" y="57" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="CallActivity_0sevgre_di" bpmnElement="CallActivity_0sevgre">
        <dc:Bounds x="1071" y="57" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_0xxvjxq_di" bpmnElement="SequenceFlow_0xxvjxq">
        <di:waypoint x="1007" y="97" />
        <di:waypoint x="1071" y="97" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1039" y="82" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="ScriptTask_1hql91g_di" bpmnElement="ScriptTask_1hql91g">
        <dc:Bounds x="436" y="461" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="CallActivity_1ksm1dz_di" bpmnElement="CallActivity_1ksm1dz">
        <dc:Bounds x="611" y="461" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="SubProcess_1k2112i_di" bpmnElement="SubProcess_1k2112i" isExpanded="true">
        <dc:Bounds x="200" y="354" width="681" height="293" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="StartEvent_110xxgx_di" bpmnElement="StartEvent_110xxgx">
        <dc:Bounds x="283" y="483" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="256" y="524" width="90" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_1rqikib_di" bpmnElement="EndEvent_1rqikib">
        <dc:Bounds x="786" y="483" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="759" y="524" width="90" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1reso2f_di" bpmnElement="SequenceFlow_1reso2f">
        <di:waypoint x="536" y="501" />
        <di:waypoint x="611" y="501" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="529" y="486" width="90" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_1ghqolv_di" bpmnElement="SequenceFlow_1ghqolv">
        <di:waypoint x="711" y="501" />
        <di:waypoint x="786" y="501" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="704" y="486" width="90" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_095crcd_di" bpmnElement="SequenceFlow_095crcd">
        <di:waypoint x="1171" y="97" />
        <di:waypoint x="1253" y="97" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1212" y="82" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_0n4umjf_di" bpmnElement="SequenceFlow_0n4umjf">
        <di:waypoint x="319" y="501" />
        <di:waypoint x="436" y="501" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="332.5" y="486" width="90" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_0rt8wax_di" bpmnElement="SequenceFlow_0rt8wax">
        <di:waypoint x="472" y="97" />
        <di:waypoint x="558" y="97" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="515" y="82" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_0eto8sn_di" bpmnElement="SequenceFlow_0eto8sn">
        <di:waypoint x="658" y="97" />
        <di:waypoint x="692" y="97" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="675" y="82" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="ScriptTask_1gpvlh8_di" bpmnElement="Task_19xbdbu">
        <dc:Bounds x="372" y="57" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ScriptTask_1rb2dsd_di" bpmnElement="Task_1nko5zz">
        <dc:Bounds x="558" y="57" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn2:definitions>
an class="o">) { componentsUtils = componentsUtils; } private static class CustomResolver extends Resolver { @Override protected void addImplicitResolvers() { // avoid implicit resolvers for strings that can be interpreted as boolean values addImplicitResolver(Tag.STR, EMPTY, ""); addImplicitResolver(Tag.STR, NULL, null); addImplicitResolver(Tag.NULL, NULL, "~nN\0"); addImplicitResolver(Tag.NULL, EMPTY, null); addImplicitResolver(Tag.INT, INT, "-+0123456789"); addImplicitResolver(Tag.FLOAT, FLOAT, "-+0123456789."); addImplicitResolver(Tag.YAML, YAML, "!&*"); } } private static void buildMap(Map<String, Object> output, Map<String, Object> map) { for (Entry<String, Object> entry : map.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof Map) { Map<String, Object> result = new LinkedHashMap<>(); buildMap(result, (Map) value); output.put(key, result); } else if (value instanceof Collection) { Map<String, Object> result = new LinkedHashMap<>(); int i = 0; for (Object item : (Collection<Object>) value) { buildMap(result, Collections.singletonMap("[" + (i++) + "]", item)); } output.put(key, new ArrayList<>(result.values())); } else { output.put(key, value); } } } public static Map<String, Object> loadYamlAsStrictMap(String content) { Map<String, Object> result = new LinkedHashMap<>(); Object map = strictYamlLoader.load(content); buildMap(result, (Map<String, Object>) map); return result; } private static class YamlLoader extends YamlProcessor { public Yaml getStrictYamlLoader() { return createYaml(); } } @SuppressWarnings("unchecked") public static Either<List<HeatParameterDefinition>, ResultStatusEnum> getHeatParamsWithoutImplicitTypes( String heatDecodedPayload, String artifactType) { Map<String, Object> heatData = (Map<String, Object>) new Yaml(new Constructor(), new Representer(), new DumperOptions(), customResolver).load(heatDecodedPayload); return getHeatParameters(heatData, artifactType); } public static class Constants { public static final String FIRST_NON_CERTIFIED_VERSION = "0.1"; public static final String VENDOR_NAME = "ONAP (Tosca)"; public static final String VENDOR_RELEASE = "1.0.0.wd03"; public static final LifecycleStateEnum NORMATIVE_TYPE_LIFE_CYCLE = LifecycleStateEnum.CERTIFIED; public static final LifecycleStateEnum NORMATIVE_TYPE_LIFE_CYCLE_NOT_CERTIFIED_CHECKOUT = LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT; public static final boolean NORMATIVE_TYPE_HIGHEST_VERSION = true; public static final String ABSTRACT_CATEGORY_NAME = "Generic"; public static final String ABSTRACT_SUBCATEGORY = "Abstract"; public static final String DEFAULT_ICON = "defaulticon"; public static final String INNER_VFC_DESCRIPTION = "Not reusable inner VFC"; public static final String USER_DEFINED_RESOURCE_NAMESPACE_PREFIX = "org.openecomp.resource."; public static final String UI_JSON_PAYLOAD_NAME = "payloadName"; public static final String CVFC_DESCRIPTION = "Complex node type that is used as nested type in VF"; public static final String ESCAPED_DOUBLE_QUOTE = "\""; public static final String QUOTE = "'"; public static final String VF_DESCRIPTION = "Nested VF in service"; private Constants() { } } public enum ResultStatusEnum { ELEMENT_NOT_FOUND, GENERAL_ERROR, OK, INVALID_PROPERTY_DEFAULT_VALUE, INVALID_PROPERTY_TYPE, INVALID_PROPERTY_VALUE, MISSING_ENTRY_SCHEMA_TYPE, INVALID_PROPERTY_NAME } public enum ToscaElementTypeEnum { BOOLEAN, STRING, MAP, LIST, ALL } @SuppressWarnings("unchecked") private static void handleElementNameNotFound(String elementName, Object elementValue, ToscaElementTypeEnum elementType, List<Object> returnedList) { if (elementValue instanceof Map) { findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList); } else if (elementValue instanceof List) { findAllToscaElementsInList((List<Object>) elementValue, elementName, elementType, returnedList); } } @SuppressWarnings("unchecked") private static void addFoundElementAccordingToItsType(String elementName, ToscaElementTypeEnum elementType, List<Object> returnedList, Object elementValue) { if (elementValue instanceof Boolean) { if (elementType == ToscaElementTypeEnum.BOOLEAN || elementType == ToscaElementTypeEnum.ALL) { returnedList.add(elementValue); } } else if (elementValue instanceof String) { if (elementType == ToscaElementTypeEnum.STRING || elementType == ToscaElementTypeEnum.ALL) { returnedList.add(elementValue); } } else if (elementValue instanceof Map) { if (elementType == ToscaElementTypeEnum.MAP || elementType == ToscaElementTypeEnum.ALL) { returnedList.add(elementValue); } findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList); } else if (elementValue instanceof List) { if (elementType == ToscaElementTypeEnum.LIST || elementType == ToscaElementTypeEnum.ALL) { returnedList.add(elementValue); } findAllToscaElementsInList((List<Object>) elementValue, elementName, elementType, returnedList); } // For Integer, Double etc... else if (elementType == ToscaElementTypeEnum.ALL && elementValue != null) { returnedList.add(String.valueOf(elementValue)); } } private static void findAllToscaElementsInList(List<Object> list, String elementName, ToscaElementTypeEnum elementType, List<Object> returnedList) { list.forEach(elementValue -> handleElementNameNotFound(elementName, elementValue, elementType, returnedList)); } public static Either<Object, ResultStatusEnum> findToscaElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementName, ToscaElementTypeEnum elementType) { List<Object> foundElements = new ArrayList<>(); findToscaElements(toscaJson, elementName.getElementName(), elementType, foundElements); if (!isEmpty(foundElements)) { return Either.left(foundElements.get(0)); } return Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND); } /** * Recursively searches for all tosca elements with key equals to elementName and value equals to elementType. <br> * Returns Either element with:<br> List with all value if values found<br> Or ELEMENT_NOT_FOUND ActionStatus * * @param toscaJson * @return */ public static Either<List<Object>, ResultStatusEnum> findToscaElements(Map<String, Object> toscaJson, String elementName, ToscaElementTypeEnum elementType, List<Object> returnedList) { Either<List<Object>, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND); String skipKey = null; if (toscaJson.containsKey(elementName)) { skipKey = handleFoundElement(toscaJson, elementName, elementType, returnedList); } Iterator<Entry<String, Object>> keyValItr = toscaJson.entrySet().iterator(); while (keyValItr.hasNext()) { Entry<String, Object> keyValEntry = keyValItr.next(); if (!String.valueOf(keyValEntry.getKey()).equals(skipKey)) { handleElementNameNotFound(elementName, keyValEntry.getValue(), elementType, returnedList); } } if (!isEmpty(returnedList)) { returnedElement = Either.left(returnedList); } return returnedElement; } private static String handleFoundElement(Map<String, Object> toscaJson, String elementName, ToscaElementTypeEnum elementType, List<Object> returnedList) { Object elementValue = toscaJson.get(elementName); addFoundElementAccordingToItsType(elementName, elementType, returnedList, elementValue); return elementName; } @SuppressWarnings("unchecked") public static <T> Either<List<T>, ResultStatusEnum> findFirstToscaListElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum toscaTagName) { Either<List<T>, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND); Either<Object, ResultStatusEnum> findFirstToscaElement = findToscaElement(toscaJson, toscaTagName, ToscaElementTypeEnum.LIST); if (findFirstToscaElement.isLeft()) { returnedElement = Either.left((List<T>) findFirstToscaElement.left().value()); } return returnedElement; } @SuppressWarnings("unchecked") public static <T> Either<Map<String, T>, ResultStatusEnum> findFirstToscaMapElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum toscaTagName) { Either<Map<String, T>, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND); Either<Object, ResultStatusEnum> findFirstToscaElement = findToscaElement(toscaJson, toscaTagName, ToscaElementTypeEnum.MAP); if (findFirstToscaElement.isLeft()) { returnedElement = Either.left((Map<String, T>) findFirstToscaElement.left().value()); } return returnedElement; } public static Either<String, ResultStatusEnum> findFirstToscaStringElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum toscaTagName) { Either<String, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND); Either<Object, ResultStatusEnum> findFirstToscaElements = findToscaElement(toscaJson, toscaTagName, ToscaElementTypeEnum.STRING); if (findFirstToscaElements.isLeft()) { returnedElement = Either.left((String) findFirstToscaElements.left().value()); } return returnedElement; } /** * searches for first Tosca in Json map (toscaJson) boolean element by name (toscaTagName) returns found element or * ELEMENT_NOT_FOUND status * * @param toscaJson * @param toscaTagName * @return */ public static Either<String, ResultStatusEnum> findFirstToscaBooleanElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum toscaTagName) { Either<String, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND); Either<Object, ResultStatusEnum> findFirstToscaElements = findToscaElement(toscaJson, toscaTagName, ToscaElementTypeEnum.BOOLEAN); if (findFirstToscaElements.isLeft()) { returnedElement = Either.left(String.valueOf(findFirstToscaElements.left().value())); } return returnedElement; } private static void setPropertyConstraints(Map<String, Object> propertyValue, PropertyDefinition property) { List<PropertyConstraint> constraints = getPropertyConstraints(propertyValue, property.getType()); if (CollectionUtils.isNotEmpty(constraints)) { property.setConstraints(constraints); } } private static List<PropertyConstraint> getPropertyConstraints(Map<String, Object> propertyValue, String propertyType) { List<Object> propertyFieldConstraints = findCurrentLevelConstraintsElement(propertyValue); if (CollectionUtils.isNotEmpty(propertyFieldConstraints)) { List<PropertyConstraint> constraintList = new ArrayList<>(); Type constraintType = new TypeToken<PropertyConstraint>() { }.getType(); Gson gson = new GsonBuilder().registerTypeAdapter(constraintType, new PropertyConstraintDeserialiser()) .create(); for (Object constraintJson : propertyFieldConstraints) { PropertyConstraint propertyConstraint = validateAndGetPropertyConstraint(propertyType, constraintType, gson, constraintJson); constraintList.add(propertyConstraint); } return constraintList; } return null; } private static List<Object> findCurrentLevelConstraintsElement(Map<String, Object> toscaJson) { List<Object> constraints = null; if (toscaJson.containsKey(TypeUtils.ToscaTagNamesEnum.CONSTRAINTS.getElementName())) { try { constraints = (List<Object>) toscaJson.get(TypeUtils.ToscaTagNamesEnum.CONSTRAINTS.getElementName()); } catch (ClassCastException e) { throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS_FORMAT, toscaJson.get(TypeUtils.ToscaTagNamesEnum.CONSTRAINTS.getElementName()).toString()); } } return constraints; } private static PropertyConstraint validateAndGetPropertyConstraint(String propertyType, Type constraintType, Gson gson, Object constraintJson) { PropertyConstraint propertyConstraint; try { propertyConstraint = gson.fromJson(gson.toJson(constraintJson), constraintType); } catch (ClassCastException | JsonParseException e) { throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS_FORMAT, constraintJson.toString()); } if (propertyConstraint != null && propertyConstraint instanceof ValidValuesConstraint) { try { ((ValidValuesConstraint) propertyConstraint).validateType(propertyType); } catch (ConstraintValueDoNotMatchPropertyTypeException e) { BeEcompErrorManager.getInstance().logInternalFlowError("GetInitializedPropertyConstraint", e.getMessage(), BeEcompErrorManager.ErrorSeverity.ERROR); throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS, ConstraintType.VALID_VALUES.name(), ((ValidValuesConstraint) propertyConstraint).getValidValues().toString(), propertyType); } } return propertyConstraint; } public static PropertyDefinition createModuleProperty(Map<String, Object> propertyValue) { PropertyDefinition propertyDef = new PropertyDefinition(); setField(propertyValue, TypeUtils.ToscaTagNamesEnum.TYPE, propertyDef::setType); setFieldBoolean(propertyValue, ToscaTagNamesEnum.REQUIRED, req -> propertyDef.setRequired(Boolean.parseBoolean(req))); setField(propertyValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, propertyDef::setDescription); setJsonStringField(propertyValue, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, propertyDef.getType(), propertyDef::setDefaultValue); setJsonStringField(propertyValue, TypeUtils.ToscaTagNamesEnum.VALUE, propertyDef.getType(), propertyDef::setValue); setFieldBoolean(propertyValue, TypeUtils.ToscaTagNamesEnum.IS_PASSWORD, pass -> propertyDef.setPassword(Boolean.parseBoolean(pass))); setField(propertyValue, TypeUtils.ToscaTagNamesEnum.STATUS, propertyDef::setStatus); setScheme(propertyValue, propertyDef); setPropertyConstraints(propertyValue, propertyDef); return propertyDef; } private static void setJsonStringField(Map<String, Object> propertyValue, ToscaTagNamesEnum elementName, String type, Consumer<String> setter) { Either<Object, ResultStatusEnum> eitherValue = findToscaElement(propertyValue, elementName, ToscaElementTypeEnum.ALL); if (eitherValue.isLeft()) { String propertyJsonStringValue = getPropertyJsonStringValue(eitherValue.left().value(), type); setter.accept(propertyJsonStringValue); } } public static Annotation createModuleAnnotation(Map<String, Object> annotationMap, AnnotationTypeOperations annotationTypeOperations) { String parsedAnnotationType = findFirstToscaStringElement(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE) .left().value(); AnnotationTypeDefinition annotationTypeObject = annotationTypeOperations.getLatestType(parsedAnnotationType); if (annotationTypeObject != null) { Annotation annotation = new Annotation(); setField(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE, annotation::setType); setField(annotationMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, annotation::setDescription); Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = getProperties(annotationMap); modifyPropertiesKeysToProperForm(properties, annotation); return annotation; } return null; } private static Either<Boolean, ResponseFormat> modifyPropertiesKeysToProperForm( Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties, Annotation annotation) { Either<Boolean, ResponseFormat> result = Either.left(true); if (properties.isLeft()) { List<PropertyDataDefinition> propertiesList = new ArrayList<>(); Map<String, PropertyDefinition> value = properties.left().value(); if (value != null) { for (Entry<String, PropertyDefinition> entry : value.entrySet()) { String name = entry.getKey(); if (!PROPERTY_NAME_PATTERN_IGNORE_LENGTH.matcher(name).matches()) { log.debug("The property with invalid name {} occurred upon import resource {}. ", name, annotation.getName()); result = Either.right(componentsUtils.getResponseFormat(componentsUtils .convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME, JsonPresentationFields.PROPERTY))); } PropertyDefinition propertyDefinition = entry.getValue(); propertyDefinition.setValue(propertyDefinition.getName()); propertyDefinition.setName(name); propertiesList.add(propertyDefinition); } } annotation.setProperties(propertiesList); } else if (properties.right().value() != ResultStatusEnum.ELEMENT_NOT_FOUND) { result = Either .right(componentsUtils.getResponseFormat(componentsUtils.convertFromResultStatusEnum(properties .right() .value(), JsonPresentationFields.PROPERTY))); } return result; } public static InputDefinition createModuleInput(Map<String, Object> inputValue, AnnotationTypeOperations annotationTypeOperations) { InputDefinition inputDef = new InputDefinition(); setField(inputValue, TypeUtils.ToscaTagNamesEnum.TYPE, inputDef::setType); setFieldBoolean(inputValue, ToscaTagNamesEnum.REQUIRED, req -> inputDef.setRequired(Boolean.parseBoolean(req))); setField(inputValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, inputDef::setDescription); setJsonStringField(inputValue, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, inputDef.getType(), inputDef::setDefaultValue); setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IS_PASSWORD, pass -> inputDef.setPassword(Boolean.parseBoolean(pass))); setField(inputValue, TypeUtils.ToscaTagNamesEnum.STATUS, inputDef::setStatus); setField(inputValue, TypeUtils.ToscaTagNamesEnum.LABEL, inputDef::setLabel); setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.HIDDEN, hidden -> inputDef.setHidden(Boolean.parseBoolean(hidden))); setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IMMUTABLE, immutable -> inputDef.setImmutable(Boolean.parseBoolean(immutable))); setScheme(inputValue, inputDef); setPropertyConstraints(inputValue, inputDef); return parseAnnotationsAndAddItToInput(inputDef, inputValue, annotationTypeOperations); } public static InputDefinition parseAnnotationsAndAddItToInput(InputDefinition inputDef, Map<String, Object> inputValue, AnnotationTypeOperations annotationTypeOperations) { Function<String, Annotation> elementGenByName = ImportUtils::createAnnotation; Function<Map<String, Object>, Annotation> func = annotation -> createModuleAnnotation(annotation, annotationTypeOperations); return getElements(inputValue, TypeUtils.ToscaTagNamesEnum.ANNOTATIONS, elementGenByName, func). left().map(annotations -> modifyInputWithAnnotations(inputDef, annotations)). left().on(err -> { log.error("Parsing annotations or adding them to the PropertyDataDefinition object failed"); return inputDef; }); } private static InputDefinition modifyInputWithAnnotations(InputDefinition inputDef, Map<String, Annotation> annotationsMap) { setAnnotationsName(annotationsMap); inputDef.setAnnotationsToInput(annotationsMap.values()); return inputDef; } public static AttributeDefinition createModuleAttribute(Map<String, Object> attributeMap) { AttributeDefinition attributeDef = new AttributeDefinition(); setField(attributeMap, TypeUtils.ToscaTagNamesEnum.TYPE, attributeDef::setType); setField(attributeMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, attributeDef::setDescription); setField(attributeMap, TypeUtils.ToscaTagNamesEnum.STATUS, attributeDef::setStatus); setJsonStringField(attributeMap, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, attributeDef.getType(), attributeDef::set_default); setScheme(attributeMap, attributeDef); return attributeDef; } private static void setScheme(Map<String, Object> propertyValue, ToscaDataDefinition toscaDataDefinition) { Either<Object, ResultStatusEnum> schemaElementRes = findSchemaElement(propertyValue); if (schemaElementRes.isLeft()) { SchemaDefinition schemaDef = getSchema(schemaElementRes.left().value()); toscaDataDefinition.setSchema(schemaDef); } } private static Either<Object, ResultStatusEnum> findSchemaElement(Map<String, Object> propertyValue) { return findToscaElement(propertyValue, TypeUtils.ToscaTagNamesEnum.ENTRY_SCHEMA, ToscaElementTypeEnum.ALL); } private static SchemaDefinition getSchema(Object propertyFieldEntryScheme) { SchemaDefinition schema = new SchemaDefinition(); if (propertyFieldEntryScheme instanceof String) { String schemaType = (String) propertyFieldEntryScheme; PropertyDefinition schemeProperty = new PropertyDefinition(); schemeProperty.setType(schemaType); schema.setProperty(schemeProperty); } else if (propertyFieldEntryScheme instanceof Map) { PropertyDefinition schemeProperty = createModuleProperty((Map<String, Object>) propertyFieldEntryScheme); schema.setProperty(schemeProperty); } return schema; } private static void setField(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum tagName, Consumer<String> setter) { Either<String, ResultStatusEnum> fieldStringValue = findFirstToscaStringElement(toscaJson, tagName); if (fieldStringValue.isLeft()) { setter.accept(fieldStringValue.left().value()); } } public static void setFieldBoolean(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum tagName, Consumer<String> setter) { Either<String, ResultStatusEnum> fieldStringValue = findFirstToscaBooleanElement(toscaJson, tagName); if (fieldStringValue.isLeft()) { setter.accept(fieldStringValue.left().value()); } } public static Either<Map<String, PropertyDefinition>, ResultStatusEnum> getProperties( Map<String, Object> toscaJson) { Function<String, PropertyDefinition> elementGenByName = ImportUtils::createProperties; Function<Map<String, Object>, PropertyDefinition> func = ImportUtils::createModuleProperty; return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.PROPERTIES, elementGenByName, func); } public static Either<Map<String, InputDefinition>, ResultStatusEnum> getInputs(Map<String, Object> toscaJson, AnnotationTypeOperations annotationTypeOperations) { Function<String, InputDefinition> elementGenByName = ImportUtils::createInputs; Function<Map<String, Object>, InputDefinition> func = object -> createModuleInput(object, annotationTypeOperations); return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS, elementGenByName, func); } public static <T> Either<Map<String, T>, ResultStatusEnum> getElements(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementTagName, Function<String, T> elementGenByName, Function<Map<String, Object>, T> func) { Either<Map<String, T>, ResultStatusEnum> eitherResult = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND); Either<Map<String, Object>, ResultStatusEnum> toscaAttributes = findFirstToscaMapElement(toscaJson, elementTagName); if (toscaAttributes.isLeft()) { Map<String, Object> jsonAttributes = toscaAttributes.left().value(); Map<String, T> moduleAttributes = new HashMap<>(); Iterator<Entry<String, Object>> propertiesNameValue = jsonAttributes.entrySet().iterator(); while (propertiesNameValue.hasNext()) { Entry<String, Object> attributeNameValue = propertiesNameValue.next(); if (attributeNameValue.getValue() instanceof Map) { @SuppressWarnings("unchecked") T attribute = func.apply((Map<String, Object>) attributeNameValue.getValue()); if (attribute != null) { moduleAttributes.put(String.valueOf(attributeNameValue.getKey()), attribute); } } else { T element = elementGenByName.apply(String.valueOf(attributeNameValue.getValue())); moduleAttributes.put(String.valueOf(attributeNameValue.getKey()), element); } } if (moduleAttributes.size() > 0) { eitherResult = Either.left(moduleAttributes); } } return eitherResult; } private static AttributeDefinition createAttribute(String name) { AttributeDefinition attribute = new AttributeDefinition(); attribute.setName(name); return attribute; } private static PropertyDefinition createProperties(String name) { PropertyDefinition property = new PropertyDefinition(); property.setDefaultValue(name); property.setName(name); return property; } private static InputDefinition createInputs(String name) { InputDefinition input = new InputDefinition(); input.setName(name); return input; } private static Annotation createAnnotation(String name) { Annotation annotation = new Annotation(); annotation.setName(name); return annotation; } public static Either<List<HeatParameterDefinition>, ResultStatusEnum> getHeatParameters(Map<String, Object> heatData, String artifactType) { Either<List<HeatParameterDefinition>, ResultStatusEnum> eitherResult = Either .right(ResultStatusEnum.ELEMENT_NOT_FOUND); Either<Map<String, Object>, ResultStatusEnum> toscaProperties = findFirstToscaMapElement(heatData, TypeUtils.ToscaTagNamesEnum.PARAMETERS); if (toscaProperties.isLeft()) { Map<String, Object> jsonProperties = toscaProperties.left().value(); List<HeatParameterDefinition> moduleProperties = new ArrayList<>(); Iterator<Entry<String, Object>> propertiesNameValue = jsonProperties.entrySet().iterator(); while (propertiesNameValue.hasNext()) { Entry<String, Object> propertyNameValue = propertiesNameValue.next(); if (propertyNameValue.getValue() instanceof Map || propertyNameValue.getValue() instanceof List) { if (!artifactType.equals(ArtifactTypeEnum.HEAT_ENV.getType())) { @SuppressWarnings("unchecked") Either<HeatParameterDefinition, ResultStatusEnum> propertyStatus = createModuleHeatParameter( (Map<String, Object>) propertyNameValue.getValue()); if (propertyStatus.isRight()) { return Either.right(propertyStatus.right().value()); } HeatParameterDefinition property = propertyStatus.left().value(); property.setName(String.valueOf(propertyNameValue.getKey())); moduleProperties.add(property); } else { addHeatParamDefinition(moduleProperties, propertyNameValue, true); } } else { addHeatParamDefinition(moduleProperties, propertyNameValue, false); } } if (!isEmpty(moduleProperties)) { eitherResult = Either.left(moduleProperties); } } return eitherResult; } private static void addHeatParamDefinition(List<HeatParameterDefinition> moduleProperties, Entry<String, Object> propertyNameValue, boolean isJson) { HeatParameterDefinition property = new HeatParameterDefinition(); Object value = propertyNameValue.getValue(); if (value != null) { property.setDefaultValue( isJson ? new Gson().toJson(value) : StringEscapeUtils.escapeJava(String.valueOf(value))); } property.setName(String.valueOf(propertyNameValue.getKey())); moduleProperties.add(property); } private static Either<HeatParameterDefinition, ResultStatusEnum> createModuleHeatParameter( Map<String, Object> propertyValue) { HeatParameterDefinition propertyDef = new HeatParameterDefinition(); String type; Either<String, ResultStatusEnum> propertyFieldType = findFirstToscaStringElement(propertyValue, TypeUtils.ToscaTagNamesEnum.TYPE); if (propertyFieldType.isLeft()) { type = propertyFieldType.left().value(); propertyDef.setType(type); } else { return Either.right(ResultStatusEnum.INVALID_PROPERTY_TYPE); } Either<String, ResultStatusEnum> propertyFieldDescription = findFirstToscaStringElement(propertyValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION); if (propertyFieldDescription.isLeft()) { propertyDef.setDescription(propertyFieldDescription.left().value()); } Either<Object, ResultStatusEnum> propertyFieldDefaultVal = findToscaElement(propertyValue, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, ToscaElementTypeEnum.ALL); if (propertyFieldDefaultVal.isLeft()) { if (propertyFieldDefaultVal.left().value() == null) { return Either.right(ResultStatusEnum.INVALID_PROPERTY_VALUE); } Object value = propertyFieldDefaultVal.left().value(); String defaultValue = type.equals(HeatParameterType.JSON.getType()) ? new Gson().toJson(value) : StringEscapeUtils.escapeJava(String.valueOf(value)); propertyDef.setDefaultValue(defaultValue); propertyDef.setCurrentValue(defaultValue); } return Either.left(propertyDef); } public static boolean containsGetInput(Object propValue) { String value = getPropertyJsonStringValue(propValue, ToscaPropertyType.MAP.getType()); return value != null && value.contains(TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName()); } public static String getPropertyJsonStringValue(Object value, String type) { Gson gson = new Gson(); if (type == null) { return null; } ToscaPropertyType validType = ToscaPropertyType.isValidType(type); if (validType == null || validType == ToscaPropertyType.JSON || validType == ToscaPropertyType.MAP || validType == ToscaPropertyType.LIST) { return gson.toJson(value); } return value.toString(); } /** * removes from Json map (toscaJson) first element found by name (elementName) note that this method could update * the received argument toscaJson * * @param toscaJson * @param elementName */ public static void removeElementFromJsonMap(Map<String, Object> toscaJson, String elementName) { for (Entry<String, Object> entry : toscaJson.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key.equals(elementName)) { toscaJson.remove(elementName); return; } else if (value instanceof Map) { removeElementFromJsonMap((Map<String, Object>) value, elementName); } } } }