Skip to content

Commit

Permalink
Feature/reorganize properties (#662) (#737)
Browse files Browse the repository at this point in the history
* deprecate old properties

* refactoring usage of properties

* wip

* wip

* wip

* wip

* legacy config still working

* removed unused configuration

* added backend issuer url to default saas props

* adjusted readme

* fixed broken test

* functionality of new property strategy proved

* moved from spring profiles to properties post processor

* moved tests as well

* worker overrides are applied over global overrides

* typo

* table format

* add a general comment for first orientation

* removed property

* typo

* updated docs about variable fetching

* typo

* update link to reflect new properties class

* typo

* deprecated classes

* updated executorserviceconfig to reflect new properties

* added a test to assert all deprecations are applied correctly

* applied deprecation notices to all legacy properties

* adjusted a reason comment

(cherry picked from commit ef37537)
  • Loading branch information
jonathanlukas committed May 6, 2024
1 parent 3c2fa96 commit 606e23a
Show file tree
Hide file tree
Showing 83 changed files with 3,895 additions and 852 deletions.
337 changes: 236 additions & 101 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public JwtCredential(String clientId, String clientSecret, String audience, Stri
this.authUrl = authUrl;
}

private String clientId;
private String clientSecret;
private String audience;
private String authUrl;
private final String clientId;
private final String clientSecret;
private final String audience;
private final String authUrl;

public String getClientId() {
return clientId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
package io.camunda.common.auth;

import java.util.Arrays;
import java.util.stream.Collectors;

/** Enum for different C8 Products */
public enum Product {
ZEEBE,
OPERATE,
TASKLIST,
CONSOLE,
OPTIMIZE,
WEB_MODELER
ZEEBE(true),
OPERATE(true),
TASKLIST(true),
CONSOLE(false),
OPTIMIZE(true),
WEB_MODELER(false),
IDENTITY(true);

private final boolean covered;

Product(boolean covered) {
this.covered = covered;
}

public static Product[] coveredProducts() {
return Arrays.stream(Product.values())
.filter(Product::covered)
.collect(Collectors.toList())
.toArray(new Product[0]);
}

public boolean covered() {
return covered;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ public class SimpleAuthentication implements Authentication {
private final SimpleConfig simpleConfig;
private final Map<Product, String> tokens = new HashMap<>();

private final String authUrl;

public SimpleAuthentication(String simpleUrl, SimpleConfig simpleConfig) {
public SimpleAuthentication(SimpleConfig simpleConfig) {
this.simpleConfig = simpleConfig;
this.authUrl = simpleUrl + "/api/login";
}

public static SimpleAuthenticationBuilder builder() {
Expand Down Expand Up @@ -64,7 +61,7 @@ private String retrieveToken(Product product, SimpleCredential simpleCredential)
}

private HttpPost buildRequest(SimpleCredential simpleCredential) {
HttpPost httpPost = new HttpPost(authUrl);
HttpPost httpPost = new HttpPost(simpleCredential.getBaseUrl() + "/api/login");
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("username", simpleCredential.getUser()));
params.add(new BasicNameValuePair("password", simpleCredential.getPassword()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@
import io.camunda.common.auth.Authentication.AuthenticationBuilder;

public class SimpleAuthenticationBuilder implements AuthenticationBuilder {
private String simpleUrl;
private SimpleConfig simpleConfig;

public SimpleAuthenticationBuilder withSimpleUrl(String simpleUrl) {
this.simpleUrl = simpleUrl;
return this;
}

public SimpleAuthenticationBuilder withSimpleConfig(SimpleConfig simpleConfig) {
this.simpleConfig = simpleConfig;
return this;
}

@Override
public Authentication build() {
return new SimpleAuthentication(simpleUrl, simpleConfig);
return new SimpleAuthentication(simpleConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
/** Contains credential for particular product. Used for Simple authentication. */
public class SimpleCredential {

public SimpleCredential(String user, String password) {
public SimpleCredential(String baseUrl, String user, String password) {
this.baseUrl = baseUrl;
this.user = user;
this.password = password;
}

private String user;
private String password;
private final String baseUrl;
private final String user;
private final String password;

public String getUser() {
return user;
Expand All @@ -18,4 +20,8 @@ public String getUser() {
public String getPassword() {
return password;
}

public String getBaseUrl() {
return baseUrl;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package io.camunda.zeebe.spring.example;

import io.camunda.operate.CamundaOperateClient;
import io.camunda.operate.exception.OperateException;
import io.camunda.operate.model.ProcessDefinition;
import io.camunda.operate.search.SearchQuery;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.ProcessInstanceEvent;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -15,7 +20,14 @@ public class PeriodicProcessStarter {

private static Logger log = LoggerFactory.getLogger(ExampleApplication.class);

@Autowired private ZeebeClient client;
private final ZeebeClient client;
private final CamundaOperateClient operateClient;

@Autowired
public PeriodicProcessStarter(ZeebeClient client, CamundaOperateClient operateClient) {
this.client = client;
this.operateClient = operateClient;
}

@Scheduled(fixedRate = 5000L)
public void startProcesses() {
Expand All @@ -40,4 +52,18 @@ public void startProcesses() {
event.getVersion(),
event.getProcessInstanceKey());
}

@Scheduled(fixedRate = 5000L)
public void listProcesses() throws OperateException {
SearchQuery query = new SearchQuery();
List<ProcessDefinition> processDefinitions = operateClient.searchProcessDefinitions(query);
processDefinitions.forEach(
processDefinition ->
log.info(
"Process Definition: Key: {}, BPMN process Id: {}, Name: {}, Tenant: {}",
processDefinition.getKey(),
processDefinition.getBpmnProcessId(),
processDefinition.getName(),
processDefinition.getTenantId()));
}
}
2 changes: 0 additions & 2 deletions example/src/main/resources/application.properties

This file was deleted.

4 changes: 4 additions & 0 deletions example/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
camunda:
client:
mode: simple

5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
<artifactId>identity-spring-boot-starter</artifactId>
<version>${identity.version}</version>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>identity-spring-boot-autoconfigure</artifactId>
<version>${identity.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand Down
9 changes: 8 additions & 1 deletion spring-boot-starter-camunda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>identity-spring-boot-starter</artifactId>
<artifactId>identity-spring-boot-autoconfigure</artifactId>
</dependency>
<!-- Make sure slf4j (transitive dependency of resilience4j is on the classpath in the version compatible with Spring boot
(not specifying a version here means it is taken from the Spring BOM pulled in on root level
Expand All @@ -62,6 +62,13 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-standalone</artifactId>
<version>3.4.1</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.common.json.SdkObjectMapper;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.JsonMapper;
import io.camunda.zeebe.client.impl.ZeebeObjectMapper;
import io.camunda.zeebe.spring.client.configuration.*;
import io.camunda.zeebe.spring.client.event.ZeebeLifecycleEventProducer;
import io.camunda.zeebe.spring.client.testsupport.SpringZeebeTestContext;
Expand All @@ -27,10 +24,12 @@
@ImportAutoConfiguration({
ZeebeClientProdAutoConfiguration.class,
ZeebeClientAllAutoConfiguration.class,
CommonClientConfiguration.class,
OperateClientConfiguration.class,
ZeebeActuatorConfiguration.class,
MetricsDefaultConfiguration.class
MetricsDefaultConfiguration.class,
AuthenticationConfiguration.class,
CommonClientConfiguration.class,
JsonMapperConfiguration.class
})
@AutoConfigureAfter(
JacksonAutoConfiguration
Expand All @@ -52,28 +51,4 @@ public ZeebeLifecycleEventProducer zeebeLifecycleEventProducer(
final ZeebeClient client, final ApplicationEventPublisher publisher) {
return new ZeebeLifecycleEventProducer(client, publisher);
}

/**
* Registering a JsonMapper bean when there is none already exists in {@link
* org.springframework.beans.factory.BeanFactory}.
*
* <p>NOTE: This method SHOULD NOT be explicitly called as it might lead to unexpected behaviour
* due to the {@link ConditionalOnMissingBean} annotation. i.e. Calling this method when another
* JsonMapper bean is defined in the context might throw {@link
* org.springframework.beans.factory.NoSuchBeanDefinitionException}
*
* @return a new JsonMapper bean if none already exists in {@link
* org.springframework.beans.factory.BeanFactory}
*/
@Bean(name = "zeebeJsonMapper")
@ConditionalOnMissingBean
public JsonMapper jsonMapper(ObjectMapper objectMapper) {
return new ZeebeObjectMapper(objectMapper);
}

@Bean(name = "commonJsonMapper")
@ConditionalOnMissingBean
public io.camunda.common.json.JsonMapper commonJsonMapper(ObjectMapper objectMapper) {
return new SdkObjectMapper(objectMapper);
}
}

0 comments on commit 606e23a

Please sign in to comment.