Skip to content

Commit

Permalink
Replace configuration prefix "camunda.bpm.*" with "camunda.*" Note: t…
Browse files Browse the repository at this point in the history
…his is a breaking change! The application will not start with old properties but throw an exception.
  • Loading branch information
tobiasschaefer authored and martisaw committed Feb 22, 2021
1 parent f8882be commit 5266f85
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 71 deletions.
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,18 @@ You may use the following properties (typically in application.yml) to configure

| Prefix |Property | Default | Description |
|-----------------------|------------------|----------------------------------------------|------------------------|
| camunda.bpm.admin-user| .id | | If present, a Camunda admin account will be created by this id (including admin group and authorizations) |
| camunda.admin-user | .id | | If present, a Camunda admin account will be created by this id (including admin group and authorizations) |
| | .password | | Admin's password (mandatory if the id is present) |
| | .firstname | | Admin's first name (optional, defaults to the capitalized id) |
| | .lastname | | Admin's last name (optional, defaults to the capitalized id) |
| | .email | | Admin's email address (optional, defaults to <id>@localhost) |
| camunda.bpm.rest | .enabled | false | Enable the REST API |
| camunda.rest | .enabled | false | Enable the REST API |
| | .context-path | /engine-rest | Context path for the REST API |
| | .basic-auth-enabled | false | Enables basic authentication for the REST API |
| camunda.bpm.webapps | .enabled | false | Enable the Webapps (Cockpit, Task list, Admin) |
| camunda.webapps | .enabled | false | Enable the Webapps (Cockpit, Task list, Admin) |
| | .context-path | /camunda | Context path for the Webapps |
| | .index-redirect-enabled | true | Registers a redirect from / to the Webapps |
| camunda.bpm.filter | .create | | Name of a "show all" filter for the task list |
| camunda.filter | .create | | Name of a "show all" filter for the task list |

### Generic Properties

Expand All @@ -216,10 +216,9 @@ Example:

```yaml
camunda:
bpm:
generic-properties:
properties:
initialize-telemetry: true
generic-properties:
properties:
initialize-telemetry: true
```

# Advanced Topics
Expand Down Expand Up @@ -277,11 +276,10 @@ By default, REST API and the Webapps are not enabled. You have to configure them

```yaml
camunda:
bpm:
webapps:
enabled: true
rest:
enabled: true
webapps:
enabled: true
rest:
enabled: true
```

