Skip to content

Commit

Permalink
Connection Local + Saas
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-yves-monnet committed Aug 7, 2024
1 parent 30f88b1 commit 89e26c0
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 133 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ The scenario does not contain any server information. It has only the server.
Process-Automator references a list of servers in the configuration in multiple ways:
* serverConnection : String, containing a list of connections separated by ;
* serverList: List of records.
* camunda7 : information to connnect a Camunda 7 server
* camunda7 : information to connect a Camunda 7 server
* camunda8 : information to connect a Camunda 8 server
* camunda8Saas: information to connect a Camunda 8 Saas server

Expand Down Expand Up @@ -188,6 +188,7 @@ The application runs only these role. Doing that, in a cluster, it's possible to

## server connection


### String connection

The string contains a list of connections, separate by a semi-colon (":").
Expand Down Expand Up @@ -218,18 +219,21 @@ The following parameters depend on the type.

**CAMUNDA_8_SAAS**

* zeebeCloudRegion,
* zeebeCloudClusterId,
* zeebeCloudClientId,
* zeebeCloudOAuthUrl,
* zeebeCloudAudience,
* zeebeSaasRegion,
* zeebeSaasClusterId,
* zeebeSaasClientId,
* clientSecret,
* OperateUserName,
* OperateUserPassword,
* OperateUrl,
* zeebeAudience
* OperateClientId,
* OperateClientPassword,
* TaskClientId
TaskClientSecret
* ExecutionThreads,
* MaxJobActive




**Example**

````yaml
Expand Down Expand Up @@ -340,23 +344,23 @@ mvn clean install
````
Now, create a docker image
````
docker build -t pierre-yves-monnet/processautomator:1.5.0 .
docker build -t pierre-yves-monnet/processautomator:1.5.1 .
````
Push the image to the Camunda hub (you must be login first to the docker registry)
````
docker tag pierre-yves-monnet/processautomator:1.5.0 ghcr.io/camunda-community-hub/process-execution-automator:1.5.0
docker push ghcr.io/camunda-community-hub/process-execution-automator:1.5.0
docker tag pierre-yves-monnet/processautomator:1.5.1 ghcr.io/camunda-community-hub/process-execution-automator:1.5.1
docker push ghcr.io/camunda-community-hub/process-execution-automator:1.5.1
````
Tag as the latest:
````
docker tag pierre-yves-monnet/processautomator:1.5.0 ghcr.io/camunda-community-hub/process-execution-automator:latest
docker tag pierre-yves-monnet/processautomator:1.5.1 ghcr.io/camunda-community-hub/process-execution-automator:latest
docker push ghcr.io/camunda-community-hub/process-execution-automator:latest
````
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<groupId>org.camunda.community.automator</groupId>
<artifactId>process-execution-automator</artifactId>

<version>1.5.0</version>
<version>1.5.2</version>
<!-- Change the banner.txt version -->
<!-- 1.5 Change OperateClient Library -->
<!-- 1.5 Change OperateClient / TaskList Library -->

