diff --git a/server/apps/server-app/build.gradle.kts b/server/apps/server-app/build.gradle.kts index 7a04136453d..b2d8f209b86 100644 --- a/server/apps/server-app/build.gradle.kts +++ b/server/apps/server-app/build.gradle.kts @@ -387,6 +387,7 @@ dependencies { implementation(project(":server:ee:libs:platform:platform-custom-component:platform-custom-component-configuration:platform-custom-component-configuration-service")) implementation(project(":server:ee:libs:platform:platform-custom-component:platform-custom-component-file-storage:platform-custom-component-file-storage-impl")) implementation(project(":server:ee:libs:platform:platform-scheduler:platform-scheduler-aws")) + implementation(project(":server:ee:libs:platform:platform-scheduler:platform-scheduler-impl")) implementation(project(":server:ee:libs:platform:platform-security-web:platform-security-web-impl")) implementation(project(":server:ee:libs:modules:components:api-platform")) diff --git a/server/ee/apps/scheduler-app/build.gradle.kts b/server/ee/apps/scheduler-app/build.gradle.kts index 23c4461ef22..05576c7c10f 100644 --- a/server/ee/apps/scheduler-app/build.gradle.kts +++ b/server/ee/apps/scheduler-app/build.gradle.kts @@ -30,8 +30,9 @@ dependencies { implementation(project(":server:ee:libs:config:observability-config")) implementation(project(":server:ee:libs:core:discovery:discovery-redis")) implementation(project(":server:ee:libs:platform:platform-component:platform-component-remote-client")) - implementation(project(":server:ee:libs:platform:platform-workflow:platform-workflow-execution:platform-workflow-execution-remote-client")) + implementation(project(":server:ee:libs:platform:platform-scheduler:platform-scheduler-impl")) implementation(project(":server:ee:libs:platform:platform-scheduler:platform-scheduler-remote-rest")) + implementation(project(":server:ee:libs:platform:platform-workflow:platform-workflow-execution:platform-workflow-execution-remote-client")) runtimeOnly("org.postgresql:postgresql") runtimeOnly("com.zaxxer:HikariCP") diff --git a/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/build.gradle.kts b/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/build.gradle.kts new file mode 100644 index 00000000000..8e45346a1a3 --- /dev/null +++ b/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/build.gradle.kts @@ -0,0 +1,9 @@ +dependencies { + implementation("org.springframework:spring-context-support") + implementation("org.springframework:spring-jdbc") + implementation("org.springframework.boot:spring-boot-autoconfigure") + implementation("org.quartz-scheduler:quartz") + implementation(project(":server:libs:config:app-config")) + implementation(project(":server:libs:core:tenant:tenant-api")) + implementation(project(":server:libs:platform:platform-api")) +} diff --git a/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/config/MultiTenantQuartzTriggerSchedulerConfiguration.java b/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/config/MultiTenantQuartzTriggerSchedulerConfiguration.java new file mode 100644 index 00000000000..3087a122a47 --- /dev/null +++ b/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/config/MultiTenantQuartzTriggerSchedulerConfiguration.java @@ -0,0 +1,61 @@ +/* + * Copyright 2025 ByteChef + * + * Licensed under the ByteChef Enterprise license (the "Enterprise License"); + * you may not use this file except in compliance with the Enterprise License. + */ + +package com.bytechef.ee.platform.scheduler.config; + +import com.bytechef.config.ApplicationProperties; +import com.bytechef.ee.platform.scheduler.tenant.MultiTenantLocalDataSourceJobStore; +import com.bytechef.platform.annotation.ConditionalOnEEVersion; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.util.Properties; +import org.quartz.spi.JobFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.quartz.QuartzProperties; +import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; + +/** + * @version ee + * + * @author Ivica Cardic + */ +@Configuration +@ConditionalOnProperty( + prefix = "bytechef", name = "coordinator.trigger.scheduler.provider", havingValue = "quartz", matchIfMissing = true) +@ConditionalOnEEVersion +public class MultiTenantQuartzTriggerSchedulerConfiguration implements SchedulerFactoryBeanCustomizer { + + private final JobFactory jobFactory; + private final ApplicationProperties.Tenant.Mode mode; + private final QuartzProperties quartzProperties; + + @SuppressFBWarnings("EI") + public MultiTenantQuartzTriggerSchedulerConfiguration( + ApplicationProperties applicationProperties, JobFactory jobFactory, QuartzProperties quartzProperties) { + + this.jobFactory = jobFactory; + this.mode = applicationProperties.getTenant() + .getMode(); + this.quartzProperties = quartzProperties; + } + + @Override + public void customize(SchedulerFactoryBean schedulerFactoryBean) { + schedulerFactoryBean.setJobFactory(jobFactory); + + Properties properties = new Properties(); + + properties.putAll(quartzProperties.getProperties()); + + if (mode == ApplicationProperties.Tenant.Mode.MULTI) { + properties.put("org.quartz.jobStore.class", MultiTenantLocalDataSourceJobStore.class.getName()); + } + + schedulerFactoryBean.setQuartzProperties(properties); + } +} diff --git a/server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/tenant/MultiTenantDriverDelegate.java b/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/tenant/MultiTenantDriverDelegate.java similarity index 97% rename from server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/tenant/MultiTenantDriverDelegate.java rename to server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/tenant/MultiTenantDriverDelegate.java index c7c01230545..a9cb1bdd726 100644 --- a/server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/tenant/MultiTenantDriverDelegate.java +++ b/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/tenant/MultiTenantDriverDelegate.java @@ -1,20 +1,11 @@ /* * Copyright 2025 ByteChef * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Licensed under the ByteChef Enterprise license (the "Enterprise License"); + * you may not use this file except in compliance with the Enterprise License. */ -package com.bytechef.platform.scheduler.tenant; +package com.bytechef.ee.platform.scheduler.tenant; import com.bytechef.tenant.TenantContext; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -40,8 +31,11 @@ import org.quartz.spi.OperableTrigger; /** + * @version ee + * * @author Ivica Cardic */ +@SuppressFBWarnings("SQL_INJECTION_JDBC") public class MultiTenantDriverDelegate extends StdJDBCDelegate { private final DriverDelegate delegate; @@ -54,6 +48,7 @@ public MultiTenantDriverDelegate(DriverDelegate delegate) { @Override public int updateTriggerStatesFromOtherStates(Connection conn, String newState, String oldState1, String oldState2) throws SQLException { + return execute(conn, (connection) -> delegate.updateTriggerStatesFromOtherStates( connection, newState, oldState1, oldState2)); } @@ -167,6 +162,7 @@ public int updateJobData(Connection conn, JobDetail job) throws IOException, SQL @Override public JobDetail selectJobDetail(Connection conn, JobKey jobKey, ClassLoadHelper loadHelper) throws ClassNotFoundException, IOException, SQLException { + return execute(conn, (connection) -> { try { return delegate.selectJobDetail(connection, jobKey, loadHelper); @@ -194,6 +190,7 @@ public Set selectJobsInGroup(Connection conn, GroupMatcher match @Override public int insertTrigger(Connection conn, OperableTrigger trigger, String state, JobDetail jobDetail) throws SQLException, IOException { + return execute(conn, (connection) -> { try { return delegate.insertTrigger(connection, trigger, state, jobDetail); @@ -206,6 +203,7 @@ public int insertTrigger(Connection conn, OperableTrigger trigger, String state, @Override public int updateTrigger(Connection conn, OperableTrigger trigger, String state, JobDetail jobDetail) throws SQLException, IOException { + return execute(conn, (connection) -> { try { return delegate.updateTrigger(connection, trigger, state, jobDetail); @@ -334,6 +332,7 @@ public List selectTriggersForCalendar(Connection conn, String c @Override public OperableTrigger selectTrigger(Connection conn, TriggerKey triggerKey) throws SQLException, ClassNotFoundException, IOException, JobPersistenceException { + return execute(conn, (connection) -> { try { return delegate.selectTrigger(connection, triggerKey); @@ -346,6 +345,7 @@ public OperableTrigger selectTrigger(Connection conn, TriggerKey triggerKey) @Override public JobDataMap selectTriggerJobDataMap(Connection conn, String triggerName, String groupName) throws SQLException, ClassNotFoundException, IOException { + return execute(conn, (connection) -> { try { return delegate.selectTriggerJobDataMap(connection, triggerName, groupName); @@ -458,6 +458,7 @@ public boolean calendarExists(Connection conn, String calendarName) throws SQLEx @Override public Calendar selectCalendar(Connection conn, String calendarName) throws ClassNotFoundException, IOException, SQLException { + return execute(conn, (connection) -> { try { return delegate.selectCalendar(connection, calendarName); @@ -506,6 +507,7 @@ public List selectTriggerToAcquire(Connection conn, long noLaterThan @Override public List selectTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount) throws SQLException { + return execute(conn, (connection) -> delegate.selectTriggerToAcquire( connection, noLaterThan, noEarlierThan, maxCount)); } diff --git a/server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/tenant/MultiTenantLocalDataSourceJobStore.java b/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/tenant/MultiTenantLocalDataSourceJobStore.java similarity index 56% rename from server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/tenant/MultiTenantLocalDataSourceJobStore.java rename to server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/tenant/MultiTenantLocalDataSourceJobStore.java index 052e5bf297c..25b4531408c 100644 --- a/server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/tenant/MultiTenantLocalDataSourceJobStore.java +++ b/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/tenant/MultiTenantLocalDataSourceJobStore.java @@ -1,20 +1,11 @@ /* * Copyright 2025 ByteChef * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Licensed under the ByteChef Enterprise license (the "Enterprise License"); + * you may not use this file except in compliance with the Enterprise License. */ -package com.bytechef.platform.scheduler.tenant; +package com.bytechef.ee.platform.scheduler.tenant; import org.quartz.impl.jdbcjobstore.DriverDelegate; import org.quartz.impl.jdbcjobstore.NoSuchDelegateException; @@ -22,6 +13,8 @@ import org.springframework.scheduling.quartz.LocalDataSourceJobStore; /** + * @version ee + * * @author Ivica Cardic */ public class MultiTenantLocalDataSourceJobStore extends LocalDataSourceJobStore { diff --git a/server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/tenant/MultiTenantSemaphore.java b/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/tenant/MultiTenantSemaphore.java similarity index 75% rename from server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/tenant/MultiTenantSemaphore.java rename to server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/tenant/MultiTenantSemaphore.java index dc806c6f780..dea9d956b42 100644 --- a/server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/tenant/MultiTenantSemaphore.java +++ b/server/ee/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/ee/platform/scheduler/tenant/MultiTenantSemaphore.java @@ -1,22 +1,14 @@ /* * Copyright 2025 ByteChef * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Licensed under the ByteChef Enterprise license (the "Enterprise License"); + * you may not use this file except in compliance with the Enterprise License. */ -package com.bytechef.platform.scheduler.tenant; +package com.bytechef.ee.platform.scheduler.tenant; import com.bytechef.tenant.TenantContext; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; @@ -24,6 +16,12 @@ import org.quartz.impl.jdbcjobstore.LockException; import org.quartz.impl.jdbcjobstore.Semaphore; +/** + * @version ee + * + * @author Ivica Cardic + */ +@SuppressFBWarnings("SQL_INJECTION_JDBC") public class MultiTenantSemaphore implements Semaphore { private final Semaphore semaphore; diff --git a/server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/ScriptComponentConnectionFactory.java b/server/libs/modules/components/script/src/main/java/com/bytechef/component/script/workflow/connection/ScriptComponentConnectionFactory.java similarity index 90% rename from server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/ScriptComponentConnectionFactory.java rename to server/libs/modules/components/script/src/main/java/com/bytechef/component/script/workflow/connection/ScriptComponentConnectionFactory.java index f73a2158913..d97e3cdc5eb 100644 --- a/server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/ScriptComponentConnectionFactory.java +++ b/server/libs/modules/components/script/src/main/java/com/bytechef/component/script/workflow/connection/ScriptComponentConnectionFactory.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package com.bytechef.platform.configuration.workflow.connection; +package com.bytechef.component.script.workflow.connection; import com.bytechef.platform.component.definition.ScriptComponentDefinition; import com.bytechef.platform.component.domain.ComponentDefinition; import com.bytechef.platform.component.service.ComponentDefinitionService; import com.bytechef.platform.configuration.domain.ComponentConnection; +import com.bytechef.platform.configuration.workflow.connection.ComponentConnectionFactory; +import com.bytechef.platform.configuration.workflow.connection.ComponentConnectionFactoryResolver; import java.util.List; import java.util.Map; import java.util.Optional; diff --git a/server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/ComponentConnectionFactory.java b/server/libs/platform/platform-configuration/platform-configuration-api/src/main/java/com/bytechef/platform/configuration/workflow/connection/ComponentConnectionFactory.java similarity index 100% rename from server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/ComponentConnectionFactory.java rename to server/libs/platform/platform-configuration/platform-configuration-api/src/main/java/com/bytechef/platform/configuration/workflow/connection/ComponentConnectionFactory.java diff --git a/server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/ComponentConnectionFactoryResolver.java b/server/libs/platform/platform-configuration/platform-configuration-api/src/main/java/com/bytechef/platform/configuration/workflow/connection/ComponentConnectionFactoryResolver.java similarity index 100% rename from server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/ComponentConnectionFactoryResolver.java rename to server/libs/platform/platform-configuration/platform-configuration-api/src/main/java/com/bytechef/platform/configuration/workflow/connection/ComponentConnectionFactoryResolver.java diff --git a/server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/DefaultComponentConnectionFactory.java b/server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/DefaultComponentConnectionFactory.java index 19c3035b675..f94a1c218f4 100644 --- a/server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/DefaultComponentConnectionFactory.java +++ b/server/libs/platform/platform-configuration/platform-configuration-service/src/main/java/com/bytechef/platform/configuration/workflow/connection/DefaultComponentConnectionFactory.java @@ -28,7 +28,7 @@ * @author Ivica Cardic */ @Component -@Order(3) +@Order class DefaultComponentConnectionFactory implements ComponentConnectionFactory, ComponentConnectionFactoryResolver { diff --git a/server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/config/QuartzTriggerSchedulerConfiguration.java b/server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/config/QuartzTriggerSchedulerConfiguration.java index efb8e7db971..c7396e19d56 100644 --- a/server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/config/QuartzTriggerSchedulerConfiguration.java +++ b/server/libs/platform/platform-scheduler/platform-scheduler-impl/src/main/java/com/bytechef/platform/scheduler/config/QuartzTriggerSchedulerConfiguration.java @@ -19,55 +19,25 @@ import com.bytechef.config.ApplicationProperties; import com.bytechef.platform.scheduler.QuartzTriggerScheduler; import com.bytechef.platform.scheduler.TriggerScheduler; -import com.bytechef.platform.scheduler.tenant.MultiTenantLocalDataSourceJobStore; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Properties; import org.quartz.Scheduler; import org.quartz.spi.JobFactory; import org.quartz.spi.TriggerFiredBundle; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.quartz.QuartzProperties; -import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; import org.springframework.scheduling.quartz.SpringBeanJobFactory; +/** + * @author Ivica Cardic + */ @Configuration @ConditionalOnProperty( prefix = "bytechef", name = "coordinator.trigger.scheduler.provider", havingValue = "quartz", matchIfMissing = true) -public class QuartzTriggerSchedulerConfiguration implements SchedulerFactoryBeanCustomizer { - - private final ApplicationProperties.Tenant.Mode mode; - private final QuartzProperties quartzProperties; - - @SuppressFBWarnings("EI") - public QuartzTriggerSchedulerConfiguration( - ApplicationProperties applicationProperties, QuartzProperties quartzProperties) { - - this.mode = applicationProperties.getTenant() - .getMode(); - this.quartzProperties = quartzProperties; - } - - @Override - public void customize(SchedulerFactoryBean schedulerFactoryBean) { - schedulerFactoryBean.setJobFactory(jobFactory()); - - Properties properties = new Properties(); - - properties.putAll(quartzProperties.getProperties()); - - if (mode == ApplicationProperties.Tenant.Mode.MULTI) { - properties.put("org.quartz.jobStore.class", MultiTenantLocalDataSourceJobStore.class.getName()); - } - - schedulerFactoryBean.setQuartzProperties(properties); - } +public class QuartzTriggerSchedulerConfiguration { @Bean JobFactory jobFactory() { diff --git a/server/libs/platform/platform-webhook/platform-webhook-impl/src/main/java/com/bytechef/platform/webhook/executor/WebhookWorkflowSyncExecutor.java b/server/libs/platform/platform-webhook/platform-webhook-impl/src/main/java/com/bytechef/platform/webhook/executor/WebhookWorkflowSyncExecutor.java index 03aa66b56a1..dfdd272ce04 100644 --- a/server/libs/platform/platform-webhook/platform-webhook-impl/src/main/java/com/bytechef/platform/webhook/executor/WebhookWorkflowSyncExecutor.java +++ b/server/libs/platform/platform-webhook/platform-webhook-impl/src/main/java/com/bytechef/platform/webhook/executor/WebhookWorkflowSyncExecutor.java @@ -20,7 +20,6 @@ import com.bytechef.atlas.configuration.service.WorkflowService; import com.bytechef.commons.util.CollectionUtils; import com.bytechef.commons.util.MapUtils; -import com.bytechef.commons.util.OptionalUtils; import com.bytechef.component.definition.TriggerDefinition.WebhookValidateResponse; import com.bytechef.evaluator.Evaluator; import com.bytechef.platform.component.constant.MetadataConstants; @@ -41,6 +40,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.apache.commons.lang3.Validate; import org.springframework.stereotype.Component; @@ -89,13 +89,15 @@ public TriggerOutput execute(WorkflowExecutionId workflowExecutionId, WebhookReq triggerExecution = triggerExecutionService.create( triggerExecution.evaluate(getInputMap(workflowExecutionId), evaluator)); - triggerExecution.setState(OptionalUtils.orElse(triggerStateService.fetchValue(workflowExecutionId), null)); + Optional valueOptional = triggerStateService.fetchValue(workflowExecutionId); + + triggerExecution.setState(valueOptional.orElse(null)); triggerExecution = preProcess(triggerExecution); WorkflowNodeType workflowNodeType = getComponentOperation(workflowExecutionId, workflowId); - Map connectIdMap = MapUtils.getMap( + Map connectionIdMap = MapUtils.getMap( triggerExecution.getMetadata(), MetadataConstants.CONNECTION_IDS, Long.class, Map.of()); TriggerOutput triggerOutput = triggerDefinitionFacade.executeTrigger( @@ -104,7 +106,7 @@ public TriggerOutput execute(WorkflowExecutionId workflowExecutionId, WebhookReq workflowExecutionId.getJobPrincipalId(), workflowExecutionId.getWorkflowUuid(), triggerExecution.getParameters(), triggerExecution.getState(), MapUtils.get(triggerExecution.getMetadata(), WebhookRequest.WEBHOOK_REQUEST, WebhookRequest.class), - OptionalUtils.orElse(CollectionUtils.findFirst(connectIdMap.values()), null), false); + CollectionUtils.findFirstOrElse(connectionIdMap.values(), null), false); triggerExecution.setBatch(triggerOutput.batch()); triggerExecution.setOutput( @@ -128,11 +130,12 @@ public WebhookValidateResponse validate(WorkflowExecutionId workflowExecutionId, TriggerExecution triggerExecution = result.triggerExecution(); WorkflowNodeType workflowNodeType = result.workflowNodeType(); - Map connectIdMap = result.connectIdMap(); + Map connectionIdMap = result.connectionIdMap(); + return triggerDefinitionFacade.executeWebhookValidate( - workflowNodeType.name(), workflowNodeType.version(), - workflowNodeType.operation(), triggerExecution.getParameters(), - webhookRequest, OptionalUtils.orElse(CollectionUtils.findFirst(connectIdMap.values()), null)); + workflowNodeType.name(), workflowNodeType.version(), workflowNodeType.operation(), + triggerExecution.getParameters(), webhookRequest, + CollectionUtils.findFirstOrElse(connectionIdMap.values(), null)); } public WebhookValidateResponse validateOnEnable( @@ -140,14 +143,14 @@ public WebhookValidateResponse validateOnEnable( PreProcessResult result = preProcess(workflowExecutionId, webhookRequest); - Map connectIdMap = result.connectIdMap(); + Map connectIdMap = result.connectionIdMap(); TriggerExecution triggerExecution = result.triggerExecution(); WorkflowNodeType workflowNodeType = result.workflowNodeType(); return triggerDefinitionFacade.executeWebhookValidateOnEnable( - workflowNodeType.name(), workflowNodeType.version(), - workflowNodeType.operation(), triggerExecution.getParameters(), - webhookRequest, OptionalUtils.orElse(CollectionUtils.findFirst(connectIdMap.values()), null)); + workflowNodeType.name(), workflowNodeType.version(), workflowNodeType.operation(), + triggerExecution.getParameters(), webhookRequest, + CollectionUtils.findFirstOrElse(connectIdMap.values(), null)); } private WorkflowNodeType getComponentOperation(WorkflowExecutionId workflowExecutionId, String workflowId) { @@ -179,10 +182,10 @@ private PreProcessResult preProcess(WorkflowExecutionId workflowExecutionId, Web WorkflowNodeType workflowNodeType = getComponentOperation(workflowExecutionId, workflowId); - Map connectIdMap = MapUtils.getMap( + Map connectionIdMap = MapUtils.getMap( triggerExecution.getMetadata(), MetadataConstants.CONNECTION_IDS, Long.class, Map.of()); - return new PreProcessResult(triggerExecution, workflowNodeType, connectIdMap); + return new PreProcessResult(triggerExecution, workflowNodeType, connectionIdMap); } private String getWorkflowId(WorkflowExecutionId workflowExecutionId) { @@ -220,6 +223,6 @@ private TriggerExecution preProcess(TriggerExecution triggerExecution) { } private record PreProcessResult( - TriggerExecution triggerExecution, WorkflowNodeType workflowNodeType, Map connectIdMap) { + TriggerExecution triggerExecution, WorkflowNodeType workflowNodeType, Map connectionIdMap) { } } diff --git a/settings.gradle.kts b/settings.gradle.kts index ac1c4811fed..a9dae58d3d9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -531,8 +531,9 @@ include("server:ee:libs:platform:platform-custom-component:platform-custom-compo include("server:ee:libs:platform:platform-data-storage:platform-data-storage-jdbc:platform-data-storage-jdbc-remote-rest") include("server:ee:libs:platform:platform-data-storage:platform-data-storage-jdbc:platform-data-storage-jdbc-remote-client") include("server:ee:libs:platform:platform-notification:platform-notification-remote-client") -include("server:ee:libs:platform:platform-scheduler:platform-scheduler-remote-client") include("server:ee:libs:platform:platform-scheduler:platform-scheduler-aws") +include("server:ee:libs:platform:platform-scheduler:platform-scheduler-impl") +include("server:ee:libs:platform:platform-scheduler:platform-scheduler-remote-client") include("server:ee:libs:platform:platform-scheduler:platform-scheduler-remote-rest") include("server:ee:libs:platform:platform-security-web:platform-security-web-impl") include("server:ee:libs:platform:platform-workflow:platform-workflow-task-dispatcher:platform-workflow-task-dispatcher-registry:platform-workflow-task-dispatcher-registry-remote-client")