Skip to content

Commit 761422d

Browse files
default tenant id (#370)
1 parent fbab570 commit 761422d

File tree

9 files changed

+62
-22
lines changed

9 files changed

+62
-22
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ tasklist:
106106
client-secret:
107107
```
108108
109-
Configure defaults that influence the client behaviour:
109+
Configure defaults that influence the client behavior:
110110
111111
```yaml
112112
tasklist:
@@ -115,6 +115,8 @@ tasklist:
115115
load-truncated-variables: true
116116
return-variables: true
117117
use-zeebe-user-tasks: true
118+
tenant-ids:
119+
- <default>
118120
```
119121
120122
### Plain Java
@@ -132,14 +134,15 @@ Add the dependency to your project:
132134
Build a Camunda Tasklist client with simple authentication:
133135

134136
```java
135-
// properties you need to provide
137+
// properties you need to provide
136138
ApiVersion apiVersion = ApiVersion.v1;
137139
String username = "demo";
138140
String password = "demo";
139141
URL tasklistUrl = URI.create("http://localhost:8082").toURL();
140142
boolean returnVariables = false;
141143
boolean loadTruncatedVariables = false;
142144
boolean useZeebeUserTasks = true;
145+
List<String> tenantIds = List.of("<default>");
143146
// if you are using camunda user tasks, you require a camunda client as well
144147
CamundaClient camundaClient = camundaClient();
145148
// bootstrapping
@@ -152,14 +155,15 @@ CamundaTasklistClientConfiguration configuration =
152155
authentication,
153156
tasklistUrl,
154157
camundaClient,
155-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
158+
new DefaultProperties(
159+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
156160
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
157161
```
158162

159163
Build a Camunda Tasklist client with identity authentication:
160164

161165
```java
162-
// properties you need to provide
166+
// properties you need to provide
163167
ApiVersion apiVersion = ApiVersion.v1;
164168
String clientId = "";
165169
String clientSecret = "";
@@ -173,6 +177,7 @@ URL authUrl =
173177
boolean returnVariables = false;
174178
boolean loadTruncatedVariables = false;
175179
boolean useZeebeUserTasks = true;
180+
List<String> tenantIds = List.of("<default>");
176181
// if you are using camunda user tasks, you require a camunda client as well
177182
CamundaClient camundaClient = camundaClient();
178183
// bootstrapping
@@ -188,14 +193,15 @@ CamundaTasklistClientConfiguration configuration =
188193
authentication,
189194
tasklistUrl,
190195
camundaClient,
191-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
196+
new DefaultProperties(
197+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
192198
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
193199
```
194200

195201
Build a Camunda Tasklist client for Saas:
196202

197203
```java
198-
// properties you need to provide
204+
// properties you need to provide
199205
ApiVersion apiVersion = ApiVersion.v1;
200206
String region = "";
201207
String clusterId = "";
@@ -204,6 +210,7 @@ String clientSecret = "";
204210
boolean returnVariables = false;
205211
boolean loadTruncatedVariables = false;
206212
boolean useZeebeUserTasks = true;
213+
List<String> tenantIds = List.of("<default>");
207214
// if you are using camunda user tasks, you require a camunda client as well
208215
CamundaClient camundaClient = camundaClient();
209216
// bootstrapping
@@ -222,7 +229,8 @@ CamundaTasklistClientConfiguration configuration =
222229
authentication,
223230
tasklistUrl,
224231
camundaClient,
225-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
232+
new DefaultProperties(
233+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
226234
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
227235
```
228236

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.ApiVersion;
@@ -24,7 +26,7 @@ public CamundaTaskListClient create() {
2426
Duration.ofMinutes(10))),
2527
URI.create("http://localhost:8082").toURL(),
2628
null,
27-
new DefaultProperties(true, true, false)));
29+
new DefaultProperties(true, true, false, DEFAULT_TENANT_IDS)));
2830
} catch (MalformedURLException e) {
2931
throw new RuntimeException("Error while bootstrapping tasklist client", e);
3032
}

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.net.URI;
1616
import java.net.URL;
1717
import java.time.Duration;
18+
import java.util.List;
1819

1920
public interface TasklistClientBootstrapper {
2021
static CamundaClient camundaClient() {
@@ -35,6 +36,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
3536
boolean returnVariables = false;
3637
boolean loadTruncatedVariables = false;
3738
boolean useZeebeUserTasks = true;
39+
List<String> tenantIds = List.of("<default>");
3840
// if you are using camunda user tasks, you require a camunda client as well
3941
CamundaClient camundaClient = camundaClient();
4042
// bootstrapping
@@ -47,7 +49,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
4749
authentication,
4850
tasklistUrl,
4951
camundaClient,
50-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
52+
new DefaultProperties(
53+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
5154
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
5255
return client;
5356
}
@@ -70,6 +73,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
7073
boolean returnVariables = false;
7174
boolean loadTruncatedVariables = false;
7275
boolean useZeebeUserTasks = true;
76+
List<String> tenantIds = List.of("<default>");
7377
// if you are using camunda user tasks, you require a camunda client as well
7478
CamundaClient camundaClient = camundaClient();
7579
// bootstrapping
@@ -85,7 +89,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
8589
authentication,
8690
tasklistUrl,
8791
camundaClient,
88-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
92+
new DefaultProperties(
93+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
8994
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
9095
return client;
9196
}
@@ -103,6 +108,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
103108
boolean returnVariables = false;
104109
boolean loadTruncatedVariables = false;
105110
boolean useZeebeUserTasks = true;
111+
List<String> tenantIds = List.of("<default>");
106112
// if you are using camunda user tasks, you require a camunda client as well
107113
CamundaClient camundaClient = camundaClient();
108114
// bootstrapping
@@ -121,7 +127,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
121127
authentication,
122128
tasklistUrl,
123129
camundaClient,
124-
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
130+
new DefaultProperties(
131+
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
125132
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
126133
return client;
127134
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ public TaskList getTasks(TaskSearch search) throws TaskListException {
563563
if (search.getWithVariables() == null) {
564564
search.setWithVariables(defaultProperties.returnVariables());
565565
}
566+
if (search.getTenantIds() == null || search.getTenantIds().isEmpty()) {
567+
search.setTenantIds(defaultProperties.tenantIds());
568+
}
566569
return new TaskList()
567570
.setItems(getTasks(toTaskSearch(search), search.getWithVariables()))
568571
.setSearch(search);

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

Lines changed: 14 additions & 4 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.client.CamundaClient;
57
import io.camunda.tasklist.CamundaTasklistClientConfiguration.ApiVersion;
@@ -20,7 +22,8 @@ public class CamundaTaskListClientBuilder {
2022
private URL tasklistUrl;
2123
private CamundaClient camundaClient;
2224
private ApiVersion apiVersion = ApiVersion.v2;
23-
private DefaultProperties defaultProperties = new DefaultProperties(false, false, false);
25+
private DefaultProperties defaultProperties =
26+
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS);
2427

2528
public CamundaTaskListClientBuilder authentication(Authentication authentication) {
2629
if (authentication != null) {
@@ -67,14 +70,18 @@ public CamundaTaskListClientBuilder shouldReturnVariables() {
6770
new DefaultProperties(
6871
true,
6972
defaultProperties.loadTruncatedVariables(),
70-
defaultProperties.useCamundaUserTasks());
73+
defaultProperties.useCamundaUserTasks(),
74+
defaultProperties.tenantIds());
7175
return this;
7276
}
7377

7478
public CamundaTaskListClientBuilder shouldLoadTruncatedVariables() {
7579
this.defaultProperties =
7680
new DefaultProperties(
77-
defaultProperties.returnVariables(), true, defaultProperties.useCamundaUserTasks());
81+
defaultProperties.returnVariables(),
82+
true,
83+
defaultProperties.useCamundaUserTasks(),
84+
defaultProperties.tenantIds());
7885
return this;
7986
}
8087

@@ -107,7 +114,10 @@ public CamundaTaskListClientBuilder useZeebeUserTasks() {
107114
public CamundaTaskListClientBuilder useCamundaUserTasks() {
108115
this.defaultProperties =
109116
new DefaultProperties(
110-
defaultProperties.returnVariables(), defaultProperties.loadTruncatedVariables(), true);
117+
defaultProperties.returnVariables(),
118+
defaultProperties.loadTruncatedVariables(),
119+
true,
120+
defaultProperties.tenantIds());
111121
return this;
112122
}
113123

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,6 +3,7 @@
33
import io.camunda.client.CamundaClient;
44
import io.camunda.tasklist.auth.Authentication;
55
import java.net.URL;
6+
import java.util.List;
67

78
public record CamundaTasklistClientConfiguration(
89
ApiVersion apiVersion,
@@ -11,10 +12,15 @@ public record CamundaTasklistClientConfiguration(
1112
CamundaClient camundaClient,
1213
DefaultProperties defaultProperties) {
1314
public record DefaultProperties(
14-
boolean returnVariables, boolean loadTruncatedVariables, boolean useCamundaUserTasks) {}
15+
boolean returnVariables,
16+
boolean loadTruncatedVariables,
17+
boolean useCamundaUserTasks,
18+
List<String> tenantIds) {}
1519

1620
public enum ApiVersion {
1721
v1,
1822
v2
1923
}
24+
25+
public static List<String> DEFAULT_TENANT_IDS = List.of("<default>");
2026
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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;
@@ -50,7 +51,7 @@ public void shouldThrowIfZeebeClientNullAndUseZeebeUserTasks() {
5051
new MockAuthentication(),
5152
baseUrl(),
5253
null,
53-
new DefaultProperties(false, false, true));
54+
new DefaultProperties(false, false, true, DEFAULT_TENANT_IDS));
5455
IllegalStateException assertionError =
5556
assertThrows(IllegalStateException.class, () -> new CamundaTaskListClient(configuration));
5657
assertEquals(
@@ -65,7 +66,7 @@ public void shouldNotThrowIfZeebeClientNullAndNotUseZeebeUserTasks() {
6566
new MockAuthentication(),
6667
baseUrl(),
6768
null,
68-
new DefaultProperties(false, false, false));
69+
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
6970
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
7071
assertNotNull(client);
7172
}
@@ -90,7 +91,7 @@ void shouldAuthenticateUsingSimpleAuth() throws MalformedURLException, TaskListE
9091
"demo", "demo", URI.create(BASE_URL).toURL(), Duration.ofMinutes(10))),
9192
baseUrl(),
9293
null,
93-
new DefaultProperties(false, false, false));
94+
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
9495
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
9596
assertNotNull(client);
9697
TaskList tasks = client.getTasks(new TaskSearch());
@@ -125,7 +126,7 @@ void shouldAuthenticateUsingJwt() throws MalformedURLException, TaskListExceptio
125126
new TokenResponseHttpClientResponseHandler(new ObjectMapper())),
126127
baseUrl(),
127128
null,
128-
new DefaultProperties(false, false, false));
129+
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
129130
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
130131
assertNotNull(client);
131132
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
@@ -51,7 +51,8 @@ public CamundaTasklistClientConfiguration tasklistClientConfiguration(
5151
new DefaultProperties(
5252
properties.defaults().returnVariables(),
5353
properties.defaults().loadTruncatedVariables(),
54-
properties.defaults().useZeebeUserTasks()));
54+
properties.defaults().useZeebeUserTasks(),
55+
properties.defaults().tenantIds()));
5556
}
5657

5758
@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
@@ -3,6 +3,7 @@
33
import io.camunda.tasklist.CamundaTasklistClientConfiguration.ApiVersion;
44
import java.net.URL;
55
import java.time.Duration;
6+
import java.util.List;
67
import org.springframework.boot.context.properties.ConfigurationProperties;
78
import org.springframework.boot.context.properties.bind.DefaultValue;
89

@@ -36,5 +37,6 @@ public enum Profile {
3637
public record ClientDefaults(
3738
@DefaultValue("true") boolean returnVariables,
3839
@DefaultValue("true") boolean loadTruncatedVariables,
39-
@DefaultValue("true") boolean useZeebeUserTasks) {}
40+
@DefaultValue("true") boolean useZeebeUserTasks,
41+
@DefaultValue("<default>") List<String> tenantIds) {}
4042
}

0 commit comments

Comments
 (0)