Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ tasklist:
client-secret:
```
Configure defaults that influence the client behaviour:
Configure defaults that influence the client behavior:
```yaml
tasklist:
Expand All @@ -115,6 +115,8 @@ tasklist:
load-truncated-variables: true
return-variables: true
use-zeebe-user-tasks: true
tenant-ids:
- <default>
```
### Plain Java
Expand All @@ -132,14 +134,15 @@ Add the dependency to your project:
Build a Camunda Tasklist client with simple authentication:

```java
// properties you need to provide
// properties you need to provide
ApiVersion apiVersion = ApiVersion.v1;
String username = "demo";
String password = "demo";
URL tasklistUrl = URI.create("http://localhost:8082").toURL();
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using camunda user tasks, you require a camunda client as well
CamundaClient camundaClient = camundaClient();
// bootstrapping
Expand All @@ -152,14 +155,15 @@ CamundaTasklistClientConfiguration configuration =
authentication,
tasklistUrl,
camundaClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
```

Build a Camunda Tasklist client with identity authentication:

```java
// properties you need to provide
// properties you need to provide
ApiVersion apiVersion = ApiVersion.v1;
String clientId = "";
String clientSecret = "";
Expand All @@ -173,6 +177,7 @@ URL authUrl =
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using camunda user tasks, you require a camunda client as well
CamundaClient camundaClient = camundaClient();
// bootstrapping
Expand All @@ -188,14 +193,15 @@ CamundaTasklistClientConfiguration configuration =
authentication,
tasklistUrl,
camundaClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
```

Build a Camunda Tasklist client for Saas:

```java
// properties you need to provide
// properties you need to provide
ApiVersion apiVersion = ApiVersion.v1;
String region = "";
String clusterId = "";
Expand All @@ -204,6 +210,7 @@ String clientSecret = "";
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using camunda user tasks, you require a camunda client as well
CamundaClient camundaClient = camundaClient();
// bootstrapping
Expand All @@ -222,7 +229,8 @@ CamundaTasklistClientConfiguration configuration =
authentication,
tasklistUrl,
camundaClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.camunda.tasklist.bootstrapping;

import static io.camunda.tasklist.CamundaTasklistClientConfiguration.*;

