Notification service upgrade to Spring Boot 3, fixing startup and dependency issues

This commit is contained in:
Thomas Georgios Giannos 2024-01-16 19:13:07 +02:00
parent b04c0aebab
commit aab7571763
109 changed files with 1322 additions and 710 deletions

View File

@ -9,6 +9,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
@Configuration @Configuration
@EnableConfigurationProperties({InboxProperties.class}) @EnableConfigurationProperties({InboxProperties.class})

View File

@ -9,6 +9,7 @@ import eu.eudat.commons.enums.notification.NotificationTrackingState;
import eu.eudat.commons.validation.ValidatorFactory; import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.data.UserContactInfoEntity; import eu.eudat.data.UserContactInfoEntity;
import eu.eudat.data.UserEntity; import eu.eudat.data.UserEntity;
import eu.eudat.integrationevent.outbox.OutboxIntegrationEvent;
import eu.eudat.integrationevent.outbox.OutboxService; import eu.eudat.integrationevent.outbox.OutboxService;
import eu.eudat.model.persist.notification.NotificationPersist; import eu.eudat.model.persist.notification.NotificationPersist;
import eu.eudat.query.UserContactInfoQuery; import eu.eudat.query.UserContactInfoQuery;
@ -26,6 +27,7 @@ import org.springframework.web.context.annotation.RequestScope;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.time.Instant; import java.time.Instant;
import java.util.List; import java.util.List;
import java.util.UUID;
@Component @Component
@RequestScope @RequestScope
@ -58,30 +60,30 @@ public class NotificationIntegrationEventHandlerImpl implements NotificationInte
@Override @Override
public void handle(NotificationIntegrationEvent event) throws InvalidApplicationException { public void handle(NotificationIntegrationEvent event) throws InvalidApplicationException {
// OutboxIntegrationEvent message = new OutboxIntegrationEvent(); OutboxIntegrationEvent message = new OutboxIntegrationEvent();
// message.setMessageId(UUID.randomUUID()); message.setMessageId(UUID.randomUUID());
// message.setType(OutboxIntegrationEvent.NOTIFY); message.setType(OutboxIntegrationEvent.NOTIFY);
// message.setEvent(event); message.setEvent(event);
// this.outboxService.publish(message); this.outboxService.publish(message);
NotificationPersist persist = new NotificationPersist(); // NotificationPersist persist = new NotificationPersist();
persist.setType(event.getNotificationType()); // persist.setType(event.getNotificationType());
persist.setUserId(event.getUserId()); // persist.setUserId(event.getUserId());
persist.setContactHint(event.getContactHint()); // persist.setContactHint(event.getContactHint());
persist.setContactTypeHint(event.getContactTypeHint()); // persist.setContactTypeHint(event.getContactTypeHint());
persist.setData(event.getData()); // persist.setData(event.getData());
persist.setNotifyState(NotificationNotifyState.PENDING); // persist.setNotifyState(NotificationNotifyState.PENDING);
persist.setNotifiedWith(event.getContactTypeHint()); // persist.setNotifiedWith(event.getContactTypeHint());
persist.setRetryCount(0); // persist.setRetryCount(0);
persist.setTrackingState(NotificationTrackingState.UNDEFINED); // persist.setTrackingState(NotificationTrackingState.UNDEFINED);
persist.setTrackingProcess(NotificationTrackingProcess.PENDING); // persist.setTrackingProcess(NotificationTrackingProcess.PENDING);
persist.setTrackingData(null); // persist.setTrackingData(null);
persist.setProvenanceRef(event.getProvenanceRef()); // persist.setProvenanceRef(event.getProvenanceRef());
persist.setNotifiedAt(Instant.now()); // persist.setNotifiedAt(Instant.now());
validatorFactory.validator(NotificationPersist.NotificationPersistValidator.class).validateForce(persist); // validatorFactory.validator(NotificationPersist.NotificationPersistValidator.class).validateForce(persist);
if (isNotificationConsistent(persist)) { // if (isNotificationConsistent(persist)) {
notificationService.persist(persist, null); // notificationService.persist(persist, null);
auditService.track(AuditableAction.Notification_Persist, "notification_event", event); // auditService.track(AuditableAction.Notification_Persist, "notification_event", event);
} // }
} }
private boolean isNotificationConsistent(NotificationPersist notification) { private boolean isNotificationConsistent(NotificationPersist notification) {

View File

@ -8,15 +8,16 @@
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>notification-service-parent</artifactId> <artifactId>notification-service-parent</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<relativePath>../pom.xml</relativePath> <relativePath>../../notification-service/pom.xml</relativePath>
</parent> </parent>
<artifactId>notification-web</artifactId> <artifactId>notification-web</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.release>21</maven.compiler.release>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
@ -24,10 +25,14 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId> <artifactId>spring-boot-starter-validation</artifactId>
<version>2.6.4</version>
</dependency> </dependency>
<dependency> <dependency>
@ -35,15 +40,21 @@
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId> <artifactId>hibernate-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>notification</artifactId> <artifactId>notification</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>oidc-authz</artifactId> <artifactId>oidc-authz</artifactId>
@ -64,15 +75,6 @@
<artifactId>cors-web</artifactId> <artifactId>cors-web</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -3,15 +3,20 @@ package gr.cite.notification.web;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication @SpringBootApplication(
@ComponentScan({ scanBasePackages = {
"gr.cite.notification", "eu.eudat",
"gr.cite",
"gr.cite.queueoutbox",
"gr.cite.queueinbox",
"gr.cite.notification.integrationevent",
"gr.cite.tools", "gr.cite.tools",
"gr.cite.commons"}) "gr.cite.commons"})
@EntityScan({ @EntityScan({
"gr.cite.notification.data"}) "gr.cite.notification.data"})
@EnableAsync
public class NotificationApplication { public class NotificationApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -18,18 +18,20 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManagerResolver; import org.springframework.security.authentication.AuthenticationManagerResolver;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter; import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
import javax.servlet.Filter; import jakarta.servlet.Filter;
import javax.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter { public class SecurityConfiguration {
private final WebSecurityProperties webSecurityProperties; private final WebSecurityProperties webSecurityProperties;
private final AuthenticationManagerResolver<HttpServletRequest> authenticationManagerResolver; private final AuthenticationManagerResolver<HttpServletRequest> authenticationManagerResolver;
@ -47,20 +49,19 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
this.ownedAuthorizationHandler = ownedAuthorizationHandler; this.ownedAuthorizationHandler = ownedAuthorizationHandler;
} }
@Override @Bean
protected void configure(HttpSecurity http) throws Exception { public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http HttpSecurity tempHttp = http
.csrf().disable() .csrf(AbstractHttpConfigurer::disable)
.cors() .cors(httpSecurityCorsConfigurer -> {})
.and() .headers(httpSecurityHeadersConfigurer -> httpSecurityHeadersConfigurer.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
.addFilterBefore(apiKeyFilter, AbstractPreAuthenticatedProcessingFilter.class) .addFilterBefore(apiKeyFilter, AbstractPreAuthenticatedProcessingFilter.class)
.authorizeRequests() .authorizeHttpRequests(authRequest ->
.antMatchers(buildAntPatterns(webSecurityProperties.getAllowedEndpoints())).anonymous() authRequest.requestMatchers(buildAntPatterns(webSecurityProperties.getAllowedEndpoints())).anonymous()
.antMatchers(buildAntPatterns(webSecurityProperties.getAuthorizedEndpoints())).authenticated() .requestMatchers(buildAntPatterns(webSecurityProperties.getAuthorizedEndpoints())).authenticated())
.and() .sessionManagement( sessionManagementConfigurer-> sessionManagementConfigurer.sessionCreationPolicy(SessionCreationPolicy.NEVER))
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
.and()
.oauth2ResourceServer(oauth2 -> oauth2.authenticationManagerResolver(authenticationManagerResolver)); .oauth2ResourceServer(oauth2 -> oauth2.authenticationManagerResolver(authenticationManagerResolver));
return tempHttp.build();
} }
@Bean @Bean

View File

@ -34,7 +34,7 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.transaction.Transactional; import jakarta.transaction.Transactional;
import java.util.*; import java.util.*;
@RestController @RestController

View File

@ -2,10 +2,8 @@ package gr.cite.notification.web.controllers;
import gr.cite.notification.audit.AuditableAction; import gr.cite.notification.audit.AuditableAction;
import gr.cite.notification.authorization.AuthorizationFlags; import gr.cite.notification.authorization.AuthorizationFlags;
import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.data.NotificationEntity; import gr.cite.notification.data.NotificationEntity;
import gr.cite.notification.model.Notification; import gr.cite.notification.model.Notification;
import gr.cite.notification.model.SendNotificationResult;
import gr.cite.notification.model.builder.NotificationBuilder; import gr.cite.notification.model.builder.NotificationBuilder;
import gr.cite.notification.model.censorship.NotificationCensor; import gr.cite.notification.model.censorship.NotificationCensor;
import gr.cite.notification.model.persist.NotificationPersist; import gr.cite.notification.model.persist.NotificationPersist;
@ -24,6 +22,7 @@ import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.MyValidate; import gr.cite.tools.validation.MyValidate;
import jakarta.transaction.Transactional;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -31,7 +30,6 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.transaction.Transactional;
import java.util.*; import java.util.*;
@RestController @RestController

View File

@ -29,7 +29,7 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.transaction.Transactional; import jakarta.transaction.Transactional;
import java.util.*; import java.util.*;
@RestController @RestController

View File

@ -32,8 +32,8 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.transaction.Transactional; import jakarta.transaction.Transactional;
import javax.validation.Valid; import jakarta.validation.Valid;
import java.util.*; import java.util.*;
@RestController @RestController

View File

@ -10,11 +10,9 @@ import gr.cite.notification.model.UserNotificationPreference;
import gr.cite.notification.model.builder.UserNotificationPreferenceBuilder; import gr.cite.notification.model.builder.UserNotificationPreferenceBuilder;
import gr.cite.notification.model.censorship.UserNotificationPreferenceCensor; import gr.cite.notification.model.censorship.UserNotificationPreferenceCensor;
import gr.cite.notification.model.persist.UserNotificationPreferencePersist; import gr.cite.notification.model.persist.UserNotificationPreferencePersist;
import gr.cite.notification.model.persist.tenantconfiguration.TenantConfigurationNotifierListPersist;
import gr.cite.notification.query.UserNotificationPreferenceQuery; import gr.cite.notification.query.UserNotificationPreferenceQuery;
import gr.cite.notification.query.lookup.NotifierListLookup; import gr.cite.notification.query.lookup.NotifierListLookup;
import gr.cite.notification.query.lookup.UserNotificationPreferenceLookup; import gr.cite.notification.query.lookup.UserNotificationPreferenceLookup;
import gr.cite.notification.service.tenantconfiguration.TenantConfigurationService;
import gr.cite.notification.service.userNotificationPreference.UserNotificationPreferenceService; import gr.cite.notification.service.userNotificationPreference.UserNotificationPreferenceService;
import gr.cite.notification.web.model.QueryResult; import gr.cite.notification.web.model.QueryResult;
import gr.cite.tools.auditing.AuditService; import gr.cite.tools.auditing.AuditService;
@ -27,15 +25,14 @@ import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.validation.Valid;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.management.InvalidApplicationException; import jakarta.transaction.Transactional;
import javax.transaction.Transactional;
import javax.validation.Valid;
import java.util.*; import java.util.*;
@RestController @RestController

View File

@ -35,8 +35,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.context.request.WebRequest; import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor; import org.springframework.web.context.request.WebRequestInterceptor;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -26,13 +26,13 @@ import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor; import org.springframework.web.context.request.WebRequestInterceptor;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import jakarta.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root; import jakarta.persistence.criteria.Root;
import javax.persistence.criteria.Subquery; import jakarta.persistence.criteria.Subquery;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;

View File

@ -22,12 +22,12 @@ import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor; import org.springframework.web.context.request.WebRequestInterceptor;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import jakarta.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root; import jakarta.persistence.criteria.Root;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;

View File

@ -17,12 +17,12 @@ import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor; import org.springframework.web.context.request.WebRequestInterceptor;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import jakarta.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root; import jakarta.persistence.criteria.Root;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;

View File

@ -21,12 +21,12 @@
//import org.springframework.web.context.request.WebRequestInterceptor; //import org.springframework.web.context.request.WebRequestInterceptor;
// //
//import javax.management.InvalidApplicationException; //import javax.management.InvalidApplicationException;
//import javax.persistence.EntityManager; //import jakarta.persistence.EntityManager;
//import javax.persistence.PersistenceContext; //import jakarta.persistence.PersistenceContext;
//import javax.persistence.Tuple; //import jakarta.persistence.Tuple;
//import javax.persistence.criteria.CriteriaBuilder; //import jakarta.persistence.criteria.CriteriaBuilder;
//import javax.persistence.criteria.CriteriaQuery; //import jakarta.persistence.criteria.CriteriaQuery;
//import javax.persistence.criteria.Root; //import jakarta.persistence.criteria.Root;
//import java.time.Instant; //import java.time.Instant;
//import java.util.List; //import java.util.List;
//import java.util.UUID; //import java.util.UUID;

View File

@ -16,5 +16,6 @@ spring:
optional:classpath:config/cors.yml[.yml], optional:classpath:config/cors-${spring.profiles.active}.yml[.yml], optional:file:../config/cors-${spring.profiles.active}.yml[.yml], optional:classpath:config/cors.yml[.yml], optional:classpath:config/cors-${spring.profiles.active}.yml[.yml], optional:file:../config/cors-${spring.profiles.active}.yml[.yml],
optional:classpath:config/notification.yml[.yml], optional:classpath:config/notification-${spring.profiles.active}.yml[.yml], optional:file:../config/notification-${spring.profiles.active}.yml[.yml], optional:classpath:config/notification.yml[.yml], optional:classpath:config/notification-${spring.profiles.active}.yml[.yml], optional:file:../config/notification-${spring.profiles.active}.yml[.yml],
optional:classpath:config/email.yml[.yml], optional:classpath:config/email-${spring.profiles.active}.yml[.yml], optional:file:../config/email-${spring.profiles.active}.yml[.yml], optional:classpath:config/email.yml[.yml], optional:classpath:config/email-${spring.profiles.active}.yml[.yml], optional:file:../config/email-${spring.profiles.active}.yml[.yml],
optional:classpath:config/queue.yml[.yml], optional:classpath:config/queue-${spring.profiles.active}.yml[.yml], optional:file:../config/queue-${spring.profiles.active}.yml[.yml],
optional:classpath:config/cipher.yml[.yml], optional:classpath:config/cipher-${spring.profiles.active}.yml[.yml], optional:file:../config/cipher-${spring.profiles.active}.yml[.yml], optional:classpath:config/cipher.yml[.yml], optional:classpath:config/cipher-${spring.profiles.active}.yml[.yml], optional:file:../config/cipher-${spring.profiles.active}.yml[.yml],
optional:classpath:config/formatting.yml[.yml], optional:classpath:config/formatting-${spring.profiles.active}.yml[.yml], optional:file:../config/formatting-${spring.profiles.active}.yml[.yml] optional:classpath:config/formatting.yml[.yml], optional:classpath:config/formatting-${spring.profiles.active}.yml[.yml], optional:file:../config/formatting-${spring.profiles.active}.yml[.yml]

View File

@ -1,5 +1,6 @@
queue: queue:
rabbitmq: rabbitmq:
enable: true
durable: true durable: true
queue: cite_dmp_devel_notification_inbox_queue queue: cite_dmp_devel_notification_inbox_queue
exchange: cite_dmp_devel_queue exchange: cite_dmp_devel_queue
@ -7,11 +8,13 @@ queue:
publisherEnabled: true publisherEnabled: true
task: task:
publisher: publisher:
enable: true
options: options:
exchange: cite_dmp_devel_queue exchange: cite_dmp_devel_queue
rabbitmq: rabbitmq:
enable: true enable: true
listener: listener:
enable: true
options: options:
exchange: cite_dmp_devel_queue exchange: cite_dmp_devel_queue
rabbitmq: rabbitmq:

View File

@ -43,9 +43,9 @@ queue:
exchange: null exchange: null
notify-topic: notification.notify notify-topic: notification.notify
tenant-removal-topic: tenant.remove tenant-removal-topic: tenant.remove
tenant-touch-topic: tenant.touch tenant-touched-topic: tenant.touch
user-removal-topic: user.remove user-removal-topic: user.remove
user-touch-topic: user.touch user-touched-topic: user.touch
rabbitmq: rabbitmq:
enable: false enable: false
interval-seconds: 30 interval-seconds: 30

View File

@ -16,5 +16,6 @@ spring:
optional:classpath:config/cors.yml[.yml], optional:classpath:config/cors-${spring.profiles.active}.yml[.yml], optional:file:../config/cors-${spring.profiles.active}.yml[.yml], optional:classpath:config/cors.yml[.yml], optional:classpath:config/cors-${spring.profiles.active}.yml[.yml], optional:file:../config/cors-${spring.profiles.active}.yml[.yml],
optional:classpath:config/notification.yml[.yml], optional:classpath:config/notification-${spring.profiles.active}.yml[.yml], optional:file:../config/notification-${spring.profiles.active}.yml[.yml], optional:classpath:config/notification.yml[.yml], optional:classpath:config/notification-${spring.profiles.active}.yml[.yml], optional:file:../config/notification-${spring.profiles.active}.yml[.yml],
optional:classpath:config/email.yml[.yml], optional:classpath:config/email-${spring.profiles.active}.yml[.yml], optional:file:../config/email-${spring.profiles.active}.yml[.yml], optional:classpath:config/email.yml[.yml], optional:classpath:config/email-${spring.profiles.active}.yml[.yml], optional:file:../config/email-${spring.profiles.active}.yml[.yml],
optional:classpath:config/queue.yml[.yml], optional:classpath:config/queue-${spring.profiles.active}.yml[.yml], optional:file:../config/queue-${spring.profiles.active}.yml[.yml],
optional:classpath:config/cipher.yml[.yml], optional:classpath:config/cipher-${spring.profiles.active}.yml[.yml], optional:file:../config/cipher-${spring.profiles.active}.yml[.yml], optional:classpath:config/cipher.yml[.yml], optional:classpath:config/cipher-${spring.profiles.active}.yml[.yml], optional:file:../config/cipher-${spring.profiles.active}.yml[.yml],
optional:classpath:config/formatting.yml[.yml], optional:classpath:config/formatting-${spring.profiles.active}.yml[.yml], optional:file:../config/formatting-${spring.profiles.active}.yml[.yml] optional:classpath:config/formatting.yml[.yml], optional:classpath:config/formatting-${spring.profiles.active}.yml[.yml], optional:file:../config/formatting-${spring.profiles.active}.yml[.yml]

View File

@ -1,5 +1,6 @@
queue: queue:
rabbitmq: rabbitmq:
enable: true
durable: true durable: true
queue: cite_dmp_devel_notification_inbox_queue queue: cite_dmp_devel_notification_inbox_queue
exchange: cite_dmp_devel_queue exchange: cite_dmp_devel_queue
@ -7,11 +8,13 @@ queue:
publisherEnabled: true publisherEnabled: true
task: task:
publisher: publisher:
enable: true
options: options:
exchange: cite_dmp_devel_queue exchange: cite_dmp_devel_queue
rabbitmq: rabbitmq:
enable: true enable: true
listener: listener:
enable: true
options: options:
exchange: cite_dmp_devel_queue exchange: cite_dmp_devel_queue
rabbitmq: rabbitmq:

View File

@ -43,9 +43,9 @@ queue:
exchange: null exchange: null
notify-topic: notification.notify notify-topic: notification.notify
tenant-removal-topic: tenant.remove tenant-removal-topic: tenant.remove
tenant-touch-topic: tenant.touch tenant-touched-topic: tenant.touch
user-removal-topic: user.remove user-removal-topic: user.remove
user-touch-topic: user.touch user-touched-topic: user.touch
rabbitmq: rabbitmq:
enable: false enable: false
interval-seconds: 30 interval-seconds: 30

View File

@ -7,16 +7,17 @@
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>notification-service-parent</artifactId> <artifactId>notification-service-parent</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<relativePath>../pom.xml</relativePath> <relativePath>../../notification-service/pom.xml</relativePath>
</parent> </parent>
<artifactId>notification</artifactId> <artifactId>notification</artifactId>
<version>1.0.0</version>
<properties> <properties>
<java.version>11</java.version> <java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -45,16 +46,11 @@
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>
<version>5.2.2</version> <version>5.2.2</version>
</dependency> </dependency>
<!-- check if this is needed here or in tools-data -->
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>data-tools</artifactId> <artifactId>data-tools</artifactId>
<version>1.0.0</version> <version>2.1.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
@ -84,16 +80,14 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>validation</artifactId> <artifactId>validation</artifactId>
<version>1.0.0</version> <version>2.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.datatype</groupId> <groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId> <artifactId>jackson-datatype-jsr310</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>cipher</artifactId> <artifactId>cipher</artifactId>

View File

@ -10,10 +10,10 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import javax.xml.bind.Marshaller; import jakarta.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller; import jakarta.xml.bind.Unmarshaller;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;

View File

@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope; import org.springframework.web.context.annotation.RequestScope;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import java.util.UUID; import java.util.UUID;
@Component @Component

View File

@ -1,10 +1,10 @@
package gr.cite.notification.common.types.tenant; package gr.cite.notification.common.types.tenant;
import javax.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "config") @XmlRootElement(name = "config")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)

View File

@ -1,6 +1,6 @@
package gr.cite.notification.common.types.tenant; package gr.cite.notification.common.types.tenant;
import javax.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;
import java.util.List; import java.util.List;

View File

@ -1,6 +1,6 @@
package gr.cite.notification.common.types.tenant; package gr.cite.notification.common.types.tenant;
import javax.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;
import java.util.List; import java.util.List;

View File

@ -1,6 +1,6 @@
package gr.cite.notification.common.types.tenant; package gr.cite.notification.common.types.tenant;
import javax.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;
import java.util.List; import java.util.List;

View File

@ -1,7 +1,7 @@
package gr.cite.notification.common.validation; package gr.cite.notification.common.validation;
import javax.validation.ConstraintValidator; import jakarta.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext; import jakarta.validation.ConstraintValidatorContext;
public class EnumNotNull implements ConstraintValidator<ValidEnum,Object> { public class EnumNotNull implements ConstraintValidator<ValidEnum,Object> {
@Override @Override

View File

@ -1,8 +1,8 @@
package gr.cite.notification.common.validation; package gr.cite.notification.common.validation;
import javax.validation.Constraint; import jakarta.validation.Constraint;
import javax.validation.Payload; import jakarta.validation.Payload;
import java.lang.annotation.*; import java.lang.annotation.*;
@Constraint( validatedBy = { FieldNotNullIfOtherSetValidator.class } ) @Constraint( validatedBy = { FieldNotNullIfOtherSetValidator.class } )

View File

@ -2,8 +2,8 @@ package gr.cite.notification.common.validation;
import org.springframework.beans.BeanWrapperImpl; import org.springframework.beans.BeanWrapperImpl;
import javax.validation.ConstraintValidator; import jakarta.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext; import jakarta.validation.ConstraintValidatorContext;
import java.util.Objects; import java.util.Objects;
public class FieldNotNullIfOtherSetValidator implements ConstraintValidator<FieldNotNullIfOtherSet, Object> { public class FieldNotNullIfOtherSetValidator implements ConstraintValidator<FieldNotNullIfOtherSet, Object> {

View File

@ -1,7 +1,7 @@
package gr.cite.notification.common.validation; package gr.cite.notification.common.validation;
import javax.validation.Constraint; import jakarta.validation.Constraint;
import javax.validation.Payload; import jakarta.validation.Payload;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;

View File

@ -2,8 +2,8 @@ package gr.cite.notification.common.validation;
import org.springframework.beans.BeanWrapperImpl; import org.springframework.beans.BeanWrapperImpl;
import javax.validation.ConstraintValidator; import jakarta.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext; import jakarta.validation.ConstraintValidatorContext;
public class FieldsValueMatchValidator implements ConstraintValidator<FieldsValueMatch, Object> { public class FieldsValueMatchValidator implements ConstraintValidator<FieldsValueMatch, Object> {

View File

@ -1,7 +1,7 @@
package gr.cite.notification.common.validation; package gr.cite.notification.common.validation;
import javax.validation.Constraint; import jakarta.validation.Constraint;
import javax.validation.Payload; import jakarta.validation.Payload;
import java.lang.annotation.*; import java.lang.annotation.*;

View File

@ -1,8 +1,8 @@
package gr.cite.notification.common.validation; package gr.cite.notification.common.validation;
import javax.validation.Constraint; import jakarta.validation.Constraint;
import javax.validation.Payload; import jakarta.validation.Payload;
import java.lang.annotation.*; import java.lang.annotation.*;
@Constraint( validatedBy = { ValidIdValidator.class } ) @Constraint( validatedBy = { ValidIdValidator.class } )

View File

@ -3,8 +3,8 @@ package gr.cite.notification.common.validation;
import gr.cite.notification.convention.ConventionService; import gr.cite.notification.convention.ConventionService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.validation.ConstraintValidator; import jakarta.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext; import jakarta.validation.ConstraintValidatorContext;
import java.util.UUID; import java.util.UUID;
public class ValidIdValidator implements ConstraintValidator<ValidId, Object> { public class ValidIdValidator implements ConstraintValidator<ValidId, Object> {

View File

@ -8,7 +8,7 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.validation.Validator; import jakarta.validation.Validator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -1,11 +1,10 @@
package gr.cite.notification.config.email; package gr.cite.notification.config.email;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;
@ConstructorBinding
@ConfigurationProperties(prefix = "email") @ConfigurationProperties(prefix = "email")
public class EmailProperties { public class EmailProperties {
private final String address; private final String address;
public EmailProperties(String address) { public EmailProperties(String address) {

View File

@ -1,16 +1,16 @@
package gr.cite.notification.config.formatting; package gr.cite.notification.config.formatting;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;
@ConstructorBinding
@ConfigurationProperties(prefix = "formatting.options") @ConfigurationProperties(prefix = "formatting.options")
public class FormattingServiceProperties { public class FormattingServiceProperties {
private final String integerFormat; private final String integerFormat;
private final String decimalFormat; private final String decimalFormat;
private final String dateTimeFormat; private final String dateTimeFormat;
private final Integer decimalDigitsRound; private final Integer decimalDigitsRound;
public FormattingServiceProperties(String integerFormat, String decimalFormat, String dateTimeFormat, Integer decimalDigitsRound) { public FormattingServiceProperties(String integerFormat, String decimalFormat, String dateTimeFormat, Integer decimalDigitsRound) {

View File

@ -5,6 +5,7 @@ import gr.cite.notification.schedule.NotificationScheduleTask;
import gr.cite.notification.service.message.common.MessageBuilderBase; import gr.cite.notification.service.message.common.MessageBuilderBase;
import gr.cite.notification.service.notificationscheduling.NotificationSchedulingService; import gr.cite.notification.service.notificationscheduling.NotificationSchedulingService;
import gr.cite.notification.service.notificationscheduling.NotificationSchedulingServiceImpl; import gr.cite.notification.service.notificationscheduling.NotificationSchedulingServiceImpl;
import gr.cite.queueinbox.task.rabbitmq.QueueListenerProperties;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -32,11 +33,13 @@ public class NotificationConfig {
} }
private final ApplicationContext applicationContext; private final ApplicationContext applicationContext;
private final NotificationProperties properties; private final NotificationProperties properties;
private final QueueListenerProperties queueListenerProperties;
@Autowired @Autowired
public NotificationConfig(ApplicationContext applicationContext, NotificationProperties properties) { public NotificationConfig(ApplicationContext applicationContext, NotificationProperties properties, QueueListenerProperties queueListenerProperties) {
this.applicationContext = applicationContext; this.applicationContext = applicationContext;
this.properties = properties; this.properties = properties;
this.queueListenerProperties = queueListenerProperties;
} }
@Bean(BeanQualifier.GLOBAL_POLICIES_MAP) @Bean(BeanQualifier.GLOBAL_POLICIES_MAP)

View File

@ -1,23 +1,25 @@
package gr.cite.notification.config.notification; package gr.cite.notification.config.notification;
import gr.cite.notification.common.enums.NotificationContactType;
import gr.cite.notification.common.enums.EmailOverrideMode; import gr.cite.notification.common.enums.EmailOverrideMode;
import gr.cite.notification.common.enums.NotificationContactType;
import gr.cite.notification.common.types.notification.FieldInfo; import gr.cite.notification.common.types.notification.FieldInfo;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ConstructorBinding
@ConfigurationProperties(prefix = "notification") @ConfigurationProperties(prefix = "notification")
public class NotificationProperties { public class NotificationProperties {
private final Task task; private final Task task;
private final Resolver resolver; private final Resolver resolver;
private final Map<String, Template> message; private final Map<String, Template> message;
private final Template overrideCache; private final Template overrideCache;
private final StaticFieldItems staticFields; private final StaticFieldItems staticFields;
public NotificationProperties(Task task, Resolver resolver, Map<String, Template> message, Template overrideCache, StaticFieldItems staticFields) { public NotificationProperties(Task task, Resolver resolver, Map<String, Template> message, Template overrideCache, StaticFieldItems staticFields) {
@ -49,6 +51,7 @@ public class NotificationProperties {
} }
public static class Task { public static class Task {
private final Processor processor; private final Processor processor;
public Task(Processor processor) { public Task(Processor processor) {
@ -60,9 +63,13 @@ public class NotificationProperties {
} }
public static class Processor { public static class Processor {
private final Boolean enable; private final Boolean enable;
private final Long intervalSeconds; private final Long intervalSeconds;
private final Options options; private final Options options;
private final List<String> overrides; private final List<String> overrides;
public Processor(Boolean enable, Long intervalSeconds, Options options, List<String> overrides) { public Processor(Boolean enable, Long intervalSeconds, Options options, List<String> overrides) {
@ -89,9 +96,13 @@ public class NotificationProperties {
} }
public static class Options { public static class Options {
private final Long retryThreshold; private final Long retryThreshold;
private final Long maxRetryDelaySeconds; private final Long maxRetryDelaySeconds;
private final Long tooOldToSendSeconds; private final Long tooOldToSendSeconds;
private final Long tooOldToTrackSeconds; private final Long tooOldToTrackSeconds;
public Options(Long retryThreshold, Long maxRetryDelaySeconds, Long tooOldToSendSeconds, Long tooOldToTrackSeconds) { public Options(Long retryThreshold, Long maxRetryDelaySeconds, Long tooOldToSendSeconds, Long tooOldToTrackSeconds) {
@ -121,6 +132,7 @@ public class NotificationProperties {
} }
public static class Resolver { public static class Resolver {
private final List<GlobalPolicy> globalPolicies; private final List<GlobalPolicy> globalPolicies;
public Resolver(List<GlobalPolicy> globalPolicies) { public Resolver(List<GlobalPolicy> globalPolicies) {
@ -132,7 +144,9 @@ public class NotificationProperties {
} }
public static class GlobalPolicy { public static class GlobalPolicy {
private final UUID type; private final UUID type;
private final List<NotificationContactType> contacts; private final List<NotificationContactType> contacts;
public GlobalPolicy(UUID type, List<NotificationContactType> contacts) { public GlobalPolicy(UUID type, List<NotificationContactType> contacts) {
@ -151,6 +165,7 @@ public class NotificationProperties {
} }
public static class Template { public static class Template {
private final TemplateCache templateCache; private final TemplateCache templateCache;
private final List<Flow> flows; private final List<Flow> flows;
@ -164,13 +179,14 @@ public class NotificationProperties {
return templateCache; return templateCache;
} }
public List<Flow> getFlows() { public List<Flow> getFlows() {
return flows; return flows;
} }
public static class TemplateCache { public static class TemplateCache {
private final String prefix; private final String prefix;
private final String keyPattern; private final String keyPattern;
public TemplateCache(String prefix, String keyPattern) { public TemplateCache(String prefix, String keyPattern) {
@ -189,6 +205,7 @@ public class NotificationProperties {
} }
public static class StaticFieldItems { public static class StaticFieldItems {
private final List<Field> Fields; private final List<Field> Fields;
public StaticFieldItems(List<Field> fields) { public StaticFieldItems(List<Field> fields) {
@ -201,8 +218,11 @@ public class NotificationProperties {
} }
public static class Field { public static class Field {
private final String key; private final String key;
private final String type; private final String type;
private final String value; private final String value;
public Field(String key, String type, String value) { public Field(String key, String type, String value) {
@ -225,20 +245,35 @@ public class NotificationProperties {
} }
public static class Flow { public static class Flow {
private final UUID key; private final UUID key;
private final String subjectPath; private final String subjectPath;
private final String subjectKey; private final String subjectKey;
private final FieldOption subjectFieldOptions; private final FieldOption subjectFieldOptions;
private final String bodyPath; private final String bodyPath;
private final String bodyKey; private final String bodyKey;
private final FieldOption bodyFieldOptions; private final FieldOption bodyFieldOptions;
private final List<String> cc; private final List<String> cc;
private final EmailOverrideMode ccMode; private final EmailOverrideMode ccMode;
private final List<String> bcc; private final List<String> bcc;
private final EmailOverrideMode bccMode; private final EmailOverrideMode bccMode;
private final Boolean allowAttachments; private final Boolean allowAttachments;
private final List<String> cipherFields; private final List<String> cipherFields;
private final String priorityKey; private final String priorityKey;
private final List<String> extraDataKeys; private final List<String> extraDataKeys;
public Flow(UUID key, String subjectPath, String subjectKey, FieldOption subjectFieldOptions, String bodyPath, String bodyKey, FieldOption bodyFieldOptions, List<String> cc, EmailOverrideMode ccMode, List<String> bcc, EmailOverrideMode bccMode, Boolean allowAttachments, List<String> cipherFields, String priorityKey, List<String> extraDataKeys) { public Flow(UUID key, String subjectPath, String subjectKey, FieldOption subjectFieldOptions, String bodyPath, String bodyKey, FieldOption bodyFieldOptions, List<String> cc, EmailOverrideMode ccMode, List<String> bcc, EmailOverrideMode bccMode, Boolean allowAttachments, List<String> cipherFields, String priorityKey, List<String> extraDataKeys) {
@ -320,7 +355,9 @@ public class NotificationProperties {
} }
public static class FieldOption { public static class FieldOption {
private final List<String> mandatory; private final List<String> mandatory;
private final List<FieldInfo> optional; private final List<FieldInfo> optional;
private final Map<String, String> formatting; private final Map<String, String> formatting;

View File

@ -8,7 +8,7 @@ import gr.cite.notification.data.conventers.IsActiveConverter;
import gr.cite.notification.data.conventers.NotificationInAppTrackingConverter; import gr.cite.notification.data.conventers.NotificationInAppTrackingConverter;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -4,7 +4,7 @@ import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.conventers.IsActiveConverter;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -4,7 +4,7 @@ import gr.cite.notification.common.enums.*;
import gr.cite.notification.data.conventers.*; import gr.cite.notification.data.conventers.*;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -4,7 +4,7 @@ import gr.cite.notification.common.enums.*;
import gr.cite.notification.data.conventers.*; import gr.cite.notification.data.conventers.*;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -5,7 +5,7 @@ import gr.cite.notification.data.conventers.IsActiveConverter;
import gr.cite.queueinbox.entity.QueueInbox; import gr.cite.queueinbox.entity.QueueInbox;
import gr.cite.queueinbox.entity.QueueInboxStatus; import gr.cite.queueinbox.entity.QueueInboxStatus;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -6,7 +6,7 @@ import gr.cite.notification.data.conventers.IsActiveConverter;
import gr.cite.queueoutbox.entity.QueueOutbox; import gr.cite.queueoutbox.entity.QueueOutbox;
import gr.cite.queueoutbox.entity.QueueOutboxNotifyStatus; import gr.cite.queueoutbox.entity.QueueOutboxNotifyStatus;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -6,7 +6,7 @@ import gr.cite.notification.data.conventers.IsActiveConverter;
import gr.cite.notification.data.conventers.TenantConfigurationTypeConverter; import gr.cite.notification.data.conventers.TenantConfigurationTypeConverter;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -3,7 +3,7 @@ package gr.cite.notification.data;
import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.conventers.IsActiveConverter;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -10,10 +10,10 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.FlushModeType; import jakarta.persistence.FlushModeType;
import javax.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import javax.persistence.Query; import jakarta.persistence.Query;
import java.util.UUID; import java.util.UUID;
@Service @Service

View File

@ -4,7 +4,7 @@ import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.conventers.IsActiveConverter;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -4,7 +4,7 @@ import gr.cite.notification.common.enums.ContactInfoType;
import gr.cite.notification.data.conventers.ContactInfoTypeConverter; import gr.cite.notification.data.conventers.ContactInfoTypeConverter;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -3,7 +3,7 @@ package gr.cite.notification.data;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -3,7 +3,7 @@ package gr.cite.notification.data;
import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.conventers.IsActiveConverter;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -5,7 +5,7 @@ import gr.cite.notification.data.composite.CompositeUserNotificationPreferenceId
import gr.cite.notification.data.conventers.NotificationContactTypeConverter; import gr.cite.notification.data.conventers.NotificationContactTypeConverter;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -3,7 +3,7 @@ package gr.cite.notification.data;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -2,7 +2,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.ContactInfoType; import gr.cite.notification.common.enums.ContactInfoType;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class ContactInfoTypeConverter extends DatabaseEnumConverter<ContactInfoType, Short>{ public class ContactInfoTypeConverter extends DatabaseEnumConverter<ContactInfoType, Short>{

View File

@ -1,8 +1,8 @@
package gr.cite.notification.data.conventers; package gr.cite.notification.data.conventers;
import javax.persistence.AttributeConverter; import jakarta.persistence.AttributeConverter;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public abstract class DatabaseEnumConverter<EnumType extends DatabaseEnum<T>, T> implements AttributeConverter<EnumType, T> { public abstract class DatabaseEnumConverter<EnumType extends DatabaseEnum<T>, T> implements AttributeConverter<EnumType, T> {

View File

@ -2,7 +2,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.InAppNotificationPriority; import gr.cite.notification.common.enums.InAppNotificationPriority;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class InAppNotificationPriorityConverter extends DatabaseEnumConverter<InAppNotificationPriority, Short> { public class InAppNotificationPriorityConverter extends DatabaseEnumConverter<InAppNotificationPriority, Short> {

View File

@ -3,7 +3,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.common.enums.IsActive;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class IsActiveConverter extends DatabaseEnumConverter<IsActive, Short> { public class IsActiveConverter extends DatabaseEnumConverter<IsActive, Short> {

View File

@ -3,7 +3,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.NotificationContactType; import gr.cite.notification.common.enums.NotificationContactType;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class NotificationContactTypeConverter extends DatabaseEnumConverter<NotificationContactType, Short> { public class NotificationContactTypeConverter extends DatabaseEnumConverter<NotificationContactType, Short> {

View File

@ -2,7 +2,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.NotificationInAppTracking; import gr.cite.notification.common.enums.NotificationInAppTracking;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class NotificationInAppTrackingConverter extends DatabaseEnumConverter<NotificationInAppTracking, Short> { public class NotificationInAppTrackingConverter extends DatabaseEnumConverter<NotificationInAppTracking, Short> {

View File

@ -3,7 +3,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.NotificationNotifyState; import gr.cite.notification.common.enums.NotificationNotifyState;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class NotificationNotifyStateConverter extends DatabaseEnumConverter<NotificationNotifyState, Short> { public class NotificationNotifyStateConverter extends DatabaseEnumConverter<NotificationNotifyState, Short> {

View File

@ -4,7 +4,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.NotificationTemplateChannel; import gr.cite.notification.common.enums.NotificationTemplateChannel;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class NotificationTemplateChannelConverter extends DatabaseEnumConverter<NotificationTemplateChannel, Short> { public class NotificationTemplateChannelConverter extends DatabaseEnumConverter<NotificationTemplateChannel, Short> {

View File

@ -3,7 +3,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.NotificationTemplateKind; import gr.cite.notification.common.enums.NotificationTemplateKind;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class NotificationTemplateKindConverter extends DatabaseEnumConverter<NotificationTemplateKind, Short> { public class NotificationTemplateKindConverter extends DatabaseEnumConverter<NotificationTemplateKind, Short> {

View File

@ -2,7 +2,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.NotificationTrackingProcess; import gr.cite.notification.common.enums.NotificationTrackingProcess;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class NotificationTrackingProcessConverter extends DatabaseEnumConverter<NotificationTrackingProcess, Short> { public class NotificationTrackingProcessConverter extends DatabaseEnumConverter<NotificationTrackingProcess, Short> {

View File

@ -3,7 +3,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.NotificationTrackingState; import gr.cite.notification.common.enums.NotificationTrackingState;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class NotificationTrackingStateConverter extends DatabaseEnumConverter<NotificationTrackingState, Short> { public class NotificationTrackingStateConverter extends DatabaseEnumConverter<NotificationTrackingState, Short> {

View File

@ -3,7 +3,7 @@ package gr.cite.notification.data.conventers;
import gr.cite.notification.common.enums.TenantConfigurationType; import gr.cite.notification.common.enums.TenantConfigurationType;
import javax.persistence.Converter; import jakarta.persistence.Converter;
@Converter @Converter
public class TenantConfigurationTypeConverter extends DatabaseEnumConverter<TenantConfigurationType, Short> { public class TenantConfigurationTypeConverter extends DatabaseEnumConverter<TenantConfigurationType, Short> {

View File

@ -12,7 +12,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
@Aspect @Aspect
@Component @Component

View File

@ -8,9 +8,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.persistence.PrePersist; import jakarta.persistence.PrePersist;
import javax.persistence.PreRemove; import jakarta.persistence.PreRemove;
import javax.persistence.PreUpdate; import jakarta.persistence.PreUpdate;
import java.util.UUID; import java.util.UUID;
public class TenantListener { public class TenantListener {

View File

@ -5,9 +5,9 @@ import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.ParamDef; import org.hibernate.annotations.ParamDef;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.EntityListeners; import jakarta.persistence.EntityListeners;
import javax.persistence.MappedSuperclass; import jakarta.persistence.MappedSuperclass;
import java.io.Serializable; import java.io.Serializable;
import java.util.UUID; import java.util.UUID;
@ -15,17 +15,22 @@ import java.util.UUID;
//@Getter //@Getter
//@Setter //@Setter
//@NoArgsConstructor //@NoArgsConstructor
@FilterDef(name = TenantScopedBaseEntity.tenantFilter, parameters = {@ParamDef(name = TenantScopedBaseEntity.tenantFilterTenantParam, type = "string")}) @FilterDef(name = TenantScopedBaseEntity.tenantFilter, parameters = {@ParamDef(name = TenantScopedBaseEntity.tenantFilterTenantParam, type = String.class)})
@Filter(name = "tenantFilter", condition = "tenant = (cast(:tenantId as uuid))") @Filter(name = "tenantFilter", condition = "tenant = (cast(:tenantId as uuid))")
@EntityListeners(TenantListener.class) @EntityListeners(TenantListener.class)
public abstract class TenantScopedBaseEntity implements TenantScoped, Serializable { public abstract class TenantScopedBaseEntity implements TenantScoped, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static final String tenantFilter = "tenantFilter"; public static final String tenantFilter = "tenantFilter";
public static final String tenantFilterTenantParam = "tenantId"; public static final String tenantFilterTenantParam = "tenantId";
@Column(name = "tenant", columnDefinition = "uuid", nullable = true) @Column(name = "tenant", columnDefinition = "uuid", nullable = true)
private UUID tenantId; private UUID tenantId;
public static final String _tenantId = "tenantId"; public static final String _tenantId = "tenantId";
public UUID getTenantId() { public UUID getTenantId() {
return tenantId; return tenantId;
} }

View File

@ -41,7 +41,7 @@ public class AppRabbitConfigurer extends RabbitConfigurer {
return new InboxBindings(bindingItems); return new InboxBindings(bindingItems);
} }
@Bean @Bean(name = "InboxCreator")
public InboxCreator inboxCreator() { public InboxCreator inboxCreator() {
return (params) -> { return (params) -> {
InboxRepository inboxRepository = this.applicationContext.getBean(InboxRepository.class); InboxRepository inboxRepository = this.applicationContext.getBean(InboxRepository.class);

View File

@ -0,0 +1,34 @@
package gr.cite.notification.integrationevent;
import gr.cite.notification.integrationevent.inbox.InboxProperties;
import gr.cite.notification.integrationevent.inbox.InboxRepositoryImpl;
import gr.cite.queueinbox.InboxConfigurer;
import gr.cite.queueinbox.repository.InboxRepository;
import jakarta.persistence.EntityManagerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
@Configuration
@EnableConfigurationProperties({InboxProperties.class})
@ConditionalOnProperty(prefix = "queue.task.listener", name = "enable", matchIfMissing = false)
public class InboxIntegrationEventConfigurer extends InboxConfigurer {
private ApplicationContext applicationContext;
private InboxProperties inboxProperties;
public InboxIntegrationEventConfigurer(ApplicationContext applicationContext, InboxProperties inboxProperties) {
this.applicationContext = applicationContext;
this.inboxProperties = inboxProperties;
}
@Bean
public InboxRepository inboxRepositoryCreator() {
return new InboxRepositoryImpl(this.applicationContext, this.inboxProperties);
}
}

View File

@ -0,0 +1,68 @@
package gr.cite.notification.integrationevent;
import gr.cite.notification.integrationevent.outbox.OutboxProperties;
import gr.cite.notification.integrationevent.outbox.OutboxRepositoryImpl;
import gr.cite.queueoutbox.IntegrationEventContextCreator;
import gr.cite.queueoutbox.OutboxConfigurer;
import gr.cite.queueoutbox.repository.OutboxRepository;
import gr.cite.rabbitmq.IntegrationEventMessageConstants;
import gr.cite.rabbitmq.RabbitProperties;
import gr.cite.rabbitmq.broker.MessageHydrator;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Date;
import java.util.UUID;
@Configuration
@EnableConfigurationProperties({OutboxProperties.class})
@ConditionalOnProperty(prefix = "queue.task.publisher", name = "enable", matchIfMissing = false)
public class OutboxIntegrationEventConfigurer extends OutboxConfigurer {
private ApplicationContext applicationContext;
private OutboxProperties outboxProperties;
public OutboxIntegrationEventConfigurer(ApplicationContext applicationContext, OutboxProperties outboxProperties) {
this.applicationContext = applicationContext;
this.outboxProperties = outboxProperties;
}
@Bean
public MessageHydrator messageHydrator(RabbitProperties rabbitProperties) {
return (message, event, eventContext) -> {
MessageProperties messageProperties = message.getMessageProperties();
messageProperties.setAppId(rabbitProperties.getAppId());
messageProperties.setContentEncoding(StandardCharsets.UTF_8.displayName());
messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON);
//messageProperties.setUserId(userContext.getCurrentUser().toString());
messageProperties.setTimestamp(Date.from(Instant.now()));
messageProperties.setMessageId(event.getMessageId().toString());
if (eventContext != null) {
UUID tenant = ((IntegrationEventContextImpl) eventContext).getTenant();
if (tenant != null) {
messageProperties.setHeader(IntegrationEventMessageConstants.TENANT, tenant);
}
}
return message;
};
}
@Bean
public IntegrationEventContextCreator integrationEventContextCreator() {
return (message) -> new IntegrationEventContextImpl();
}
@Bean
public OutboxRepository outboxRepositoryCreator() {
return new OutboxRepositoryImpl(this.applicationContext, this.outboxProperties);
}
}

View File

@ -1,33 +1,22 @@
package gr.cite.notification.integrationevent.inbox; package gr.cite.notification.integrationevent.inbox;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
@Validated
@ConfigurationProperties(prefix = "queue.task.listener.options") @ConfigurationProperties(prefix = "queue.task.listener.options")
@ConstructorBinding
public class InboxProperties { public class InboxProperties {
@NotNull
private final String exchange; private final String exchange;
@NotNull
private final List<String> notifyTopic; private final List<String> notifyTopic;
@NotNull
private final List<String> tenantRemovalTopic; private final List<String> tenantRemovalTopic;
@NotNull
private final List<String> tenantTouchedTopic; private final List<String> tenantTouchedTopic;
@NotNull
private final List<String> userRemovalTopic; private final List<String> userRemovalTopic;
@NotNull
private final List<String> userTouchedTopic; private final List<String> userTouchedTopic;
public InboxProperties( public InboxProperties(

View File

@ -0,0 +1,19 @@
package gr.cite.notification.integrationevent.outbox;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import gr.cite.notification.integrationevent.TrackedEvent;
import gr.cite.rabbitmq.IntegrationEvent;
@JsonIgnoreProperties(ignoreUnknown = true)
public class OutboxIntegrationEvent extends IntegrationEvent {
private TrackedEvent event;
public TrackedEvent getEvent() {
return event;
}
public void setEvent(TrackedEvent event) {
this.event = event;
}
}

View File

@ -1,60 +1,35 @@
package gr.cite.notification.integrationevent.outbox; package gr.cite.notification.integrationevent.outbox;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
@Validated
@ConfigurationProperties(prefix = "queue.task.publisher.options") @ConfigurationProperties(prefix = "queue.task.publisher.options")
public class OutboxProperties { public class OutboxProperties {
@NotNull
private final String exchange; private final String exchange;
@NotNull
private final String tenantTouchTopic; private final String tenantTouchTopic;
@NotNull
private final String tenantRemovalTopic; private final String tenantRemovalTopic;
@NotNull private final String userTouchTopic;
private final String tenantReactivationTopic;
@NotNull private final String userRemovalTopic;
private final String tenantUserInviteTopic;
@NotNull
private final String notifyTopic; private final String notifyTopic;
@NotNull
private final String forgetMeCompletedTopic;
@NotNull
private final String whatYouKnowAboutMeCompletedTopic;
@NotNull
private final String generateFileTopic;
public OutboxProperties(String exchange, public OutboxProperties(String exchange,
String tenantTouchTopic, String tenantTouchTopic,
String tenantRemovalTopic, String tenantRemovalTopic,
String tenantReactivationTopic, String userTouchTopic,
String tenantUserInviteTopic, String userRemovalTopic,
String notifyTopic, String notifyTopic
String forgetMeCompletedTopic,
String whatYouKnowAboutMeCompletedTopic,
String generateFileTopic
) { ) {
this.exchange = exchange; this.exchange = exchange;
this.tenantTouchTopic = tenantTouchTopic; this.tenantTouchTopic = tenantTouchTopic;
this.tenantRemovalTopic = tenantRemovalTopic; this.tenantRemovalTopic = tenantRemovalTopic;
this.tenantReactivationTopic = tenantReactivationTopic; this.userTouchTopic = userTouchTopic;
this.tenantUserInviteTopic = tenantUserInviteTopic; this.userRemovalTopic = userRemovalTopic;
this.notifyTopic = notifyTopic; this.notifyTopic = notifyTopic;
this.forgetMeCompletedTopic = forgetMeCompletedTopic;
this.whatYouKnowAboutMeCompletedTopic = whatYouKnowAboutMeCompletedTopic;
this.generateFileTopic = generateFileTopic;
} }
public String getExchange() { public String getExchange() {
@ -69,27 +44,15 @@ public class OutboxProperties {
return tenantRemovalTopic; return tenantRemovalTopic;
} }
public String getTenantReactivationTopic() { public String getUserTouchTopic() {
return tenantReactivationTopic; return userTouchTopic;
} }
public String getTenantUserInviteTopic() { public String getUserRemovalTopic() {
return tenantUserInviteTopic; return userRemovalTopic;
} }
public String getNotifyTopic() { public String getNotifyTopic() {
return notifyTopic; return notifyTopic;
} }
public String getForgetMeCompletedTopic() {
return forgetMeCompletedTopic;
}
public String getWhatYouKnowAboutMeCompletedTopic() {
return whatYouKnowAboutMeCompletedTopic;
}
public String getGenerateFileTopic() {
return generateFileTopic;
}
} }

View File

@ -0,0 +1,397 @@
package gr.cite.notification.integrationevent.outbox;
import gr.cite.notification.common.JsonHandlingService;
import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.common.scope.fake.FakeRequestScope;
import gr.cite.notification.data.QueueOutboxEntity;
import gr.cite.notification.query.QueueOutboxQuery;
import gr.cite.queueoutbox.entity.QueueOutbox;
import gr.cite.queueoutbox.entity.QueueOutboxNotifyStatus;
import gr.cite.queueoutbox.repository.CandidateInfo;
import gr.cite.queueoutbox.repository.OutboxRepository;
import gr.cite.queueoutbox.task.MessageOptions;
import gr.cite.rabbitmq.IntegrationEvent;
import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.EntityTransaction;
import jakarta.persistence.OptimisticLockException;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.time.Instant;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;
public class OutboxRepositoryImpl implements OutboxRepository {
protected final ApplicationContext applicationContext;
private final Random random = new Random();
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(OutboxRepositoryImpl.class));
private final JsonHandlingService jsonHandlingService;
private final OutboxProperties outboxProperties;
public OutboxRepositoryImpl(
ApplicationContext applicationContext,
OutboxProperties outboxProperties
) {
this.applicationContext = applicationContext;
this.jsonHandlingService = this.applicationContext.getBean(JsonHandlingService.class);
this.outboxProperties = outboxProperties;
}
@Override
public CandidateInfo candidate(Instant lastCandidateCreationTimestamp, MessageOptions messageOptions, Function<QueueOutbox, Boolean> onConfirmTimeout) {
EntityTransaction transaction = null;
EntityManager entityManager = null;
CandidateInfo candidate = null;
try (FakeRequestScope ignored = new FakeRequestScope()) {
try {
QueryFactory queryFactory = this.applicationContext.getBean(QueryFactory.class);
EntityManagerFactory entityManagerFactory = this.applicationContext.getBean(EntityManagerFactory.class);
entityManager = entityManagerFactory.createEntityManager();
transaction = entityManager.getTransaction();
transaction.begin();
QueueOutboxEntity item = queryFactory.query(QueueOutboxQuery.class)
.isActives(IsActive.Active)
.notifyStatus(QueueOutboxNotifyStatus.PENDING, QueueOutboxNotifyStatus.WAITING_CONFIRMATION, QueueOutboxNotifyStatus.ERROR)
.retryThreshold(messageOptions.getRetryThreashold())
.confirmTimeout(messageOptions.getConfirmTimeoutSeconds())
.createdAfter(lastCandidateCreationTimestamp)
.ordering(new Ordering().addAscending(QueueOutboxEntity._createdAt))
.first();
if (item != null) {
boolean confirmTimeout = onConfirmTimeout.apply(item);
QueueOutboxNotifyStatus prevState = item.getNotifyStatus();
item.setNotifyStatus(QueueOutboxNotifyStatus.PROCESSING);
entityManager.merge(item);
entityManager.flush();
candidate = new CandidateInfo();
candidate.setId(item.getId());
candidate.setCreatedAt(item.getCreatedAt());
candidate.setPreviousState(prevState);
}
transaction.commit();
} catch (OptimisticLockException ex) {
// we get this if/when someone else already modified the notifications. We want to essentially ignore this, and keep working
logger.debug("Concurrency exception getting queue outbox. Skipping: {} ", ex.getMessage());
if (transaction != null) transaction.rollback();
candidate = null;
} catch (Exception ex) {
logger.error("Problem getting list of queue outbox. Skipping: {}", ex.getMessage(), ex);
if (transaction != null) transaction.rollback();
candidate = null;
} finally {
if (entityManager != null) entityManager.close();
}
} catch (Exception ex) {
logger.error("Problem getting list of queue outbox. Skipping: {}", ex.getMessage(), ex);
}
return candidate;
}
@Override
public Boolean shouldOmit(CandidateInfo candidate, Function<QueueOutbox, Boolean> shouldOmit) {
EntityTransaction transaction = null;
EntityManager entityManager = null;
boolean success = false;
try (FakeRequestScope ignored = new FakeRequestScope()) {
try {
EntityManagerFactory entityManagerFactory = this.applicationContext.getBean(EntityManagerFactory.class);
entityManager = entityManagerFactory.createEntityManager();
transaction = entityManager.getTransaction();
transaction.begin();
QueryFactory queryFactory = this.applicationContext.getBean(QueryFactory.class);
QueueOutboxEntity item = queryFactory.query(QueueOutboxQuery.class).ids(candidate.getId()).first();
if (item == null) {
logger.warn("Could not lookup queue outbox {} to process. Continuing...", candidate.getId());
} else {
if (shouldOmit.apply(item)) {
item.setNotifyStatus(QueueOutboxNotifyStatus.OMITTED);
entityManager.merge(item);
entityManager.flush();
success = true;
}
}
transaction.commit();
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
if (transaction != null) transaction.rollback();
success = false;
} finally {
if (entityManager != null) entityManager.close();
}
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
}
return success;
}
@Override
public Boolean shouldWait(CandidateInfo candidate, Function<QueueOutbox, Boolean> itIsTimeFunc) {
EntityTransaction transaction = null;
EntityManager entityManager = null;
boolean success = false;
try (FakeRequestScope ignored = new FakeRequestScope()) {
try {
EntityManagerFactory entityManagerFactory = this.applicationContext.getBean(EntityManagerFactory.class);
entityManager = entityManagerFactory.createEntityManager();
transaction = entityManager.getTransaction();
transaction.begin();
QueryFactory queryFactory = this.applicationContext.getBean(QueryFactory.class);
QueueOutboxEntity item = queryFactory.query(QueueOutboxQuery.class).ids(candidate.getId()).first();
if (item.getRetryCount() != null && item.getRetryCount() >= 1) {
Boolean itIsTime = itIsTimeFunc.apply(item);
if (!itIsTime) {
item.setNotifyStatus(candidate.getPreviousState());
entityManager.merge(item);
entityManager.flush();
success = true;
}
success = !itIsTime;
}
transaction.commit();
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
if (transaction != null) transaction.rollback();
success = false;
} finally {
if (entityManager != null) entityManager.close();
}
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
}
return success;
}
@Override
public Boolean process(CandidateInfo candidateInfo, Boolean isAutoconfirmOnPublish, Function<QueueOutbox, Boolean> publish) {
EntityTransaction transaction = null;
EntityManager entityManager = null;
Boolean success = false;
try (FakeRequestScope ignored = new FakeRequestScope()) {
try {
EntityManagerFactory entityManagerFactory = this.applicationContext.getBean(EntityManagerFactory.class);
entityManager = entityManagerFactory.createEntityManager();
transaction = entityManager.getTransaction();
transaction.begin();
QueryFactory queryFactory = this.applicationContext.getBean(QueryFactory.class);
QueueOutboxEntity item = queryFactory.query(QueueOutboxQuery.class).ids(candidateInfo.getId()).first();
if (item == null) {
logger.warn("Could not lookup queue outbox {} to process. Continuing...", candidateInfo.getId());
} else {
success = publish.apply(item);
if (success) {
if (isAutoconfirmOnPublish) {
item.setNotifyStatus(QueueOutboxNotifyStatus.CONFIRMED);
item.setConfirmedAt(Instant.now());
} else {
item.setNotifyStatus(QueueOutboxNotifyStatus.WAITING_CONFIRMATION);
}
item.setPublishedAt(Instant.now());
} else {
item.setNotifyStatus(QueueOutboxNotifyStatus.ERROR);
item.setRetryCount(item.getRetryCount() != null ? item.getRetryCount() + 1 : 0);
item.setPublishedAt(null);
}
entityManager.merge(item);
entityManager.flush();
}
transaction.commit();
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
if (transaction != null) transaction.rollback();
success = false;
} finally {
if (entityManager != null) entityManager.close();
}
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
}
return success;
}
@Override
public void handleConfirm(List<UUID> confirmedMessages) {
EntityTransaction transaction = null;
EntityManager entityManager = null;
try (FakeRequestScope ignored = new FakeRequestScope()) {
try {
EntityManagerFactory entityManagerFactory = this.applicationContext.getBean(EntityManagerFactory.class);
entityManager = entityManagerFactory.createEntityManager();
transaction = entityManager.getTransaction();
transaction.begin();
QueryFactory queryFactory = this.applicationContext.getBean(QueryFactory.class);
List<QueueOutboxEntity> queueOutboxMessages = queryFactory.query(QueueOutboxQuery.class).ids(confirmedMessages).collect();
if (queueOutboxMessages == null) {
logger.warn("Could not lookup messages {} to process. Continuing...", String.join(",", confirmedMessages.stream().map(x -> x.toString()).collect(Collectors.toList())));
} else {
for (QueueOutboxEntity queueOutboxMessage : queueOutboxMessages) {
queueOutboxMessage.setNotifyStatus(QueueOutboxNotifyStatus.CONFIRMED);
queueOutboxMessage.setConfirmedAt(Instant.now());
entityManager.merge(queueOutboxMessage);
}
entityManager.flush();
}
transaction.commit();
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
if (transaction != null) transaction.rollback();
} finally {
if (entityManager != null) entityManager.close();
}
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
}
}
@Override
public void handleNack(List<UUID> nackedMessages) {
EntityTransaction transaction = null;
EntityManager entityManager = null;
try (FakeRequestScope ignored = new FakeRequestScope()) {
try {
EntityManagerFactory entityManagerFactory = this.applicationContext.getBean(EntityManagerFactory.class);
entityManager = entityManagerFactory.createEntityManager();
transaction = entityManager.getTransaction();
transaction.begin();
QueryFactory queryFactory = this.applicationContext.getBean(QueryFactory.class);
List<QueueOutboxEntity> queueOutboxMessages = queryFactory.query(QueueOutboxQuery.class).ids(nackedMessages).collect();
if (queueOutboxMessages == null) {
logger.warn("Could not lookup messages {} to process. Continuing...", String.join(",", nackedMessages.stream().map(x -> x.toString()).collect(Collectors.toList())));
} else {
for (QueueOutboxEntity queueOutboxMessage : queueOutboxMessages) {
queueOutboxMessage.setNotifyStatus(QueueOutboxNotifyStatus.ERROR);
queueOutboxMessage.setRetryCount(queueOutboxMessage.getRetryCount() != null ? queueOutboxMessage.getRetryCount() + 1 : 0);
entityManager.merge(queueOutboxMessage);
}
entityManager.flush();
}
transaction.commit();
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
if (transaction != null) transaction.rollback();
} finally {
if (entityManager != null) entityManager.close();
}
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
}
}
@Override
public QueueOutbox create(IntegrationEvent item) {
EntityTransaction transaction = null;
EntityManager entityManager = null;
boolean success = false;
QueueOutboxEntity queueMessage = null;
try (FakeRequestScope ignored = new FakeRequestScope()) {
try {
queueMessage = this.mapEvent((OutboxIntegrationEvent) item);
EntityManagerFactory entityManagerFactory = this.applicationContext.getBean(EntityManagerFactory.class);
entityManager = entityManagerFactory.createEntityManager();
transaction = entityManager.getTransaction();
transaction.begin();
entityManager.persist(queueMessage);
entityManager.flush();
transaction.commit();
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
if (transaction != null) transaction.rollback();
success = false;
} finally {
if (entityManager != null) entityManager.close();
}
} catch (Exception ex) {
logger.error("Problem executing purge. rolling back any db changes and marking error. Continuing...", ex);
}
return queueMessage;
}
private QueueOutboxEntity mapEvent(OutboxIntegrationEvent event) {
String routingKey;
switch (event.getType()) {
default: {
logger.error("unrecognized outgoing integration event {}. Skipping...", event.getType());
return null;
}
}
// UUID correlationId = UUID.randomUUID();
// if (event.getEvent() != null) event.getEvent().setTrackingContextTag(correlationId.toString());
// event.setMessage(this.jsonHandlingService.toJsonSafe(event.getEvent()));
// //this._logTrackingService.Trace(correlationId.ToString(), $"Correlating current tracking context with new correlationId {correlationId}");
//
// QueueOutboxEntity queueMessage = new QueueOutboxEntity();
// queueMessage.setId(UUID.randomUUID());
// queueMessage.setTenantId(null);
// queueMessage.setExchange(this.outboxProperties.getExchange());
// queueMessage.setRoute(routingKey);
// queueMessage.setMessageId(event.getMessageId());
// queueMessage.setMessage(this.jsonHandlingService.toJsonSafe(event));
// queueMessage.setIsActive(IsActive.Active);
// queueMessage.setNotifyStatus(QueueOutboxNotifyStatus.PENDING);
// queueMessage.setRetryCount(0);
// queueMessage.setCreatedAt(Instant.now());
// queueMessage.setUpdatedAt(Instant.now());
//
// return queueMessage;
}
}

View File

@ -5,7 +5,7 @@ import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.common.enums.NotificationInAppTracking; import gr.cite.notification.common.enums.NotificationInAppTracking;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
public class InAppNotification { public class InAppNotification {

View File

@ -5,8 +5,8 @@ import gr.cite.notification.data.conventers.IsActiveConverter;
import gr.cite.notification.data.conventers.NotificationTrackingProcessConverter; import gr.cite.notification.data.conventers.NotificationTrackingProcessConverter;
import gr.cite.notification.data.conventers.NotificationTrackingStateConverter; import gr.cite.notification.data.conventers.NotificationTrackingStateConverter;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Convert; import jakarta.persistence.Convert;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -4,7 +4,7 @@ import gr.cite.notification.common.enums.NotificationContactType;
import gr.cite.notification.data.composite.CompositeUserNotificationPreferenceId; import gr.cite.notification.data.composite.CompositeUserNotificationPreferenceId;
import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
import javax.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -4,7 +4,7 @@ import gr.cite.notification.common.enums.NotificationContactType;
import gr.cite.notification.common.enums.NotificationNotifyState; import gr.cite.notification.common.enums.NotificationNotifyState;
import gr.cite.notification.common.validation.ValidId; import gr.cite.notification.common.validation.ValidId;
import javax.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -6,8 +6,8 @@ import gr.cite.notification.common.validation.ValidEnum;
import gr.cite.notification.common.validation.ValidId; import gr.cite.notification.common.validation.ValidId;
import gr.cite.notification.model.persist.notificationtemplate.NotificationTemplateValuePersist; import gr.cite.notification.model.persist.notificationtemplate.NotificationTemplateValuePersist;
import javax.validation.Valid; import jakarta.validation.Valid;
import javax.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.util.UUID; import java.util.UUID;
public class NotificationTemplatePersist { public class NotificationTemplatePersist {

View File

@ -2,9 +2,9 @@ package gr.cite.notification.model.persist;
import gr.cite.notification.common.validation.ValidId; import gr.cite.notification.common.validation.ValidId;
import javax.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import javax.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.util.UUID; import java.util.UUID;
public class TenantTouchedIntegrationEventPersist { public class TenantTouchedIntegrationEventPersist {

View File

@ -5,8 +5,8 @@ import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.common.validation.FieldNotNullIfOtherSet; import gr.cite.notification.common.validation.FieldNotNullIfOtherSet;
import gr.cite.notification.common.validation.ValidId; import gr.cite.notification.common.validation.ValidId;
import javax.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;

View File

@ -2,9 +2,9 @@ package gr.cite.notification.model.persist;
import gr.cite.notification.common.validation.ValidId; import gr.cite.notification.common.validation.ValidId;
import javax.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import javax.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.util.UUID; import java.util.UUID;
public class UserTouchedIntegrationEventPersist { public class UserTouchedIntegrationEventPersist {

View File

@ -3,8 +3,8 @@ package gr.cite.notification.model.persist.notificationtemplate;
import gr.cite.notification.common.enums.NotificationDataType; import gr.cite.notification.common.enums.NotificationDataType;
import gr.cite.notification.common.validation.ValidEnum; import gr.cite.notification.common.validation.ValidEnum;
import javax.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
public class FieldInfoPersist { public class FieldInfoPersist {

View File

@ -1,7 +1,7 @@
package gr.cite.notification.model.persist.notificationtemplate; package gr.cite.notification.model.persist.notificationtemplate;
import javax.validation.Valid; import jakarta.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -3,9 +3,9 @@ package gr.cite.notification.model.persist.notificationtemplate;
import gr.cite.notification.common.enums.EmailOverrideMode; import gr.cite.notification.common.enums.EmailOverrideMode;
import gr.cite.notification.common.validation.ValidEnum; import gr.cite.notification.common.validation.ValidEnum;
import javax.validation.Valid; import jakarta.validation.Valid;
import javax.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.util.List; import java.util.List;
public class NotificationTemplateValuePersist { public class NotificationTemplateValuePersist {

View File

@ -1,9 +1,10 @@
package gr.cite.notification.query; package gr.cite.notification.query;
import gr.cite.notification.authorization.AuthorizationFlags; import gr.cite.notification.authorization.AuthorizationFlags;
import gr.cite.notification.common.enums.*; import gr.cite.notification.common.enums.InAppNotificationPriority;
import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.common.enums.NotificationInAppTracking;
import gr.cite.notification.data.InAppNotificationEntity; import gr.cite.notification.data.InAppNotificationEntity;
import gr.cite.notification.data.LanguageEntity;
import gr.cite.notification.model.InAppNotification; import gr.cite.notification.model.InAppNotification;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
@ -12,8 +13,8 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;

View File

@ -11,9 +11,9 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;

View File

@ -12,8 +12,8 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;

View File

@ -12,10 +12,10 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import javax.persistence.criteria.Subquery; import jakarta.persistence.criteria.Subquery;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
@ -198,9 +198,8 @@ public class NotificationTemplateQuery extends QueryBase<NotificationTemplateEnt
} }
if (this.languageQuery != null) { if (this.languageQuery != null) {
Subquery<LanguageEntity> subQuery = queryContext.Query.subquery(this.languageQuery.entityClass()); QueryContext<LanguageEntity, UUID> subQuery = this.applySubQuery(this.languageQuery, queryContext, UUID.class, root -> root.get(NotificationTemplateEntity._id));
this.applySubQuery(this.languageQuery, queryContext.CriteriaBuilder, subQuery); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(NotificationTemplateEntity._languageId)).value(subQuery.Query));
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(NotificationTemplateEntity._languageId)).value(subQuery));
} }
if (this.channels != null) { if (this.channels != null) {

View File

@ -11,9 +11,9 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;

View File

@ -12,9 +12,9 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;

View File

@ -12,9 +12,9 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;

View File

@ -11,8 +11,8 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;

View File

@ -17,10 +17,10 @@ import gr.cite.tools.data.query.QueryContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope; import org.springframework.web.context.annotation.RequestScope;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import javax.persistence.criteria.Subquery; import jakarta.persistence.criteria.Subquery;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
@ -226,12 +226,11 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
predicates.add(inClause); predicates.add(inClause);
} }
if (this.userQuery != null) { if (this.userQuery != null) {
Subquery<UserEntity> subQuery = queryContext.Query.subquery(this.userQuery.entityClass()); QueryContext<UserEntity, UUID> subQuery = this.applySubQuery(this.userQuery, queryContext, UUID.class, root -> root.get(UserContactInfoEntity._userId));
this.applySubQuery(this.userQuery, queryContext.CriteriaBuilder, subQuery); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(subQuery.Query));
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(subQuery));
} }
if (predicates.size() > 0) { if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray); return queryContext.CriteriaBuilder.and(predicatesArray);
} else { } else {

View File

@ -13,9 +13,9 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;

View File

@ -10,8 +10,8 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.Tuple; import jakarta.persistence.Tuple;
import javax.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;

Some files were not shown because too many files have changed in this diff Show More