Skip to content

Commit 07d3ce3

Browse files
committed
default tenant id
1 parent 2970d1f commit 07d3ce3

File tree

10 files changed

+77
-19
lines changed

10 files changed

+77
-19
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ tasklist:
9898
client-secret:
9999
```
100100
101-
Configure defaults that influence the client behaviour:
101+
Configure defaults that influence the client behavior:
102102
103103
```yaml
104104
tasklist:
@@ -107,6 +107,8 @@ tasklist:
107107
load-truncated-variables: true
108108
return-variables: true
109109
use-zeebe-user-tasks: true
110+
tenant-ids:
111+
- <default>
110112
```
111113
112114
### Plain Java
@@ -131,6 +133,7 @@ URL tasklistUrl = URI.create("http://localhost:8082").toURL();
131133
boolean returnVariables = false;
132134
boolean loadTruncatedVariables = false;
133135
boolean useZeebeUserTasks = true;
136+
List<String> tenantIds = List.of("<default>");
134137
// if you are using zeebe user tasks, you require a zeebe client as well
135138
ZeebeClient zeebeClient = zeebeClient();
136139
// bootstrapping
@@ -142,14 +145,16 @@ CamundaTasklistClientConfiguration configuration =
142145
authentication,
143146
tasklistUrl,
144147
zeebeClient,
145-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
148+
new DefaultProperties(
149+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
150+
146151
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
147152
```
148153

149154
Build a Camunda Tasklist client with identity authentication:
150155

151156
```java
152-
// properties you need to provide
157+
// properties you need to provide
153158
String clientId = "";
154159
String clientSecret = "";
155160
String audience = "tasklist-api";
@@ -162,6 +167,7 @@ URL authUrl =
162167
boolean returnVariables = false;
163168
boolean loadTruncatedVariables = false;
164169
boolean useZeebeUserTasks = true;
170+
List<String> tenantIds = List.of("<default>");
165171
// if you are using zeebe user tasks, you require a zeebe client as well
166172
ZeebeClient zeebeClient = zeebeClient();
167173
// bootstrapping
@@ -176,21 +182,23 @@ CamundaTasklistClientConfiguration configuration =
176182
authentication,
177183
tasklistUrl,
178184
zeebeClient,
179-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
185+
new DefaultProperties(
186+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
180187
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
181188
```
182189

183190
Build a Camunda Tasklist client for Saas:
184191

185192
```java
186-
// properties you need to provide
193+
// properties you need to provide
187194
String region = "";
188195
String clusterId = "";
189196
String clientId = "";
190197
String clientSecret = "";
191198
boolean returnVariables = false;
192199
boolean loadTruncatedVariables = false;
193200
boolean useZeebeUserTasks = true;
201+
List<String> tenantIds = List.of("<default>");
194202
// if you are using zeebe user tasks, you require a zeebe client as well
195203
ZeebeClient zeebeClient = zeebeClient();
196204
// bootstrapping
@@ -208,7 +216,8 @@ CamundaTasklistClientConfiguration configuration =
208216
authentication,
209217
tasklistUrl,
210218
zeebeClient,
211-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
219+
new DefaultProperties(
220+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
212221
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
213222
```
214223

example/bootstrapping-test/src/main/java/io/camunda/tasklist/bootstrapping/Bootstrapper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.camunda.tasklist.bootstrapping;
22

3+
import static io.camunda.tasklist.CamundaTasklistClientConfiguration.*;
4+
35
import io.camunda.tasklist.CamundaTaskListClient;
46
import io.camunda.tasklist.CamundaTasklistClientConfiguration;
57
import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties;
@@ -22,7 +24,7 @@ public CamundaTaskListClient create() {
2224
Duration.ofMinutes(10))),
2325
URI.create("http://localhost:8082").toURL(),
2426
null,
25-
new DefaultProperties(true, true, false)));
27+
new DefaultProperties(true, true, false, DEFAULT_TENANT_IDS)));
2628
} catch (MalformedURLException e) {
2729
throw new RuntimeException("Error while bootstrapping tasklist client", e);
2830
}

example/readme-snippets/src/main/java/io/camunda/tasklist/example/TasklistClientBootstrapper.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.net.URI;
1515
import java.net.URL;
1616
import java.time.Duration;
17+
import java.util.List;
1718

