11<?xml version =" 1.0" encoding =" UTF-8" ?>
22<bpmn : definitions xmlns : bpmn =" http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns : bpmndi =" http://www.omg.org/spec/BPMN/20100524/DI" xmlns : dc =" http://www.omg.org/spec/DD/20100524/DC" xmlns : camunda =" http://camunda.org/schema/1.0/bpmn" xmlns : di =" http://www.omg.org/spec/DD/20100524/DI" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xmlns : modeler =" http://camunda.org/schema/modeler/1.0" id =" Definitions_08oxgyg" targetNamespace =" http://bpmn.io/schema/bpmn" exporter =" Camunda Modeler" exporterVersion =" 5.0.0" modeler : executionPlatform =" Camunda Platform" >
3+ <bpmn : error id =" Error_BucketCreation" name =" BucketCreationError" errorCode =" BUCKET_CREATION_FAILED" />
34 <bpmn : process id =" create-bucket" name =" CreateBucketWorkflow" isExecutable =" true" camunda : historyTimeToLive =" 300" >
45 <bpmn : startEvent id =" Event_0kew5uc" name =" Start" >
56 <bpmn : outgoing >Flow_15fflso</bpmn : outgoing >
@@ -44,7 +45,8 @@ JSON.stringify(p)</camunda:script>
4445 <camunda : script scriptFormat =" groovy" >var system = java.lang.System;
4546system.getenv('COMS_API_HOST_URL')+"/api/v1/bucket"</camunda : script >
4647 </camunda : inputParameter >
47- <camunda : outputParameter name =" bucketInfo" >${S(response)}</camunda : outputParameter >
48+ <camunda : outputParameter name =" bucketResponse" >${response}</camunda : outputParameter >
49+ <camunda : outputParameter name =" bucketStatusCode" >${statusCode}</camunda : outputParameter >
4850 </camunda : inputOutput >
4951 <camunda : connectorId >http-connector</camunda : connectorId >
5052 </camunda : connector >
@@ -56,6 +58,56 @@ system.getenv('COMS_API_HOST_URL')+"/api/v1/bucket"</camunda:script>
5658 <bpmn : incoming >Flow_0bn2xps</bpmn : incoming >
5759 <bpmn : incoming >Flow_01w6ao9</bpmn : incoming >
5860 </bpmn : endEvent >
61+ <bpmn : endEvent id =" Event_ErrorEnd" name =" Error End" >
62+ <bpmn : incoming >Flow_ErrorToEnd</bpmn : incoming >
63+ <bpmn : errorEventDefinition id =" ErrorEventDefinition_CreateBucket" errorRef =" Error_BucketCreation" />
64+ </bpmn : endEvent >
65+ <bpmn : scriptTask id =" Activity_HandleError" name =" Handle Bucket Creation Error" scriptFormat =" javascript" >
66+ <bpmn : incoming >Flow_TokenError</bpmn : incoming >
67+ <bpmn : incoming >Flow_BucketError</bpmn : incoming >
68+ <bpmn : incoming >Flow_ScriptError</bpmn : incoming >
69+ <bpmn : outgoing >Flow_ErrorToEnd</bpmn : outgoing >
70+ <bpmn : script >var system = java.lang.System;
71+
72+
73+
74+ var applicationId = execution.getVariable('applicationId');
75+ var processInstanceId = execution.getProcessInstanceId();
76+ var activityId = execution.getCurrentActivityId();
77+ var timestamp = new java.util.Date().toString();
78+
79+
80+ var errorMessage = "BUCKET_CREATION_FAILED - " +
81+ "ApplicationId: " + applicationId +
82+ ", ProcessInstanceId: " + processInstanceId +
83+ ", ActivityId: " + activityId +
84+ ", Timestamp: " + timestamp;
85+
86+
87+ system.out.println(errorMessage);
88+
89+
90+ // Store detailed error info for monitoring
91+ execution.setVariable('bucketCreationError', true);
92+ execution.setVariable('bucketErrorTimestamp', timestamp);
93+ execution.setVariable('bucketErrorProcessId', processInstanceId);</bpmn : script >
94+ </bpmn : scriptTask >
95+ <bpmn : boundaryEvent id =" Event_TokenGenerationError" name =" Token Error" attachedToRef =" Activity_0nm63gf" >
96+ <bpmn : outgoing >Flow_TokenError</bpmn : outgoing >
97+ <bpmn : errorEventDefinition id =" ErrorEventDefinition_Token" />
98+ </bpmn : boundaryEvent >
99+ <bpmn : boundaryEvent id =" Event_BucketCreationError" name =" Bucket Error" attachedToRef =" Activity_1w8sq4d" >
100+ <bpmn : outgoing >Flow_BucketError</bpmn : outgoing >
101+ <bpmn : errorEventDefinition id =" ErrorEventDefinition_Bucket" />
102+ </bpmn : boundaryEvent >
103+ <bpmn : boundaryEvent id =" Event_ScriptError" name =" Script Error" attachedToRef =" Activity_1cy9bql" >
104+ <bpmn : outgoing >Flow_ScriptError</bpmn : outgoing >
105+ <bpmn : errorEventDefinition id =" ErrorEventDefinition_Script" />
106+ </bpmn : boundaryEvent >
107+ <bpmn : sequenceFlow id =" Flow_TokenError" sourceRef =" Event_TokenGenerationError" targetRef =" Activity_HandleError" />
108+ <bpmn : sequenceFlow id =" Flow_BucketError" sourceRef =" Event_BucketCreationError" targetRef =" Activity_HandleError" />
109+ <bpmn : sequenceFlow id =" Flow_ScriptError" sourceRef =" Event_ScriptError" targetRef =" Activity_HandleError" />
110+ <bpmn : sequenceFlow id =" Flow_ErrorToEnd" sourceRef =" Activity_HandleError" targetRef =" Event_ErrorEnd" />
59111 <bpmn : sequenceFlow id =" Flow_093urcj" sourceRef =" Activity_1w8sq4d" targetRef =" Activity_1cy9bql" />
60112 <bpmn : sequenceFlow id =" Flow_15fflso" sourceRef =" Event_0kew5uc" targetRef =" Activity_04ks0sg" >
61113 <bpmn : extensionElements >
@@ -67,9 +119,28 @@ system.getenv('COMS_API_HOST_URL')+"/api/v1/bucket"</camunda:script>
67119 <bpmn : incoming >Flow_093urcj</bpmn : incoming >
68120 <bpmn : outgoing >Flow_1lr16lw</bpmn : outgoing >
69121 <bpmn : script >var system = java.lang.System;
70- system.out.println ("bucketInfo:"+bucketInfo);
71- execution.setVariable('bucketId',bucketInfo.prop("bucketId").value());
72- system.out.println ("bucketId:"+execution.getVariable('bucketId'));
122+ system.out.println ("bucketResponse:"+bucketResponse);
123+ system.out.println ("bucketStatusCode:"+bucketStatusCode);
124+
125+ // Parse bucket response safely
126+ try {
127+ if (bucketResponse != null && (bucketStatusCode == 200 || bucketStatusCode == 201)) {
128+ var bucketData = S(bucketResponse);
129+ if (bucketData.hasProp('bucketId')) {
130+ execution.setVariable('bucketId', bucketData.prop('bucketId').value());
131+ system.out.println ('bucketId:'+execution.getVariable('bucketId'));
132+ } else {
133+ system.out.println ('ERROR: No bucketId in response');
134+ throw new org.camunda.bpm.engine.delegate.BpmnError('BUCKET_CREATION_FAILED', 'No bucketId in response');
135+ }
136+ } else {
137+ system.out.println ('ERROR: Bucket creation failed - Status: ' + bucketStatusCode);
138+ throw new org.camunda.bpm.engine.delegate.BpmnError('BUCKET_CREATION_FAILED', 'Bucket creation API call failed');
139+ }
140+ } catch (e) {
141+ system.out.println ('ERROR: Failed to parse bucket response: ' + e.message);
142+ throw new org.camunda.bpm.engine.delegate.BpmnError('BUCKET_CREATION_FAILED', 'Failed to parse bucket response');
143+ }
73144
74145</bpmn : script >
75146 </bpmn : scriptTask >
@@ -115,7 +186,7 @@ JSON.stringify(p)</camunda:script>
115186 <camunda : script scriptFormat =" groovy" >var system = java.lang.System;
116187system.getenv('COMS_API_HOST_URL')+"/api/v1/permission/bucket/"+execution.getVariable("bucketId")</camunda : script >
117188 </camunda : inputParameter >
118- <camunda : outputParameter name =" permissionInfo " >${S( response) }</camunda : outputParameter >
189+ <camunda : outputParameter name =" permissionResponse " >${response}</camunda : outputParameter >
119190 </camunda : inputOutput >
120191 <camunda : connectorId >http-connector</camunda : connectorId >
121192 </camunda : connector >
@@ -132,7 +203,7 @@ system.getenv('COMS_API_HOST_URL')+"/api/v1/permission/bucket/"+execution.getVar
132203 <bpmn : incoming >Flow_0yp68e5</bpmn : incoming >
133204 <bpmn : outgoing >Flow_1kisrm5</bpmn : outgoing >
134205 <bpmn : script >var system = java.lang.System;
135- system.out.println ("permissionInfo :"+permissionInfo );
206+ system.out.println ("permissionResponse :"+permissionResponse );
136207execution.setVariable('uploadLink',system.getenv('BCBOX_HOST_URL')+'/list/objects?bucketId='+execution.getVariable('bucketId'));
137208execution.setVariable('name','User');
138209
@@ -226,7 +297,7 @@ system.getenv('COMS_API_HOST_URL')+"/api/v1/user?email="+execution.getVariable("
226297 <camunda : outputParameter name =" statusCode" >
227298 <camunda : script scriptFormat =" javascript" >statusCode;</camunda : script >
228299 </camunda : outputParameter >
229- <camunda : outputParameter name =" userInfoResponse" >${S( response) }</camunda : outputParameter >
300+ <camunda : outputParameter name =" userInfoResponse" >${response}</camunda : outputParameter >
230301 </camunda : inputOutput >
231302 <camunda : connectorId >http-connector</camunda : connectorId >
232303 </camunda : connector >
@@ -261,11 +332,25 @@ execution.setVariable('failedEmailIdsToProcess',JSON.stringify(failedEmailIdsToP
261332 <bpmn : outgoing >Flow_02ipbuj</bpmn : outgoing >
262333 <bpmn : script >var system = java.lang.System;
263334system.out.println ("status"+statusCode);
264- system.out.println ("userInfoResponse"+userInfoResponse);
265- var responseArray = userInfoResponse.mapTo("java.util.ArrayList");
266- if(responseArray.length == 0 )
267- {
268- execution.setVariable('noUserFound',true);
335+ system.out.println ("userResponse"+userInfoResponse);
336+
337+ // Handle user search response safely
338+ execution.setVariable('noUserFound', true); // Default to not found
339+
340+ try {
341+ if (userInfoResponse != null && statusCode == 200) {
342+ var userData = S(userInfoResponse);
343+ var responseArray = userData.mapTo('java.util.ArrayList');
344+ if(responseArray.length > 0) {
345+ execution.setVariable('noUserFound', false);
346+ execution.setVariable('userInfoResponse', userData); // Set for downstream processing
347+ }
348+ } else {
349+ system.out.println ('User search failed - Status: ' + statusCode);
350+ }
351+ } catch (e) {
352+ system.out.println ('ERROR: Failed to parse user response: ' + e.message);
353+ execution.setVariable('noUserFound', true);
269354}</bpmn : script >
270355 </bpmn : scriptTask >
271356 <bpmn : exclusiveGateway id =" Gateway_19dzxjx" >
@@ -355,7 +440,7 @@ mypayload;</camunda:script>
355440var authUrl = system.getenv('BCBOX_AUTH_URL');
356441authUrl;</camunda : script >
357442 </camunda : inputParameter >
358- <camunda : outputParameter name =" token " >${S( response).prop("access_token").value() }</camunda : outputParameter >
443+ <camunda : outputParameter name =" tokenResponse " >${response}</camunda : outputParameter >
359444 </camunda : inputOutput >
360445 <camunda : connectorId >http-connector</camunda : connectorId >
361446 </camunda : connector >
@@ -369,7 +454,27 @@ authUrl;</camunda:script>
369454 <bpmn : script >var system = java.lang.System;
370455
371456system.out.println ("category: "+category);
372- system.out.println ("name: "+name);</bpmn : script >
457+ system.out.println ("name: "+name);
458+
459+ // Parse token from response safely
460+ try {
461+ if (tokenResponse != null) {
462+ var tokenData = S(tokenResponse);
463+ if (tokenData.hasProp('access_token')) {
464+ execution.setVariable('token', tokenData.prop('access_token').value());
465+ system.out.println ('Token generated successfully');
466+ } else {
467+ system.out.println ('ERROR: No access_token in response');
468+ throw new org.camunda.bpm.engine.delegate.BpmnError('TOKEN_GENERATION_FAILED', 'No access token in response');
469+ }
470+ } else {
471+ system.out.println ('ERROR: Token generation failed - no response received');
472+ throw new org.camunda.bpm.engine.delegate.BpmnError('TOKEN_GENERATION_FAILED', 'Failed to generate authentication token');
473+ }
474+ } catch (e) {
475+ system.out.println ('ERROR: Failed to parse token response: ' + e.message);
476+ throw new org.camunda.bpm.engine.delegate.BpmnError('TOKEN_GENERATION_FAILED', 'Failed to parse token response');
477+ }</bpmn : script >
373478 </bpmn : scriptTask >
374479 <bpmn : sequenceFlow id =" Flow_0cog7s9" sourceRef =" Activity_0nm63gf" targetRef =" Activity_14p4bxs" />
375480 <bpmn : sequenceFlow id =" Flow_1xs70ve" sourceRef =" Activity_14p4bxs" targetRef =" Activity_1w8sq4d" />
@@ -492,6 +597,28 @@ system.out.println ("name: "+name);</bpmn:script>
492597 <di : waypoint x =" 550" y =" 250" />
493598 <di : waypoint x =" 440" y =" 250" />
494599 </bpmndi : BPMNEdge >
600+ <bpmndi : BPMNEdge id =" Flow_ErrorToEnd_di" bpmnElement =" Flow_ErrorToEnd" >
601+ <di : waypoint x =" 1250" y =" 190" />
602+ <di : waypoint x =" 1466" y =" 190" />
603+ <di : waypoint x =" 1466" y =" 160" />
604+ <di : waypoint x =" 1682" y =" 160" />
605+ </bpmndi : BPMNEdge >
606+ <bpmndi : BPMNEdge id =" Flow_ScriptError_di" bpmnElement =" Flow_ScriptError" >
607+ <di : waypoint x =" 440" y =" 308" />
608+ <di : waypoint x =" 440" y =" 360" />
609+ <di : waypoint x =" 1220" y =" 360" />
610+ <di : waypoint x =" 1220" y =" 230" />
611+ </bpmndi : BPMNEdge >
612+ <bpmndi : BPMNEdge id =" Flow_BucketError_di" bpmnElement =" Flow_BucketError" >
613+ <di : waypoint x =" 668" y =" 290" />
614+ <di : waypoint x =" 1200" y =" 290" />
615+ <di : waypoint x =" 1200" y =" 230" />
616+ </bpmndi : BPMNEdge >
617+ <bpmndi : BPMNEdge id =" Flow_TokenError_di" bpmnElement =" Flow_TokenError" >
618+ <di : waypoint x =" 510" y =" 178" />
619+ <di : waypoint x =" 510" y =" 190" />
620+ <di : waypoint x =" 1150" y =" 190" />
621+ </bpmndi : BPMNEdge >
495622 <bpmndi : BPMNShape id =" Event_0kew5uc_di" bpmnElement =" Event_0kew5uc" >
496623 <dc : Bounds x =" 172" y =" 102" width =" 36" height =" 36" />
497624 <bpmndi : BPMNLabel >
@@ -511,6 +638,16 @@ system.out.println ("name: "+name);</bpmn:script>
511638 <dc : Bounds x =" 1670" y =" 678" width =" 20" height =" 14" />
512639 </bpmndi : BPMNLabel >
513640 </bpmndi : BPMNShape >
641+ <bpmndi : BPMNShape id =" BPMNShape_ErrorEnd" bpmnElement =" Event_ErrorEnd" >
642+ <dc : Bounds x =" 1682" y =" 142" width =" 36" height =" 36" />
643+ <bpmndi : BPMNLabel >
644+ <dc : Bounds x =" 1676" y =" 185" width =" 48" height =" 14" />
645+ </bpmndi : BPMNLabel >
646+ </bpmndi : BPMNShape >
647+ <bpmndi : BPMNShape id =" BPMNShape_HandleError" bpmnElement =" Activity_HandleError" >
648+ <dc : Bounds x =" 1150" y =" 150" width =" 100" height =" 80" />
649+ <bpmndi : BPMNLabel />
650+ </bpmndi : BPMNShape >
514651 <bpmndi : BPMNShape id =" Activity_13xdoy5_di" bpmnElement =" Activity_1cy9bql" >
515652 <dc : Bounds x =" 340" y =" 210" width =" 100" height =" 80" />
516653 <bpmndi : BPMNLabel />
@@ -575,6 +712,24 @@ system.out.println ("name: "+name);</bpmn:script>
575712 <bpmndi : BPMNShape id =" BPMNShape_16v32xz" bpmnElement =" Activity_14p4bxs" >
576713 <dc : Bounds x =" 550" y =" 80" width =" 100" height =" 80" />
577714 </bpmndi : BPMNShape >
715+ <bpmndi : BPMNShape id =" BPMNShape_BucketError" bpmnElement =" Event_BucketCreationError" >
716+ <dc : Bounds x =" 632" y =" 272" width =" 36" height =" 36" />
717+ <bpmndi : BPMNLabel >
718+ <dc : Bounds x =" 618.5" y =" 318" width =" 63" height =" 14" />
719+ </bpmndi : BPMNLabel >
720+ </bpmndi : BPMNShape >
721+ <bpmndi : BPMNShape id =" BPMNShape_TokenError" bpmnElement =" Event_TokenGenerationError" >
722+ <dc : Bounds x =" 492" y =" 142" width =" 36" height =" 36" />
723+ <bpmndi : BPMNLabel >
724+ <dc : Bounds x =" 538" y =" 153" width =" 58" height =" 14" />
725+ </bpmndi : BPMNLabel >
726+ </bpmndi : BPMNShape >
727+ <bpmndi : BPMNShape id =" Event_ScriptError_di" bpmnElement =" Event_ScriptError" >
728+ <dc : Bounds x =" 422" y =" 272" width =" 36" height =" 36" />
729+ <bpmndi : BPMNLabel >
730+ <dc : Bounds x =" 467.5" y =" 283" width =" 57" height =" 14" />
731+ </bpmndi : BPMNLabel >
732+ </bpmndi : BPMNShape >
578733 </bpmndi : BPMNPlane >
579734 </bpmndi : BPMNDiagram >
580735</bpmn : definitions >
0 commit comments