Skip to content

Commit b91d3ae

Browse files
committed
2629 SF
1 parent 6959328 commit b91d3ae

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

server/libs/platform/platform-webhook/platform-webhook-impl/src/main/java/com/bytechef/platform/webhook/executor/WebhookWorkflowSyncExecutor.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.bytechef.atlas.configuration.service.WorkflowService;
2121
import com.bytechef.commons.util.CollectionUtils;
2222
import com.bytechef.commons.util.MapUtils;
23-
import com.bytechef.commons.util.OptionalUtils;
2423
import com.bytechef.component.definition.TriggerDefinition.WebhookValidateResponse;
2524
import com.bytechef.evaluator.Evaluator;
2625
import com.bytechef.platform.component.constant.MetadataConstants;
@@ -41,6 +40,7 @@
4140
import java.util.List;
4241
import java.util.Map;
4342
import java.util.Objects;
43+
import java.util.Optional;
4444
import org.apache.commons.lang3.Validate;
4545
import org.springframework.stereotype.Component;
4646

@@ -89,13 +89,15 @@ public TriggerOutput execute(WorkflowExecutionId workflowExecutionId, WebhookReq
8989
triggerExecution = triggerExecutionService.create(
9090
triggerExecution.evaluate(getInputMap(workflowExecutionId), evaluator));
9191

92-
triggerExecution.setState(OptionalUtils.orElse(triggerStateService.fetchValue(workflowExecutionId), null));
92+
Optional<Object> valueOptional = triggerStateService.fetchValue(workflowExecutionId);
93+
94+
triggerExecution.setState(valueOptional.orElse(null));
9395

9496
triggerExecution = preProcess(triggerExecution);
9597

9698
WorkflowNodeType workflowNodeType = getComponentOperation(workflowExecutionId, workflowId);
9799

98-
Map<String, Long> connectIdMap = MapUtils.getMap(
100+
Map<String, Long> connectionIdMap = MapUtils.getMap(
99101
triggerExecution.getMetadata(), MetadataConstants.CONNECTION_IDS, Long.class, Map.of());
100102

101103
TriggerOutput triggerOutput = triggerDefinitionFacade.executeTrigger(
@@ -104,7 +106,7 @@ public TriggerOutput execute(WorkflowExecutionId workflowExecutionId, WebhookReq
104106
workflowExecutionId.getJobPrincipalId(), workflowExecutionId.getWorkflowUuid(),
105107
triggerExecution.getParameters(), triggerExecution.getState(),
106108
MapUtils.get(triggerExecution.getMetadata(), WebhookRequest.WEBHOOK_REQUEST, WebhookRequest.class),
107-
OptionalUtils.orElse(CollectionUtils.findFirst(connectIdMap.values()), null), false);
109+
CollectionUtils.findFirstOrElse(connectionIdMap.values(), null), false);
108110

109111
triggerExecution.setBatch(triggerOutput.batch());
110112
triggerExecution.setOutput(
@@ -128,26 +130,27 @@ public WebhookValidateResponse validate(WorkflowExecutionId workflowExecutionId,
128130
TriggerExecution triggerExecution = result.triggerExecution();
129131
WorkflowNodeType workflowNodeType = result.workflowNodeType();
130132

131-
Map<String, Long> connectIdMap = result.connectIdMap();
133+
Map<String, Long> connectionIdMap = result.connectionIdMap();
134+
132135
return triggerDefinitionFacade.executeWebhookValidate(
133-
workflowNodeType.name(), workflowNodeType.version(),
134-
workflowNodeType.operation(), triggerExecution.getParameters(),
135-
webhookRequest, OptionalUtils.orElse(CollectionUtils.findFirst(connectIdMap.values()), null));
136+
workflowNodeType.name(), workflowNodeType.version(), workflowNodeType.operation(),
137+
triggerExecution.getParameters(), webhookRequest,
138+
CollectionUtils.findFirstOrElse(connectionIdMap.values(), null));
136139
}
137140

138141
public WebhookValidateResponse validateOnEnable(
139142
WorkflowExecutionId workflowExecutionId, WebhookRequest webhookRequest) {
140143

141144
PreProcessResult result = preProcess(workflowExecutionId, webhookRequest);
142145

143-
Map<String, Long> connectIdMap = result.connectIdMap();
146+
Map<String, Long> connectIdMap = result.connectionIdMap();
144147
TriggerExecution triggerExecution = result.triggerExecution();
145148
WorkflowNodeType workflowNodeType = result.workflowNodeType();
146149

147150
return triggerDefinitionFacade.executeWebhookValidateOnEnable(
148-
workflowNodeType.name(), workflowNodeType.version(),
149-
workflowNodeType.operation(), triggerExecution.getParameters(),
150-
webhookRequest, OptionalUtils.orElse(CollectionUtils.findFirst(connectIdMap.values()), null));
151+
workflowNodeType.name(), workflowNodeType.version(), workflowNodeType.operation(),
152+
triggerExecution.getParameters(), webhookRequest,
153+
CollectionUtils.findFirstOrElse(connectIdMap.values(), null));
151154
}
152155

153156
private WorkflowNodeType getComponentOperation(WorkflowExecutionId workflowExecutionId, String workflowId) {
@@ -179,10 +182,10 @@ private PreProcessResult preProcess(WorkflowExecutionId workflowExecutionId, Web
179182

180183
WorkflowNodeType workflowNodeType = getComponentOperation(workflowExecutionId, workflowId);
181184

182-
Map<String, Long> connectIdMap = MapUtils.getMap(
185+
Map<String, Long> connectionIdMap = MapUtils.getMap(
183186
triggerExecution.getMetadata(), MetadataConstants.CONNECTION_IDS, Long.class, Map.of());
184187

185-
return new PreProcessResult(triggerExecution, workflowNodeType, connectIdMap);
188+
return new PreProcessResult(triggerExecution, workflowNodeType, connectionIdMap);
186189
}
187190

188191
private String getWorkflowId(WorkflowExecutionId workflowExecutionId) {
@@ -220,6 +223,6 @@ private TriggerExecution preProcess(TriggerExecution triggerExecution) {
220223
}
221224

222225
private record PreProcessResult(
223-
TriggerExecution triggerExecution, WorkflowNodeType workflowNodeType, Map<String, Long> connectIdMap) {
226+
TriggerExecution triggerExecution, WorkflowNodeType workflowNodeType, Map<String, Long> connectionIdMap) {
224227
}
225228
}

0 commit comments

Comments
 (0)