Further Information:
Expand Down
25 changes: 12 additions & 13 deletions micronaut-camunda-bpm-example/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ micronaut:
application:
name: micronaut-camunda-example
camunda:
bpm:
admin-user:
id: admin
password: admin
generic-properties:
properties:
initialize-telemetry: true
webapps:
enabled: true
rest:
enabled: true
filter:
create: "All tasks"
admin-user:
id: admin
password: admin
generic-properties:
properties:
initialize-telemetry: true
webapps:
enabled: true
rest:
enabled: true
filter:
create: "All tasks"
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class JettyRestCustomConfigurationTest : TestPropertyProvider {

override fun getProperties(): MutableMap<String, String> {
return mutableMapOf(
"camunda.bpm.rest.context-path" to "/custom-rest-path",
"camunda.bpm.rest.basic-auth-enabled" to "true",
"camunda.bpm.admin-user.id" to "admin",
"camunda.bpm.admin-user.password" to "admin",
"camunda.rest.context-path" to "/custom-rest-path",
"camunda.rest.basic-auth-enabled" to "true",
"camunda.admin-user.id" to "admin",
"camunda.admin-user.password" to "admin",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class JettyWebappCustomConfigurationTest : TestPropertyProvider {

override fun getProperties(): MutableMap<String, String> {
return mutableMapOf(
"camunda.bpm.webapps.context-path" to "/custom-webapp-path",
"camunda.bpm.webapps.index-redirect-enabled" to "false",
"camunda.bpm.rest.context-path" to "/custom-rest-path",
"camunda.webapps.context-path" to "/custom-webapp-path",
"camunda.webapps.index-redirect-enabled" to "false",
"camunda.rest.context-path" to "/custom-rest-path",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class RedirectToWebappsControllerTest : TestPropertyProvider {

override fun getProperties(): MutableMap<String, String> {
return mutableMapOf(
"camunda.bpm.webapps.enabled" to "false",
"camunda.bpm.webapps.index-redirect-enabled" to "true",
"camunda.webapps.enabled" to "false",
"camunda.webapps.index-redirect-enabled" to "true",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ micronaut:
application:
name: jetty-webapp-and-rest
camunda:
bpm:
admin-user:
id: admin
password: admin
webapps:
enabled: true
rest:
enabled: true
admin-user:
id: admin
password: admin
webapps:
enabled: true
rest:
enabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
import static org.camunda.bpm.engine.authorization.Permissions.ALL;

/**
* Bean creating Camunda Admin User, Group and Authorizations if {@code camunda.bpm.admin-user.id} Property is present.
* Bean creating Camunda Admin User, Group and Authorizations if {@code camunda.admin-user.id} Property is present.
*
* @author Titus Meyer
* @author Tobias Schäfer
*/
// Implementation based on: https://github.com/camunda/camunda-bpm-platform/blob/master/spring-boot-starter/starter/src/main/java/org/camunda/bpm/spring/boot/starter/configuration/impl/custom/CreateAdminUserConfiguration.java
@Singleton
@Requires(property = "camunda.bpm.admin-user.id")
@Requires(property = "camunda.admin-user.id")
public class AdminUserCreator implements ApplicationEventListener<ServerStartupEvent> {
private static final Logger log = LoggerFactory.getLogger(AdminUserCreator.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* @author Tobias Schäfer
*/
@ConfigurationProperties("camunda.bpm")
@ConfigurationProperties( "camunda")
public interface Configuration {

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import javax.inject.Singleton;

/**
* Create a simple "show all" filter if {@code camunda.bpm.filter.create} property is present.
* Create a simple "show all" filter if {@code camunda.filter.create} property is present.
*
* @author Martin Sawilla
*/
// Implementation based on https://github.com/camunda/camunda-bpm-spring-boot-starter/blob/master/starter/src/main/java/org/camunda/bpm/spring/boot/starter/configuration/impl/custom/CreateFilterConfiguration.java
@Singleton
@Requires(property = "camunda.bpm.filter.create")
@Requires(property = "camunda.filter.create")
public class FilterAllTaskCreator implements ApplicationEventListener<ServerStartupEvent> {
private static final Logger log = LoggerFactory.getLogger(FilterAllTaskCreator.class);

Expand All @@ -28,7 +28,7 @@ public class FilterAllTaskCreator implements ApplicationEventListener<ServerStar
public FilterAllTaskCreator(ProcessEngine processEngine, Configuration configuration) {
this.processEngine = processEngine;
filterName = configuration.getFilter().getCreate()
.orElseThrow(() -> new IllegalArgumentException("If property 'camunda.bpm.filter.create' is set it must have a value."));
.orElseThrow(() -> new IllegalArgumentException("If property 'camunda.filter.create' is set it must have a value."));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public MnProcessEngineConfiguration(SynchronousTransactionManager<Connection> tr
this.environment = environment;
this.camundaBpmVersion = camundaBpmVersion;
this.basicJdbcConfiguration = basicJdbcConfiguration;
checkForDeprecatedConfiguration();
setDataSource(dataSource);
setTransactionsExternallyManaged(true);
setExpressionManager(new MnExpressionManager(new ApplicationContextElResolver(applicationContext)));
Expand Down Expand Up @@ -144,6 +145,14 @@ protected List<CommandInterceptor> getCommandInterceptors(boolean requiresNew) {
);
}

protected void checkForDeprecatedConfiguration() {
if (!environment.getPropertyEntries("camunda.bpm").isEmpty()) {
String msg = "All properties with the prefix 'camunda.bpm.*' have been renamed to 'camunda.*'. Please update your configuration!";
log.error(msg);
throw new IllegalArgumentException(msg);
}
}

/**
* Configure telemetry registry and always disable if the "test" profile is active, i.e. tests are being executed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Tobias Schäfer
*/
@Singleton
@Requires(property = "camunda.bpm.webapps.enabled", value="true")
@Requires(property = "camunda.webapps.enabled", value="true")
public class CockpitRuntimeDelegateInitializer implements ApplicationEventListener<ServerStartupEvent> {

private static final Logger log = LoggerFactory.getLogger(CockpitRuntimeDelegateInitializer.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*
* @author Martin Sawilla
*/
@Requires(property = "camunda.bpm.webapps.enabled", value = "true")
@Requires(property = "camunda.bpm.webapps.index-redirect-enabled", notEquals = "false", defaultValue = "true")
@Requires(property = "camunda.webapps.enabled", value = "true")
@Requires(property = "camunda.webapps.index-redirect-enabled", notEquals = "false", defaultValue = "true")
@Controller
public class RedirectToWebappsController {
protected final Configuration configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ class AdminUserCreatorTest {

override fun getProperties(): MutableMap<String, String> {
return mutableMapOf(
"camunda.bpm.admin-user.id" to "admin",
"camunda.bpm.admin-user.password" to "admin",
"camunda.bpm.admin-user.firstname" to "Donald",
"camunda.bpm.admin-user.lastname" to "Duck",
"camunda.bpm.admin-user.email" to "Donald.Duck@example.org",
"camunda.admin-user.id" to "admin",
"camunda.admin-user.password" to "admin",
"camunda.admin-user.firstname" to "Donald",
"camunda.admin-user.lastname" to "Duck",
"camunda.admin-user.email" to "Donald.Duck@example.org",
)
}

Expand Down Expand Up @@ -116,8 +116,8 @@ class AdminUserCreatorTest {

override fun getProperties(): MutableMap<String, String> {
return mutableMapOf(
"camunda.bpm.admin-user.id" to "admin2",
"camunda.bpm.admin-user.password" to "admin2",
"camunda.admin-user.id" to "admin2",
"camunda.admin-user.password" to "admin2",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FilterAllTaskCreatorTest {
}

@MicronautTest
@Property(name = "camunda.bpm.filter.create", value = "Custom Filter")
@Property(name = "camunda.filter.create", value = "Custom Filter")
@Nested
inner class Filter {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package info.novatec.micronaut.camunda.bpm.feature.test

import io.micronaut.context.ApplicationContext
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import java.lang.RuntimeException
import java.util.*

/**
* Deprecated property tests for [info.novatec.micronaut.camunda.bpm.feature.MnProcessEngineConfiguration].
*
* We no longer support the "camunda.bpm" prefix.
*
* @author Tobias Schäfer
*/
class MnProcessEngineConfigurationDeprecatedPropertiesTest {
@Test
fun `valid property starts the application`() {
val properties = Collections.singletonMap<String, Any>("camunda.generic-properties.properties.dmn-enabled", true)
ApplicationContext.run(properties)
}

@Test
fun `deprecated camunda-bpm property prevents application start`() {
val properties = Collections.singletonMap<String, Any>("camunda.bpm.generic-properties.properties.dmn-enabled", true)
Assertions.assertThrows(RuntimeException::class.java) { ApplicationContext.run(properties) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import org.junit.jupiter.api.Test
import java.lang.RuntimeException
import java.util.*

/**
* Generic property tests for [info.novatec.micronaut.camunda.bpm.feature.MnProcessEngineConfiguration].
*
* @author Tobias Schäfer
*/
class MnProcessEngineConfigurationGenericPropertiesTest {
@Test
fun correctDefaultValue() {
Expand All @@ -25,10 +30,10 @@ class MnProcessEngineConfigurationGenericPropertiesTest {
@Test
fun validGenericPropertyAsString() {
val properties: Map<String, Any> = mapOf(
"camunda.bpm.generic-properties.properties.history-cleanup-strategy" to "endTimeBased",
"camunda.bpm.generic-properties.properties.batch-job-priority" to "30",
"camunda.bpm.generic-properties.properties.default-number-of-retries" to "1",
"camunda.bpm.generic-properties.properties.dmn-enabled" to "false"
"camunda.generic-properties.properties.history-cleanup-strategy" to "endTimeBased",
"camunda.generic-properties.properties.batch-job-priority" to "30",
"camunda.generic-properties.properties.default-number-of-retries" to "1",
"camunda.generic-properties.properties.dmn-enabled" to "false"
)
ApplicationContext.run(properties).use { applicationContext ->
val processEngineConfiguration = applicationContext.getBean(MnProcessEngineConfiguration::class.java)
Expand All @@ -45,9 +50,9 @@ class MnProcessEngineConfigurationGenericPropertiesTest {
@Test
fun validGenericPropertyAsPrimitive() {
val properties: Map<String, Any> = mapOf(
"camunda.bpm.generic-properties.properties.batch-job-priority" to 30,
"camunda.bpm.generic-properties.properties.default-number-of-retries" to 1,
"camunda.bpm.generic-properties.properties.dmn-enabled" to false
"camunda.generic-properties.properties.batch-job-priority" to 30,
"camunda.generic-properties.properties.default-number-of-retries" to 1,
"camunda.generic-properties.properties.dmn-enabled" to false
)
ApplicationContext.run(properties).use { applicationContext ->
val processEngineConfiguration = applicationContext.getBean(MnProcessEngineConfiguration::class.java)
Expand All @@ -60,7 +65,7 @@ class MnProcessEngineConfigurationGenericPropertiesTest {
@Test
fun validGenericPropertyOfTypeStringAsBoolean() {
val properties: Map<String, Any> = mapOf(
"camunda.bpm.generic-properties.properties.database-schema-update" to true,
"camunda.generic-properties.properties.database-schema-update" to true,
)
ApplicationContext.run(properties).use { applicationContext ->
val processEngineConfiguration = applicationContext.getBean(MnProcessEngineConfiguration::class.java)
Expand All @@ -74,7 +79,7 @@ class MnProcessEngineConfigurationGenericPropertiesTest {
@Test
fun camelCase() {
val properties: Map<String, Any> = mapOf(
"camunda.bpm.generic-properties.properties.historyCleanupStrategy" to "endTimeBased"
"camunda.generic-properties.properties.historyCleanupStrategy" to "endTimeBased"
)
ApplicationContext.run(properties).use { applicationContext ->
val processEngineConfiguration = applicationContext.getBean(MnProcessEngineConfiguration::class.java)
Expand All @@ -84,7 +89,7 @@ class MnProcessEngineConfigurationGenericPropertiesTest {

@Test
fun invalidGenericProperty() {
val properties = Collections.singletonMap<String, Any>("camunda.bpm.generic-properties.properties.xyz", "1")
val properties = Collections.singletonMap<String, Any>("camunda.generic-properties.properties.xyz", "1")
assertThrows(RuntimeException::class.java) { ApplicationContext.run(properties) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MnProcessEngineConfigurationTelemetryTest {

ApplicationContext.builder()
.deduceEnvironment(false)
.properties(mapOf("camunda.bpm.generic-properties.properties.initialize-telemetry" to true))
.properties(mapOf("camunda.generic-properties.properties.initialize-telemetry" to true))
.build()
.registerSingleton(CamundaBpmVersion::class.java, camundaBpmVersion)
.start()
Expand Down

0 comments on commit 5266f85

Please sign in to comment.