import io.camunda.tasklist.CamundaTaskListClient;
import io.camunda.tasklist.CamundaTasklistClientConfiguration;
import io.camunda.tasklist.CamundaTasklistClientConfiguration.ApiVersion;
Expand All @@ -24,7 +26,7 @@ public CamundaTaskListClient create() {
Duration.ofMinutes(10))),
URI.create("http://localhost:8082").toURL(),
null,
new DefaultProperties(true, true, false)));
new DefaultProperties(true, true, false, DEFAULT_TENANT_IDS)));
} catch (MalformedURLException e) {
throw new RuntimeException("Error while bootstrapping tasklist client", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.net.URI;
import java.net.URL;
import java.time.Duration;
import java.util.List;

public interface TasklistClientBootstrapper {
static CamundaClient camundaClient() {
Expand All @@ -35,6 +36,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using camunda user tasks, you require a camunda client as well
CamundaClient camundaClient = camundaClient();
// bootstrapping
Expand All @@ -47,7 +49,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
authentication,
tasklistUrl,
camundaClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
return client;
}
Expand All @@ -70,6 +73,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using camunda user tasks, you require a camunda client as well
CamundaClient camundaClient = camundaClient();
// bootstrapping
Expand All @@ -85,7 +89,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
authentication,
tasklistUrl,
camundaClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
return client;
}
Expand All @@ -103,6 +108,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using camunda user tasks, you require a camunda client as well
CamundaClient camundaClient = camundaClient();
// bootstrapping
Expand All @@ -121,7 +127,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
authentication,
tasklistUrl,
camundaClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
return client;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ public TaskList getTasks(TaskSearch search) throws TaskListException {
if (search.getWithVariables() == null) {
search.setWithVariables(defaultProperties.returnVariables());
}
if (search.getTenantIds() == null || search.getTenantIds().isEmpty()) {
search.setTenantIds(defaultProperties.tenantIds());
}
return new TaskList()
.setItems(getTasks(toTaskSearch(search), search.getWithVariables()))
.setSearch(search);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.camunda.tasklist;

import static io.camunda.tasklist.CamundaTasklistClientConfiguration.*;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.client.CamundaClient;
import io.camunda.tasklist.CamundaTasklistClientConfiguration.ApiVersion;
Expand All @@ -20,7 +22,8 @@ public class CamundaTaskListClientBuilder {
private URL tasklistUrl;
private CamundaClient camundaClient;
private ApiVersion apiVersion = ApiVersion.v2;
private DefaultProperties defaultProperties = new DefaultProperties(false, false, false);
private DefaultProperties defaultProperties =
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS);

public CamundaTaskListClientBuilder authentication(Authentication authentication) {
if (authentication != null) {
Expand Down Expand Up @@ -67,14 +70,18 @@ public CamundaTaskListClientBuilder shouldReturnVariables() {
new DefaultProperties(
true,
defaultProperties.loadTruncatedVariables(),
defaultProperties.useCamundaUserTasks());
defaultProperties.useCamundaUserTasks(),
defaultProperties.tenantIds());
return this;
}

public CamundaTaskListClientBuilder shouldLoadTruncatedVariables() {
this.defaultProperties =
new DefaultProperties(
defaultProperties.returnVariables(), true, defaultProperties.useCamundaUserTasks());
defaultProperties.returnVariables(),
true,
defaultProperties.useCamundaUserTasks(),
defaultProperties.tenantIds());
return this;
}

Expand Down Expand Up @@ -107,7 +114,10 @@ public CamundaTaskListClientBuilder useZeebeUserTasks() {
public CamundaTaskListClientBuilder useCamundaUserTasks() {
this.defaultProperties =
new DefaultProperties(
defaultProperties.returnVariables(), defaultProperties.loadTruncatedVariables(), true);
defaultProperties.returnVariables(),
defaultProperties.loadTruncatedVariables(),
true,
defaultProperties.tenantIds());
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.camunda.client.CamundaClient;
import io.camunda.tasklist.auth.Authentication;
import java.net.URL;
import java.util.List;

public record CamundaTasklistClientConfiguration(
ApiVersion apiVersion,
Expand All @@ -11,10 +12,15 @@ public record CamundaTasklistClientConfiguration(
CamundaClient camundaClient,
DefaultProperties defaultProperties) {
public record DefaultProperties(
boolean returnVariables, boolean loadTruncatedVariables, boolean useCamundaUserTasks) {}
boolean returnVariables,
boolean loadTruncatedVariables,
boolean useCamundaUserTasks,
List<String> tenantIds) {}

public enum ApiVersion {
v1,
v2
}

public static List<String> DEFAULT_TENANT_IDS = List.of("<default>");
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.camunda.tasklist;

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

import com.auth0.jwt.JWT;
Expand Down Expand Up @@ -50,7 +51,7 @@ public void shouldThrowIfZeebeClientNullAndUseZeebeUserTasks() {
new MockAuthentication(),
baseUrl(),
null,
new DefaultProperties(false, false, true));
new DefaultProperties(false, false, true, DEFAULT_TENANT_IDS));
IllegalStateException assertionError =
assertThrows(IllegalStateException.class, () -> new CamundaTaskListClient(configuration));
assertEquals(
Expand All @@ -65,7 +66,7 @@ public void shouldNotThrowIfZeebeClientNullAndNotUseZeebeUserTasks() {
new MockAuthentication(),
baseUrl(),
null,
new DefaultProperties(false, false, false));
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
assertNotNull(client);
}
Expand All @@ -90,7 +91,7 @@ void shouldAuthenticateUsingSimpleAuth() throws MalformedURLException, TaskListE
"demo", "demo", URI.create(BASE_URL).toURL(), Duration.ofMinutes(10))),
baseUrl(),
null,
new DefaultProperties(false, false, false));
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
assertNotNull(client);
TaskList tasks = client.getTasks(new TaskSearch());
Expand Down Expand Up @@ -125,7 +126,7 @@ void shouldAuthenticateUsingJwt() throws MalformedURLException, TaskListExceptio
new TokenResponseHttpClientResponseHandler(new ObjectMapper())),
baseUrl(),
null,
new DefaultProperties(false, false, false));
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
assertNotNull(client);
TaskList tasks = client.getTasks(new TaskSearch());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public CamundaTasklistClientConfiguration tasklistClientConfiguration(
new DefaultProperties(
properties.defaults().returnVariables(),
properties.defaults().loadTruncatedVariables(),
properties.defaults().useZeebeUserTasks()));
properties.defaults().useZeebeUserTasks(),
properties.defaults().tenantIds()));
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.camunda.tasklist.CamundaTasklistClientConfiguration.ApiVersion;
import java.net.URL;
import java.time.Duration;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.DefaultValue;

Expand Down Expand Up @@ -36,5 +37,6 @@ public enum Profile {
public record ClientDefaults(
@DefaultValue("true") boolean returnVariables,
@DefaultValue("true") boolean loadTruncatedVariables,
@DefaultValue("true") boolean useZeebeUserTasks) {}
@DefaultValue("true") boolean useZeebeUserTasks,
@DefaultValue("<default>") List<String> tenantIds) {}
}