<properties>
<java.version>17</java.version>
Expand Down Expand Up @@ -102,7 +102,7 @@
<dependency>
<groupId>io.camunda</groupId>
<artifactId>camunda-tasklist-client-java</artifactId>
<version>1.6.1</version>
<version>8.5.3.5</version>
</dependency>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static BpmnEngineList getCamundaSaas8(String zeebeCloudRegister,
serverDefinition.serverType = BpmnEngineList.CamundaEngine.CAMUNDA_8;
serverDefinition.zeebeSaasRegion = zeebeCloudRegion;
serverDefinition.zeebeSaasClusterId = zeebeCloudClusterId;
serverDefinition.zeebeSaasClientId = zeebeCloudClientId;
serverDefinition.zeebeClientId = zeebeCloudClientId;

bpmEngineConfiguration.addExplicitServer(serverDefinition);

Expand Down

Large diffs are not rendered by default.

109 changes: 70 additions & 39 deletions src/main/java/org/camunda/automator/configuration/BpmnEngineList.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ public class BpmnEngineList {
public static final String CONF_WORKER_MAX_JOBS_ACTIVE = "workerMaxJobsActive";
public static final String CONF_WORKER_EXECUTION_THREADS = "workerExecutionThreads";
public static final String CONF_TASK_LIST_URL = "taskListUrl";
public static final String CONF_TASK_LIST_USER = "taskListUserName";
public static final String CONF_TASK_LIST_PASSWORD = "taskListUserPassword";
public static final String CONF_TASK_LIST_CLIENT_ID = "taskListClientId";
public static final String CONF_TASK_LIST_CLIENT_SECRET = "taskListClientSecret";

public static final String CONF_IDENTITY_URL = "identityUrl";
public static final String CONF_OPERATE_URL = "operateUrl";
public static final String CONF_OPERATE_USER_PASSWORD = "operateUserPassword";
public static final String CONF_OPERATE_USER_NAME = "operateUserName";
public static final String CONF_OPERATE_AUTHENTICATIONURL = "operateAuthenticationUrl";
public static final String CONF_OPERATE_CLIENTID = "operateClientId";
public static final String CONF_OPERATE_CLIENTSECRET = "operateClientSecret";
public static final String CONF_AUTHENTICATIONURL = "authenticationUrl";
public static final String CONF_OPERATE_CLIENT_ID = "operateClientId";
public static final String CONF_OPERATE_CLIENT_SECRET = "operateClientSecret";
public static final String CONF_OPERATE_AUDIENCE = "operateAudientce";

public static final String CONF_ZEEBE_GATEWAY_ADDRESS = "zeebeGatewayAddress";
Expand All @@ -44,11 +49,11 @@ public class BpmnEngineList {
public static final String CONF_TYPE_V_CAMUNDA_7 = "camunda7";

public static final String CONF_ZEEBE_SAAS_REGION = "region";
public static final String CONF_ZEEBE_SAAS_SECRET = "secret";
public static final String CONF_ZEEBE_SECRET = "zeebeClientSecret";
public static final String CONF_ZEEBE_SAAS_CLUSTER_ID = "clusterId";
public static final String CONF_ZEEBE_SAAS_CLIENT_ID = "clientId";
public static final String CONF_ZEEBE_SAAS_OAUTHURL = "oAuthUrl";
public static final String CONF_ZEEBE_SAAS_AUDIENCE = "audience";
public static final String CONF_ZEEBE_CLIENT_ID = "zeebeClientId";
public static final String CONF_ZEEBE_AUDIENCE = "zeebeAudience";
public static final String ZEEBE_DEFAULT_AUDIENCE = "zeebe.camunda.io";

static Logger logger = LoggerFactory.getLogger(BpmnEngineList.class);

Expand Down Expand Up @@ -83,7 +88,7 @@ public void init() {
serverDetails += switch (server.serverType) {
case CAMUNDA_8 -> "ZeebeadressGateway [" + server.zeebeGatewayAddress + "]";
case CAMUNDA_8_SAAS ->
"ZeebeClientId [" + server.zeebeSaasClientId + "] ClusterId[" + server.zeebeSaasClusterId + "] RegionId["
"ZeebeClientId [" + server.zeebeClientId + "] ClusterId[" + server.zeebeSaasClusterId + "] RegionId["
+ server.zeebeSaasRegion + "]";
case CAMUNDA_7 -> "Camunda7URL [" + server.camunda7ServerUrl + "]";
case DUMMY -> "Dummy";
Expand Down Expand Up @@ -127,7 +132,7 @@ public BpmnEngineList.BpmnServerDefinition getByServerName(String serverName) th
* @return a server
* @throws AutomatorException on any error
*/
public BpmnEngineList.BpmnServerDefinition getByServerType(CamundaEngine serverType) throws AutomatorException {
public BpmnEngineList.BpmnServerDefinition getByServerType(CamundaEngine serverType) {
Optional<BpmnServerDefinition> first = allServers.stream()
.filter(t -> sameType(t.serverType, serverType))
.findFirst();
Expand Down Expand Up @@ -195,41 +200,56 @@ private List<BpmnServerDefinition> getFromServersList() throws AutomatorExceptio
throw new AutomatorException(
"Incorrect Definition - [url] expected for [" + CONF_TYPE_V_CAMUNDA_7 + "] type " + contextLog);
}


if (CONF_TYPE_V_CAMUNDA_8.equalsIgnoreCase(getString(CONF_TYPE, serverMap, null, contextLog, true))) {
bpmnServerDefinition.serverType = CamundaEngine.CAMUNDA_8;
bpmnServerDefinition.zeebeGatewayAddress = getString(CONF_ZEEBE_GATEWAY_ADDRESS, serverMap, null, contextLog,
true);
bpmnServerDefinition.zeebeClientId = getString(CONF_ZEEBE_CLIENT_ID, serverMap, null, contextLog,
false);
bpmnServerDefinition.zeebeClientSecret = getString(CONF_ZEEBE_SECRET, serverMap, null, contextLog,
false);
bpmnServerDefinition.zeebeAudience = getString(CONF_ZEEBE_AUDIENCE, serverMap, ZEEBE_DEFAULT_AUDIENCE, contextLog, false);
bpmnServerDefinition.authenticationUrl = getString(CONF_AUTHENTICATIONURL, serverMap, null, contextLog,
false);

bpmnServerDefinition.identityUrl = getString(CONF_IDENTITY_URL, serverMap, null, contextLog, false);
bpmnServerDefinition.operateUrl = getString(CONF_OPERATE_URL, serverMap, null, contextLog, false);
bpmnServerDefinition.operateUserName = getString(CONF_OPERATE_USER_NAME, serverMap, "Demo", contextLog, false);
bpmnServerDefinition.operateUserPassword = getString(CONF_OPERATE_USER_PASSWORD, serverMap, "Demo", contextLog,
false);
bpmnServerDefinition.operateUrl = getString(CONF_OPERATE_URL, serverMap, null, contextLog, false);
bpmnServerDefinition.operateAuthenticationUrl = getString(CONF_OPERATE_AUTHENTICATIONURL, serverMap, null,
contextLog, false);
bpmnServerDefinition.operateClientId = getString(CONF_OPERATE_CLIENTID, serverMap, null, contextLog, false);
bpmnServerDefinition.operateClientSecret = getString(CONF_OPERATE_CLIENTSECRET, serverMap, null, contextLog,
bpmnServerDefinition.operateClientId = getString(CONF_OPERATE_CLIENT_ID, serverMap, null, contextLog, false);
bpmnServerDefinition.operateClientSecret = getString(CONF_OPERATE_CLIENT_SECRET, serverMap, null, contextLog,
false);
bpmnServerDefinition.operateAudience = getString(CONF_OPERATE_AUDIENCE, serverMap, null, contextLog, false);

bpmnServerDefinition.taskListUrl = getString(CONF_TASK_LIST_URL, serverMap, null, contextLog, false);
bpmnServerDefinition.taskListUserName = getString(CONF_TASK_LIST_USER, serverMap, null, contextLog, false);
bpmnServerDefinition.taskListUserPassword = getString(CONF_TASK_LIST_PASSWORD, serverMap, null, contextLog, false);
bpmnServerDefinition.taskListClientId = getString(CONF_TASK_LIST_CLIENT_ID, serverMap, null, contextLog, false);
bpmnServerDefinition.taskListClientSecret = getString(CONF_TASK_LIST_CLIENT_SECRET, serverMap, null, contextLog,
false);
bpmnServerDefinition.workerExecutionThreads = getInteger(CONF_WORKER_EXECUTION_THREADS, serverMap,
DEFAULT_VALUE_EXECUTION_THREADS, contextLog);
if (bpmnServerDefinition.zeebeGatewayAddress == null)
throw new AutomatorException(
"Incorrect Definition - [zeebeGatewayAddress] expected for [" + CONF_TYPE_V_CAMUNDA_8 + "] type");
}


if (CONF_TYPE_V_CAMUNDA_8_SAAS.equalsIgnoreCase(getString(CONF_TYPE, serverMap, null, contextLog, true))) {
bpmnServerDefinition.serverType = CamundaEngine.CAMUNDA_8_SAAS;
bpmnServerDefinition.zeebeSaasRegion = getString(CONF_ZEEBE_SAAS_REGION, serverMap, null, contextLog, true);
bpmnServerDefinition.zeebeSaasClientSecret = getString(CONF_ZEEBE_SAAS_SECRET, serverMap, null, contextLog,
true);
bpmnServerDefinition.zeebeSaasClusterId = getString(CONF_ZEEBE_SAAS_CLUSTER_ID, serverMap, null, contextLog,
true);
bpmnServerDefinition.zeebeSaasClientId = getString(CONF_ZEEBE_SAAS_CLIENT_ID, serverMap, null, contextLog,
bpmnServerDefinition.zeebeClientId = getString(CONF_ZEEBE_CLIENT_ID, serverMap, null, contextLog,
true);
bpmnServerDefinition.zeebeSaasOAuthUrl = getString(CONF_ZEEBE_SAAS_OAUTHURL, serverMap, null, contextLog, true);
bpmnServerDefinition.zeebeSaasAudience = getString(CONF_ZEEBE_SAAS_AUDIENCE, serverMap, null, contextLog, true);
bpmnServerDefinition.zeebeClientSecret = getString(CONF_ZEEBE_SECRET, serverMap, null, contextLog,
true);
bpmnServerDefinition.zeebeAudience = getString(CONF_ZEEBE_AUDIENCE, serverMap, ZEEBE_DEFAULT_AUDIENCE, contextLog, true);
bpmnServerDefinition.authenticationUrl = getString(CONF_AUTHENTICATIONURL, serverMap, "https://login.cloud.camunda.io/oauth/token", contextLog,
false);

bpmnServerDefinition.workerExecutionThreads = getInteger(CONF_WORKER_EXECUTION_THREADS, serverMap,
DEFAULT_VALUE_EXECUTION_THREADS, contextLog);
Expand All @@ -238,8 +258,11 @@ private List<BpmnServerDefinition> getFromServersList() throws AutomatorExceptio
false);
bpmnServerDefinition.operateUrl = getString(CONF_OPERATE_URL, serverMap, null, contextLog, false);
bpmnServerDefinition.taskListUrl = getString(CONF_TASK_LIST_URL, serverMap, null, contextLog, false);
if (bpmnServerDefinition.zeebeSaasRegion == null || bpmnServerDefinition.zeebeSaasClientSecret == null
|| bpmnServerDefinition.zeebeSaasClusterId == null || bpmnServerDefinition.zeebeSaasClientId == null)
bpmnServerDefinition.taskListClientId = getString(CONF_TASK_LIST_CLIENT_ID, serverMap, null, contextLog, false);
bpmnServerDefinition.taskListClientSecret = getString(CONF_TASK_LIST_CLIENT_SECRET, serverMap, null, contextLog,false);

if (bpmnServerDefinition.zeebeSaasRegion == null || bpmnServerDefinition.zeebeClientSecret == null
|| bpmnServerDefinition.zeebeSaasClusterId == null || bpmnServerDefinition.zeebeClientId == null)
throw new AutomatorException(
"Incorrect Definition - [zeebeCloudRegister],[zeebeCloudRegion], [zeebeClientSecret},[zeebeCloudClusterId],[zeebeCloudClientId] expected for [Camunda8SaaS] type");
}
Expand Down Expand Up @@ -281,14 +304,14 @@ private BpmnServerDefinition decodeServerConnection(String connectionString, Str
} else if (CamundaEngine.CAMUNDA_8_SAAS.equals(bpmnServerDefinition.serverType)) {
bpmnServerDefinition.zeebeSaasRegion = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.zeebeSaasClusterId = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.zeebeSaasClientId = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.zeebeSaasClientSecret = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.zeebeSaasOAuthUrl = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.zeebeSaasAudience = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.operateUrl = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.operateUserName = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.operateUserPassword = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.taskListUrl = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.zeebeClientId = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.zeebeClientSecret = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.zeebeAudience = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.operateClientId = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.operateClientSecret = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.taskListClientId = (st.hasMoreTokens() ? st.nextToken() : null);
bpmnServerDefinition.taskListClientSecret = (st.hasMoreTokens() ? st.nextToken() : null);

bpmnServerDefinition.workerExecutionThreads = (st.hasMoreTokens() ?
parseInt(CONF_WORKER_EXECUTION_THREADS, st.nextToken(), DEFAULT_VALUE_EXECUTION_THREADS, contextLog) :
null);
Expand Down Expand Up @@ -356,10 +379,10 @@ private List<BpmnServerDefinition> getFromServerConfiguration() {
camunda8.name = configurationServersEngine.zeebeName;
camunda8.zeebeSaasRegion = configurationServersEngine.zeebeSaasRegion;
camunda8.zeebeSaasClusterId = configurationServersEngine.zeebeSaasClusterId;
camunda8.zeebeSaasClientId = configurationServersEngine.zeebeSaasClientId;
camunda8.zeebeSaasClientSecret = configurationServersEngine.zeebeSaasClientSecret;
camunda8.zeebeSaasOAuthUrl = configurationServersEngine.zeebeSaasOAuthUrl;
camunda8.zeebeSaasAudience = configurationServersEngine.zeebeSaasAudience;
camunda8.zeebeClientId = configurationServersEngine.zeebeSaasClientId;
camunda8.zeebeClientSecret = configurationServersEngine.zeebeSaasClientSecret;
camunda8.authenticationUrl = configurationServersEngine.zeebeSaasOAuthUrl;
camunda8.zeebeAudience = configurationServersEngine.zeebeSaasAudience;
camunda8.operateUrl = configurationServersEngine.zeebeOperateUrl;
camunda8.operateUserName = configurationServersEngine.zeebeOperateUserName;
camunda8.operateUserPassword = configurationServersEngine.zeebeOperateUserPassword;
Expand Down Expand Up @@ -469,10 +492,9 @@ public static class BpmnServerDefinition {
*/
public String zeebeSaasRegion;
public String zeebeSaasClusterId;
public String zeebeSaasClientId;
public String zeebeSaasClientSecret;
public String zeebeSaasOAuthUrl;
public String zeebeSaasAudience;
public String zeebeClientId;
public String zeebeClientSecret;
public String zeebeAudience;

public String identityUrl;
/**
Expand All @@ -483,11 +505,16 @@ public static class BpmnServerDefinition {
public String operateUrl;

// something like "http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token"
public String operateAuthenticationUrl;
public String authenticationUrl;
public String operateClientId;
public String operateClientSecret;
public String operateAudience;

public String taskListUrl;
public String taskListUserName;
public String taskListUserPassword;
public String taskListClientId;
public String taskListClientSecret;

/**
* Camunda 7
Expand Down Expand Up @@ -515,6 +542,10 @@ public boolean isTaskList() {
return !(taskListUrl == null || taskListUrl.isEmpty());
}

public boolean isAuthenticationUrl() {
return !(authenticationUrl == null || authenticationUrl.isEmpty());
}

public String getSynthesis() {
String synthesis = serverType.name();
if (serverType.equals(CamundaEngine.CAMUNDA_7)) {
Expand All @@ -525,7 +556,7 @@ public String getSynthesis() {
+ workerMaxJobsActive + "]";
}
if (serverType.equals(CamundaEngine.CAMUNDA_8_SAAS)) {
synthesis += " clientId[" + zeebeSaasClientId + "] workerThread[" + workerExecutionThreads + "] MaxJobActive["
synthesis += " clientId[" + zeebeClientId + "] workerThread[" + workerExecutionThreads + "] MaxJobActive["
+ workerMaxJobsActive + "]";
}
return synthesis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ public class ConfigurationServersEngine {
public String zeebeSaasClusterId;
@Value("${automator.servers.camunda8Saas.clientId:''}")
public String zeebeSaasClientId;

@Value("${automator.servers.camunda8Saas.secret:''}")
public String zeebeSaasClientSecret;

@Value("${automator.servers.camunda8Saas.oAuthUrl:''}")
public String zeebeSaasOAuthUrl;
@Value("${automator.servers.camunda8Saas.audience:''}")
public String zeebeSaasAudience;

@Value("${automator.servers.camunda8Saas.secret:''}")
public String zeebeSaasClientSecret;
@Value("${automator.servers.camunda8Saas.operateUrl:''}")
public String zeebeSaasOperateUrl;
@Value("${automator.servers.camunda8Saas.operateUserName:''}")
Expand Down
Loading

0 comments on commit 89e26c0

Please sign in to comment.