1819
public interface TasklistClientBootstrapper {
1920
static ZeebeClient zeebeClient() {
@@ -33,6 +34,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
3334
boolean returnVariables = false;
3435
boolean loadTruncatedVariables = false;
3536
boolean useZeebeUserTasks = true;
37+
List<String> tenantIds = List.of("<default>");
3638
// if you are using zeebe user tasks, you require a zeebe client as well
3739
ZeebeClient zeebeClient = zeebeClient();
3840
// bootstrapping
@@ -44,7 +46,9 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
4446
authentication,
4547
tasklistUrl,
4648
zeebeClient,
47-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
49+
new DefaultProperties(
50+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
51+
4852
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
4953
return client;
5054
}
@@ -66,6 +70,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
6670
boolean returnVariables = false;
6771
boolean loadTruncatedVariables = false;
6872
boolean useZeebeUserTasks = true;
73+
List<String> tenantIds = List.of("<default>");
6974
// if you are using zeebe user tasks, you require a zeebe client as well
7075
ZeebeClient zeebeClient = zeebeClient();
7176
// bootstrapping
@@ -80,7 +85,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
8085
authentication,
8186
tasklistUrl,
8287
zeebeClient,
83-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
88+
new DefaultProperties(
89+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
8490
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
8591
return client;
8692
}
@@ -97,6 +103,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
97103
boolean returnVariables = false;
98104
boolean loadTruncatedVariables = false;
99105
boolean useZeebeUserTasks = true;
106+
List<String> tenantIds = List.of("<default>");
100107
// if you are using zeebe user tasks, you require a zeebe client as well
101108
ZeebeClient zeebeClient = zeebeClient();
102109
// bootstrapping
@@ -114,7 +121,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
114121
authentication,
115122
tasklistUrl,
116123
zeebeClient,
117-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
124+
new DefaultProperties(
125+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
118126
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
119127
return client;
120128
}

extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public CamundaTaskListClient(
6464
new DefaultProperties(
6565
properties.isDefaultShouldReturnVariables(),
6666
properties.isDefaultShouldLoadTruncatedVariables(),
67-
properties.isUseZeebeUserTasks())));
67+
properties.isUseZeebeUserTasks(),
68+
properties.getTenantIds())));
6869
}
6970

