update queues to use smallint enums

This commit is contained in:
Efstratios Giannopoulos 2024-03-29 14:32:47 +02:00
parent 21e6015f89
commit 102141aa0d
44 changed files with 334 additions and 170 deletions

View File

@ -62,7 +62,7 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>oidc-authn</artifactId> <artifactId>oidc-authn</artifactId>
<version>1.0.0</version> <version>2.2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
@ -72,7 +72,7 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>oidc-authz</artifactId> <artifactId>oidc-authz</artifactId>
<version>1.0.0</version> <version>2.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
@ -82,7 +82,7 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>validation</artifactId> <artifactId>validation</artifactId>
<version>3.0.2</version> <version>3.0.3</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -2,6 +2,7 @@ package gr.cite.annotation.data;
import gr.cite.annotation.common.enums.IsActive; import gr.cite.annotation.common.enums.IsActive;
import gr.cite.annotation.data.conventers.IsActiveConverter; import gr.cite.annotation.data.conventers.IsActiveConverter;
import gr.cite.annotation.data.conventers.QueueInboxStatusConverter;
import gr.cite.annotation.data.types.JsonSQLType; import gr.cite.annotation.data.types.JsonSQLType;
import gr.cite.queueinbox.entity.QueueInbox; import gr.cite.queueinbox.entity.QueueInbox;
import gr.cite.queueinbox.entity.QueueInboxStatus; import gr.cite.queueinbox.entity.QueueInboxStatus;
@ -21,17 +22,17 @@ public class QueueInboxEntity implements QueueInbox {
public static final String _id = "id"; public static final String _id = "id";
@Column(name = "\"queue\"", nullable = false, length = 50) @Column(name = "\"queue\"", nullable = false, length = 200)
private String queue; private String queue;
public static final String _queue = "queue"; public static final String _queue = "queue";
@Column(name = "\"exchange\"", nullable = false, length = 50) @Column(name = "\"exchange\"", nullable = false, length = 200)
private String exchange; private String exchange;
public static final String _exchange = "exchange"; public static final String _exchange = "exchange";
@Column(name = "\"route\"", nullable = false, length = 50) @Column(name = "\"route\"", nullable = false, length = 200)
private String route; private String route;
public static final String _route = "route"; public static final String _route = "route";
@ -62,11 +63,11 @@ public class QueueInboxEntity implements QueueInbox {
public static final String _tenantId = "tenantId"; public static final String _tenantId = "tenantId";
@Column(name = "\"status\"", length = 50, nullable = false) @Column(name = "\"status\"", nullable = false)
@Enumerated(EnumType.STRING) @Convert(converter = QueueInboxStatusConverter.class)
private QueueInboxStatus status; private QueueInboxStatus status;
public final static String _status = "status";
public static final String _status = "status";
@Column(name = "\"created_at\"", nullable = false) @Column(name = "\"created_at\"", nullable = false)
private Instant createdAt; private Instant createdAt;
@ -79,7 +80,7 @@ public class QueueInboxEntity implements QueueInbox {
public static final String _updatedAt = "updatedAt"; public static final String _updatedAt = "updatedAt";
@Column(name = "\"is_active\"", length = 20, nullable = false) @Column(name = "\"is_active\"", nullable = false)
@Convert(converter = IsActiveConverter.class) @Convert(converter = IsActiveConverter.class)
private IsActive isActive; private IsActive isActive;

View File

@ -2,6 +2,7 @@ package gr.cite.annotation.data;
import gr.cite.annotation.common.enums.IsActive; import gr.cite.annotation.common.enums.IsActive;
import gr.cite.annotation.data.conventers.IsActiveConverter; import gr.cite.annotation.data.conventers.IsActiveConverter;
import gr.cite.annotation.data.conventers.QueueOutboxNotifyStatusConverter;
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 jakarta.persistence.*; import jakarta.persistence.*;
@ -19,12 +20,12 @@ public class QueueOutboxEntity implements QueueOutbox {
public static final String _id = "id"; public static final String _id = "id";
@Column(name = "\"exchange\"", nullable = false, length = 50) @Column(name = "\"exchange\"", nullable = false, length = 200)
private String exchange; private String exchange;
public static final String _exchange = "exchange"; public static final String _exchange = "exchange";
@Column(name = "\"route\"", length = 50) @Column(name = "\"route\"", length = 200)
private String route; private String route;
public static final String _route = "route"; public static final String _route = "route";
@ -39,11 +40,10 @@ public class QueueOutboxEntity implements QueueOutbox {
public static final String _message = "message"; public static final String _message = "message";
@Column(name = "\"notify_status\"", length = 20, nullable = false) @Column(name = "\"notify_status\"", nullable = false)
@Enumerated(EnumType.STRING) @Convert(converter = QueueOutboxNotifyStatusConverter.class)
private QueueOutboxNotifyStatus notifyStatus; private QueueOutboxNotifyStatus notifyStatus;
public final static String _notifyStatus = "notifyStatus";
public static final String _notifyStatus = "notifyStatus";
@Column(name = "\"retry_count\"", nullable = false) @Column(name = "\"retry_count\"", nullable = false)
private Integer retryCount; private Integer retryCount;

View File

@ -0,0 +1,19 @@
package gr.cite.annotation.data.conventers;
import gr.cite.queueinbox.entity.QueueInboxStatus;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class QueueInboxStatusConverter implements AttributeConverter<QueueInboxStatus, Short> {
@Override
public Short convertToDatabaseColumn(QueueInboxStatus value) {
if (value == null) throw new IllegalArgumentException("Value could not be null for: " + this.getClass().getSimpleName());
return value.getValue();
}
@Override
public QueueInboxStatus convertToEntityAttribute(Short dbData) {
return QueueInboxStatus.of(dbData);
}
}

View File

@ -0,0 +1,19 @@
package gr.cite.annotation.data.conventers;
import gr.cite.queueoutbox.entity.QueueOutboxNotifyStatus;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class QueueOutboxNotifyStatusConverter implements AttributeConverter<QueueOutboxNotifyStatus, Short> {
@Override
public Short convertToDatabaseColumn(QueueOutboxNotifyStatus value) {
if (value == null) throw new IllegalArgumentException("Value could not be null for: " + this.getClass().getSimpleName());
return value.getValue();
}
@Override
public QueueOutboxNotifyStatus convertToEntityAttribute(Short dbData) {
return QueueOutboxNotifyStatus.of(dbData);
}
}

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.2</version> <version>3.2.1</version>
</parent> </parent>
<modules> <modules>
@ -136,18 +136,18 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>rabbitmq-core</artifactId> <artifactId>rabbitmq-core</artifactId>
<version>2.1.1</version> <version>2.1.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>queue-inbox</artifactId> <artifactId>queue-inbox</artifactId>
<version>1.0.0</version> <version>2.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>queue-outbox</artifactId> <artifactId>queue-outbox</artifactId>
<version>1.0.0</version> <version>2.1.1</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -65,12 +65,12 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>queue-inbox</artifactId> <artifactId>queue-inbox</artifactId>
<version>1.0.0</version> <version>2.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>queue-outbox</artifactId> <artifactId>queue-outbox</artifactId>
<version>1.0.0</version> <version>2.1.1</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -0,0 +1,20 @@
package eu.eudat.configurations.db;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.ConstructorBinding;
@ConfigurationProperties(prefix = "naming-strategy")
public class NamingStrategyProperties {
private final String prefix;
@ConstructorBinding
public NamingStrategyProperties(String prefix) {
this.prefix = prefix;
}
public String getPrefix() {
return prefix;
}
}

View File

@ -0,0 +1,30 @@
package eu.eudat.configurations.db;
import eu.eudat.convention.ConventionService;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@EnableConfigurationProperties({NamingStrategyProperties.class})
public class PrefixPhysicalNamingStrategy extends PhysicalNamingStrategyStandardImpl {
private final NamingStrategyProperties namingStrategyProperties;
private final ConventionService conventionService;
public PrefixPhysicalNamingStrategy(NamingStrategyProperties namingStrategyProperties, ConventionService conventionService) {
this.namingStrategyProperties = namingStrategyProperties;
this.conventionService = conventionService;
}
@Override
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment context) {
if (conventionService.isNullOrEmpty(namingStrategyProperties.getPrefix()))
return super.toPhysicalTableName(logicalName, context);
Identifier identifier = new Identifier(namingStrategyProperties.getPrefix() + logicalName.getText(), logicalName.isQuoted());
return super.toPhysicalTableName(identifier, context);
}
}

View File

@ -2,6 +2,7 @@ package eu.eudat.data;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.converters.enums.QueueInboxStatusConverter;
import eu.eudat.data.types.JsonSQLType; import eu.eudat.data.types.JsonSQLType;
import gr.cite.queueinbox.entity.QueueInbox; import gr.cite.queueinbox.entity.QueueInbox;
import gr.cite.queueinbox.entity.QueueInboxStatus; import gr.cite.queueinbox.entity.QueueInboxStatus;
@ -19,15 +20,15 @@ public class QueueInboxEntity implements QueueInbox {
private UUID id; private UUID id;
public final static String _id = "id"; public final static String _id = "id";
@Column(name = "\"queue\"", nullable = false, length = 50) @Column(name = "\"queue\"", nullable = false, length = 200)
private String queue; private String queue;
public final static String _queue = "queue"; public final static String _queue = "queue";
@Column(name = "\"exchange\"", nullable = false, length = 50) @Column(name = "\"exchange\"", nullable = false, length = 200)
private String exchange; private String exchange;
public final static String _exchange = "exchange"; public final static String _exchange = "exchange";
@Column(name = "\"route\"", nullable = false, length = 50) @Column(name = "\"route\"", nullable = false, length = 200)
private String route; private String route;
public final static String _route = "route"; public final static String _route = "route";
@ -52,14 +53,13 @@ public class QueueInboxEntity implements QueueInbox {
private UUID tenantId; private UUID tenantId;
public final static String _tenantId = "tenantId"; public final static String _tenantId = "tenantId";
@Column(name = "\"is_active\"", length = 20, nullable = false) @Column(name = "\"is_active\"", nullable = false)
@Convert(converter = IsActiveConverter.class) @Convert(converter = IsActiveConverter.class)
private IsActive isActive; private IsActive isActive;
public final static String _isActive = "isActive"; public final static String _isActive = "isActive";
//TODO: as integer @Column(name = "\"status\"", nullable = false)
@Column(name = "\"status\"", length = 50, nullable = false) @Convert(converter = QueueInboxStatusConverter.class)
@Enumerated(EnumType.STRING)
private QueueInboxStatus status; private QueueInboxStatus status;
public final static String _status = "status"; public final static String _status = "status";

View File

@ -2,6 +2,7 @@ package eu.eudat.data;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.converters.enums.QueueOutboxNotifyStatusConverter;
import gr.cite.queueoutbox.entity.QueueOutbox; import gr.cite.queueoutbox.entity.QueueOutbox;
import gr.cite.queueoutbox.entity.QueueOutboxNotifyStatus; import gr.cite.queueoutbox.entity.QueueOutboxNotifyStatus;
@ -17,11 +18,11 @@ public class QueueOutboxEntity implements QueueOutbox {
private UUID id; private UUID id;
public final static String _id = "id"; public final static String _id = "id";
@Column(name = "\"exchange\"", nullable = false, length = 50) @Column(name = "\"exchange\"", nullable = false, length = 200)
private String exchange; private String exchange;
public final static String _exchange = "exchange"; public final static String _exchange = "exchange";
@Column(name = "\"route\"", length = 50) @Column(name = "\"route\"", length = 200)
private String route; private String route;
public final static String _route = "route"; public final static String _route = "route";
@ -33,9 +34,8 @@ public class QueueOutboxEntity implements QueueOutbox {
private String message; private String message;
public final static String _message = "message"; public final static String _message = "message";
//TODO: as integer @Column(name = "\"notify_status\"", nullable = false)
@Column(name = "\"notify_status\"", length = 20, nullable = false) @Convert(converter = QueueOutboxNotifyStatusConverter.class)
@Enumerated(EnumType.STRING)
private QueueOutboxNotifyStatus notifyStatus; private QueueOutboxNotifyStatus notifyStatus;
public final static String _notifyStatus = "notifyStatus"; public final static String _notifyStatus = "notifyStatus";
@ -55,7 +55,7 @@ public class QueueOutboxEntity implements QueueOutbox {
private UUID tenantId; private UUID tenantId;
public final static String _tenantId = "tenantId"; public final static String _tenantId = "tenantId";
@Column(name = "\"is_active\"", length = 20, nullable = false) @Column(name = "\"is_active\"", nullable = false)
@Convert(converter = IsActiveConverter.class) @Convert(converter = IsActiveConverter.class)
private IsActive isActive; private IsActive isActive;
public final static String _isActive = "isActive"; public final static String _isActive = "isActive";

View File

@ -0,0 +1,19 @@
package eu.eudat.data.converters.enums;
import gr.cite.queueinbox.entity.QueueInboxStatus;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class QueueInboxStatusConverter implements AttributeConverter<QueueInboxStatus, Short> {
@Override
public Short convertToDatabaseColumn(QueueInboxStatus value) {
if (value == null) throw new IllegalArgumentException("Value could not be null for: " + this.getClass().getSimpleName());
return value.getValue();
}
@Override
public QueueInboxStatus convertToEntityAttribute(Short dbData) {
return QueueInboxStatus.of(dbData);
}
}

View File

@ -0,0 +1,19 @@
package eu.eudat.data.converters.enums;
import gr.cite.queueoutbox.entity.QueueOutboxNotifyStatus;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class QueueOutboxNotifyStatusConverter implements AttributeConverter<QueueOutboxNotifyStatus, Short> {
@Override
public Short convertToDatabaseColumn(QueueOutboxNotifyStatus value) {
if (value == null) throw new IllegalArgumentException("Value could not be null for: " + this.getClass().getSimpleName());
return value.getValue();
}
@Override
public QueueOutboxNotifyStatus convertToEntityAttribute(Short dbData) {
return QueueOutboxNotifyStatus.of(dbData);
}
}

View File

@ -4,13 +4,13 @@ import eu.eudat.commons.validation.BaseValidator;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -29,7 +29,7 @@ public class CloneDmpPersist {
public static final String _description = "description"; public static final String _description = "description";
private List<UUID> descriptions = Lists.newArrayList(); private List<UUID> descriptions = new ArrayList<>();
public static final String _descriptions = "descriptions"; public static final String _descriptions = "descriptions";

View File

@ -5,13 +5,13 @@ import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -33,7 +33,7 @@ public class NewVersionDmpPersist {
public static final String _blueprintId = "blueprintId"; public static final String _blueprintId = "blueprintId";
private List<UUID> descriptions = Lists.newArrayList(); private List<UUID> descriptions = new ArrayList<>();
public static final String _descriptions = "descriptions"; public static final String _descriptions = "descriptions";

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.2</version> <version>3.2.1</version>
</parent> </parent>
<modules> <modules>
@ -41,7 +41,7 @@
<dependency> <dependency>
<groupId>org.json</groupId> <groupId>org.json</groupId>
<artifactId>json</artifactId> <artifactId>json</artifactId>
<version>20230227</version> <version>20240303</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
@ -92,7 +92,7 @@
<dependency> <dependency>
<groupId>org.elasticsearch.client</groupId> <groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId> <artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.6.0</version> <version>7.17.19</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hibernate.orm</groupId> <groupId>org.hibernate.orm</groupId>
@ -109,7 +109,7 @@
<dependency> <dependency>
<groupId>com.jayway.jsonpath</groupId> <groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId> <artifactId>json-path</artifactId>
<version>2.4.0</version> <version>2.9.0</version>
</dependency> </dependency>
@ -153,24 +153,8 @@
<version>3.5</version> <version>3.5</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop --> <!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>2.3</version>
</dependency>
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
@ -190,11 +174,6 @@
<version>1.0.6</version> <version>1.0.6</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/fr.opensagres.xdocreport.itext.extension --> <!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/fr.opensagres.xdocreport.itext.extension -->
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.xdocreport.itext.extension</artifactId>
<version>2.0.4</version>
</dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
@ -356,18 +335,18 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>queue-inbox</artifactId> <artifactId>queue-inbox</artifactId>
<version>1.0.0</version> <version>2.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>queue-outbox</artifactId> <artifactId>queue-outbox</artifactId>
<version>1.0.0</version> <version>2.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>rabbitmq-core</artifactId> <artifactId>rabbitmq-core</artifactId>
<version>1.0.0</version> <version>2.1.2</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -16,7 +16,7 @@ spring:
dialect: org.hibernate.dialect.PostgreSQLDialect dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate: hibernate:
naming: naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl physical-strategy: eu.eudat.configurations.db.PrefixPhysicalNamingStrategy
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
datasource: datasource:
url: ${DB_URL:} url: ${DB_URL:}
@ -29,3 +29,6 @@ spring:
maximum-pool-size: 10 maximum-pool-size: 10
idle-timeout: 600000 idle-timeout: 600000
max-lifetime: 1800000 max-lifetime: 1800000
naming-strategy:
prefix:

View File

@ -10,7 +10,7 @@ BEGIN
exchange character varying(200) COLLATE pg_catalog."default" NOT NULL, exchange character varying(200) COLLATE pg_catalog."default" NOT NULL,
route character varying(200) COLLATE pg_catalog."default" NOT NULL, route character varying(200) COLLATE pg_catalog."default" NOT NULL,
message_id uuid NOT NULL, message_id uuid NOT NULL,
notify_status character varying(100) COLLATE pg_catalog."default" NOT NULL, notify_status smallint NOT NULL,
retry_count integer NOT NULL, retry_count integer NOT NULL,
published_at timestamp without time zone, published_at timestamp without time zone,
confirmed_at timestamp without time zone, confirmed_at timestamp without time zone,

View File

@ -7,14 +7,14 @@ BEGIN
CREATE TABLE public."QueueInbox" CREATE TABLE public."QueueInbox"
( (
id uuid NOT NULL, id uuid NOT NULL,
queue character varying(50) COLLATE pg_catalog."default" NOT NULL, queue character varying(200) COLLATE pg_catalog."default" NOT NULL,
exchange character varying(50) COLLATE pg_catalog."default" NOT NULL, exchange character varying(200) COLLATE pg_catalog."default" NOT NULL,
route character varying(50) COLLATE pg_catalog."default" NOT NULL, route character varying(200) COLLATE pg_catalog."default" NOT NULL,
application_id character varying(100) COLLATE pg_catalog."default" NOT NULL, application_id character varying(100) COLLATE pg_catalog."default" NOT NULL,
message_id uuid NOT NULL, message_id uuid NOT NULL,
message json NOT NULL, message json NOT NULL,
retry_count integer, retry_count integer,
status character varying(50) COLLATE pg_catalog."default" NOT NULL, status smallint NOT NULL,
created_at timestamp without time zone NOT NULL, created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL,
tenant uuid, tenant uuid,

View File

@ -7,14 +7,14 @@ BEGIN
CREATE TABLE public."ntf_QueueInbox" CREATE TABLE public."ntf_QueueInbox"
( (
id uuid NOT NULL, id uuid NOT NULL,
queue character varying(50) COLLATE pg_catalog."default" NOT NULL, queue character varying(200) COLLATE pg_catalog."default" NOT NULL,
exchange character varying(50) COLLATE pg_catalog."default" NOT NULL, exchange character varying(200) COLLATE pg_catalog."default" NOT NULL,
route character varying(50) COLLATE pg_catalog."default" NOT NULL, route character varying(200) COLLATE pg_catalog."default" NOT NULL,
application_id character varying(100) COLLATE pg_catalog."default" NOT NULL, application_id character varying(100) COLLATE pg_catalog."default" NOT NULL,
message_id uuid NOT NULL, message_id uuid NOT NULL,
message json NOT NULL, message json NOT NULL,
retry_count integer, retry_count integer,
status character varying(50) COLLATE pg_catalog."default" NOT NULL, status smallint NOT NULL,
created_at timestamp without time zone NOT NULL, created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL,
tenant uuid, tenant uuid,

View File

@ -10,7 +10,7 @@ BEGIN
exchange character varying(200) COLLATE pg_catalog."default" NOT NULL, exchange character varying(200) COLLATE pg_catalog."default" NOT NULL,
route character varying(200) COLLATE pg_catalog."default" NOT NULL, route character varying(200) COLLATE pg_catalog."default" NOT NULL,
message_id uuid NOT NULL, message_id uuid NOT NULL,
notify_status character varying(100) COLLATE pg_catalog."default" NOT NULL, notify_status smallint NOT NULL,
retry_count integer NOT NULL, retry_count integer NOT NULL,
published_at timestamp without time zone, published_at timestamp without time zone,
confirmed_at timestamp without time zone, confirmed_at timestamp without time zone,

View File

@ -7,14 +7,14 @@ BEGIN
CREATE TABLE public."ant_QueueInbox" CREATE TABLE public."ant_QueueInbox"
( (
id uuid NOT NULL, id uuid NOT NULL,
queue character varying(50) COLLATE pg_catalog."default" NOT NULL, queue character varying(200) COLLATE pg_catalog."default" NOT NULL,
exchange character varying(50) COLLATE pg_catalog."default" NOT NULL, exchange character varying(200) COLLATE pg_catalog."default" NOT NULL,
route character varying(50) COLLATE pg_catalog."default" NOT NULL, route character varying(200) COLLATE pg_catalog."default" NOT NULL,
application_id character varying(100) COLLATE pg_catalog."default" NOT NULL, application_id character varying(100) COLLATE pg_catalog."default" NOT NULL,
message_id uuid NOT NULL, message_id uuid NOT NULL,
message json NOT NULL, message json NOT NULL,
retry_count integer, retry_count integer,
status character varying(50) COLLATE pg_catalog."default" NOT NULL, status smallint NOT NULL,
created_at timestamp without time zone NOT NULL, created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL,
tenant uuid, tenant uuid,

View File

@ -10,7 +10,7 @@ BEGIN
exchange character varying(200) COLLATE pg_catalog."default" NOT NULL, exchange character varying(200) COLLATE pg_catalog."default" NOT NULL,
route character varying(200) COLLATE pg_catalog."default" NOT NULL, route character varying(200) COLLATE pg_catalog."default" NOT NULL,
message_id uuid NOT NULL, message_id uuid NOT NULL,
notify_status character varying(100) COLLATE pg_catalog."default" NOT NULL, notify_status smallint NOT NULL,
retry_count integer NOT NULL, retry_count integer NOT NULL,
published_at timestamp without time zone, published_at timestamp without time zone,
confirmed_at timestamp without time zone, confirmed_at timestamp without time zone,

View File

@ -71,10 +71,10 @@ public class InAppNotificationController {
@PostMapping("query") @PostMapping("query")
public QueryResult<InAppNotification> Query(@RequestBody InAppNotificationLookup lookup) throws MyApplicationException, MyForbiddenException, InvalidApplicationException { public QueryResult<InAppNotification> Query(@RequestBody InAppNotificationLookup lookup) throws MyApplicationException, MyForbiddenException, InvalidApplicationException {
logger.debug("querying {}", InAppNotification.class.getSimpleName()); logger.debug("querying {}", InAppNotification.class.getSimpleName());
this.censorFactory.censor(InAppNotificationCensor.class).censor(lookup.getProject());
UUID userId = this.userScope.getUserId(); UUID userId = this.userScope.getUserId();
this.censorFactory.censor(InAppNotificationCensor.class).censor(lookup.getProject(), userId);
if (userId == null) throw new MyForbiddenException(this.errors.getNonPersonPrincipal().getCode(), this.errors.getNonPersonPrincipal().getMessage()); if (userId == null) throw new MyForbiddenException(this.errors.getNonPersonPrincipal().getCode(), this.errors.getNonPersonPrincipal().getMessage());
InAppNotificationQuery query = lookup.enrich(this.queryFactory).userId(userId); InAppNotificationQuery query = lookup.enrich(this.queryFactory).userId(userId);
List<InAppNotificationEntity> data = query.collectAs(lookup.getProject()); List<InAppNotificationEntity> data = query.collectAs(lookup.getProject());
@ -88,12 +88,13 @@ public class InAppNotificationController {
@GetMapping("{id}") @GetMapping("{id}")
@Transactional @Transactional
public InAppNotification Get(@PathVariable UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException { public InAppNotification Get(@PathVariable UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
logger.debug(new MapLogEntry("retrieving" + InAppNotification.class.getSimpleName()).And("id", id).And("fields", fieldSet)); logger.debug(new MapLogEntry("retrieving" + InAppNotification.class.getSimpleName()).And("id", id).And("fields", fieldSet));
this.censorFactory.censor(InAppNotificationCensor.class).censor(fieldSet); UUID userId = this.userScope.getUserId();
this.censorFactory.censor(InAppNotificationCensor.class).censor(fieldSet, userId);
InAppNotificationQuery query = this.queryFactory.query(InAppNotificationQuery.class).authorize(AuthorizationFlags.OwnerOrPermission).ids(id); InAppNotificationQuery query = this.queryFactory.query(InAppNotificationQuery.class).authorize(AuthorizationFlags.OwnerOrPermission).userId(userId).ids(id);
InAppNotification model = this.builderFactory.builder(InAppNotificationBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fieldSet, query.firstAs(fieldSet)); InAppNotification model = this.builderFactory.builder(InAppNotificationBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fieldSet, query.firstAs(fieldSet));
if (model == null) if (model == null)
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Notification.class.getSimpleName()}, LocaleContextHolder.getLocale())); throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Notification.class.getSimpleName()}, LocaleContextHolder.getLocale()));
@ -142,7 +143,7 @@ public class InAppNotificationController {
UUID userId = this.userScope.getUserId(); UUID userId = this.userScope.getUserId();
if (userId == null) throw new MyForbiddenException(this.errors.getNonPersonPrincipal().getCode(), this.errors.getNonPersonPrincipal().getMessage()); if (userId == null) throw new MyForbiddenException(this.errors.getNonPersonPrincipal().getCode(), this.errors.getNonPersonPrincipal().getMessage());
this.censorFactory.censor(InAppNotificationCensor.class).censor(new BaseFieldSet(InAppNotification.Field.ID)); this.censorFactory.censor(InAppNotificationCensor.class).censor(new BaseFieldSet(InAppNotification.Field.ID), userId);
InAppNotificationQuery query = this.queryFactory.query(InAppNotificationQuery.class).isActive(IsActive.Active).trackingState(NotificationInAppTracking.STORED).userId(userId); InAppNotificationQuery query = this.queryFactory.query(InAppNotificationQuery.class).isActive(IsActive.Active).trackingState(NotificationInAppTracking.STORED).userId(userId);
int count = Math.toIntExact(query.count()); int count = Math.toIntExact(query.count());

View File

@ -66,7 +66,7 @@ public class UserNotificationPreferenceController {
public QueryResult<UserNotificationPreference> query(@RequestBody UserNotificationPreferenceLookup lookup) throws MyApplicationException, MyForbiddenException { public QueryResult<UserNotificationPreference> query(@RequestBody UserNotificationPreferenceLookup lookup) throws MyApplicationException, MyForbiddenException {
logger.debug("querying {}", UserNotificationPreference.class.getSimpleName()); logger.debug("querying {}", UserNotificationPreference.class.getSimpleName());
this.censorFactory.censor(UserNotificationPreferenceCensor.class).censor(lookup.getProject()); this.censorFactory.censor(UserNotificationPreferenceCensor.class).censor(lookup.getProject(), null);
UserNotificationPreferenceQuery query = lookup.enrich(this.queryFactory); UserNotificationPreferenceQuery query = lookup.enrich(this.queryFactory);
List<UserNotificationPreferenceEntity> data = query.collectAs(lookup.getProject()); List<UserNotificationPreferenceEntity> data = query.collectAs(lookup.getProject());
@ -83,7 +83,7 @@ public class UserNotificationPreferenceController {
public UserNotificationPreference current(@PathVariable UUID userId, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException { public UserNotificationPreference current(@PathVariable UUID userId, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
logger.debug(new MapLogEntry("retrieving" + UserNotificationPreference.class.getSimpleName()).And("userId", userId).And("fields", fieldSet)); logger.debug(new MapLogEntry("retrieving" + UserNotificationPreference.class.getSimpleName()).And("userId", userId).And("fields", fieldSet));
this.censorFactory.censor(UserNotificationPreferenceCensor.class).censor(fieldSet); this.censorFactory.censor(UserNotificationPreferenceCensor.class).censor(fieldSet, userId);
UserNotificationPreferenceQuery query = this.queryFactory.query(UserNotificationPreferenceQuery.class).userId(userId); UserNotificationPreferenceQuery query = this.queryFactory.query(UserNotificationPreferenceQuery.class).userId(userId);
UserNotificationPreference model = this.builderFactory.builder(UserNotificationPreferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fieldSet, query.firstAs(fieldSet)); UserNotificationPreference model = this.builderFactory.builder(UserNotificationPreferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fieldSet, query.firstAs(fieldSet));

View File

@ -39,9 +39,6 @@ cache:
enableRecordStats: false enableRecordStats: false
expireAfterWriteSeconds: 60 expireAfterWriteSeconds: 60
mapCaches: mapCaches:
- names: [ cacheB ]
allowNullValues: true
storeByValue: true
apiKey: apiKey:
name: apikey name: apikey
keyPattern: resolve_$keyhash$:v0 keyPattern: resolve_$keyhash$:v0

View File

@ -1,7 +1,11 @@
spring: spring:
jpa: jpa:
properties: properties:
org:
hibernate: hibernate:
flushMode: MANUAL
hibernate:
globally_quoted_identifiers: true
ddl-auto: validate ddl-auto: validate
dialect: org.hibernate.dialect.PostgreSQLDialect dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate: hibernate:
@ -16,9 +20,10 @@ spring:
hikari: hikari:
connection-timeout: 30000 connection-timeout: 30000
minimum-idle: 3 minimum-idle: 3
maximum-pool-size: 5 maximum-pool-size: 10
idle-timeout: 600000 idle-timeout: 600000
max-lifetime: 1800000 max-lifetime: 1800000
naming-strategy: naming-strategy:
prefix: ntf_ prefix: ntf_

View File

@ -1,14 +1,14 @@
spring: spring:
mail: mail:
host: ${MAIL_HOST:} host: ${MAIL_HOST}
port: ${MAIL_PORT:} port: ${MAIL_PORT}
username: ${MAIL_USERNAME:} username: ${MAIL_USERNAME}
password: ${MAIL_PASSWORD:} password: ${MAIL_PASSWORD}
properties: properties:
mail: mail:
smtp: smtp:
auth: ${MAIL_AUTH:} auth: ${MAIL_AUTH}
starttls: starttls:
enable: ${MAIL_TLS:} enable: ${MAIL_TLS}
email: email:
address: ${MAIL_ADDRESS:} address: ${MAIL_ADDRESS}

View File

@ -37,3 +37,5 @@ idpclient:
- type: azp - type: azp
Authorities: Authorities:
- type: authorities - type: authorities
ExternalProviderName:
- type: identity_provider

View File

@ -5,26 +5,26 @@ permissions:
# Tenants # Tenants
BrowseTenant: BrowseTenant:
roles: roles:
- ic-sti-superuser - Admin
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
EditTenant: EditTenant:
roles: roles:
- ic-sti-superuser - Admin
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
DeleteTenant: DeleteTenant:
roles: roles:
- ic-sti-superuser - Admin
claims: [ ] claims: [ ]
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
AllowNoTenant: AllowNoTenant:
roles: roles:
- ic-sti-superuser - Admin
claims: [ ] claims: [ ]
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
@ -32,21 +32,19 @@ permissions:
# Users # Users
BrowseUser: BrowseUser:
roles: roles:
- ic-sti-superuser - Admin
- tenantadmin
clients: [ ] clients: [ ]
allowAnonymous: true allowAnonymous: true
allowAuthenticated: false allowAuthenticated: false
EditUser: EditUser:
roles: roles:
- admin - Admin
- ic-sti-superuser
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
DeleteUser: DeleteUser:
roles: roles:
- ic-sti-superuser - Admin
claims: [ ] claims: [ ]
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
@ -54,20 +52,19 @@ permissions:
# UserContactInfo # UserContactInfo
BrowseUserContactInfo: BrowseUserContactInfo:
roles: roles:
- ic-sti-superuser - Admin
clients: [ ] clients: [ ]
allowAnonymous: true allowAnonymous: true
allowAuthenticated: false allowAuthenticated: false
EditUserContactInfo: EditUserContactInfo:
roles: roles:
- ic-sti-superuser - Admin
- user
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
DeleteUserContactInfo: DeleteUserContactInfo:
roles: roles:
- ic-sti-superuser - Admin
claims: [ ] claims: [ ]
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
@ -94,27 +91,26 @@ permissions:
#Tenant Configuration #Tenant Configuration
BrowseTenantConfiguration: BrowseTenantConfiguration:
roles: roles:
- ic-sti-superuser - Admin
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
EditTenantConfiguration: EditTenantConfiguration:
roles: roles:
- ic-sti-superuser - Admin
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
#User Notification Preference #User Notification Preference
BrowseUserNotificationPreference: BrowseUserNotificationPreference:
roles: roles:
- ic-sti-superuser - Admin
clients: [ ] clients: [ ]
allowAnonymous: true allowAnonymous: true
allowAuthenticated: false allowAuthenticated: false
EditUserNotificationPreference: EditUserNotificationPreference:
roles: roles:
- ic-sti-superuser - Admin
- user
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
@ -122,26 +118,25 @@ permissions:
# ViewPage Permissions # ViewPage Permissions
ViewNotificationPage: ViewNotificationPage:
roles: roles:
- ic-sti-superuser - Admin
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
ViewNotificationEventRulePage: ViewNotificationEventRulePage:
roles: roles:
- ic-sti-superuser - Admin
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
ViewInAppNotificationPage: ViewInAppNotificationPage:
roles: roles:
- ic-sti-superuser - Admin
- tenantadmin
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
ViewNotificationTemplatePage: ViewNotificationTemplatePage:
roles: roles:
- ic-sti-superuser - Admin
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
@ -170,7 +165,6 @@ permissions:
BrowseInAppNotification: BrowseInAppNotification:
roles: roles:
- Admin - Admin
- User
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false

View File

@ -0,0 +1,6 @@
web:
security:
idp:
resource:
jwt:
audiences: [ "dmp_notification" ]

View File

@ -2,19 +2,13 @@ web:
security: security:
enabled: true enabled: true
authorized-endpoints: [ api ] authorized-endpoints: [ api ]
allowed-endpoints: [ public, dataset, master-item, test ] allowed-endpoints: [ public ]
idp: idp:
api-key: api-key:
enabled: true enabled: false
authorization-header: Authorization
client-id: ${IDP_APIKEY_CLIENT_ID}
client-secret: ${IDP_APIKEY_CLIENT_SECRET}
scope: ${IDP_APIKEY_SCOPE}
resource: resource:
token-type: JWT token-type: JWT #| opaque
opaque:
client-id: ${IDP_OPAQUE_CLIENT_ID}
client-secret: ${IDP_OPAQUE_CLIENT_SECRET}
jwt: jwt:
claims: [ role, x-role ] claims: [ role, x-role ]
issuer-uri: ${IDP_ISSUER_URI:} issuer-uri: ${IDP_ISSUER_URI}
validIssuer: ${IDP_ISSUER_URI}

View File

@ -1,3 +1,13 @@
server: server:
port: ${WEB_PORT} port: ${WEB_PORT}
forward-headers-strategy: NONE forward-headers-strategy: NONE
tomcat:
threads:
max: 20
max-connections: 10000
spring:
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB

View File

@ -63,7 +63,7 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>oidc-authn</artifactId> <artifactId>oidc-authn</artifactId>
<version>1.0.0</version> <version>2.2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
@ -73,7 +73,7 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>oidc-authz</artifactId> <artifactId>oidc-authz</artifactId>
<version>1.0.0</version> <version>2.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>

View File

@ -2,6 +2,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 gr.cite.notification.data.conventers.QueueInboxStatusConverter;
import gr.cite.notification.data.types.JsonSQLType; import gr.cite.notification.data.types.JsonSQLType;
import gr.cite.queueinbox.entity.QueueInbox; import gr.cite.queueinbox.entity.QueueInbox;
import gr.cite.queueinbox.entity.QueueInboxStatus; import gr.cite.queueinbox.entity.QueueInboxStatus;
@ -21,17 +22,17 @@ public class QueueInboxEntity implements QueueInbox {
public static final String _id = "id"; public static final String _id = "id";
@Column(name = "\"queue\"", nullable = false, length = 50) @Column(name = "\"queue\"", nullable = false, length = 200)
private String queue; private String queue;
public static final String _queue = "queue"; public static final String _queue = "queue";
@Column(name = "\"exchange\"", nullable = false, length = 50) @Column(name = "\"exchange\"", nullable = false, length = 200)
private String exchange; private String exchange;
public static final String _exchange = "exchange"; public static final String _exchange = "exchange";
@Column(name = "\"route\"", nullable = false, length = 50) @Column(name = "\"route\"", nullable = false, length = 200)
private String route; private String route;
public static final String _route = "route"; public static final String _route = "route";
@ -62,11 +63,11 @@ public class QueueInboxEntity implements QueueInbox {
public static final String _tenantId = "tenantId"; public static final String _tenantId = "tenantId";
@Column(name = "\"status\"", length = 50, nullable = false) @Column(name = "\"status\"", nullable = false)
@Enumerated(EnumType.STRING) @Convert(converter = QueueInboxStatusConverter.class)
private QueueInboxStatus status; private QueueInboxStatus status;
public final static String _status = "status";
public static final String _status = "status";
@Column(name = "\"created_at\"", nullable = false) @Column(name = "\"created_at\"", nullable = false)
private Instant createdAt; private Instant createdAt;
@ -79,7 +80,7 @@ public class QueueInboxEntity implements QueueInbox {
public static final String _updatedAt = "updatedAt"; public static final String _updatedAt = "updatedAt";
@Column(name = "\"is_active\"", length = 20, nullable = false) @Column(name = "\"is_active\"", nullable = false)
@Convert(converter = IsActiveConverter.class) @Convert(converter = IsActiveConverter.class)
private IsActive isActive; private IsActive isActive;

View File

@ -2,6 +2,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 gr.cite.notification.data.conventers.QueueOutboxNotifyStatusConverter;
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 jakarta.persistence.*; import jakarta.persistence.*;
@ -19,12 +20,12 @@ public class QueueOutboxEntity implements QueueOutbox {
public static final String _id = "id"; public static final String _id = "id";
@Column(name = "\"exchange\"", nullable = false, length = 50) @Column(name = "\"exchange\"", nullable = false, length = 200)
private String exchange; private String exchange;
public static final String _exchange = "exchange"; public static final String _exchange = "exchange";
@Column(name = "\"route\"", length = 50) @Column(name = "\"route\"", length = 200)
private String route; private String route;
public static final String _route = "route"; public static final String _route = "route";
@ -39,11 +40,10 @@ public class QueueOutboxEntity implements QueueOutbox {
public static final String _message = "message"; public static final String _message = "message";
@Column(name = "\"notify_status\"", length = 20, nullable = false) @Column(name = "\"notify_status\"", nullable = false)
@Enumerated(EnumType.STRING) @Convert(converter = QueueOutboxNotifyStatusConverter.class)
private QueueOutboxNotifyStatus notifyStatus; private QueueOutboxNotifyStatus notifyStatus;
public final static String _notifyStatus = "notifyStatus";
public static final String _notifyStatus = "notifyStatus";
@Column(name = "\"retry_count\"", nullable = false) @Column(name = "\"retry_count\"", nullable = false)
private Integer retryCount; private Integer retryCount;
@ -75,7 +75,7 @@ public class QueueOutboxEntity implements QueueOutbox {
public static final String _updatedAt = "updatedAt"; public static final String _updatedAt = "updatedAt";
@Column(name = "\"is_active\"", length = 20, nullable = false) @Column(name = "\"is_active\"", nullable = false)
@Convert(converter = IsActiveConverter.class) @Convert(converter = IsActiveConverter.class)
private IsActive isActive; private IsActive isActive;

View File

@ -0,0 +1,19 @@
package gr.cite.notification.data.conventers;
import gr.cite.queueinbox.entity.QueueInboxStatus;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class QueueInboxStatusConverter implements AttributeConverter<QueueInboxStatus, Short> {
@Override
public Short convertToDatabaseColumn(QueueInboxStatus value) {
if (value == null) throw new IllegalArgumentException("Value could not be null for: " + this.getClass().getSimpleName());
return value.getValue();
}
@Override
public QueueInboxStatus convertToEntityAttribute(Short dbData) {
return QueueInboxStatus.of(dbData);
}
}

View File

@ -0,0 +1,19 @@
package gr.cite.notification.data.conventers;
import gr.cite.queueoutbox.entity.QueueOutboxNotifyStatus;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class QueueOutboxNotifyStatusConverter implements AttributeConverter<QueueOutboxNotifyStatus, Short> {
@Override
public Short convertToDatabaseColumn(QueueOutboxNotifyStatus value) {
if (value == null) throw new IllegalArgumentException("Value could not be null for: " + this.getClass().getSimpleName());
return value.getValue();
}
@Override
public QueueOutboxNotifyStatus convertToEntityAttribute(Short dbData) {
return QueueOutboxNotifyStatus.of(dbData);
}
}

View File

@ -29,8 +29,6 @@ public class User {
public static final String _hash = "hash"; public static final String _hash = "hash";
private String hash; private String hash;
public static final String _tenantUsers = "tenantUsers";
public UUID getId() { public UUID getId() {
return id; return id;
} }

View File

@ -1,6 +1,7 @@
package gr.cite.notification.model.censorship; package gr.cite.notification.model.censorship;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.notification.authorization.OwnedResource;
import gr.cite.notification.authorization.Permission; import gr.cite.notification.authorization.Permission;
import gr.cite.notification.convention.ConventionService; import gr.cite.notification.convention.ConventionService;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
@ -12,6 +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 java.util.List;
import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class InAppNotificationCensor extends BaseCensor { public class InAppNotificationCensor extends BaseCensor {
@ -24,9 +28,9 @@ public class InAppNotificationCensor extends BaseCensor {
this.authService = authService; this.authService = authService;
} }
public void censor(FieldSet fields) { public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (this.isEmpty(fields)) return; if (this.isEmpty(fields)) return;
this.authService.authorizeForce(Permission.BrowseInAppNotification); this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseInAppNotification);
} }
} }

View File

@ -43,8 +43,5 @@ public class UserCensor extends BaseCensor {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (this.isEmpty(fields)) return; if (this.isEmpty(fields)) return;
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUser); this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUser);
FieldSet tenantUsersFields = fields.extractPrefixed(this.asIndexerPrefix(User._tenantUsers));
//FieldSet indicatorAccessesFields = fields.extractPrefixed(this.asIndexerPrefix(User._indicatorAccesses));
//this.censorFactory.censor(IndicatorAccessCensor.class).censor(indicatorAccessesFields, userId);
} }
} }

View File

@ -1,6 +1,7 @@
package gr.cite.notification.model.censorship; package gr.cite.notification.model.censorship;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.notification.authorization.OwnedResource;
import gr.cite.notification.authorization.Permission; import gr.cite.notification.authorization.Permission;
import gr.cite.notification.convention.ConventionService; import gr.cite.notification.convention.ConventionService;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
@ -12,6 +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 java.util.List;
import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class UserNotificationPreferenceCensor extends BaseCensor { public class UserNotificationPreferenceCensor extends BaseCensor {
@ -24,9 +28,9 @@ public class UserNotificationPreferenceCensor extends BaseCensor {
this.authService = authService; this.authService = authService;
} }
public void censor(FieldSet fields) { public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (this.isEmpty(fields)) return; if (this.isEmpty(fields)) return;
this.authService.authorizeForce(Permission.BrowseUserNotificationPreference); this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUserNotificationPreference);
} }
} }

View File

@ -3,6 +3,7 @@ package gr.cite.notification.service.inappnotification;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.notification.authorization.Permission; import gr.cite.notification.authorization.Permission;
import gr.cite.notification.common.enums.NotificationInAppTracking; import gr.cite.notification.common.enums.NotificationInAppTracking;
import gr.cite.notification.common.scope.user.UserScope;
import gr.cite.notification.data.InAppNotificationEntity; import gr.cite.notification.data.InAppNotificationEntity;
import gr.cite.notification.data.TenantScopedEntityManager; import gr.cite.notification.data.TenantScopedEntityManager;
import gr.cite.notification.model.deleter.InAppNotificationDeleter; import gr.cite.notification.model.deleter.InAppNotificationDeleter;
@ -36,13 +37,15 @@ public class InAppNotificationServiceImpl implements InAppNotificationService {
private final AuthorizationService authService; private final AuthorizationService authService;
private final DeleterFactory deleterFactory; private final DeleterFactory deleterFactory;
private final UserScope userScope;
@Autowired @Autowired
public InAppNotificationServiceImpl(QueryFactory queryFactory, TenantScopedEntityManager entityManager, AuthorizationService authService, DeleterFactory deleterFactory) { public InAppNotificationServiceImpl(QueryFactory queryFactory, TenantScopedEntityManager entityManager, AuthorizationService authService, DeleterFactory deleterFactory, UserScope userScope) {
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.entityManager = entityManager; this.entityManager = entityManager;
this.authService = authService; this.authService = authService;
this.deleterFactory = deleterFactory; this.deleterFactory = deleterFactory;
this.userScope = userScope;
} }
public void markAsRead(UUID id) { public void markAsRead(UUID id) {
@ -52,9 +55,10 @@ public class InAppNotificationServiceImpl implements InAppNotificationService {
public void markAsRead(List<UUID> ids) { public void markAsRead(List<UUID> ids) {
try { try {
logger.debug(new DataLogEntry("marking as read in-app notifications", ids)); logger.debug(new DataLogEntry("marking as read in-app notifications", ids));
UUID userId = this.userScope.getUserId();
List<InAppNotificationEntity> items = this.queryFactory.query(InAppNotificationQuery.class) List<InAppNotificationEntity> items = this.queryFactory.query(InAppNotificationQuery.class)
.ids(ids) .ids(ids)
.userId(userId)
.collect(); .collect();
Instant now = Instant.now(); Instant now = Instant.now();

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.2</version> <version>3.2.1</version>
</parent> </parent>
<modules> <modules>
@ -136,18 +136,18 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>rabbitmq-core</artifactId> <artifactId>rabbitmq-core</artifactId>
<version>2.1.1</version> <version>2.1.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>queue-inbox</artifactId> <artifactId>queue-inbox</artifactId>
<version>1.0.0</version> <version>2.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>queue-outbox</artifactId> <artifactId>queue-outbox</artifactId>
<version>1.0.0</version> <version>2.1.1</version>
</dependency> </dependency>
<dependency> <dependency>