diff --git a/example/bootstrapping-test/src/main/java/io/camunda/tasklist/bootstrapping/Bootstrapper.java b/example/bootstrapping-test/src/main/java/io/camunda/tasklist/bootstrapping/Bootstrapper.java index 74b17d8..bbf7a22 100644 --- a/example/bootstrapping-test/src/main/java/io/camunda/tasklist/bootstrapping/Bootstrapper.java +++ b/example/bootstrapping-test/src/main/java/io/camunda/tasklist/bootstrapping/Bootstrapper.java @@ -1,6 +1,6 @@ package io.camunda.tasklist.bootstrapping; -import io.camunda.tasklist.CamundaTaskListClient; +import io.camunda.tasklist.CamundaTaskListClientV1; import io.camunda.tasklist.CamundaTasklistClientConfiguration; import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties; import io.camunda.tasklist.auth.SimpleAuthentication; @@ -10,9 +10,9 @@ import java.time.Duration; public class Bootstrapper { - public CamundaTaskListClient create() { + public CamundaTaskListClientV1 create() { try { - return new CamundaTaskListClient( + return new CamundaTaskListClientV1( new CamundaTasklistClientConfiguration( new SimpleAuthentication( new SimpleCredential( diff --git a/example/bootstrapping-test/src/test/java/io/camunda/tasklist/bootstrapping/BootstrappingTest.java b/example/bootstrapping-test/src/test/java/io/camunda/tasklist/bootstrapping/BootstrappingTest.java index ea8d574..08d47c3 100644 --- a/example/bootstrapping-test/src/test/java/io/camunda/tasklist/bootstrapping/BootstrappingTest.java +++ b/example/bootstrapping-test/src/test/java/io/camunda/tasklist/bootstrapping/BootstrappingTest.java @@ -2,13 +2,13 @@ import static org.junit.jupiter.api.Assertions.*; -import io.camunda.tasklist.CamundaTaskListClient; +import io.camunda.tasklist.CamundaTaskListClientV1; import org.junit.jupiter.api.Test; public class BootstrappingTest { @Test void shouldRun() { - CamundaTaskListClient camundaTaskListClient = new Bootstrapper().create(); + CamundaTaskListClientV1 camundaTaskListClient = new Bootstrapper().create(); assertNotNull(camundaTaskListClient); } } diff --git a/example/readme-snippets/src/main/java/io/camunda/tasklist/example/TasklistClientBootstrapper.java b/example/readme-snippets/src/main/java/io/camunda/tasklist/example/TasklistClientBootstrapper.java index 1b5b1c4..6fe01f9 100644 --- a/example/readme-snippets/src/main/java/io/camunda/tasklist/example/TasklistClientBootstrapper.java +++ b/example/readme-snippets/src/main/java/io/camunda/tasklist/example/TasklistClientBootstrapper.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.camunda.tasklist.CamundaTaskListClient; +import io.camunda.tasklist.CamundaTaskListClientV1; import io.camunda.tasklist.CamundaTasklistClientConfiguration; import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties; import io.camunda.tasklist.auth.JwtAuthentication; @@ -46,7 +47,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException tasklistUrl, zeebeClient, new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks)); - CamundaTaskListClient client = new CamundaTaskListClient(configuration); + CamundaTaskListClient client = new CamundaTaskListClientV1(configuration); return client; } } @@ -81,7 +82,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException tasklistUrl, zeebeClient, new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks)); - CamundaTaskListClient client = new CamundaTaskListClient(configuration); + CamundaTaskListClient client = new CamundaTaskListClientV1(configuration); return client; } } @@ -114,7 +115,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException tasklistUrl, zeebeClient, new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks)); - CamundaTaskListClient client = new CamundaTaskListClient(configuration); + CamundaTaskListClient client = new CamundaTaskListClientV1(configuration); return client; } } diff --git a/extension/client-java/src/main/java/io/camunda/client/CamundaClient.java b/extension/client-java/src/main/java/io/camunda/client/CamundaClient.java new file mode 100644 index 0000000..c69918f --- /dev/null +++ b/extension/client-java/src/main/java/io/camunda/client/CamundaClient.java @@ -0,0 +1,5 @@ +package io.camunda.client; + +/** This is a placeholder class until the actual camunda client can be used */ +@Deprecated +public interface CamundaClient {} diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/AbstractCamundaTaskListClient.java b/extension/client-java/src/main/java/io/camunda/tasklist/AbstractCamundaTaskListClient.java new file mode 100644 index 0000000..b1b4d64 --- /dev/null +++ b/extension/client-java/src/main/java/io/camunda/tasklist/AbstractCamundaTaskListClient.java @@ -0,0 +1,138 @@ +package io.camunda.tasklist; + +import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties; +import io.camunda.tasklist.dto.Pagination; +import io.camunda.tasklist.dto.SearchType; +import io.camunda.tasklist.dto.Task; +import io.camunda.tasklist.dto.TaskList; +import io.camunda.tasklist.dto.TaskSearch; +import io.camunda.tasklist.dto.Variable; +import io.camunda.tasklist.exception.TaskListException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +public abstract class AbstractCamundaTaskListClient implements CamundaTaskListClient { + private final DefaultProperties defaultProperties; + + public AbstractCamundaTaskListClient(DefaultProperties defaultProperties) { + this.defaultProperties = defaultProperties; + } + + @Override + public Task getTask(String taskId) throws TaskListException { + return getTask(taskId, defaultProperties.returnVariables()); + } + + @Override + public List getVariables(String taskId) throws TaskListException { + return getVariables(taskId, defaultProperties.loadTruncatedVariables()); + } + + @Override + public TaskList before(TaskList taskList) throws TaskListException { + return paginate(taskList, SearchType.BEFORE); + } + + @Override + public TaskList beforeOrEquals(TaskList taskList) throws TaskListException { + return paginate(taskList, SearchType.BEFORE_OR_EQUAL); + } + + @Override + public TaskList after(TaskList taskList) throws TaskListException { + return paginate(taskList, SearchType.AFTER); + } + + @Override + public TaskList afterOrEqual(TaskList taskList) throws TaskListException { + return paginate(taskList, SearchType.AFTER_OR_EQUAL); + } + + @Override + public void loadVariables(List tasks) throws TaskListException { + loadVariables(tasks, defaultProperties.loadTruncatedVariables()); + } + + @Override + public void loadVariables(List tasks, boolean loadTruncated) throws TaskListException { + try { + Map>> futures = new HashMap<>(); + Map taskMap = new HashMap<>(); + for (Task task : tasks) { + taskMap.put(task.getId(), task); + futures.put( + task.getId(), + CompletableFuture.supplyAsync( + () -> { + try { + return getVariables(task.getId(), loadTruncated); + } catch (TaskListException e) { + return null; + } + })); + } + for (Map.Entry>> varFutures : futures.entrySet()) { + taskMap.get(varFutures.getKey()).setVariables(varFutures.getValue().get()); + } + futures.clear(); + taskMap.clear(); + } catch (ExecutionException | InterruptedException e) { + throw new TaskListException("Error loading task variables", e); + } + } + + @Override + public TaskList getTasks(TaskSearch search) throws TaskListException { + if (search.getWithVariables() == null) { + search.setWithVariables(defaultProperties.returnVariables()); + } + return getTasksInternal(search); + } + + protected abstract TaskList getTasksInternal(TaskSearch search) throws TaskListException; + + private TaskList paginate(TaskList taskList, SearchType direction) throws TaskListException { + if (taskList.getSearch().getPagination() == null + || taskList.getSearch().getPagination().getPageSize() == null) { + throw new TaskListException( + "Before/After/AfterOrEquals search are only possible if a pageSize is set"); + } + if (taskList.getItems() == null || taskList.getItems().isEmpty()) { + throw new TaskListException( + "Before/After/AfterOrEquals search are only possible if some items are present"); + } + + TaskSearch newSearch = + taskList.getSearch().clone().setPagination(getSearchPagination(taskList, direction)); + return getTasks(newSearch); + } + + private Pagination getSearchPagination(TaskList taskList, SearchType type) { + return switch (type) { + case BEFORE -> + new Pagination.Builder() + .pageSize(taskList.getSearch().getPagination().getPageSize()) + .before(taskList.first().getSortValues()) + .build(); + case BEFORE_OR_EQUAL -> + new Pagination.Builder() + .pageSize(taskList.getSearch().getPagination().getPageSize()) + .beforeOrEqual(taskList.first().getSortValues()) + .build(); + case AFTER -> + new Pagination.Builder() + .pageSize(taskList.getSearch().getPagination().getPageSize()) + .after(taskList.last().getSortValues()) + .build(); + default -> + new Pagination.Builder() + .pageSize(taskList.getSearch().getPagination().getPageSize()) + .afterOrEqual(taskList.last().getSortValues()) + .build(); + }; + } +} diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClient.java b/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClient.java index abd93d4..bb9acbf 100644 --- a/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClient.java +++ b/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClient.java @@ -1,161 +1,32 @@ package io.camunda.tasklist; -import static io.camunda.tasklist.util.ConverterUtils.*; +import static io.camunda.tasklist.util.PaginationUtil.*; -import com.fasterxml.jackson.core.JsonProcessingException; -import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties; -import io.camunda.tasklist.auth.Authentication; import io.camunda.tasklist.dto.DateFilter; import io.camunda.tasklist.dto.Form; import io.camunda.tasklist.dto.Pagination; -import io.camunda.tasklist.dto.SearchType; import io.camunda.tasklist.dto.Task; -import io.camunda.tasklist.dto.Task.Implementation; import io.camunda.tasklist.dto.TaskList; import io.camunda.tasklist.dto.TaskSearch; +import io.camunda.tasklist.dto.TaskSearch.IncludeVariable; +import io.camunda.tasklist.dto.TaskSearch.TaskByVariables; import io.camunda.tasklist.dto.TaskState; import io.camunda.tasklist.dto.Variable; -import io.camunda.tasklist.exception.TaskListException; -import io.camunda.tasklist.generated.api.FormApi; -import io.camunda.tasklist.generated.api.TaskApi; -import io.camunda.tasklist.generated.api.VariablesApi; -import io.camunda.tasklist.generated.invoker.ApiClient; -import io.camunda.tasklist.generated.invoker.ApiException; -import io.camunda.tasklist.generated.model.IncludeVariable; -import io.camunda.tasklist.generated.model.SaveVariablesRequest; -import io.camunda.tasklist.generated.model.TaskAssignRequest; -import io.camunda.tasklist.generated.model.TaskByVariables; -import io.camunda.tasklist.generated.model.TaskCompleteRequest; -import io.camunda.tasklist.generated.model.TaskSearchRequest; -import io.camunda.tasklist.generated.model.VariableInputDTO; -import io.camunda.tasklist.generated.model.VariablesSearchRequest; -import io.camunda.tasklist.util.ConverterUtils; -import io.camunda.zeebe.client.ZeebeClient; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.stream.Collectors; -import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; -import org.apache.hc.client5.http.impl.classic.HttpClients; - -public class CamundaTaskListClient { - private final ZeebeClient zeebeClient; - private final DefaultProperties defaultProperties; - private final TaskApi taskApi; - private final FormApi formApi; - private final VariablesApi variablesApi; - - @Deprecated - public CamundaTaskListClient( - CamundaTaskListClientProperties properties, ZeebeClient zeebeClient) { - this( - new CamundaTasklistClientConfiguration( - Objects.requireNonNull(properties.getAuthentication(), "No authentication provided"), - toUrl(properties.getTaskListUrl()), - zeebeClient, - new DefaultProperties( - properties.isDefaultShouldReturnVariables(), - properties.isDefaultShouldLoadTruncatedVariables(), - properties.isUseZeebeUserTasks()))); - } - - public CamundaTaskListClient(CamundaTasklistClientConfiguration configuration) { - if (configuration.defaultProperties().useZeebeUserTasks() - && configuration.zeebeClient() == null) { - throw new IllegalStateException("ZeebeClient is required when using ZeebeUserTasks"); - } - this.zeebeClient = configuration.zeebeClient(); - this.defaultProperties = configuration.defaultProperties(); - CloseableHttpClient httpClient = buildTasklistHttpClient(configuration.authentication()); - ApiClient apiClient = new ApiClient(httpClient); - apiClient.setBasePath(configuration.baseUrl().toExternalForm()); - this.taskApi = new TaskApi(apiClient); - this.formApi = new FormApi(apiClient); - this.variablesApi = new VariablesApi(apiClient); - } - - private static URL toUrl(String url) { - try { - return URI.create(url).toURL(); - } catch (MalformedURLException e) { - throw new RuntimeException("Error while creating tasklist url", e); - } - } - private static CloseableHttpClient buildTasklistHttpClient(Authentication authentication) { - return HttpClients.custom() - .useSystemProperties() - .addRequestInterceptorFirst( - (request, entity, context) -> - authentication.getTokenHeader().forEach(request::addHeader)) - .build(); - } - - @Deprecated - public static CamundaTaskListClientBuilder builder() { - return new CamundaTaskListClientBuilder(); - } - - public Task unclaim(String taskId) throws TaskListException { - try { - return ConverterUtils.toTask(taskApi.unassignTask(taskId), null); - } catch (TaskListException | ApiException e) { - throw new TaskListException("Error unclaiming task " + taskId, e); - } - } +public interface CamundaTaskListClient { + Task unclaim(String taskId); - public Task claim(String taskId, String assignee) throws TaskListException { + default Task claim(String taskId, String assignee) { return claim(taskId, assignee, false); } - public Task claim(String taskId, String assignee, Boolean allowOverrideAssignment) - throws TaskListException { - try { - return ConverterUtils.toTask( - taskApi.assignTask( - taskId, - new TaskAssignRequest() - .assignee(assignee) - .allowOverrideAssignment(allowOverrideAssignment)), - null); - } catch (TaskListException | ApiException e) { - throw new TaskListException("Error assigning task " + taskId, e); - } - } + Task claim(String taskId, String assignee, Boolean allowOverrideAssignment); - public void completeTask(String taskId, Map variablesMap) - throws TaskListException { - try { - Task task = getTask(taskId); - if (task.getImplementation() == null - || task.getImplementation().equals(Implementation.JOB_WORKER)) { - List variables = ConverterUtils.toVariableInput(variablesMap); - taskApi.completeTask(taskId, new TaskCompleteRequest().variables(variables)); - } else if (task.getImplementation().equals(Implementation.ZEEBE_USER_TASK)) { - if (zeebeClient == null) { - throw new IllegalStateException( - "zeebeClient must not be null, please set useZeebeUserTasks to assert this on startup"); - } - zeebeClient - .newUserTaskCompleteCommand(Long.parseLong(taskId)) - .variables(variablesMap) - .send() - .join(); - } - } catch (TaskListException | ApiException e) { - throw new TaskListException("Error assigning task " + taskId, e); - } - } + void completeTask(String taskId, Map variablesMap); - public TaskList getTasks(Boolean assigned, TaskState state, Integer pageSize) - throws TaskListException { + default TaskList getTasks(Boolean assigned, TaskState state, Integer pageSize) { return getTasks( new TaskSearch() .setAssigned(assigned) @@ -163,15 +34,13 @@ public TaskList getTasks(Boolean assigned, TaskState state, Integer pageSize) .setPagination(createPagination(pageSize))); } - public TaskList getTasks(Boolean assigned, TaskState state, Pagination pagination) - throws TaskListException { + default TaskList getTasks(Boolean assigned, TaskState state, Pagination pagination) { return getTasks( new TaskSearch().setAssigned(assigned).setState(state).setPagination(pagination)); } - public TaskList getTasks( - Boolean assigned, TaskState state, boolean withVariables, Integer pageSize) - throws TaskListException { + default TaskList getTasks( + Boolean assigned, TaskState state, boolean withVariables, Integer pageSize) { return getTasks( new TaskSearch() .setAssigned(assigned) @@ -180,13 +49,8 @@ public TaskList getTasks( .setPagination(createPagination(pageSize))); } - private Pagination createPagination(Integer pageSize) { - return new Pagination().setPageSize(pageSize); - } - - public TaskList getTasks( - Boolean assigned, TaskState state, boolean withVariables, Pagination pagination) - throws TaskListException { + default TaskList getTasks( + Boolean assigned, TaskState state, boolean withVariables, Pagination pagination) { return getTasks( new TaskSearch() .setAssigned(assigned) @@ -195,8 +59,7 @@ public TaskList getTasks( .setPagination(pagination)); } - public TaskList getAssigneeTasks(String assigneeId, TaskState state, Integer pageSize) - throws TaskListException { + default TaskList getAssigneeTasks(String assigneeId, TaskState state, Integer pageSize) { return getTasks( new TaskSearch() .setAssignee(assigneeId) @@ -204,19 +67,13 @@ public TaskList getAssigneeTasks(String assigneeId, TaskState state, Integer pag .setPagination(createPagination(pageSize))); } - public TaskList getAssigneeTasks(String assigneeId, TaskState state, Pagination pagination) - throws TaskListException { + default TaskList getAssigneeTasks(String assigneeId, TaskState state, Pagination pagination) { return getTasks( - new TaskSearch() - .setAssignee(assigneeId) - .setState(state) - .setWithVariables(defaultProperties.returnVariables()) - .setPagination(pagination)); + new TaskSearch().setAssignee(assigneeId).setState(state).setPagination(pagination)); } - public TaskList getAssigneeTasks( - String assigneeId, TaskState state, boolean withVariables, Integer pageSize) - throws TaskListException { + default TaskList getAssigneeTasks( + String assigneeId, TaskState state, boolean withVariables, Integer pageSize) { return getTasks( new TaskSearch() .setAssigned(true) @@ -226,9 +83,8 @@ public TaskList getAssigneeTasks( .setPagination(createPagination(pageSize))); } - public TaskList getAssigneeTasks( - String assigneeId, TaskState state, boolean withVariables, Pagination pagination) - throws TaskListException { + default TaskList getAssigneeTasks( + String assigneeId, TaskState state, boolean withVariables, Pagination pagination) { return getTasks( new TaskSearch() .setAssignee(assigneeId) @@ -237,8 +93,7 @@ public TaskList getAssigneeTasks( .setPagination(pagination)); } - public TaskList getGroupTasks(String group, TaskState state, Integer pageSize) - throws TaskListException { + default TaskList getGroupTasks(String group, TaskState state, Integer pageSize) { return getTasks( new TaskSearch() .setCandidateGroup(group) @@ -246,15 +101,13 @@ public TaskList getGroupTasks(String group, TaskState state, Integer pageSize) .setPagination(createPagination(pageSize))); } - public TaskList getGroupTasks(String group, TaskState state, Pagination pagination) - throws TaskListException { + default TaskList getGroupTasks(String group, TaskState state, Pagination pagination) { return getTasks( new TaskSearch().setCandidateGroup(group).setState(state).setPagination(pagination)); } - public TaskList getGroupTasks( - String group, TaskState state, boolean withVariables, Integer pageSize) - throws TaskListException { + default TaskList getGroupTasks( + String group, TaskState state, boolean withVariables, Integer pageSize) { return getTasks( new TaskSearch() .setCandidateGroup(group) @@ -263,9 +116,8 @@ public TaskList getGroupTasks( .setPagination(createPagination(pageSize))); } - public TaskList getGroupTasks( - String group, TaskState state, boolean withVariables, Pagination pagination) - throws TaskListException { + default TaskList getGroupTasks( + String group, TaskState state, boolean withVariables, Pagination pagination) { return getTasks( new TaskSearch() .setCandidateGroup(group) @@ -274,9 +126,8 @@ public TaskList getGroupTasks( .setPagination(pagination)); } - public TaskList getGroupsTasks( - List groups, TaskState state, boolean withVariables, Pagination pagination) - throws TaskListException { + default TaskList getGroupsTasks( + List groups, TaskState state, boolean withVariables, Pagination pagination) { return getTasks( new TaskSearch() .setCandidateGroups(groups) @@ -285,169 +136,39 @@ public TaskList getGroupsTasks( .setPagination(pagination)); } - public Task getTask(String taskId) throws TaskListException { - return getTask(taskId, defaultProperties.returnVariables()); - } - - public Task getTask(String taskId, boolean withVariables) throws TaskListException { + Task getTask(String taskId); - try { - List variables = null; - if (withVariables) { - variables = getVariables(taskId); - } + Task getTask(String taskId, boolean withVariables); - return ConverterUtils.toTask(taskApi.getTaskById(taskId), variables); - } catch (TaskListException | ApiException e) { - throw new TaskListException("Error reading task " + taskId, e); - } - } + List getVariables(String taskId); - public List getVariables(String taskId) throws TaskListException { - return getVariables(taskId, defaultProperties.loadTruncatedVariables()); - } + List getVariables(String taskId, boolean loadTruncated); - public List getVariables(String taskId, boolean loadTruncated) - throws TaskListException { - try { - return taskApi.searchTaskVariables(taskId, new VariablesSearchRequest()).stream() - .map( - vsr -> { - if (loadTruncated && Boolean.TRUE.equals(vsr.getIsValueTruncated())) { - try { - return getVariable(vsr.getId()); - } catch (TaskListException e) { - throw new RuntimeException("Error while loading full value of variable", e); - } - } else { - try { - return improveVariable(vsr); - } catch (JsonProcessingException e) { - throw new RuntimeException("Error while improving variable", e); - } - } - }) - .collect(Collectors.toList()); - } catch (ApiException | RuntimeException e) { - throw new TaskListException("Error reading task " + taskId, e); - } - } - - public Variable getVariable(String variableId) throws TaskListException { - try { - return toVariable(variablesApi.getVariableById(variableId)); - } catch (ApiException | JsonProcessingException e) { - throw new TaskListException("Error while loading variable " + variableId, e); - } - } + Variable getVariable(String variableId); - public Form getForm(String formId, String processDefinitionId) throws TaskListException { + default Form getForm(String formId, String processDefinitionId) { return getForm(formId, processDefinitionId, null); } - public Form getForm(String formId, String processDefinitionId, Long version) - throws TaskListException { - try { - if (formId.startsWith(CamundaTasklistConstants.CAMUNDA_FORMS_PREFIX)) { - formId = formId.substring(CamundaTasklistConstants.CAMUNDA_FORMS_PREFIX.length()); - } - return ConverterUtils.toForm(formApi.getForm(formId, processDefinitionId, version)); - } catch (ApiException e) { - throw new TaskListException("Error reading form " + formId, e); - } - } - - public TaskList before(TaskList taskList) throws TaskListException { - return paginate(taskList, SearchType.BEFORE); - } - - public TaskList beforeOrEquals(TaskList taskList) throws TaskListException { - return paginate(taskList, SearchType.BEFORE_OR_EQUAL); - } + Form getForm(String formId, String processDefinitionId, Long version); - public TaskList after(TaskList taskList) throws TaskListException { - return paginate(taskList, SearchType.AFTER); - } + TaskList before(TaskList taskList); - public TaskList afterOrEqual(TaskList taskList) throws TaskListException { - return paginate(taskList, SearchType.AFTER_OR_EQUAL); - } + TaskList beforeOrEquals(TaskList taskList); - private TaskList paginate(TaskList taskList, SearchType direction) throws TaskListException { - if (taskList.getSearch().getPagination() == null - || taskList.getSearch().getPagination().getPageSize() == null) { - throw new TaskListException( - "Before/After/AfterOrEquals search are only possible if a pageSize is set"); - } - if (taskList.getItems() == null || taskList.getItems().isEmpty()) { - throw new TaskListException( - "Before/After/AfterOrEquals search are only possible if some items are present"); - } - - TaskSearch newSearch = - taskList.getSearch().clone().setPagination(getSearchPagination(taskList, direction)); - return getTasks(newSearch); - } + TaskList after(TaskList taskList); - private Pagination getSearchPagination(TaskList taskList, SearchType type) { - switch (type) { - case BEFORE: - return new Pagination.Builder() - .pageSize(taskList.getSearch().getPagination().getPageSize()) - .before(taskList.first().getSortValues()) - .build(); - case BEFORE_OR_EQUAL: - return new Pagination.Builder() - .pageSize(taskList.getSearch().getPagination().getPageSize()) - .beforeOrEqual(taskList.first().getSortValues()) - .build(); - case AFTER: - return new Pagination.Builder() - .pageSize(taskList.getSearch().getPagination().getPageSize()) - .after(taskList.last().getSortValues()) - .build(); - default: - return new Pagination.Builder() - .pageSize(taskList.getSearch().getPagination().getPageSize()) - .afterOrEqual(taskList.last().getSortValues()) - .build(); - } - } + TaskList afterOrEqual(TaskList taskList); - public TaskList getTasks(TaskSearch search) throws TaskListException { - if (search.getWithVariables() == null) { - search.setWithVariables(defaultProperties.returnVariables()); - } - Pagination pagination = search.getPagination(); - TaskSearchRequest request = ConverterUtils.toTaskSearchRequest(search); - if (pagination != null) { - if (pagination.getSearchType() != null - && pagination.getSearch() != null - && !pagination.getSearch().isEmpty()) { - if (pagination.getSearchType().equals(SearchType.BEFORE)) { - request.searchBefore(pagination.getSearch()); - } else if (pagination.getSearchType().equals(SearchType.BEFORE_OR_EQUAL)) { - request.searchBeforeOrEqual(pagination.getSearch()); - } else if (pagination.getSearchType().equals(SearchType.AFTER)) { - request.searchAfter(pagination.getSearch()); - } else if (pagination.getSearchType().equals(SearchType.AFTER_OR_EQUAL)) { - request.searchAfterOrEqual(pagination.getSearch()); - } - } - request.pageSize(pagination.getPageSize()); - request.sort(pagination.getSort()); - } - return new TaskList().setItems(getTasks(request, search.getWithVariables())).setSearch(search); - } + TaskList getTasks(TaskSearch search); - public TaskList getTasks( + default TaskList getTasks( String group, Boolean assigned, String assigneeId, TaskState state, boolean withVariables, - Pagination pagination) - throws TaskListException { + Pagination pagination) { return getTasks( new TaskSearch() .setCandidateGroup(group) @@ -458,7 +179,7 @@ public TaskList getTasks( .setPagination(pagination)); } - public TaskList getTasks( + default TaskList getTasks( String candidateUser, List candidateUsers, String group, @@ -475,8 +196,7 @@ public TaskList getTasks( List tenantIds, List includeVariables, boolean withVariables, - Pagination pagination) - throws TaskListException { + Pagination pagination) { return getTasks( new TaskSearch() .setCandidateUser(candidateUser) @@ -498,61 +218,9 @@ public TaskList getTasks( .setPagination(pagination)); } - public List getTasks(TaskSearchRequest search, boolean withVariables) - throws TaskListException { - try { - - List tasks = ConverterUtils.toTasks(taskApi.searchTasks(search)); - if (withVariables - && (search.getIncludeVariables() == null || search.getIncludeVariables().isEmpty())) { - loadVariables(tasks); - } - return tasks; - } catch (ApiException e) { - throw new TaskListException("Error searching tasks", e); - } - } + void loadVariables(List tasks); - public void loadVariables(List tasks) throws TaskListException { - loadVariables(tasks, defaultProperties.loadTruncatedVariables()); - } + void loadVariables(List tasks, boolean loadTruncated); - public void loadVariables(List tasks, boolean loadTruncated) throws TaskListException { - try { - Map>> futures = new HashMap<>(); - Map taskMap = new HashMap<>(); - for (Task task : tasks) { - taskMap.put(task.getId(), task); - futures.put( - task.getId(), - CompletableFuture.supplyAsync( - () -> { - try { - return getVariables(task.getId(), loadTruncated); - } catch (TaskListException e) { - return null; - } - })); - } - for (Map.Entry>> varFutures : futures.entrySet()) { - taskMap.get(varFutures.getKey()).setVariables(varFutures.getValue().get()); - } - futures.clear(); - taskMap.clear(); - } catch (ExecutionException | InterruptedException e) { - throw new TaskListException("Error loading task variables", e); - } - } - - public void saveDraftVariables(String taskId, Map variables) - throws TaskListException { - try { - List convertedVariables = ConverterUtils.toVariableInput(variables); - SaveVariablesRequest variablesInput = new SaveVariablesRequest(); - variablesInput.setVariables(convertedVariables); - taskApi.saveDraftTaskVariables(taskId, variablesInput); - } catch (ApiException e) { - throw new TaskListException("Error saving draft variables for task " + taskId, e); - } - } + void saveDraftVariables(String taskId, Map variables); } diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientBuilder.java b/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientBuilder.java index 55f10c0..ee91980 100644 --- a/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientBuilder.java +++ b/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientBuilder.java @@ -9,11 +9,10 @@ import io.camunda.zeebe.client.ZeebeClient; import java.net.MalformedURLException; import java.net.URI; -import java.time.Duration; @Deprecated public class CamundaTaskListClientBuilder { - private CamundaTaskListClientProperties properties = new CamundaTaskListClientProperties(); + private final CamundaTaskListClientProperties properties = new CamundaTaskListClientProperties(); private ZeebeClient zeebeClient; public CamundaTaskListClientBuilder authentication(Authentication authentication) { @@ -47,19 +46,6 @@ public CamundaTaskListClientBuilder shouldLoadTruncatedVariables() { return this; } - @Deprecated(forRemoval = true) - public CamundaTaskListClientBuilder alwaysReconnect() { - return this; - } - - /** - * Force cookie expiration after some time (default 3mn). Only usefull with SimpleAuthentication - */ - @Deprecated(forRemoval = true) - public CamundaTaskListClientBuilder cookieExpiration(Duration cookieExpiration) { - return this; - } - /** * Enable when using zeebe user tasks (only relevant for >8.5). Will require presence of a zeebe * client @@ -69,8 +55,8 @@ public CamundaTaskListClientBuilder useZeebeUserTasks() { return this; } - public CamundaTaskListClient build() throws TaskListException { - return new CamundaTaskListClient(properties, zeebeClient); + public CamundaTaskListClientV1 build() throws TaskListException { + return new CamundaTaskListClientV1(properties, zeebeClient); } public CamundaTaskListClientBuilder selfManagedAuthentication( diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientV1.java b/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientV1.java new file mode 100644 index 0000000..5a37934 --- /dev/null +++ b/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientV1.java @@ -0,0 +1,254 @@ +package io.camunda.tasklist; + +import static io.camunda.tasklist.util.ConverterUtils.*; + +import com.fasterxml.jackson.core.JsonProcessingException; +import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties; +import io.camunda.tasklist.auth.Authentication; +import io.camunda.tasklist.dto.Form; +import io.camunda.tasklist.dto.Pagination; +import io.camunda.tasklist.dto.SearchType; +import io.camunda.tasklist.dto.Task; +import io.camunda.tasklist.dto.Task.Implementation; +import io.camunda.tasklist.dto.TaskList; +import io.camunda.tasklist.dto.TaskSearch; +import io.camunda.tasklist.dto.Variable; +import io.camunda.tasklist.exception.TaskListException; +import io.camunda.tasklist.generated.api.FormApi; +import io.camunda.tasklist.generated.api.TaskApi; +import io.camunda.tasklist.generated.api.VariablesApi; +import io.camunda.tasklist.generated.invoker.ApiClient; +import io.camunda.tasklist.generated.invoker.ApiException; +import io.camunda.tasklist.generated.model.SaveVariablesRequest; +import io.camunda.tasklist.generated.model.TaskAssignRequest; +import io.camunda.tasklist.generated.model.TaskCompleteRequest; +import io.camunda.tasklist.generated.model.TaskSearchRequest; +import io.camunda.tasklist.generated.model.VariableInputDTO; +import io.camunda.tasklist.generated.model.VariablesSearchRequest; +import io.camunda.zeebe.client.ZeebeClient; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; + +public class CamundaTaskListClientV1 extends AbstractCamundaTaskListClient { + private final ZeebeClient zeebeClient; + private final TaskApi taskApi; + private final FormApi formApi; + private final VariablesApi variablesApi; + + @Deprecated + public CamundaTaskListClientV1( + CamundaTaskListClientProperties properties, ZeebeClient zeebeClient) { + this( + new CamundaTasklistClientConfiguration( + Objects.requireNonNull(properties.getAuthentication(), "No authentication provided"), + toUrl(properties.getTaskListUrl()), + zeebeClient, + new DefaultProperties( + properties.isDefaultShouldReturnVariables(), + properties.isDefaultShouldLoadTruncatedVariables(), + properties.isUseZeebeUserTasks()))); + } + + public CamundaTaskListClientV1(CamundaTasklistClientConfiguration configuration) { + super(configuration.defaultProperties()); + if (configuration.defaultProperties().useZeebeUserTasks() + && configuration.zeebeClient() == null) { + throw new IllegalStateException("ZeebeClient is required when using ZeebeUserTasks"); + } + this.zeebeClient = configuration.zeebeClient(); + CloseableHttpClient httpClient = buildTasklistHttpClient(configuration.authentication()); + ApiClient apiClient = new ApiClient(httpClient); + apiClient.setBasePath(configuration.baseUrl().toExternalForm()); + this.taskApi = new TaskApi(apiClient); + this.formApi = new FormApi(apiClient); + this.variablesApi = new VariablesApi(apiClient); + } + + private static URL toUrl(String url) { + try { + return URI.create(url).toURL(); + } catch (MalformedURLException e) { + throw new RuntimeException("Error while creating tasklist url", e); + } + } + + private static CloseableHttpClient buildTasklistHttpClient(Authentication authentication) { + return HttpClients.custom() + .useSystemProperties() + .addRequestInterceptorFirst( + (request, entity, context) -> + authentication.getTokenHeader().forEach(request::addHeader)) + .build(); + } + + @Deprecated + public static CamundaTaskListClientBuilder builder() { + return new CamundaTaskListClientBuilder(); + } + + @Override + public Task unclaim(String taskId) { + try { + return toTask(taskApi.unassignTask(taskId), null); + } catch (Exception e) { + throw new TaskListException("Error unclaiming task " + taskId, e); + } + } + + @Override + public Task claim(String taskId, String assignee, Boolean allowOverrideAssignment) { + try { + return toTask( + taskApi.assignTask( + taskId, + new TaskAssignRequest() + .assignee(assignee) + .allowOverrideAssignment(allowOverrideAssignment)), + null); + } catch (Exception e) { + throw new TaskListException("Error assigning task " + taskId, e); + } + } + + @Override + public void completeTask(String taskId, Map variablesMap) { + try { + Task task = getTask(taskId); + if (task.getImplementation() == null + || task.getImplementation().equals(Implementation.JOB_WORKER)) { + List variables = toVariableInput(variablesMap); + taskApi.completeTask(taskId, new TaskCompleteRequest().variables(variables)); + } else if (task.getImplementation().equals(Implementation.ZEEBE_USER_TASK)) { + if (zeebeClient == null) { + throw new IllegalStateException( + "zeebeClient must not be null, please set useZeebeUserTasks to assert this on startup"); + } + zeebeClient + .newUserTaskCompleteCommand(Long.parseLong(taskId)) + .variables(variablesMap) + .send() + .join(); + } + } catch (TaskListException | ApiException e) { + throw new TaskListException("Error completing task " + taskId, e); + } + } + + @Override + public Task getTask(String taskId, boolean withVariables) { + try { + List variables = null; + if (withVariables) { + variables = getVariables(taskId); + } + + return toTask(taskApi.getTaskById(taskId), variables); + } catch (TaskListException | ApiException e) { + throw new TaskListException("Error reading task " + taskId, e); + } + } + + @Override + public List getVariables(String taskId, boolean loadTruncated) { + try { + return taskApi.searchTaskVariables(taskId, new VariablesSearchRequest()).stream() + .map( + vsr -> { + if (loadTruncated && Boolean.TRUE.equals(vsr.getIsValueTruncated())) { + try { + return getVariable(vsr.getId()); + } catch (TaskListException e) { + throw new RuntimeException("Error while loading full value of variable", e); + } + } else { + try { + return improveVariable(vsr); + } catch (Exception e) { + throw new RuntimeException("Error while improving variable", e); + } + } + }) + .collect(Collectors.toList()); + } catch (ApiException | RuntimeException e) { + throw new TaskListException("Error reading task " + taskId, e); + } + } + + @Override + public Variable getVariable(String variableId) { + try { + return toVariable(variablesApi.getVariableById(variableId)); + } catch (ApiException | JsonProcessingException e) { + throw new TaskListException("Error while loading variable " + variableId, e); + } + } + + @Override + public Form getForm(String formId, String processDefinitionId, Long version) { + try { + if (formId.startsWith(CamundaTasklistConstants.CAMUNDA_FORMS_PREFIX)) { + formId = formId.substring(CamundaTasklistConstants.CAMUNDA_FORMS_PREFIX.length()); + } + return toForm(formApi.getForm(formId, processDefinitionId, version)); + } catch (ApiException e) { + throw new TaskListException("Error reading form " + formId, e); + } + } + + @Override + protected TaskList getTasksInternal(TaskSearch search) { + Pagination pagination = search.getPagination(); + TaskSearchRequest request = toTaskSearchRequest(search); + if (pagination != null) { + if (pagination.getSearchType() != null + && pagination.getSearch() != null + && !pagination.getSearch().isEmpty()) { + if (pagination.getSearchType().equals(SearchType.BEFORE)) { + request.searchBefore(pagination.getSearch()); + } else if (pagination.getSearchType().equals(SearchType.BEFORE_OR_EQUAL)) { + request.searchBeforeOrEqual(pagination.getSearch()); + } else if (pagination.getSearchType().equals(SearchType.AFTER)) { + request.searchAfter(pagination.getSearch()); + } else if (pagination.getSearchType().equals(SearchType.AFTER_OR_EQUAL)) { + request.searchAfterOrEqual(pagination.getSearch()); + } + } + request.pageSize(pagination.getPageSize()); + request.sort(toSort(pagination.getSort())); + } + return new TaskList().setItems(getTasks(request, search.getWithVariables())).setSearch(search); + } + + private List getTasks(TaskSearchRequest search, boolean withVariables) { + try { + + List tasks = toTasks(taskApi.searchTasks(search)); + if (withVariables + && (search.getIncludeVariables() == null || search.getIncludeVariables().isEmpty())) { + loadVariables(tasks); + } + return tasks; + } catch (ApiException e) { + throw new TaskListException("Error searching tasks", e); + } + } + + @Override + public void saveDraftVariables(String taskId, Map variables) { + try { + List convertedVariables = toVariableInput(variables); + SaveVariablesRequest variablesInput = new SaveVariablesRequest(); + variablesInput.setVariables(convertedVariables); + taskApi.saveDraftTaskVariables(taskId, variablesInput); + } catch (ApiException e) { + throw new TaskListException("Error saving draft variables for task " + taskId, e); + } + } +} diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientV2.java b/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientV2.java new file mode 100644 index 0000000..187b85e --- /dev/null +++ b/extension/client-java/src/main/java/io/camunda/tasklist/CamundaTaskListClientV2.java @@ -0,0 +1,66 @@ +package io.camunda.tasklist; + +import io.camunda.client.CamundaClient; +import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties; +import io.camunda.tasklist.dto.Form; +import io.camunda.tasklist.dto.Task; +import io.camunda.tasklist.dto.TaskList; +import io.camunda.tasklist.dto.TaskSearch; +import io.camunda.tasklist.dto.Variable; +import io.camunda.tasklist.exception.TaskListException; +import java.util.List; +import java.util.Map; + +public class CamundaTaskListClientV2 extends AbstractCamundaTaskListClient { + private final CamundaClient camundaClient; + + public CamundaTaskListClientV2(CamundaClient camundaClient, DefaultProperties defaultProperties) { + super(defaultProperties); + this.camundaClient = camundaClient; + } + + @Override + protected TaskList getTasksInternal(TaskSearch search) { + throw new TaskListException("Not implemented"); + } + + @Override + public Task unclaim(String taskId) { + throw new TaskListException("Not implemented"); + } + + @Override + public Task claim(String taskId, String assignee, Boolean allowOverrideAssignment) { + throw new TaskListException("Not implemented"); + } + + @Override + public void completeTask(String taskId, Map variablesMap) { + throw new TaskListException("Not implemented"); + } + + @Override + public Task getTask(String taskId, boolean withVariables) { + throw new TaskListException("Not implemented"); + } + + @Override + public List getVariables(String taskId, boolean loadTruncated) { + throw new TaskListException("Not implemented"); + } + + @Override + public Variable getVariable(String variableId) { + throw new TaskListException("Not implemented"); + } + + @Override + public Form getForm(String formId, String processDefinitionId, Long version) { + throw new TaskListException("Not implemented"); + } + + @Override + public void saveDraftVariables(String taskId, Map variables) { + throw new TaskListException("Not implemented"); + } +} diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/dto/Pagination.java b/extension/client-java/src/main/java/io/camunda/tasklist/dto/Pagination.java index fd82ea0..270a94a 100644 --- a/extension/client-java/src/main/java/io/camunda/tasklist/dto/Pagination.java +++ b/extension/client-java/src/main/java/io/camunda/tasklist/dto/Pagination.java @@ -1,6 +1,5 @@ package io.camunda.tasklist.dto; -import io.camunda.tasklist.generated.model.TaskOrderBy; import java.util.ArrayList; import java.util.List; @@ -89,11 +88,11 @@ public Builder afterOrEqual(List search) { return this; } - public Builder sortBy(TaskOrderBy.FieldEnum field, TaskOrderBy.OrderEnum order) { + public Builder sortBy(TaskOrderBy.Field field, TaskOrderBy.Order order) { if (sort == null) { sort = new ArrayList<>(); } - sort.add(new TaskOrderBy().field(field).order(order)); + sort.add(new TaskOrderBy(field, order)); return this; } @@ -105,4 +104,19 @@ public Pagination build() { .setSort(sort); } } + + public record TaskOrderBy(Field field, Order order) { + public enum Field { + COMPLETION_TIME, + CREATION_TIME, + FOLLOW_UP_DATE, + DUE_DATE, + PRIORITY + } + + public enum Order { + ASC, + DESC + } + } } diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/dto/Task.java b/extension/client-java/src/main/java/io/camunda/tasklist/dto/Task.java index 7a79da8..1a27e3b 100644 --- a/extension/client-java/src/main/java/io/camunda/tasklist/dto/Task.java +++ b/extension/client-java/src/main/java/io/camunda/tasklist/dto/Task.java @@ -16,9 +16,9 @@ public class Task { private String assignee; - private String creationDate; + private OffsetDateTime creationDate; - private String completionDate; + private OffsetDateTime completionDate; private TaskState taskState; @@ -105,19 +105,19 @@ public void setAssignee(String assignee) { this.assignee = assignee; } - public String getCreationDate() { + public OffsetDateTime getCreationDate() { return creationDate; } - public void setCreationDate(String creationDate) { + public void setCreationDate(OffsetDateTime creationDate) { this.creationDate = creationDate; } - public String getCompletionDate() { + public OffsetDateTime getCompletionDate() { return completionDate; } - public void setCompletionDate(String completionDate) { + public void setCompletionDate(OffsetDateTime completionDate) { this.completionDate = completionDate; } diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/dto/TaskSearch.java b/extension/client-java/src/main/java/io/camunda/tasklist/dto/TaskSearch.java index 56915e8..2daf566 100644 --- a/extension/client-java/src/main/java/io/camunda/tasklist/dto/TaskSearch.java +++ b/extension/client-java/src/main/java/io/camunda/tasklist/dto/TaskSearch.java @@ -1,11 +1,8 @@ package io.camunda.tasklist.dto; import com.fasterxml.jackson.databind.ObjectMapper; +import io.camunda.tasklist.dto.TaskSearch.TaskByVariables.Operator; import io.camunda.tasklist.exception.TaskListException; -import io.camunda.tasklist.generated.model.IncludeVariable; -import io.camunda.tasklist.generated.model.TaskByVariables; -import io.camunda.tasklist.generated.model.TaskByVariables.OperatorEnum; -import io.camunda.tasklist.util.JsonUtils; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -47,11 +44,6 @@ public TaskSearch setCandidateUsers(List candidateUsers) { return this; } - public TaskSearch setWithVariables(Boolean withVariables) { - this.withVariables = withVariables; - return this; - } - public String getCandidateUser() { return candidateUser; } @@ -153,11 +145,7 @@ public TaskSearch setTaskVariables(List taskVariables) { public TaskSearch addVariableFilter(String variableName, Object variableValue) throws TaskListException { - return this.addVariableFilter( - new TaskByVariables() - .name(variableName) - .value(JsonUtils.toJsonString(variableValue)) - .operator(OperatorEnum.EQ)); + return this.addVariableFilter(new TaskByVariables(variableName, variableValue, Operator.EQ)); } public TaskSearch addVariableFilter(TaskByVariables variableFilter) { @@ -194,6 +182,11 @@ public boolean isWithVariables() { return withVariables != null && withVariables; } + public TaskSearch setWithVariables(Boolean withVariables) { + this.withVariables = withVariables; + return this; + } + public TaskSearch setWithVariables(boolean withVariables) { this.withVariables = withVariables; return this; @@ -216,9 +209,7 @@ public TaskSearch fetchVariable(String variable, boolean alwaysReturnFullValue) if (this.includeVariables == null) { this.includeVariables = new ArrayList<>(); } - IncludeVariable iv = new IncludeVariable(); - iv.setName(variable); - iv.alwaysReturnFullValue(alwaysReturnFullValue); + IncludeVariable iv = new IncludeVariable(variable, alwaysReturnFullValue); this.includeVariables.add(iv); return this; } @@ -242,4 +233,12 @@ public TaskSearch clone() { throw new RuntimeException("Error while cloning TaskSearch", e); } } + + public record IncludeVariable(String name, boolean alwaysReturnFullValue) {} + + public record TaskByVariables(String name, Object value, Operator operator) { + public enum Operator { + EQ + } + } } diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/exception/TaskListException.java b/extension/client-java/src/main/java/io/camunda/tasklist/exception/TaskListException.java index 715f083..fe89dee 100644 --- a/extension/client-java/src/main/java/io/camunda/tasklist/exception/TaskListException.java +++ b/extension/client-java/src/main/java/io/camunda/tasklist/exception/TaskListException.java @@ -1,6 +1,6 @@ package io.camunda.tasklist.exception; -public class TaskListException extends Exception { +public class TaskListException extends RuntimeException { public TaskListException() { super(); diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/util/ConverterUtils.java b/extension/client-java/src/main/java/io/camunda/tasklist/util/ConverterUtils.java index a1cd0c8..898aa02 100644 --- a/extension/client-java/src/main/java/io/camunda/tasklist/util/ConverterUtils.java +++ b/extension/client-java/src/main/java/io/camunda/tasklist/util/ConverterUtils.java @@ -7,23 +7,41 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import io.camunda.tasklist.dto.Form; +import io.camunda.tasklist.dto.Pagination; +import io.camunda.tasklist.dto.Pagination.TaskOrderBy.Field; +import io.camunda.tasklist.dto.Pagination.TaskOrderBy.Order; import io.camunda.tasklist.dto.Task; +import io.camunda.tasklist.dto.Task.Implementation; import io.camunda.tasklist.dto.TaskSearch; +import io.camunda.tasklist.dto.TaskSearch.IncludeVariable; +import io.camunda.tasklist.dto.TaskSearch.TaskByVariables; +import io.camunda.tasklist.dto.TaskSearch.TaskByVariables.Operator; import io.camunda.tasklist.dto.TaskState; import io.camunda.tasklist.dto.Variable; import io.camunda.tasklist.dto.VariableType; -import io.camunda.tasklist.exception.TaskListException; +import io.camunda.tasklist.generated.model.DateFilter; import io.camunda.tasklist.generated.model.FormResponse; +import io.camunda.tasklist.generated.model.TaskByVariables.OperatorEnum; +import io.camunda.tasklist.generated.model.TaskOrderBy; +import io.camunda.tasklist.generated.model.TaskOrderBy.FieldEnum; +import io.camunda.tasklist.generated.model.TaskOrderBy.OrderEnum; +import io.camunda.tasklist.generated.model.TaskResponse; import io.camunda.tasklist.generated.model.TaskSearchRequest; import io.camunda.tasklist.generated.model.TaskSearchResponse; import io.camunda.tasklist.generated.model.VariableInputDTO; import io.camunda.tasklist.generated.model.VariableResponse; import io.camunda.tasklist.generated.model.VariableSearchResponse; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; public class ConverterUtils { + public static String DATE_TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; private static ObjectMapper objectMapper = null; @@ -33,16 +51,66 @@ public static TaskSearchRequest.StateEnum toSearchState(TaskState value) { return value == null ? null : TaskSearchRequest.StateEnum.fromValue(value.getRawValue()); } + public static List toSort(List sort) { + if (sort == null) { + return null; + } + return sort.stream() + .map(s -> new TaskOrderBy().field(toField(s.field())).order(toOrder(s.order()))) + .toList(); + } + + public static FieldEnum toField(Field field) { + if (field == null) { + return null; + } + switch (field) { + case DUE_DATE -> { + return FieldEnum.DUE_DATE; + } + case PRIORITY -> { + return FieldEnum.PRIORITY; + } + case CREATION_TIME -> { + return FieldEnum.CREATION_TIME; + } + case FOLLOW_UP_DATE -> { + return FieldEnum.FOLLOW_UP_DATE; + } + case COMPLETION_TIME -> { + return FieldEnum.COMPLETION_TIME; + } + } + throw new IllegalArgumentException("Unknown field: " + field); + } + + public static OrderEnum toOrder(Order order) { + if (order == null) { + return null; + } + switch (order) { + case ASC -> { + return OrderEnum.ASC; + } + case DESC -> { + return OrderEnum.DESC; + } + } + throw new IllegalArgumentException("Unknown order: " + order); + } + public static Variable toVariable(VariableResponse var) throws JsonProcessingException { + if (var == null) { + return null; + } return buildVariable(var.getId(), var.getName(), var.getValue()); } - private static Variable buildVariable(String id, String name, String value) - throws JsonProcessingException { + private static Variable buildVariable(String id, String name, String value) { Variable result = new Variable(); result.setName(name); result.setId(id); - JsonNode nodeValue = getObjectMapper().readTree(value); + JsonNode nodeValue = toJsonNode(value); if (nodeValue.canConvertToLong()) { result.setValue(nodeValue.asLong()); result.setType(VariableType.NUMBER); @@ -69,59 +137,236 @@ private static Variable buildVariable(String id, String name, String value) return result; } - public static Variable improveVariable(VariableSearchResponse var) - throws JsonProcessingException { + private static JsonNode toJsonNode(String value) { + try { + return getObjectMapper().readTree(value); + } catch (JsonProcessingException e) { + throw new RuntimeException("Error while reading a string value to json", e); + } + } + + public static Variable improveVariable(VariableSearchResponse var) { return buildVariable(var.getId(), var.getName(), var.getValue()); } - public static List toVariables(List variables) - throws TaskListException { - try { - List result = null; + public static List toVariables(List variables) { + if (variables == null) { + return null; + } + List result = new ArrayList<>(); + for (VariableSearchResponse var : variables) { + result.add(improveVariable(var)); + } + return result; + } - if (variables != null) { - result = new ArrayList<>(); + public static Task toTask(TaskSearchResponse task) { + return toTask(task, null); + } - for (VariableSearchResponse var : variables) { - result.add(improveVariable(var)); - } + public static Task toTask(TaskSearchResponse sourceTask, List variables) { + if (sourceTask == null) { + return null; + } + Task task = new Task(); + List.of( + mapper(sourceTask::getId, task::setId), + mapper(sourceTask::getName, task::setName), + mapper(sourceTask::getProcessName, task::setProcessName), + mapper(sourceTask::getProcessDefinitionKey, task::setProcessDefinitionKey), + mapper(sourceTask::getProcessInstanceKey, task::setProcessInstanceKey), + mapper(sourceTask::getAssignee, task::setAssignee), + mapper( + sourceTask::getCreationDate, + ConverterUtils::toOffsetDateTime, + task::setCreationDate), + mapper( + sourceTask::getCompletionDate, + ConverterUtils::toOffsetDateTime, + task::setCompletionDate), + mapper(sourceTask::getTaskState, ConverterUtils::toTaskState, task::setTaskState), + mapper(sourceTask::getCandidateUsers, task::setCandidateUsers), + mapper(sourceTask::getCandidateGroups, task::setCandidateGroups), + mapper(sourceTask::getFollowUpDate, task::setFollowUpDate), + mapper(sourceTask::getDueDate, task::setDueDate), + mapper(sourceTask::getFormKey, task::setFormKey), + mapper(sourceTask::getFormId, task::setFormId), + mapper(sourceTask::getFormVersion, task::setFormVersion), + mapper(sourceTask::getIsFormEmbedded, task::setFormEmbedded), + mapper(sourceTask::getTaskDefinitionId, task::setTaskDefinitionId), + // sortValues, + // isFirst, + mapper(sourceTask::getTenantId, task::setTenantId), + // variables + mapper( + sourceTask::getImplementation, + ConverterUtils::toImplementation, + task::setImplementation)) + .forEach(Mapper::map); + if (variables != null) { + task.setVariables(variables); + } else if (task.getVariables() != null && !task.getVariables().isEmpty()) { + List improvedList = new ArrayList<>(); + for (Variable v : task.getVariables()) { + improvedList.add(buildVariable(v.getId(), v.getName(), (String) v.getValue())); } - return result; - } catch (JsonProcessingException e) { - throw new TaskListException(e); + task.setVariables(improvedList); } + + return task; } - public static Task toTask(Object sourceTask, List variables) throws TaskListException { - try { - Task task = - getObjectMapper().readValue(getObjectMapper().writeValueAsString(sourceTask), Task.class); - if (variables != null) { - task.setVariables(variables); - } else if (task.getVariables() != null && !task.getVariables().isEmpty()) { - List improvedList = new ArrayList<>(); - for (Variable v : task.getVariables()) { - improvedList.add(buildVariable(v.getId(), v.getName(), (String) v.getValue())); - } - task.setVariables(improvedList); + private static OffsetDateTime toOffsetDateTime(String dateTime) { + if (dateTime == null) { + return null; + } + return OffsetDateTime.parse(dateTime, DateTimeFormatter.ofPattern(DATE_TIME_PATTERN)); + } + + public static Task toTask(TaskResponse sourceTask) { + return toTask(sourceTask, null); + } + + public static Task toTask(TaskResponse sourceTask, List variables) { + if (sourceTask == null) { + return null; + } + Task task = new Task(); + List.of( + mapper(sourceTask::getId, task::setId), + mapper(sourceTask::getName, task::setName), + mapper(sourceTask::getProcessName, task::setProcessName), + mapper(sourceTask::getProcessDefinitionKey, task::setProcessDefinitionKey), + mapper(sourceTask::getProcessInstanceKey, task::setProcessInstanceKey), + mapper(sourceTask::getAssignee, task::setAssignee), + mapper( + sourceTask::getCreationDate, + ConverterUtils::toOffsetDateTime, + task::setCreationDate), + mapper( + sourceTask::getCompletionDate, + ConverterUtils::toOffsetDateTime, + task::setCompletionDate), + mapper(sourceTask::getTaskState, ConverterUtils::toTaskState, task::setTaskState), + mapper(sourceTask::getCandidateUsers, task::setCandidateUsers), + mapper(sourceTask::getCandidateGroups, task::setCandidateGroups), + mapper(sourceTask::getFollowUpDate, task::setFollowUpDate), + mapper(sourceTask::getDueDate, task::setDueDate), + mapper(sourceTask::getFormKey, task::setFormKey), + mapper(sourceTask::getFormId, task::setFormId), + mapper(sourceTask::getFormVersion, task::setFormVersion), + mapper(sourceTask::getIsFormEmbedded, task::setFormEmbedded), + mapper(sourceTask::getTaskDefinitionId, task::setTaskDefinitionId), + // sortValues, + // isFirst, + mapper(sourceTask::getTenantId, task::setTenantId), + // variables + mapper( + sourceTask::getImplementation, + ConverterUtils::toImplementation, + task::setImplementation)) + .forEach(Mapper::map); + if (variables != null) { + task.setVariables(variables); + } else if (task.getVariables() != null && !task.getVariables().isEmpty()) { + List improvedList = new ArrayList<>(); + for (Variable v : task.getVariables()) { + improvedList.add(buildVariable(v.getId(), v.getName(), (String) v.getValue())); } + task.setVariables(improvedList); + } - return task; - } catch (JsonProcessingException e) { - throw new TaskListException(e); + return task; + } + + public static Implementation toImplementation(TaskResponse.ImplementationEnum implementation) { + if (implementation == null) { + return null; + } + switch (implementation) { + case JOB_WORKER -> { + return Implementation.JOB_WORKER; + } + case ZEEBE_USER_TASK -> { + return Implementation.ZEEBE_USER_TASK; + } + } + throw new IllegalArgumentException("Unknown implementation: " + implementation); + } + + public static Implementation toImplementation( + TaskSearchResponse.ImplementationEnum implementation) { + if (implementation == null) { + return null; + } + switch (implementation) { + case JOB_WORKER -> { + return Implementation.JOB_WORKER; + } + case ZEEBE_USER_TASK -> { + return Implementation.ZEEBE_USER_TASK; + } } + throw new IllegalArgumentException("Unknown implementation: " + implementation); } - public static List toTasks(List tasks) throws TaskListException { + public static TaskState toTaskState(TaskSearchResponse.TaskStateEnum taskState) { + if (taskState == null) { + return null; + } + switch (taskState) { + case CREATED -> { + return TaskState.CREATED; + } + case COMPLETED -> { + return TaskState.COMPLETED; + } + case FAILED -> { + return TaskState.FAILED; + } + case CANCELED -> { + return TaskState.CANCELED; + } + } + throw new IllegalArgumentException("Unknown task state: " + taskState); + } + + public static TaskState toTaskState(TaskResponse.TaskStateEnum taskState) { + if (taskState == null) { + return null; + } + switch (taskState) { + case CREATED -> { + return TaskState.CREATED; + } + case COMPLETED -> { + return TaskState.COMPLETED; + } + case FAILED -> { + return TaskState.FAILED; + } + case CANCELED -> { + return TaskState.CANCELED; + } + } + throw new IllegalArgumentException("Unknown task state: " + taskState); + } + + public static List toTasks(List tasks) { + if (tasks == null) { + return null; + } List result = new ArrayList<>(); for (TaskSearchResponse task : tasks) { - result.add(toTask(task, null)); + result.add(toTask(task)); } return result; } - public static List toVariableInput(Map variablesMap) - throws TaskListException { + public static List toVariableInput(Map variablesMap) { + if (variablesMap == null) { + return null; + } try { List variables = new ArrayList<>(); for (Map.Entry entry : variablesMap.entrySet()) { @@ -134,29 +379,171 @@ public static List toVariableInput(Map variabl } return variables; } catch (JsonProcessingException e) { - throw new TaskListException(e); + throw new RuntimeException("Error while creating variable input", e); } } - public static Form toForm(FormResponse apolloTask) throws TaskListException { - try { - return getObjectMapper() - .readValue(getObjectMapper().writeValueAsString(apolloTask), Form.class); - } catch (JsonProcessingException e) { - throw new TaskListException(e); + public static Form toForm(FormResponse formResponse) { + if (formResponse == null) { + return null; + } + Form form = new Form(); + List.of( + mapper(formResponse::getId, form::setId), + mapper(formResponse::getProcessDefinitionKey, form::setProcessDefinitionId), + mapper(formResponse::getSchema, form::setSchema), + mapper(formResponse::getVersion, form::setVersion), + mapper(formResponse::getTenantId, form::setTenantId), + mapper(formResponse::getIsDeleted, form::setIsDeleted)) + .forEach(Mapper::map); + return form; + } + + public static TaskSearchRequest toTaskSearchRequest(TaskSearch taskSearch) { + if (taskSearch == null) { + return null; + } + TaskSearchRequest taskSearchRequest = new TaskSearchRequest(); + List.of( + mapper(taskSearch::getCandidateGroup, taskSearchRequest::setCandidateGroup), + mapper(taskSearch::getCandidateGroups, taskSearchRequest::setCandidateGroups), + mapper(taskSearch::getAssignee, taskSearchRequest::setAssignee), + mapper(taskSearch::getCandidateUser, taskSearchRequest::setCandidateUser), + mapper(taskSearch::getCandidateUsers, taskSearchRequest::setCandidateUsers), + mapper(taskSearch::getAssigned, taskSearchRequest::setAssigned), + mapper(taskSearch::getState, ConverterUtils::toState, taskSearchRequest::setState), + mapper(taskSearch::getProcessDefinitionKey, taskSearchRequest::setProcessDefinitionKey), + mapper(taskSearch::getProcessInstanceKey, taskSearchRequest::setProcessInstanceKey), + mapper(taskSearch::getTaskDefinitionId, taskSearchRequest::setTaskDefinitionId), + mapper( + taskSearch::getTaskVariables, + ConverterUtils::toTaskVariables, + taskSearchRequest::setTaskVariables), + mapper(taskSearch::getTenantIds, taskSearchRequest::setTenantIds), + // withVariables, + mapper( + taskSearch::getFollowUpDate, + ConverterUtils::toDateFilter, + taskSearchRequest::setFollowUpDate), + mapper( + taskSearch::getDueDate, + ConverterUtils::toDateFilter, + taskSearchRequest::setDueDate), + mapper( + taskSearch::getIncludeVariables, + ConverterUtils::toIncludeVariables, + taskSearchRequest::setIncludeVariables) + // pagination + ) + .forEach(Mapper::map); + return taskSearchRequest; + } + + public static TaskSearchRequest.StateEnum toState(TaskState taskState) { + if (taskState == null) { + return null; + } + switch (taskState) { + case CREATED -> { + return TaskSearchRequest.StateEnum.CREATED; + } + case COMPLETED -> { + return TaskSearchRequest.StateEnum.COMPLETED; + } + case FAILED -> { + return TaskSearchRequest.StateEnum.FAILED; + } + case CANCELED -> { + return TaskSearchRequest.StateEnum.CANCELED; + } + } + throw new IllegalArgumentException("Unknown task state: " + taskState); + } + + public static List toTaskVariables( + List taskVariables) { + if (taskVariables == null) { + return null; + } + return taskVariables.stream().map(ConverterUtils::toTaskVariable).toList(); + } + + public static List toIncludeVariables( + List includeVariables) { + if (includeVariables == null) { + return null; } + return includeVariables.stream().map(ConverterUtils::toIncludeVariable).toList(); } - public static TaskSearchRequest toTaskSearchRequest(TaskSearch taskSearch) - throws TaskListException { + public static io.camunda.tasklist.generated.model.IncludeVariable toIncludeVariable( + IncludeVariable includeVariables) { + if (includeVariables == null) { + return null; + } + io.camunda.tasklist.generated.model.IncludeVariable result = + new io.camunda.tasklist.generated.model.IncludeVariable(); + List.of( + mapper(includeVariables::name, result::setName), + mapper(includeVariables::alwaysReturnFullValue, result::setAlwaysReturnFullValue)) + .forEach(Mapper::map); + return result; + } + + public static io.camunda.tasklist.generated.model.TaskByVariables toTaskVariable( + TaskByVariables taskVariable) { + if (taskVariable == null) { + return null; + } + io.camunda.tasklist.generated.model.TaskByVariables request = + new io.camunda.tasklist.generated.model.TaskByVariables(); + List.of( + mapper(taskVariable::name, request::setName), + mapper(taskVariable::operator, ConverterUtils::toOperator, request::setOperator), + mapper(taskVariable::value, ConverterUtils::toValue, request::setValue)) + .forEach(Mapper::map); + return request; + } + + public static OperatorEnum toOperator(Operator operator) { + if (operator == null) { + return null; + } + switch (operator) { + case EQ -> { + return OperatorEnum.EQ; + } + } + throw new IllegalArgumentException("Unknown operator: " + operator); + } + + public static String toValue(Object value) { try { - return getObjectMapper() - .readValue(getObjectMapper().writeValueAsString(taskSearch), TaskSearchRequest.class); + return getObjectMapper().writeValueAsString(value); } catch (JsonProcessingException e) { - throw new TaskListException(e); + throw new RuntimeException("Error while transforming a value to a json string", e); } } + public static DateFilter toDateFilter(io.camunda.tasklist.dto.DateFilter dateFilter) { + if (dateFilter == null) { + return null; + } + DateFilter result = new DateFilter(); + List.of(mapper(dateFilter::getFrom, result::setFrom), mapper(dateFilter::getTo, result::setTo)) + .forEach(Mapper::map); + return result; + } + + private static Mapper mapper(Supplier getter, Consumer setter) { + return new Mapper<>(getter, o -> o, setter); + } + + private static Mapper mapper( + Supplier getter, Function mapper, Consumer setter) { + return new Mapper<>(getter, mapper, setter); + } + private static ObjectMapper getObjectMapper() { if (objectMapper == null) { objectMapper = new ObjectMapper(); @@ -165,4 +552,13 @@ private static ObjectMapper getObjectMapper() { } return objectMapper; } + + private record Mapper(Supplier getter, Function mapper, Consumer setter) { + + public void map() { + S s = getter.get(); + T t = mapper.apply(s); + setter.accept(t); + } + } } diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/util/JsonUtils.java b/extension/client-java/src/main/java/io/camunda/tasklist/util/JsonUtils.java deleted file mode 100644 index 59b1ed2..0000000 --- a/extension/client-java/src/main/java/io/camunda/tasklist/util/JsonUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.camunda.tasklist.util; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.camunda.tasklist.exception.TaskListException; -import java.io.IOException; - -public class JsonUtils { - - private JsonUtils() {} - - private static ObjectMapper mapper; - - public static JsonNode toJsonNode(String json) throws IOException { - if (mapper == null) { - mapper = new ObjectMapper(); - } - return mapper.readTree(json); - } - - public static String toJsonString(Object object) throws TaskListException { - if (mapper == null) { - mapper = new ObjectMapper(); - } - try { - return mapper.writeValueAsString(object); - } catch (IOException e) { - throw new TaskListException(e); - } - } -} diff --git a/extension/client-java/src/main/java/io/camunda/tasklist/util/PaginationUtil.java b/extension/client-java/src/main/java/io/camunda/tasklist/util/PaginationUtil.java new file mode 100644 index 0000000..f69a5b8 --- /dev/null +++ b/extension/client-java/src/main/java/io/camunda/tasklist/util/PaginationUtil.java @@ -0,0 +1,9 @@ +package io.camunda.tasklist.util; + +import io.camunda.tasklist.dto.Pagination; + +public class PaginationUtil { + public static Pagination createPagination(Integer pageSize) { + return new Pagination().setPageSize(pageSize); + } +} diff --git a/extension/client-java/src/test/java/io/camunda/tasklist/CamundaTasklistClientTest.java b/extension/client-java/src/test/java/io/camunda/tasklist/CamundaTasklistClientTest.java index a8e00b4..3757bc5 100644 --- a/extension/client-java/src/test/java/io/camunda/tasklist/CamundaTasklistClientTest.java +++ b/extension/client-java/src/test/java/io/camunda/tasklist/CamundaTasklistClientTest.java @@ -47,7 +47,7 @@ public void shouldThrowIfZeebeClientNullAndUseZeebeUserTasks() { new CamundaTasklistClientConfiguration( new MockAuthentication(), baseUrl(), null, new DefaultProperties(false, false, true)); IllegalStateException assertionError = - assertThrows(IllegalStateException.class, () -> new CamundaTaskListClient(configuration)); + assertThrows(IllegalStateException.class, () -> new CamundaTaskListClientV1(configuration)); assertEquals("ZeebeClient is required when using ZeebeUserTasks", assertionError.getMessage()); } @@ -56,7 +56,7 @@ public void shouldNotThrowIfZeebeClientNullAndNotUseZeebeUserTasks() { CamundaTasklistClientConfiguration configuration = new CamundaTasklistClientConfiguration( new MockAuthentication(), baseUrl(), null, new DefaultProperties(false, false, false)); - CamundaTaskListClient client = new CamundaTaskListClient(configuration); + CamundaTaskListClientV1 client = new CamundaTaskListClientV1(configuration); assertNotNull(client); } @@ -80,7 +80,7 @@ void shouldAuthenticateUsingSimpleAuth() throws MalformedURLException, TaskListE baseUrl(), null, new DefaultProperties(false, false, false)); - CamundaTaskListClient client = new CamundaTaskListClient(configuration); + CamundaTaskListClient client = new CamundaTaskListClientV1(configuration); assertNotNull(client); TaskList tasks = client.getTasks(new TaskSearch()); assertNotNull(tasks); @@ -114,7 +114,7 @@ void shouldAuthenticateUsingJwt() throws MalformedURLException, TaskListExceptio baseUrl(), null, new DefaultProperties(false, false, false)); - CamundaTaskListClient client = new CamundaTaskListClient(configuration); + CamundaTaskListClient client = new CamundaTaskListClientV1(configuration); assertNotNull(client); TaskList tasks = client.getTasks(new TaskSearch()); assertNotNull(tasks); diff --git a/extension/client-java/src/test/java/io/camunda/tasklist/TaskSearchTest.java b/extension/client-java/src/test/java/io/camunda/tasklist/TaskSearchTest.java index 898ec38..b192b2c 100644 --- a/extension/client-java/src/test/java/io/camunda/tasklist/TaskSearchTest.java +++ b/extension/client-java/src/test/java/io/camunda/tasklist/TaskSearchTest.java @@ -12,6 +12,6 @@ void shouldCloneTaskSearch() { TaskSearch clone = taskSearch.clone(); assertThat(clone).isNotSameAs(taskSearch); assertThat(clone.getIncludeVariables()).hasSize(1); - assertThat(clone.getIncludeVariables().get(0).getName()).isEqualTo("foo"); + assertThat(clone.getIncludeVariables().get(0).name()).isEqualTo("foo"); } } diff --git a/extension/spring-boot-starter-camunda-tasklist/src/main/java/io/camunda/tasklist/spring/TasklistClientConfiguration.java b/extension/spring-boot-starter-camunda-tasklist/src/main/java/io/camunda/tasklist/spring/TasklistClientConfiguration.java index fbfad18..c3ce15a 100644 --- a/extension/spring-boot-starter-camunda-tasklist/src/main/java/io/camunda/tasklist/spring/TasklistClientConfiguration.java +++ b/extension/spring-boot-starter-camunda-tasklist/src/main/java/io/camunda/tasklist/spring/TasklistClientConfiguration.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.camunda.tasklist.CamundaTaskListClient; +import io.camunda.tasklist.CamundaTaskListClientV1; import io.camunda.tasklist.CamundaTasklistClientConfiguration; import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties; import io.camunda.tasklist.auth.Authentication; @@ -36,7 +37,7 @@ public TasklistClientConfiguration( @ConditionalOnMissingBean public CamundaTaskListClient camundaTasklistClient( CamundaTasklistClientConfiguration configuration) { - return new CamundaTaskListClient(configuration); + return new CamundaTaskListClientV1(configuration); } @Bean