7071
public CamundaTaskListClient(CamundaTasklistClientConfiguration configuration) {
@@ -457,6 +458,9 @@ public TaskList getTasks(TaskSearch search) throws TaskListException {
457458
if (search.getWithVariables() == null) {
458459
search.setWithVariables(defaultProperties.returnVariables());
459460
}
461+
if (search.getTenantIds() == null || search.getTenantIds().isEmpty()) {
462+
search.setTenantIds(defaultProperties.tenantIds());
463+
}
460464
Pagination pagination = search.getPagination();
461465
TaskSearchRequest request = ConverterUtils.toTaskSearchRequest(search);
462466
if (pagination != null) {

extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientBuilder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.camunda.tasklist;
22

3+
import static io.camunda.tasklist.CamundaTasklistClientConfiguration.*;
4+
35
import com.fasterxml.jackson.databind.ObjectMapper;
46
import io.camunda.tasklist.auth.Authentication;
57
import io.camunda.tasklist.auth.JwtAuthentication;
@@ -13,6 +15,7 @@
1315

1416
@Deprecated
1517
public class CamundaTaskListClientBuilder {
18+
1619
private CamundaTaskListClientProperties properties = new CamundaTaskListClientProperties();
1720
private ZeebeClient zeebeClient;
1821

@@ -38,12 +41,16 @@ public CamundaTaskListClientBuilder zeebeClient(ZeebeClient zeebeClient) {
3841
* @return the builder
3942
*/
4043
public CamundaTaskListClientBuilder shouldReturnVariables() {
44+
4145
properties.setDefaultShouldReturnVariables(true);
46+
4247
return this;
4348
}
4449

4550
public CamundaTaskListClientBuilder shouldLoadTruncatedVariables() {
51+
4652
properties.setDefaultShouldLoadTruncatedVariables(true);
53+
4754
return this;
4855
}
4956

extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientProperties.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package io.camunda.tasklist;
22

3+
import static io.camunda.tasklist.CamundaTasklistClientConfiguration.*;
4+
35
import io.camunda.tasklist.auth.Authentication;
6+
import java.util.ArrayList;
7+
import java.util.List;
48

59
@Deprecated
610
public class CamundaTaskListClientProperties {
@@ -10,6 +14,7 @@ public class CamundaTaskListClientProperties {
1014
private boolean defaultShouldReturnVariables;
1115
private boolean defaultShouldLoadTruncatedVariables;
1216
private boolean useZeebeUserTasks;
17+
private List<String> tenantIds = new ArrayList<>(DEFAULT_TENANT_IDS);
1318

1419
public CamundaTaskListClientProperties() {}
1520

@@ -65,4 +70,12 @@ public boolean isUseZeebeUserTasks() {
6570
public void setUseZeebeUserTasks(boolean useZeebeUserTasks) {
6671
this.useZeebeUserTasks = useZeebeUserTasks;
6772
}
73+
74+
public List<String> getTenantIds() {
75+
return tenantIds;
76+
}
77+
78+
public void setTenantIds(List<String> tenantIds) {
79+
this.tenantIds = tenantIds;
80+
}
6881
}

extension/client-java/src/main/java/io/camunda/tasklist/CamundaTasklistClientConfiguration.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
import io.camunda.tasklist.auth.Authentication;
44
import io.camunda.zeebe.client.ZeebeClient;
55
import java.net.URL;
6+
import java.util.List;
67

78
public record CamundaTasklistClientConfiguration(
89
Authentication authentication,
910
URL baseUrl,
1011
ZeebeClient zeebeClient,
1112
DefaultProperties defaultProperties) {
1213
public record DefaultProperties(
13-
boolean returnVariables, boolean loadTruncatedVariables, boolean useZeebeUserTasks) {}
14+
boolean returnVariables,
15+
boolean loadTruncatedVariables,
16+
boolean useZeebeUserTasks,
17+
List<String> tenantIds) {}
18+
19+
public static List<String> DEFAULT_TENANT_IDS = List.of("<default>");
1420
}

extension/client-java/src/test/java/io/camunda/tasklist/CamundaTasklistClientTest.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package io.camunda.tasklist;
22

33
import static com.github.tomakehurst.wiremock.client.WireMock.*;
4+
import static io.camunda.tasklist.CamundaTasklistClientConfiguration.*;
45
import static org.junit.jupiter.api.Assertions.*;
56

67
import com.auth0.jwt.JWT;
78
import com.auth0.jwt.algorithms.Algorithm;
89
import com.fasterxml.jackson.databind.ObjectMapper;
910
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
10-
import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties;
1111
import io.camunda.tasklist.auth.Authentication;
1212
import io.camunda.tasklist.auth.JwtAuthentication;
1313
import io.camunda.tasklist.auth.JwtCredential;
@@ -45,7 +45,10 @@ private static URL baseUrl() {
4545
public void shouldThrowIfZeebeClientNullAndUseZeebeUserTasks() {
4646
CamundaTasklistClientConfiguration configuration =
4747
new CamundaTasklistClientConfiguration(
48-
new MockAuthentication(), baseUrl(), null, new DefaultProperties(false, false, true));
48+
new MockAuthentication(),
49+
baseUrl(),
50+
null,
51+
new DefaultProperties(false, false, true, DEFAULT_TENANT_IDS));
4952
IllegalStateException assertionError =
5053
assertThrows(IllegalStateException.class, () -> new CamundaTaskListClient(configuration));
5154
assertEquals("ZeebeClient is required when using ZeebeUserTasks", assertionError.getMessage());
@@ -55,7 +58,10 @@ public void shouldThrowIfZeebeClientNullAndUseZeebeUserTasks() {
5558
public void shouldNotThrowIfZeebeClientNullAndNotUseZeebeUserTasks() {
5659
CamundaTasklistClientConfiguration configuration =
5760
new CamundaTasklistClientConfiguration(
58-
new MockAuthentication(), baseUrl(), null, new DefaultProperties(false, false, false));
61+
new MockAuthentication(),
62+
baseUrl(),
63+
null,
64+
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
5965
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
6066
assertNotNull(client);
6167
}
@@ -79,7 +85,7 @@ void shouldAuthenticateUsingSimpleAuth() throws MalformedURLException, TaskListE
7985
"demo", "demo", URI.create(BASE_URL).toURL(), Duration.ofMinutes(10))),
8086
baseUrl(),
8187
null,
82-
new DefaultProperties(false, false, false));
88+
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
8389
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
8490
assertNotNull(client);
8591
TaskList tasks = client.getTasks(new TaskSearch());
@@ -113,7 +119,7 @@ void shouldAuthenticateUsingJwt() throws MalformedURLException, TaskListExceptio
113119
new TokenResponseHttpClientResponseHandler(new ObjectMapper())),
114120
baseUrl(),
115121
null,
116-
new DefaultProperties(false, false, false));
122+
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
117123
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
118124
assertNotNull(client);
119125
TaskList tasks = client.getTasks(new TaskSearch());

extension/spring-boot-starter-camunda-tasklist/src/main/java/io/camunda/tasklist/spring/TasklistClientConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public CamundaTasklistClientConfiguration tasklistClientConfiguration(
5050
new DefaultProperties(
5151
properties.defaults().returnVariables(),
5252
properties.defaults().loadTruncatedVariables(),
53-
properties.defaults().useZeebeUserTasks()));
53+
properties.defaults().useZeebeUserTasks(),
54+
properties.defaults().tenantIds()));
5455
}
5556

5657
@Bean

extension/spring-boot-starter-camunda-tasklist/src/main/java/io/camunda/tasklist/spring/TasklistClientConfigurationProperties.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.net.URL;
44
import java.time.Duration;
5+
import java.util.List;
56
import org.springframework.boot.context.properties.ConfigurationProperties;
67
import org.springframework.boot.context.properties.bind.DefaultValue;
78

@@ -34,5 +35,6 @@ public enum Profile {
3435
public record ClientDefaults(
3536
@DefaultValue("true") boolean returnVariables,
3637
@DefaultValue("true") boolean loadTruncatedVariables,
37-
@DefaultValue("true") boolean useZeebeUserTasks) {}
38+
@DefaultValue("true") boolean useZeebeUserTasks,
39+
@DefaultValue("<default>") List<String> tenantIds) {}
3840
}

0 commit comments

Comments
 (0)