Skip to content

Commit

Permalink
Merge pull request #175 from karelmaxa/flowable-compatibility
Browse files Browse the repository at this point in the history
Enable Flowable5 compatibility mode.
  • Loading branch information
pavelhoral authored Mar 4, 2024
2 parents f8fc6f2 + 86fc017 commit f528132
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 94 deletions.
6 changes: 0 additions & 6 deletions openidm-zip/src/main/assembly/zip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,6 @@
</includes>
<outputDirectory>/wrenidm/bin</outputDirectory>
</dependencySet>
<dependencySet>
<outputDirectory>/wrenidm/bin/workflow</outputDirectory>
<includes>
<include>org.wrensecurity.wrenidm:wrenidm-workflow-flowable:**:jar-with-dependencies</include>
</includes>
</dependencySet>
<dependencySet>
<unpack>false</unpack>
<includes>
Expand Down
77 changes: 16 additions & 61 deletions wrenidm-workflow-flowable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</parent>

<artifactId>wrenidm-workflow-flowable</artifactId>
<packaging>bundle</packaging>

<name>Wren:IDM - Flowable BPMN 2.0 Integration</name>
<description>
Expand Down Expand Up @@ -94,6 +95,13 @@
<version>${flowable.version}</version>
</dependency>

<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable5-compatibility</artifactId>
<version>${flowable.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>org.apache.aries.blueprint.core</artifactId>
Expand Down Expand Up @@ -158,74 +166,21 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Import-Package>!org.flowable.camel.impl,!org.flowable.mule,*</Import-Package>
<DynamicImport-Package>*</DynamicImport-Package>
<Embed-Dependency>
<!-- Embed flowable dependencies with missing OSGI metadata -->
artifactId=flowable5-*,
artifactId=flowable-engine-common;inline=org/flowable/common/db/mapping/*.xml|org/flowable/common/db/mapping/**/*.xml
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>

<executions>
<execution>
<id>unpack</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>
</goals>

<configuration>
<artifactItems>
<artifactItem>
<groupId>org.flowable</groupId>
<artifactId>flowable-engine-common</artifactId>
<version>${flowable.version}</version>

<!-- Unpack files that are missing in the OSGI metadata (see https://github.com/flowable/flowable-engine/issues/3333) -->
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<includes>org/flowable/common/db/mapping/**/*.xml</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>remotejar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>

<configuration>
<descriptors>
<descriptor>src/assemble/assemblyCfg.xml</descriptor>
</descriptors>
</configuration>

<executions>
<execution>
<id>make-jar-with-dependencies</id>
<phase>package</phase>

<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
26 changes: 0 additions & 26 deletions wrenidm-workflow-flowable/src/assemble/assemblyCfg.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import javax.sql.DataSource;
import org.flowable.common.engine.impl.scripting.ResolverFactory;
import org.flowable.common.engine.impl.scripting.ScriptBindingsFactory;
import org.flowable.compatibility.DefaultFlowable5CompatibilityHandler;
import org.flowable.engine.ProcessEngine;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.delegate.JavaDelegate;
Expand Down Expand Up @@ -295,6 +296,10 @@ void activate(ComponentContext context) {
configuration.setDisableEventRegistry(true);
configuration.setDisableIdmEngine(true);

// Enable v5 compatibility mode
configuration.setFlowable5CompatibilityEnabled(true);
configuration.setFlowable5CompatibilityHandler(new DefaultFlowable5CompatibilityHandler());

// Retrieve process engine instance
processEngineFactory = new ProcessEngineFactory();
processEngineFactory.setProcessEngineConfiguration(configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.forgerock.json.JsonValue.array;
import static org.forgerock.json.JsonValue.json;
import static org.forgerock.json.resource.Responses.newActionResponse;
import static org.forgerock.json.resource.Responses.newQueryResponse;
import static org.forgerock.json.resource.Responses.newResourceResponse;
import static org.forgerock.openidm.util.ResourceUtil.notSupportedOnCollection;
Expand Down Expand Up @@ -45,6 +46,7 @@
import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityImpl;
import org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
Expand Down Expand Up @@ -117,7 +119,30 @@ public Promise<ActionResponse, ResourceException> actionCollection(Context conte

@Override
public Promise<ActionResponse, ResourceException> actionInstance(Context context, String resourceId, ActionRequest request) {
return notSupportedOnInstance(request).asPromise();
if ("migrate".equals(request.getAction())) {
ProcessInstance instance = processEngine.getRuntimeService().createProcessInstanceQuery()
.processInstanceId(resourceId).singleResult();
if (instance == null) {
return new BadRequestException("Invalid process instance '" + resourceId + "' to migrate.").asPromise();
}
ProcessDefinition definition = processEngine.getRepositoryService().createProcessDefinitionQuery()
.processDefinitionKey(instance.getProcessDefinitionKey()).latestVersion().singleResult();
if (definition == null) {
return new BadRequestException("Missing process definition for '" + instance.getProcessDefinitionKey() + "'.").asPromise();
}
if (instance.getProcessDefinitionId().equals(definition.getId())) {
return new BadRequestException("Process instance '" + resourceId + "' is already using the latest process definition.").asPromise();
}
try {
processEngine.getProcessMigrationService().createProcessInstanceMigrationBuilder()
.migrateToProcessDefinition(definition.getId())
.migrate(resourceId);
} catch (Exception e) {
return new InternalServerErrorException("Failed to migrate process instance '" + resourceId + "'.").asPromise();
}
return newActionResponse(new JsonValue(Map.of("Successfully migrated process instance", resourceId))).asPromise();
}
return new BadRequestException("Unknown action '" + request.getAction() + "'.").asPromise();
}

@Override
Expand Down

0 comments on commit f528132

Please sign in to comment.