From 060dd6bdc57ad7ea5323efc62560251f58f7bed8 Mon Sep 17 00:00:00 2001 From: Andrej Petras Date: Wed, 10 Apr 2024 09:47:02 +0200 Subject: [PATCH] feat: update quarkus to 3.9.2 version (#148) --- README.md | 113 +-------------- .../pages/includes/attributes.adoc | 4 +- .../includes/tkit-quarkus-rs-context.adoc | 17 +++ docs/pom.xml | 30 ++++ extensions/README.md | 14 -- extensions/context/README.md | 18 --- extensions/data-import/README.md | 102 ------------- extensions/data-import/tests/pom.xml | 4 +- extensions/jpa-models/README.md | 115 --------------- extensions/jpa-tenant/README.md | 22 --- extensions/jpa/README.md | 71 --------- extensions/jpa/tests/pom.xml | 4 +- extensions/log/README.md | 6 - extensions/log/cdi/README.md | 67 --------- extensions/log/json/README.md | 45 ------ extensions/log/rs/README.md | 112 -------------- extensions/log/rs/deployment/pom.xml | 2 +- extensions/rest-context/README.md | 137 ------------------ .../deployment/RestContextBuildConfig.java | 6 +- extensions/rest-dto/README.md | 27 ---- extensions/rest/README.md | 20 --- extensions/security/README.md | 10 -- extensions/test-db-import/README.md | 22 --- it/amqp/pom.xml | 4 +- it/jpa/pom.xml | 2 +- it/panache-reactive/pom.xml | 2 +- it/panache/pom.xml | 2 +- it/rest-context/pom.xml | 4 +- it/rs-client-reactive/pom.xml | 4 +- it/rs-client/pom.xml | 4 +- .../it/rs/client/UserRestController.java | 10 +- pom.xml | 4 +- 32 files changed, 85 insertions(+), 919 deletions(-) delete mode 100644 extensions/README.md delete mode 100644 extensions/context/README.md delete mode 100644 extensions/data-import/README.md delete mode 100644 extensions/jpa-models/README.md delete mode 100644 extensions/jpa-tenant/README.md delete mode 100644 extensions/jpa/README.md delete mode 100644 extensions/log/README.md delete mode 100644 extensions/log/cdi/README.md delete mode 100644 extensions/log/json/README.md delete mode 100644 extensions/log/rs/README.md delete mode 100644 extensions/rest-context/README.md delete mode 100644 extensions/rest/README.md delete mode 100644 extensions/security/README.md delete mode 100644 extensions/test-db-import/README.md diff --git a/README.md b/README.md index 1cceef3f..6c92d8b4 100644 --- a/README.md +++ b/README.md @@ -15,114 +15,17 @@ Set of Quarkus extensions and libraries to speed up development of backend micro Tkit-Quarkus provides two different version streams, one compatible with Quarkus 2.x and the other compatible with Quarkus 3.x. -| Quarkus | Tkit-Quarkus | -|---------|--------------| -| 2.x | 0.x | -| 3.2.x | 1.x | -| > 3.3.x | 2.x (main) | - +| Quarkus | Tkit-Quarkus | +|---------|------------------| +| 2.x | = 0.x | +| 3.2.x | = 1.x | +| > 3.3.x | >= 2.x | +| > 3.9.x | >= 2.18.0 (main) | Use the latest version of the corresponding stream, [the list of versions is available on Maven Central](https://search.maven.org/artifact/org.tkit.quarkus.lib/tkit-quarkus-bom). -## Getting started - -Include the following bom artifact into your pom or parent pom and then pick the components you need. - -```xml - - - - org.tkit.quarkus.lib - tkit-quarkus-bom - ${tkit.quarkus.version} - pom - import - - - -``` - -## Components - -Include the component in your project by including the corresponding dependency. - -:information_source: Some component come with additional documentation and configuration - check the 'Documentation' link for particular section. - -| Name | ArtifactId | Info | Description | Documentation | -|------------------|-----------------------------|--------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------| -| Context | tkit-quarkus-context | | Context propagation helpers used by other extensions like logging or jpa. | [Link](extensions/context) | -| Data Import | tkit-quarkus-data-import | | Extension for business data import - initial data, mounted import files etc. | [Link](extensions/data-import) | -| JPA models | tkit-quarkus-jpa-models | | Base classes for JPA entities, traceable superclass and related classes. | [Link](extensions/jpa-models) | -| JPA DAO | tkit-quarkus-jpa | > Note: Consider using official Quarkus Panache extension instead. | Abstract DAO/Repository superclass and related utilities. | [Link](extensions/jpa) | -| JPA tenant | tkit-quarkus-tenant-jpa | | Tenant extension for JPA layer. | [Link](extensions/jpa-tenant) | -| Log CDI | tkit-quarkus-log-cdi | | Quarkus extension for CDI method logging(business method start/stop logging). | [Link](extensions/log/cdi) | -| Log RS | tkit-quarkus-log-rs | | Quarkus extension for HTTP request logging (client & server). | [Link](extensions/log/rs) | -| Log JSON | tkit-quarkus-log-json | | Custom JSON log formatter that provides additional features not included in [Official Quarkus json logger](https://quarkus.io/guides/logging#json-logging). Make sure you only include this if you need those extra features, otherwise use the official extension. | [Link](extensions/log/json) | -| Rest | tkit-quarkus-rest | | Helper classes for JAX-RS and Jackson. | [Link](extensions/rest) | -| Rest context | tkit-quarkus-rest-context | | Create application context from rest context. | [Link](extensions/rest-context) | -| Rest DTO | tkit-quarkus-rest-dto | > DEPRECATED | Helper classes for REST - model mapping, exception handling, DTOs. | [Link](extensions/rest-dto) | -| Test data import | tkit-quarkus-test-db-import | | Test extension for data import from excel into database during unit tests. | [Link](extensions/test-db-import) | -| Security | tkit-quarkus-security | | Enhanced security configuration | [Link](extensions/security) | - -### Migration from older version - -If you have used previous versions of tkit quarkus libraries (mvn groupId `org.tkit.quarkus`) then there are a few breaking changes in this new version, however the migration is straightforward: - -#### Change maven imports -Group id of the libraries has changed to `org.tkit.quarkus.lib`. Also, prefer the use of bom import, to ensure version compatibility. So if your current pom.xml looks sth like this: - -```xml - - - org.tkit.quarkus - tkit-quarkus-.... - - -``` -Change it to: -```xml - - - - org.tkit.quarkus.lib - tkit-quarkus-bom - ${tkit.quarkus.version} - pom - import - - - - - - -``` - -#### Update configuration -All extensions and libraries now have unified configuration properties structure, starting with `tkit.` prefix, some keys have been renamed or otherwise updated. Check the table bellow for config property migration: - -| Old | New | Note | -|-----------------------------------|----------------------------------------------|------------------------------------------------------------------------------------------------------------------------| -| `quarkus.tkit.log.ignore.pattern` | `tkit.log.cdi.auto-discovery.ignore.pattern` | | -| `quarkus.tkit.log.packages` | `tkit.log.cdi.auto-discovery.packages` | In order to enable auto binding of logging extension, you must add property `tkit.log.cdi.auto-discovery.enabled=true` | - -#### Default behavior changes - -Logging: -CDI logging now only logs end of business methods (success or error) to reduce logging verbosity. If you restore the behavior and still log start method invocations, set the property: `tkit.log.cdi.start.enabled=true` - -Old behavior: -``` -[com.acme.dom.dao.SomeBean] someMethod(param) started -[com.acme.dom.dao.SomeBean] someMethod(param):SomeResultClass finished [0.035s] -``` -[com.acme.dom.dao.SomeBean] (executor-thread-0) someMethod(param) started [0.035s] - -New behavior: -``` -[com.acme.dom.dao.SomeBean] someMethod(param):SomeResultClass [0.035s] -``` +## Documentation -#### JPA ModificationCount -Use `modificationCount` instead of `version` when working with `TraceableEntity`. Therefore, annotations like `@Mapping(target = "version", ignore = true)` should be changed to `@Mapping(target = "modificationCount", ignore = true)`. +Please, see the latest released [documentation page](https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/index.html). ## Contributors ✨ diff --git a/docs/modules/tkit-quarkus/pages/includes/attributes.adoc b/docs/modules/tkit-quarkus/pages/includes/attributes.adoc index 30b345aa..f9206f67 100644 --- a/docs/modules/tkit-quarkus/pages/includes/attributes.adoc +++ b/docs/modules/tkit-quarkus/pages/includes/attributes.adoc @@ -1,4 +1,4 @@ -:project-version: 2.16.0 -:quarkus-version: 3.8.2 +:project-version: 2.17.0 +:quarkus-version: 3.9.2 :examples-dir: ./../examples/ \ No newline at end of file diff --git a/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rs-context.adoc b/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rs-context.adoc index 8060c42a..85c4b415 100644 --- a/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rs-context.adoc +++ b/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rs-context.adoc @@ -10,6 +10,23 @@ h|[[tkit-quarkus-rs-context_configuration]]link:#tkit-quarkus-rs-context_configu h|Type h|Default +a|icon:lock[title=Fixed at build time] [[tkit-quarkus-rs-context_tkit-rs-context-build-tenant-enabled]]`link:#tkit-quarkus-rs-context_tkit-rs-context-build-tenant-enabled[tkit.rs.context.build.tenant.enabled]` + + +[.description] +-- +Enable tenant annotation discovery + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++TKIT_RS_CONTEXT_BUILD_TENANT_ENABLED+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++TKIT_RS_CONTEXT_BUILD_TENANT_ENABLED+++` +endif::add-copy-button-to-env-var[] +--|boolean +|`true` + + a| [[tkit-quarkus-rs-context_tkit-rs-context-token-enabled]]`link:#tkit-quarkus-rs-context_tkit-rs-context-token-enabled[tkit.rs.context.token.enabled]` diff --git a/docs/pom.xml b/docs/pom.xml index 74f39c79..640a7e87 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -18,6 +18,36 @@ tkit-quarkus-context ${project.version} + + org.tkit.quarkus.lib + tkit-quarkus-data-import-deployment + ${project.version} + + + org.tkit.quarkus.lib + tkit-quarkus-jpa-deployment + ${project.version} + + + org.tkit.quarkus.lib + tkit-quarkus-jpa-tenant + ${project.version} + + + org.tkit.quarkus.lib + tkit-quarkus-rest-context-deployment + ${project.version} + + + org.tkit.quarkus.lib + tkit-quarkus-security + ${project.version} + + + org.tkit.quarkus.lib + tkit-quarkus-test-db-import-deployment + ${project.version} + diff --git a/extensions/README.md b/extensions/README.md deleted file mode 100644 index a52313d1..00000000 --- a/extensions/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Extensions -List of [Quarkus](https://quarkus.io/) extensions. - -* [context](context) - Context propagation helpers used by other extensions like logging or jpa. -* [data-import](data-import) - Extension for business data import - initial data, mounted import files etc. -* [jpa](jpa) - Abstract DAO/Repository superclass and related utilities. -* [jpa-tenant](jpa-tenant) - tenant for JPA. -* [jpa-models](jpa-models) - Base classes for JPA entities, traceable superclass and related classes. -* [log](log) - This group of the extension contains several interceptors implementation and utilities for extending logging in the application. -* [rest](rest) - Helper classes for JAX-RS - model mapping, exception handling, DTOs. -* [test-db-import](test-db-import) - Test extension for data import from excel into database during unit tests. -* [rest-context](rest-context) - Create application context from rest context. -* [rest-dto](rest-dto) - DEPRECATED common rest models -* [security](security) - extension of Quarkus security. \ No newline at end of file diff --git a/extensions/context/README.md b/extensions/context/README.md deleted file mode 100644 index 35a5ec44..00000000 --- a/extensions/context/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# tkit-quarkus-context - -Context propagation helpers used by other extensions like logging or jpa. - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-context - -``` - -Context object holds - -* request ID -* principal name -* principal token -* business values \ No newline at end of file diff --git a/extensions/data-import/README.md b/extensions/data-import/README.md deleted file mode 100644 index 4f2a15ad..00000000 --- a/extensions/data-import/README.md +++ /dev/null @@ -1,102 +0,0 @@ -# tkit-quarkus-data-import - -1000kit quarkus data import extension during the start of the application. - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-data-import - -``` - -Configuration -```properties -# enable or disable the data import. Default `true` -tkit.dataimport.enabled=true|false -# file to import -tkit.dataimport.configurations..file= -# bean key defined in the @DataImport annotation. Default empty and -# value will be used for mapping the configuration to the bean. -tkit.dataimport.configurations..bean= -# metadata string-string map -tkit.dataimport.configurations..metadata= -# enable or disable the data import for the key. Default `true` -tkit.dataimport.configurations..enabled=true|false -# stop at error. Default `false` -tkit.dataimport.configurations..stop-at-error=true|false -``` - - -Example configuration -```properties -tkit.dataimport.enabled=true -tkit.dataimport.configurations.key1.file=/data/example_data.json -tkit.dataimport.configurations.key1.metadata.operation=UPDATE -tkit.dataimport.configurations.key1.metadata.check=FALSE -tkit.dataimport.configurations.key1.enabled=true -tkit.dataimport.configurations.key1.stop-at-error=false -``` - -The log of the data import changes is stored in the `dataimportlog` table. To create this table copy and paste these liquibase changes to your project. -```xml - - - - - - - - - - - - - - - -``` -Or embedded it in the project from file [create-log-table](runtime/src/main/resources/db/changelog/create-log-table.xml) -```xml - -``` -Example [changelog.xml](tests/src/main/resources/db/changeLog.xml) - -Flyway sql script: -```sql -CREATE TABLE DATAIMPORTLOG ( - ID VARCHAR(255) NOT NULL, - CREATIONDATE TIMESTAMP WITHOUT TIME ZONE, - MODIFICATIONDATE TIMESTAMP WITHOUT TIME ZONE, - FILE VARCHAR(255), - MD5 VARCHAR(255), - ERROR VARCHAR(255), - CONSTRAINT DATAIMPORTLOG_PKEY PRIMARY KEY (ID) -); -``` - -Create bean with `@DataImport("my-import-key")` bean which implements the `DataImportService` interface. -Example bean: [ParameterTestImport](tests/src/main/java/org/tkit/quarkus/dataimport/test/ParameterTestImport.java) -```java -@DataImport("my-import-key") -public class ParameterTestImport implements DataImportService { - - @Inject MyModelDAO dao; - @Inject ObjectMapper mapper; - - @Override - public void importData(DataImportConfig config) { - try { - MyModel model = mapper.readValue(config.getData(), MyModel.class); - dao.create(model); - } catch (Exception ex) { - throw new RuntimeException("Error import", ex); - } - } -} -``` \ No newline at end of file diff --git a/extensions/data-import/tests/pom.xml b/extensions/data-import/tests/pom.xml index 856a7c47..e96e0ca7 100644 --- a/extensions/data-import/tests/pom.xml +++ b/extensions/data-import/tests/pom.xml @@ -30,11 +30,11 @@ io.quarkus - quarkus-resteasy + quarkus-rest io.quarkus - quarkus-resteasy-jackson + quarkus-rest-jackson io.quarkus diff --git a/extensions/jpa-models/README.md b/extensions/jpa-models/README.md deleted file mode 100644 index 7950f75b..00000000 --- a/extensions/jpa-models/README.md +++ /dev/null @@ -1,115 +0,0 @@ -# tkit-quarkus-jpa - -1000kit Quarkus JPA database models extension - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-jpa-models - -``` - -## Documentation - -This extension contains abstract classes for the `JPA Entity` - -We have these abstract classes for `Entity` -* `org.tkit.quarkus.jpa.models.TraceableEntity` - base `Entity` abstract class which implements - traceable fields `creationUser`,`creationDate`,`modificationDate` and `modificationUser`. The type of the `ID` field is `String`. - The `ID` is generated when you create java instance with `UUID.randomUUID().toString()` - -In the project you need to extend `Entities` from one of these abstract classes. - -## Business ID - -For the `business ID` use corresponding pattern. The primary ID is `GUID` from the `TraceableEntity`. - -### PostgreSQL SERIAL type -```java -@Entity -@Table(name = "BUSINESS_PROJECT") -public class BusinessProject extends TraceableEntity { - - @Generated(GenerationTime.INSERT) - @Column(name = "bid", columnDefinition = "SERIAL") - private Long bid; - - public Long getBid() { return bid; } - public void setBid(Long bid) { this.bid = bid; } -} -``` -### Generic sequence implementation. -```java -import jakarta.persistence.Column; - -import org.my.group.BusinessId; - -@BusinessId(sequence = "SEQ_MY_ENTITY_BID") -@Column(name = "bid_anno") -Long bid; -``` -Follow the implementation of the custom annotation `org.my.group.BusinessId`. -```java -package org.my.group; - -import org.hibernate.annotations.ValueGenerationType; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@ValueGenerationType(generatedBy = BusinessIdValueGeneration.class) -@Retention(RetentionPolicy.RUNTIME) -public @interface BusinessId { - - String sequence() default ""; - -} -``` -Follow the implementation of the custom generator which we use in the annotation. -```java -public class BusinessIdGenerator implements ValueGenerator { - - String sequence; - - BusinessIdGenerator(String sequence) { - this.sequence = sequence; - } - - @Override - public Long generateValue(Session session, Object owner) { - SessionFactoryImpl sessionFactory = (SessionFactoryImpl) session.getSessionFactory(); - String sql = sessionFactory.getJdbcServices().getDialect().getSequenceNextValString(sequence); - ReturningWork seq = connection -> { - try (PreparedStatement preparedStatement = connection.prepareStatement(sql); - ResultSet resultSet = preparedStatement.executeQuery(); - ) { - resultSet.next(); - return resultSet.getLong(1); - } - }; - return sessionFactory.getCurrentSession().doReturningWork(seq); - } -} -``` -We need to add the sequence to the import.sql for the local development. -```sql -CREATE SEQUENCE IF NOT EXISTS seq_my_entity_bid; -``` -### Custom in-Memory generator -```java -@GeneratorType(type = BidStringGenerator.class, when = GenerationTime.INSERT) -@Column(name = "CUSTOM") -String custom; -``` -Follow the implementation of the custom generator `org.my.group.BidStringGenerator`. -```java -public class BidStringGenerator implements ValueGenerator { - - @Override - public String generateValue(Session session, Object owner) { - MyEntity e = (MyEntity) owner; - return e.name + "+" + UUID.randomUUID(); - } -} -``` \ No newline at end of file diff --git a/extensions/jpa-tenant/README.md b/extensions/jpa-tenant/README.md deleted file mode 100644 index bda8d2dc..00000000 --- a/extensions/jpa-tenant/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# tkit-quarkus-jpa-tenant - -1000kit Quarkus hibernate tenant resolver. - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-jpa-tenant - -``` - -### Configuration - -Runtime configuration. - -```properties -# Default tenant for the hibernate tenant resolver. -tkit.jpa.tenant.default=default -``` - -This will be not use if tenant is set in the `ApplicationContext`. See [rest-context](../rest-context) \ No newline at end of file diff --git a/extensions/jpa/README.md b/extensions/jpa/README.md deleted file mode 100644 index 2a999c2a..00000000 --- a/extensions/jpa/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# tkit-quarkus-jpa - -1000kit Quarkus JPA extension - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-jpa - -``` -> Note: Consider using official Quarkus Panache extension instead. -> -## Documentation - -The main class of this extension is `AbstractDAO` class which implements basic `CRUD` operation. -The `AbstractDAO` represent `DAO pattern` which implements `CRUD` operation. - -```java -@ApplicationScoped -public class UserDAO extends AbstractDAO { - -} -``` -The operation `create`,`delete`,`update` and `findById` are implemented in the abstract class. -In your `DAO` class you need to implement only the business logic. - -## Exception - -All method of the `AbstractDAO` class throws `DAOException` which is `RuntimeException` and has enumerated `ErrorCode`. -These errors are defined in the `AbstractDAO` class. - -The `ConstraintException` extends from the `DAOException` and is use for database constraints. -For example the `create` or `update` operation can throw this exception. - -## PageQuery - -The `AbstractDAO` class implements the `PageQuery`. With the method `PagedQuery createPageQuery(CriteriaQuery query, Page page)` -could you create a `PageQuery` for you entity. The method `getPageResult` of the `PageQuery` return `PageResult` which contains: -* stream - stream of entities. -* totalElements - total elements in the database for your criteria. -* number - the page number -* size - size of the page -* totalPages - total pages - -Examaple method: -```java -public PageResult searchByCriteria(UserSearchCriteria criteria) { - if (criteria == null) { - return null; - } - CriteriaQuery cq = criteriaQuery(); - Root root = cq.from(User.class); - List predicates = new ArrayList<>(); - CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); - - if (criteria.getName() != null && !criteria.getName().isEmpty()) { - predicates.add(cb.like(root.get(User_.USERNAME), wildcard(criteria.getName()))); - } - if (criteria.getEmail() != null && !criteria.getEmail().isEmpty()) { - predicates.add(cb.like(root.get(User_.EMAIL), wildcard(criteria.getEmail()))); - } - if (!predicates.isEmpty()) { - cq.where(predicates.toArray(new Predicate[0])); - } - - return createPageQuery(cq, Page.of(criteria.getPageNumber(), criteria.getPageSize())).getPageResult(); -} -``` -Default sorting by id attribute was added to avoid a problem with unpredictable data order for paging. -There could be a situation where some rows are selected from DB more than once, and some rows were skipped. \ No newline at end of file diff --git a/extensions/jpa/tests/pom.xml b/extensions/jpa/tests/pom.xml index 76c23bd2..b0f0b1cb 100644 --- a/extensions/jpa/tests/pom.xml +++ b/extensions/jpa/tests/pom.xml @@ -34,11 +34,11 @@ io.quarkus - quarkus-resteasy + quarkus-rest io.quarkus - quarkus-resteasy-jackson + quarkus-rest-jackson diff --git a/extensions/log/README.md b/extensions/log/README.md deleted file mode 100644 index 17e03538..00000000 --- a/extensions/log/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Log extensions -This group of the extension contains several interceptors implementation and utilities for extending logging in the application. - -* [cdi](cdi) - Quarkus extension for CDI method logging(business method start/stop logging). -* [rs](rs) - Quarkus extension for HTTP request logging (client & server). -* [json](json) - Custom JSON log formatter that provides additional features \ No newline at end of file diff --git a/extensions/log/cdi/README.md b/extensions/log/cdi/README.md deleted file mode 100644 index 7e7543a3..00000000 --- a/extensions/log/cdi/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# tkit-quarkus-log-cdi - -1000kit Quarkus logger extension, core log library for Quarkus ARC `cdi` implementation. - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-log-cdi - -``` -### Configuration - -Build time configuration. - -```properties -# Enable or disable autodiscovery -tkit.log.cdi.auto-discovery.enabled=false -# Binding includes packages. (list) -tkit.log.cdi.auto-discovery.packages=org.tkit -# Specify ignore pattern. (optional) -tkit.log.cdi.auto-discovery.ignore.pattern= -# Bean annotations to discovery. (list) -tkit.log.cdi.auto-discovery.bean.annotations=jakarta.enterprise.context.ApplicationScoped,jakarta.enterprise.context.Singleton,jakarta.enterprise.context.RequestScoped -``` -To activate the auto discovery only for rest-controllers use this configuration - -```properties -tkit.log.cdi.auto-discovery.bean.annotations=jakarta.ws.rs.Path -``` - -Runtime configuration. - -```properties -# Enable or disable interceptor -tkit.log.cdi.enabled=true -# Prefix for custom data mdc entries. (optional) -tkit.log.cdi.custom-data.prefix= -# Enable or disable start message -tkit.log.cdi.start.enabled=false -# Start log message template. (%1 - method, %2 - method parameters) -tkit.log.cdi.start.template=%1$s(%2$s) started. -# Enable or disable succeed message -tkit.log.cdi.succeed.enabled=true -# Succeed message template (%1 - method, %2 - parameters, %3 - return value, %4 - time) -tkit.log.cdi.succeed.template=%1$s(%2$s):%3$s [%4$.3fs] -# Enable or disable failed message -tkit.log.cdi.failed.enabled=true -# Failed message template (%1 - method, %2 - parameters, %3 - return value, %4 - time) -tkit.log.cdi.failed.template=%1$s(%2$s) throw %3$s [%4$.3fs] -# Return void method template -tkit.log.cdi.return-void-template=void -# Return void method template -tkit.log.cdi.mdc.errorKey=errorNumber -# Enable or disable service log. (optional) -tkit.log.cdi.service..log= -# Enable or disable service stacktrace. (optional) -tkit.log.cdi.service..stacktrace= -# Enable or disable service method log. (optional) -tkit.log.cdi.service..method..log= -# Enable or disable service method stacktrace. (optional) -tkit.log.cdi.service..method..stacktrace= -# Set up the mask string for the return type. (optional) -tkit.log.cdi.service..method..returnMask= -# Exclude parameters or mask method parameters. (optional) -tkit.log.cdi.service..method..param.= -``` \ No newline at end of file diff --git a/extensions/log/json/README.md b/extensions/log/json/README.md deleted file mode 100644 index aab2b1f4..00000000 --- a/extensions/log/json/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# tkit-quarkus-log-json - -Custom JSON log formatter that provides additional features not included in [Official Quarkus json logger](https://quarkus.io/guides/logging#json-logging). -Make sure you only include this if you need those extra features, otherwise use the official extension. - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-log-json - -``` -### Configuration - -```properties -# Determine whether to enable the JSON console formatting extension, which disables "normal" console formatting. -tkit.log.json.enabled=true -# Enable "pretty printing" of the JSON record. Note that some JSON parsers will fail to read pretty printed output. -tkit.log.json.pretty-print=false -# The date format to use. The special string "default" indicates that the default format should be used. -tkit.log.json.date-format=default -# The special end-of-record delimiter to be used. By default, no delimiter is used. (optional) -tkit.log.json.record-delimiter= -# The zone ID to use. The special string "default" indicates that the default zone should be used. -tkit.log.json.zone-id=default -# The exception output type to specify. -tkit.log.json.exception-output-type=formatted -# Enable printing of more details in the log. -tkit.log.json.print-details=false -# Add MDC keys mapping. (list) -tkit.log.json.keys.mdc= -# Add MDC prefix mapping. (list) -tkit.log.json.keys.group= -# Ignore keys. (list) -tkit.log.json.keys.ignore= -# Override keys. (list) -tkit.log.json.keys.override= -# Type of the keys. (list) -tkit.log.json.keys.type= -# Environment keys. (list) -tkit.log.json.keys.env= -# Number of characters after which the stacktrace is split. We produce linked messages. -tkit.log.json.split-stacktrace-after=12000 -``` - diff --git a/extensions/log/rs/README.md b/extensions/log/rs/README.md deleted file mode 100644 index ed8741de..00000000 --- a/extensions/log/rs/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# tkit-quarkus-log-rs - -Quarkus extension for HTTP request logging (client & server). - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-log-rs - -``` -### Configuration - -```properties -# Enabled or disable the rest log interceptor -tkit.log.rs.enabled=true -# Enabled or disable the correlation ID -tkit.log.rs.correlation-id-enabled=true -# The correlation ID header name -tkit.log.rs.correlation-id-header=X-Correlation-ID -# Map of MDC headers -tkit.log.rs.mdc-headers.= -# Enable or disable start message -tkit.log.rs.start.enabled=false -# Start log message template (%1 - HTTP method, %2 - URI) -tkit.log.rs.start.template=%1$s %2$s started. -# Enable or disable end message -tkit.log.rs.end.enabled=true -# End log message template (%1 - HTTP method, %2 - Path, %3 - Duration, %4 - HTTP response code, %5 - HTTP response name, %6 - URI) -tkit.log.rs.end.template=%1$s %2$s [%4$s] [%3$ss] -# Enable duration time as MDC parameter in rest calls -tkit.log.rs.end.mdc.duration.enabled=true -# MDC duration name -tkit.log.rs.end.mdc.duration.name=rs-time -# Response status MDC key name -tkit.log.rs.end.mdc.response-status.name=rs-status -# Enable or disable error log message -tkit.log.rs.error.enabled=true -# Enable or disable error log message -tkit.log.rs.regex.enabled=false -# Exclude request path patterns -tkit.log.rs.regex.exclude= -# Enable or disable error log message -tkit.log.rs.payload.enabled=true -# Payload log template (%1 - HTTP method, %2 - URL, %3 - Body) -tkit.log.rs.payload.template=%1$s %2$s payload: %3$s -# Empty body enabled or disabled -tkit.log.rs.payload.empty-body-enabled=true -# Empty body message -tkit.log.rs.payload.empty-body-message= -# Body content page last line message -tkit.log.rs.payload.page-message=...more... -# Maximum entity size -tkit.log.rs.payload.max-entity-size=1048576 -# Enable or disable error log message -tkit.log.rs.payload.regex.enabled=false -# Exclude request path patterns -tkit.log.rs.payload.regex.exclude= -# Enabled or disable controller log (Optional) -tkit.log.rs.controller..log= -# Enable or disable rest controller payload (Optional) -tkit.log.rs.controller..payload= -# Map of MDC headers for the controller (Optional) -tkit.log.rs.controller..mdc-headers.= -# Enabled or disable controller method log (Optional) -tkit.log.rs.controller...log= -# Enable or disable rest controller method payload (Optional) -tkit.log.rs.controller...payload= -# Map of MDC headers for the controller method (Optional) -tkit.log.rs.controller...mdc-headers.= -# Enable or disable rest-client log interceptor. -tkit.log.rs.client.enabled=true -# Enable or disable error log message -tkit.log.rs.client.regex.enabled=false -# Exclude request path patterns -tkit.log.rs.client.regex.exclude= -# Enable or disable error log message -tkit.log.rs.client.payload.enabled=true -# Payload log template (%1 - HTTP method, %2 - URL, %3 - Body) -tkit.log.rs.client.payload.template=%1$s %2$s payload: %3$s -# Empty body enabled or disabled -tkit.log.rs.client.payload.empty-body-enabled=true -# Empty body message -tkit.log.rs.client.payload.empty-body-message= -# Body content page last line message -tkit.log.rs.client.payload.page-message=...more... -# Maximum entity size -tkit.log.rs.client.payload.max-entity-size=1048576 -# Enable or disable error log message -tkit.log.rs.client.payload.regex.enabled=false -# Exclude request path patterns -tkit.log.rs.client.payload.regex.exclude= -# Map of MDC headers -tkit.log.rs.client.mdc-headers.= -# Enable or disable start message -tkit.log.rs.client.start.enabled=false -# Client start log message template (%1 - HTTP method, %1 - URI) -tkit.log.rs.client.start.template=%1$s %2$s started. -# Enable or disable client end message -tkit.log.rs.client.end.enabled=true -# Client end message template (%1 - HTTP method, %2 - URI, %3 - Duration, %4 - HTTP response code, %5 - HTTP response name) -tkit.log.rs.client.end.template=%1$s %2$s [%4$s] [%3$ss] -# Enable duration in the MDC rest client -tkit.log.rs.client.end.mdc.enabled=true -# MDC duration name -tkit.log.rs.client.end.mdc.duration.name=rs-client-time -# Response client status MDC key name -tkit.log.rs.client.end.mdc.response-status.name=rs-client-status -# Enable or disable error log message -tkit.log.rs.client.error.enabled=true -``` - diff --git a/extensions/log/rs/deployment/pom.xml b/extensions/log/rs/deployment/pom.xml index 056571e2..75085c68 100644 --- a/extensions/log/rs/deployment/pom.xml +++ b/extensions/log/rs/deployment/pom.xml @@ -32,7 +32,7 @@ io.quarkus - quarkus-resteasy-deployment + quarkus-rest-deployment test diff --git a/extensions/rest-context/README.md b/extensions/rest-context/README.md deleted file mode 100644 index af12b5eb..00000000 --- a/extensions/rest-context/README.md +++ /dev/null @@ -1,137 +0,0 @@ -# tkit-quarkus-rest-context - -1000kit Quarkus rest application context. This library contains rest interceptor with priority `1` that -start [ApplicationContext](../context) with `PrincipalName`, `Tenant-Id`, `Request-Id` and `Business-Context` - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-rest-context - -``` - -### Configuration - -Runtime configuration. - -```properties -# Enable or disable interceptor -tkit.rs.context.enabled=true -# Enable or disable correlation ID from header -tkit.rs.context.correlation-id.enabled=true -# Correlation ID header parameter -tkit.rs.context.correlation-id.header-param-name=X-Correlation-ID -# Enable or disable business context from header -tkit.rs.context.business-context.enabled=false -# Business context header parameter -tkit.rs.context.business-context.header-param-name=business-context -# Add token to the application context -tkit.rs.context.add-token-to-context=true -# Principal token is mandatory -tkit.rs.context.token-mandatory=false -# Principal is mandatory -tkit.rs.context.principal-mandatory=false -# Enable or disable token parser service -tkit.rs.context.token.enabled=true -# Make principal token required -tkit.rs.context.token.required=true -# Token type name for parsing token -tkit.rs.context.token.type=principal-token -# Verify the token or skip token verification -tkit.rs.context.token.verify=false -# Enable or disable the public key location for the verified token. -tkit.rs.context.token.public-key-location.enabled=false -# Token public key location suffix. This property is use only if public-key-location.enabled set to true. -tkit.rs.context.token.public-key-location.suffix=/protocol/openid-connect/certs -# Token header parameter -tkit.rs.context.token.header-param=apm-principal-token - -``` - -Runtime principal name configuration. - -```properties -# Enable or disable principal name for the context -tkit.rs.context.principal.name.enabled=true -# Enable or disable custom principal service -tkit.rs.context.principal.name.custom-service-enabled=false -# Enabled or disable `SecurityContext` principal name resolver -tkit.rs.context.principal.name.security-context.enabled=false -# Optional default principal name, default null -tkit.rs.context.principal.name.default= -# Read name from token -tkit.rs.context.principal.name.token-enabled=true -# Token claim name for principal name -tkit.rs.context.principal.name.token-claim-name=sub -# Use header parameter as principal name -tkit.rs.context.principal.name.header-param-enabled=false -# Principal name header for header-param-enabled -tkit.rs.context.principal.name.header-param-name=x-principal-id -``` - -Runtime principal token configuration. - -```properties -# Enabled or disable token resolver for principal name -tkit.rs.context.principal.token.enabled=true -``` - -Runtime tenant configuration. - -```properties -# Enable or disable tenant ID resolver for the context. -tkit.rs.context.tenant-id.enabled=false -# default tenant ID -tkit.rs.context.tenant-id.default=default -# Use token claim to setup tenant ID -tkit.rs.context.tenant-id.token.enabled=false -# Token claim parameter for tenant ID -tkit.rs.context.tenant-id.token.claim-tenant-param=tenantId -# enable or disable tenant ID from header parameter -tkit.rs.context.tenant-id.header-param-enabled=false -# header parameter of the tenant ID -tkit.rs.context.tenant-id.header-param-name=tenant-id -``` - -Tenant mock service for testing - -```properties -# enable or disable tenant ID mock service -tkit.rs.context.tenant-id.mock.enabled=false -# default tenant ID -tkit.rs.context.tenant-id.mock.default-tenant=default -# mock data orgId - tenantId -tkit.rs.context.tenant-id.mock.data.= -# token claim parameter of organization ID -tkit.rs.context.tenant-id.mock.claim-org-id=orgId -``` - -Priority of the tenant ID resolver: -* mock service -* custom implementation of th `RestCustomTenantResolver` interface -* header parameter - -The application can implement its own tenant resolver by implementing the `RestCustomTenantResolver` interface. The header parameter can be accessed using the input parameter `ContainerRequestContext` or by including the request scope bean `RestContextHeaderContainer`. - -For `ApplicationContext`. See [context](../context) - -### Tenant - -To skip the tenant resolver for the rest method, annotate the method with the `@TenantExclude` annotation. - -```java -import org.tkit.quarkus.rs.context.tenant.TenantExclude; - -@Path("test") -@ApplicationScoped -public class OperatorRestController { - - @GET - @TenantExclude - public Response test() { - // ... - } - -} -``` \ No newline at end of file diff --git a/extensions/rest-context/deployment/src/main/java/org/tkit/quarkus/rs/context/deployment/RestContextBuildConfig.java b/extensions/rest-context/deployment/src/main/java/org/tkit/quarkus/rs/context/deployment/RestContextBuildConfig.java index 4ea93f63..196aeda7 100644 --- a/extensions/rest-context/deployment/src/main/java/org/tkit/quarkus/rs/context/deployment/RestContextBuildConfig.java +++ b/extensions/rest-context/deployment/src/main/java/org/tkit/quarkus/rs/context/deployment/RestContextBuildConfig.java @@ -1,13 +1,11 @@ package org.tkit.quarkus.rs.context.deployment; -import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; -import io.quarkus.runtime.annotations.ConfigPhase; -import io.quarkus.runtime.annotations.ConfigRoot; +import io.quarkus.runtime.annotations.*; /** * Rest context build configuration. */ +@ConfigDocFilename("tkit-quarkus-rs-context.adoc") @ConfigRoot(prefix = "tkit", name = "rs.context", phase = ConfigPhase.BUILD_TIME) public class RestContextBuildConfig { diff --git a/extensions/rest-dto/README.md b/extensions/rest-dto/README.md index eee3f771..dd9fe816 100644 --- a/extensions/rest-dto/README.md +++ b/extensions/rest-dto/README.md @@ -3,30 +3,3 @@ > tkit-quarkus-rest-dto is deprecated. It will be removed in the next major release. Helper classes for JAX-RS - model mapping, exception handling, DTOs. - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-rest-dto - -``` - -### DTO - -All `DTO` classes are in the package `org.tkit.quarkus.rs.models`. These classes have weak reference to the -`Entity` classes and `PageResult` class in the [tkit-quarkus-jpa-models](../jpa-models) extension. -The class [RestExceptionDTO](src/main/java/org/tkit/quarkus/rs/models/RestExceptionDTO.java) is for the -[RestException](src/main/java/org/tkit/quarkus/rs/exceptions/RestException.java). - -### Exception - -This extension define the `RestException` which should be used in the `RestController`. This exception support -translation for the `errorCode` with `parameters`. The local is taken from the HTTP request. For default value use -Quarkus configuration value `quarkus.default-locale`. Exception is in the package `org.tkit.quarkus.rs.exceptions` - -### Mappers - -In the package `org.tkit.quarkus.rs.mappers` is the `ExceptionMapper` for all `Exception` in the project with priority `DefaultExceptionMapper.PRIORITY`. -You can `extend` and overwrite this `ExceptionMapper`. Use the `@Priority` to overwrite existing registration. - diff --git a/extensions/rest/README.md b/extensions/rest/README.md deleted file mode 100644 index 051699e8..00000000 --- a/extensions/rest/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# tkit-quarkus-rest - -Helper classes for JAX-RS. - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-rest - -``` - -### Jackson - -This module registered jackson customize module [RegisterCustomModuleCustomizer](src/main/java/org/tkit/quarkus/rs/jackson/RegisterCustomModuleCustomizer.java) - -### OffsetDateTimeMapper - -`OffsetDateTimeMapper` and `OffsetDateTimeParamConverterProvider` are used for correct OffsetDateTime mapping. - diff --git a/extensions/security/README.md b/extensions/security/README.md deleted file mode 100644 index f9a10fce..00000000 --- a/extensions/security/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# tkit-quarkus-security - -Enhanced security configuration - -## Configuration - -```properties -# disable or enable authorization -tkit.security.auth.enabled=true -``` \ No newline at end of file diff --git a/extensions/test-db-import/README.md b/extensions/test-db-import/README.md deleted file mode 100644 index d71388e2..00000000 --- a/extensions/test-db-import/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# tkit-quarkus-test-db-import - -Test extension for data import from excel into database during unit tests. - -Maven dependency -```xml - - org.tkit.quarkus.lib - tkit-quarkus-test-db-import - test - -``` -### Configuration - -```properties -# Enable or disable database import utility for the tests. -tkit.db-import.enabled=true|false -# Name of the database docker image used in the project. The utility will create a JDBC client to service created with this docker image. -tkit.db-import.db-image-name=docker.io/postgres -``` - - diff --git a/it/amqp/pom.xml b/it/amqp/pom.xml index cfb19350..a39be8ff 100644 --- a/it/amqp/pom.xml +++ b/it/amqp/pom.xml @@ -20,11 +20,11 @@ io.quarkus - quarkus-resteasy + quarkus-rest io.quarkus - quarkus-resteasy-jackson + quarkus-rest-jackson io.quarkus diff --git a/it/jpa/pom.xml b/it/jpa/pom.xml index ca919a20..a1bb2c62 100644 --- a/it/jpa/pom.xml +++ b/it/jpa/pom.xml @@ -35,7 +35,7 @@ io.quarkus - quarkus-resteasy-jackson + quarkus-rest-jackson io.quarkus diff --git a/it/panache-reactive/pom.xml b/it/panache-reactive/pom.xml index 5c901cb2..72a83294 100644 --- a/it/panache-reactive/pom.xml +++ b/it/panache-reactive/pom.xml @@ -34,7 +34,7 @@ io.quarkus - quarkus-resteasy-reactive-jackson + quarkus-rest-jackson io.quarkus diff --git a/it/panache/pom.xml b/it/panache/pom.xml index 91433cb8..6b8fee5f 100644 --- a/it/panache/pom.xml +++ b/it/panache/pom.xml @@ -39,7 +39,7 @@ io.quarkus - quarkus-resteasy-jackson + quarkus-rest-jackson io.quarkus diff --git a/it/rest-context/pom.xml b/it/rest-context/pom.xml index 49ac3230..a9f36e03 100644 --- a/it/rest-context/pom.xml +++ b/it/rest-context/pom.xml @@ -35,11 +35,11 @@ io.quarkus - quarkus-resteasy-reactive + quarkus-rest io.quarkus - quarkus-resteasy-reactive-jackson + quarkus-rest-jackson diff --git a/it/rs-client-reactive/pom.xml b/it/rs-client-reactive/pom.xml index 6b88814a..09087d84 100644 --- a/it/rs-client-reactive/pom.xml +++ b/it/rs-client-reactive/pom.xml @@ -20,11 +20,11 @@ io.quarkus - quarkus-resteasy-reactive + quarkus-rest io.quarkus - quarkus-resteasy-reactive-jackson + quarkus-rest-jackson io.quarkus diff --git a/it/rs-client/pom.xml b/it/rs-client/pom.xml index 6d2967cc..f2380c90 100644 --- a/it/rs-client/pom.xml +++ b/it/rs-client/pom.xml @@ -20,11 +20,11 @@ io.quarkus - quarkus-resteasy + quarkus-rest io.quarkus - quarkus-resteasy-jackson + quarkus-rest-jackson io.quarkus diff --git a/it/rs-client/src/main/java/org/tkit/quarkus/it/rs/client/UserRestController.java b/it/rs-client/src/main/java/org/tkit/quarkus/it/rs/client/UserRestController.java index 4b6ee8c4..f215aeec 100644 --- a/it/rs-client/src/main/java/org/tkit/quarkus/it/rs/client/UserRestController.java +++ b/it/rs-client/src/main/java/org/tkit/quarkus/it/rs/client/UserRestController.java @@ -24,12 +24,18 @@ public class UserRestController { @GET @Path("{id}") public Response getUser(@PathParam("id") String id) { - return Response.fromResponse(client.getUserById(id)).build(); + try (Response response = client.getUserById(id)) { + var tmp = response.readEntity(String.class); + return Response.ok(tmp).build(); + } } @POST @Path("{id}") public Response createUser(@PathParam("id") String id, String data) { - return Response.fromResponse(client.createUser(id, data)).build(); + try (Response response = client.createUser(id, data)) { + var tmp = response.readEntity(String.class); + return Response.ok(tmp).build(); + } } } diff --git a/pom.xml b/pom.xml index b5d21409..5b0d46db 100644 --- a/pom.xml +++ b/pom.xml @@ -49,9 +49,9 @@ - 3.8.2 + 3.9.2 6.4.4.Final - 1.5.0 + 1.6.0 3.1.7