From 26bdabe03b95f1454ea2045040c21e3795f58e45 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Fri, 19 Apr 2024 15:34:07 +0300 Subject: [PATCH] add tenant configuration --- .../eu/eudat/authorization/Permission.java | 5 + .../enums/TenantConfigurationType.java | 33 +++++ .../types/deposit/DepositSourceEntity.java | 77 +++++++++++ .../FileTransformerSourceEntity.java | 59 ++++++++ .../CssColorsTenantConfigurationEntity.java | 40 ++++++ ...ltUserLocaleTenantConfigurationEntity.java | 32 +++++ .../DepositTenantConfigurationEntity.java | 17 +++ ...eTransformerTenantConfigurationEntity.java | 18 +++ .../LogoTenantConfigurationEntity.java | 15 ++ .../eudat/data/TenantConfigurationEntity.java | 92 +++++++++++++ .../TenantConfigurationTypeConverter.java | 11 ++ .../deposit/DepositSourceCensor.java | 38 ++++++ .../FileTransformerSourceCensor.java | 40 ++++++ .../CssColorsTenantConfigurationCensor.java | 38 ++++++ ...ltUserLocaleTenantConfigurationCensor.java | 38 ++++++ .../DepositTenantConfigurationCensor.java | 47 +++++++ ...eTransformerTenantConfigurationCensor.java | 50 +++++++ .../LogoTenantConfigurationCensor.java | 38 ++++++ .../TenantConfigurationCensor.java | 60 ++++++++ .../eu/eudat/model/deposit/DepositSource.java | 85 ++++++++++++ .../FileTransformerSource.java | 65 +++++++++ .../CssColorsTenantConfiguration.java | 44 ++++++ .../DefaultUserLocaleTenantConfiguration.java | 35 +++++ .../DepositTenantConfiguration.java | 18 +++ .../FileTransformerTenantConfiguration.java | 19 +++ .../LogoTenantConfiguration.java | 16 +++ .../TenantConfiguration.java | 129 ++++++++++++++++++ .../service/deposit/DepositProperties.java | 84 +----------- .../service/deposit/DepositServiceImpl.java | 11 +- .../description/DescriptionServiceImpl.java | 3 +- .../eu/eudat/service/dmp/DmpServiceImpl.java | 2 +- .../FileTransformerCacheOptions.java | 2 +- .../FileTransformerConfiguration.java | 2 +- .../FileTransformerConfigurationCache.java | 2 +- .../FileTransformerProperties.java | 20 +++ .../FileTransformerRepository.java | 2 +- .../FileTransformerService.java | 3 +- .../FileTransformerServiceImpl.java | 5 +- .../FileTransformerProperties.java | 65 --------- .../FileTransformerController.java | 2 +- .../src/main/resources/config/permissions.yml | 20 +++ ...uration_add_tenant_configuration_table.sql | 25 ++++ 42 files changed, 1245 insertions(+), 162 deletions(-) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/commons/enums/TenantConfigurationType.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/commons/types/deposit/DepositSourceEntity.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/commons/types/filetransformer/FileTransformerSourceEntity.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/CssColorsTenantConfigurationEntity.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/DefaultUserLocaleTenantConfigurationEntity.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/DepositTenantConfigurationEntity.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/FileTransformerTenantConfigurationEntity.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/LogoTenantConfigurationEntity.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/data/TenantConfigurationEntity.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/TenantConfigurationTypeConverter.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/censorship/deposit/DepositSourceCensor.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/censorship/filetransformer/FileTransformerSourceCensor.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/CssColorsTenantConfigurationCensor.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/DefaultUserLocaleTenantConfigurationCensor.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/DepositTenantConfigurationCensor.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/FileTransformerTenantConfigurationCensor.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/LogoTenantConfigurationCensor.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/TenantConfigurationCensor.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/deposit/DepositSource.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/filetransformer/FileTransformerSource.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/CssColorsTenantConfiguration.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/DefaultUserLocaleTenantConfiguration.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/DepositTenantConfiguration.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/FileTransformerTenantConfiguration.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/LogoTenantConfiguration.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/TenantConfiguration.java rename dmp-backend/core/src/main/java/eu/eudat/service/{transformer => filetransformer}/FileTransformerCacheOptions.java (85%) rename dmp-backend/core/src/main/java/eu/eudat/service/{transformer => filetransformer}/FileTransformerConfiguration.java (87%) rename dmp-backend/core/src/main/java/eu/eudat/service/{transformer => filetransformer}/FileTransformerConfigurationCache.java (93%) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerProperties.java rename dmp-backend/core/src/main/java/eu/eudat/service/{transformer => filetransformer}/FileTransformerRepository.java (98%) rename dmp-backend/core/src/main/java/eu/eudat/service/{transformer => filetransformer}/FileTransformerService.java (81%) rename dmp-backend/core/src/main/java/eu/eudat/service/{transformer => filetransformer}/FileTransformerServiceImpl.java (97%) delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerProperties.java create mode 100644 dmp-db-scema/updates/TenantConfiguration_add_tenant_configuration_table.sql diff --git a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java index ce571ec85..ce33da9b4 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java +++ b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java @@ -168,6 +168,11 @@ public final class Permission { public static String DeleteTenant = "DeleteTenant"; public static String AllowNoTenant = "AllowNoTenant"; + //TenantConfiguration + public static String BrowseTenantConfiguration = "BrowseTenantConfiguration"; + public static String EditTenantConfiguration = "EditTenantConfiguration"; + public static String DeleteTenantConfiguration = "DeleteTenantConfiguration"; + //TenantUser public static String BrowseTenantUser = "BrowseTenantUser"; public static String EditTenantUser = "EditTenantUser"; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/TenantConfigurationType.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/TenantConfigurationType.java new file mode 100644 index 000000000..b2dc07f5e --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/TenantConfigurationType.java @@ -0,0 +1,33 @@ +package eu.eudat.commons.enums; + +import com.fasterxml.jackson.annotation.JsonValue; +import eu.eudat.data.converters.enums.DatabaseEnum; + +import java.util.Map; + +public enum TenantConfigurationType implements DatabaseEnum { + + DepositPlugins((short) 0), + FileTransformerPlugins((short) 1), + DefaultUserLocale((short) 2), + Logo((short) 3), + CssColors((short) 4); + + private final Short value; + + TenantConfigurationType(Short value) { + this.value = value; + } + + @JsonValue + public Short getValue() { + return value; + } + + private static final Map map = EnumUtils.getEnumValueMap(TenantConfigurationType.class); + + public static TenantConfigurationType of(Short i) { + return map.get(i); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/deposit/DepositSourceEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/deposit/DepositSourceEntity.java new file mode 100644 index 000000000..f9ddc9815 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/deposit/DepositSourceEntity.java @@ -0,0 +1,77 @@ +package eu.eudat.commons.types.deposit; + +public class DepositSourceEntity { + + private String repositoryId; + private String url; + private String issuerUrl; + private String clientId; + private String clientSecret; + private String scope; + private String pdfTransformerId; + private String rdaTransformerId; + + public String getRepositoryId() { + return repositoryId; + } + + public void setRepositoryId(String repositoryId) { + this.repositoryId = repositoryId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getIssuerUrl() { + return issuerUrl; + } + + public void setIssuerUrl(String issuerUrl) { + this.issuerUrl = issuerUrl; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getPdfTransformerId() { + return pdfTransformerId; + } + + public void setPdfTransformerId(String pdfTransformerId) { + this.pdfTransformerId = pdfTransformerId; + } + + public String getRdaTransformerId() { + return rdaTransformerId; + } + + public void setRdaTransformerId(String rdaTransformerId) { + this.rdaTransformerId = rdaTransformerId; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/filetransformer/FileTransformerSourceEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/filetransformer/FileTransformerSourceEntity.java new file mode 100644 index 000000000..e4e557c1a --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/filetransformer/FileTransformerSourceEntity.java @@ -0,0 +1,59 @@ +package eu.eudat.commons.types.filetransformer; + +public class FileTransformerSourceEntity { + + private String url; + private String transformerId; + private String issuerUrl; + private String clientId; + private String clientSecret; + private String scope; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getTransformerId() { + return transformerId; + } + + public void setTransformerId(String transformerId) { + this.transformerId = transformerId; + } + + public String getIssuerUrl() { + return issuerUrl; + } + + public void setIssuerUrl(String issuerUrl) { + this.issuerUrl = issuerUrl; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } +} \ No newline at end of file diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/CssColorsTenantConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/CssColorsTenantConfigurationEntity.java new file mode 100644 index 000000000..186e058b2 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/CssColorsTenantConfigurationEntity.java @@ -0,0 +1,40 @@ +package eu.eudat.commons.types.tenantconfiguration; + +public class CssColorsTenantConfigurationEntity { + private String primaryColor; + private String primaryColor2; + private String primaryColor3; + private String secondaryColor; + + public String getPrimaryColor() { + return primaryColor; + } + + public void setPrimaryColor(String primaryColor) { + this.primaryColor = primaryColor; + } + + public String getPrimaryColor2() { + return primaryColor2; + } + + public void setPrimaryColor2(String primaryColor2) { + this.primaryColor2 = primaryColor2; + } + + public String getPrimaryColor3() { + return primaryColor3; + } + + public void setPrimaryColor3(String primaryColor3) { + this.primaryColor3 = primaryColor3; + } + + public String getSecondaryColor() { + return secondaryColor; + } + + public void setSecondaryColor(String secondaryColor) { + this.secondaryColor = secondaryColor; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/DefaultUserLocaleTenantConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/DefaultUserLocaleTenantConfigurationEntity.java new file mode 100644 index 000000000..39c7ff53b --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/DefaultUserLocaleTenantConfigurationEntity.java @@ -0,0 +1,32 @@ +package eu.eudat.commons.types.tenantconfiguration; + +public class DefaultUserLocaleTenantConfigurationEntity { + private String timezone; + private String language; + private String culture; + + public String getTimezone() { + return timezone; + } + + public void setTimezone(String timezone) { + this.timezone = timezone; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public String getCulture() { + return culture; + } + + public void setCulture(String culture) { + this.culture = culture; + } +} + diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/DepositTenantConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/DepositTenantConfigurationEntity.java new file mode 100644 index 000000000..b6834ae24 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/DepositTenantConfigurationEntity.java @@ -0,0 +1,17 @@ +package eu.eudat.commons.types.tenantconfiguration; + +import eu.eudat.commons.types.deposit.DepositSourceEntity; + +import java.util.List; + +public class DepositTenantConfigurationEntity { + private List sources; + + public List getSources() { + return sources; + } + + public void setSources(List sources) { + this.sources = sources; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/FileTransformerTenantConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/FileTransformerTenantConfigurationEntity.java new file mode 100644 index 000000000..736d83c36 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/FileTransformerTenantConfigurationEntity.java @@ -0,0 +1,18 @@ +package eu.eudat.commons.types.tenantconfiguration; + +import eu.eudat.commons.types.filetransformer.FileTransformerSourceEntity; + +import java.util.List; + +public class FileTransformerTenantConfigurationEntity { + + private List sources; + + public List getSources() { + return sources; + } + + public void setSources(List sources) { + this.sources = sources; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/LogoTenantConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/LogoTenantConfigurationEntity.java new file mode 100644 index 000000000..542d0676c --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/tenantconfiguration/LogoTenantConfigurationEntity.java @@ -0,0 +1,15 @@ +package eu.eudat.commons.types.tenantconfiguration; + +import java.util.UUID; + +public class LogoTenantConfigurationEntity { + private UUID storageFileId; + + public UUID getStorageFileId() { + return storageFileId; + } + + public void setStorageFileId(UUID storageFileId) { + this.storageFileId = storageFileId; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/TenantConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/TenantConfigurationEntity.java new file mode 100644 index 000000000..0a32b3c8f --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/data/TenantConfigurationEntity.java @@ -0,0 +1,92 @@ +package eu.eudat.data; + + +import eu.eudat.commons.enums.IsActive; +import eu.eudat.commons.enums.TenantConfigurationType; +import eu.eudat.data.converters.enums.IsActiveConverter; +import eu.eudat.data.converters.enums.TenantConfigurationTypeConverter; +import eu.eudat.data.tenant.TenantScopedBaseEntity; +import jakarta.persistence.*; + +import java.time.Instant; +import java.util.UUID; + +@Entity +@Table(name = "\"TenantConfiguration\"") +public class TenantConfigurationEntity extends TenantScopedBaseEntity { + + @Id + @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID id; + public final static String _id = "id"; + + @Column(name = "value", nullable = false) + private String value; + public final static String _value = "value"; + + @Column(name = "type", nullable = false) + @Convert(converter = TenantConfigurationTypeConverter.class) + private TenantConfigurationType type; + public final static String _type = "type"; + + @Column(name = "is_active", nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; + public final static String _isActive = "isActive"; + + @Column(name = "created_at", nullable = false) + private Instant createdAt; + public final static String _createdAt = "createdAt"; + + @Column(name = "updated_at", nullable = false) + private Instant updatedAt; + public final static String _updatedAt = "updatedAt"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public TenantConfigurationType getType() { + return type; + } + + public void setType(TenantConfigurationType type) { + this.type = type; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/TenantConfigurationTypeConverter.java b/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/TenantConfigurationTypeConverter.java new file mode 100644 index 000000000..070c9a4bd --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/TenantConfigurationTypeConverter.java @@ -0,0 +1,11 @@ +package eu.eudat.data.converters.enums; + +import eu.eudat.commons.enums.TenantConfigurationType; +import jakarta.persistence.Converter; + +@Converter +public class TenantConfigurationTypeConverter extends DatabaseEnumConverter { + public TenantConfigurationType of(Short i) { + return TenantConfigurationType.of(i); + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/deposit/DepositSourceCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/deposit/DepositSourceCensor.java new file mode 100644 index 000000000..d364adb48 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/deposit/DepositSourceCensor.java @@ -0,0 +1,38 @@ +package eu.eudat.model.censorship.deposit; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DepositSourceCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositSourceCensor.class)); + + protected final AuthorizationService authService; + + + public DepositSourceCensor(ConventionService conventionService, AuthorizationService authService) { + super(conventionService); + this.authService = authService; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields == null || fields.isEmpty()) + return; + this.authService.authorize(Permission.BrowseTenantConfiguration); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/filetransformer/FileTransformerSourceCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/filetransformer/FileTransformerSourceCensor.java new file mode 100644 index 000000000..7bb07c2b6 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/filetransformer/FileTransformerSourceCensor.java @@ -0,0 +1,40 @@ +package eu.eudat.model.censorship.filetransformer; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +import eu.eudat.model.censorship.deposit.DepositSourceCensor; +import eu.eudat.model.tenantconfiguration.DepositTenantConfiguration; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class FileTransformerSourceCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerSourceCensor.class)); + + protected final AuthorizationService authService; + + + public FileTransformerSourceCensor(ConventionService conventionService, AuthorizationService authService) { + super(conventionService); + this.authService = authService; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields == null || fields.isEmpty()) + return; + this.authService.authorize(Permission.BrowseTenantConfiguration); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/CssColorsTenantConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/CssColorsTenantConfigurationCensor.java new file mode 100644 index 000000000..e002c50bf --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/CssColorsTenantConfigurationCensor.java @@ -0,0 +1,38 @@ +package eu.eudat.model.censorship.tenantconfiguration; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class CssColorsTenantConfigurationCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(CssColorsTenantConfigurationCensor.class)); + + protected final AuthorizationService authService; + + + public CssColorsTenantConfigurationCensor(ConventionService conventionService, AuthorizationService authService) { + super(conventionService); + this.authService = authService; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields == null || fields.isEmpty()) + return; + this.authService.authorize(Permission.BrowseTenantConfiguration); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/DefaultUserLocaleTenantConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/DefaultUserLocaleTenantConfigurationCensor.java new file mode 100644 index 000000000..444a4d376 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/DefaultUserLocaleTenantConfigurationCensor.java @@ -0,0 +1,38 @@ +package eu.eudat.model.censorship.tenantconfiguration; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DefaultUserLocaleTenantConfigurationCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DefaultUserLocaleTenantConfigurationCensor.class)); + + protected final AuthorizationService authService; + + + public DefaultUserLocaleTenantConfigurationCensor(ConventionService conventionService, AuthorizationService authService) { + super(conventionService); + this.authService = authService; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields == null || fields.isEmpty()) + return; + this.authService.authorize(Permission.BrowseTenantConfiguration); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/DepositTenantConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/DepositTenantConfigurationCensor.java new file mode 100644 index 000000000..ecf6261bb --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/DepositTenantConfigurationCensor.java @@ -0,0 +1,47 @@ +package eu.eudat.model.censorship.tenantconfiguration; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +import eu.eudat.model.censorship.deposit.DepositSourceCensor; +import eu.eudat.model.tenantconfiguration.DepositTenantConfiguration; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.censor.CensorFactory; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DepositTenantConfigurationCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositTenantConfigurationCensor.class)); + + protected final AuthorizationService authService; + + protected final CensorFactory censorFactory; + + + public DepositTenantConfigurationCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) { + super(conventionService); + this.authService = authService; + this.censorFactory = censorFactory; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields == null || fields.isEmpty()) + return; + this.authService.authorize(Permission.BrowseTenantConfiguration); + + FieldSet sourcesFields = fields.extractPrefixed(this.asIndexerPrefix(DepositTenantConfiguration._sources)); + this.censorFactory.censor(DepositSourceCensor.class).censor(sourcesFields, userId); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/FileTransformerTenantConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/FileTransformerTenantConfigurationCensor.java new file mode 100644 index 000000000..eab3fab5d --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/FileTransformerTenantConfigurationCensor.java @@ -0,0 +1,50 @@ +package eu.eudat.model.censorship.tenantconfiguration; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +import eu.eudat.model.censorship.deposit.DepositSourceCensor; +import eu.eudat.model.censorship.filetransformer.FileTransformerSourceCensor; +import eu.eudat.model.filetransformer.FileTransformerSource; +import eu.eudat.model.tenantconfiguration.DepositTenantConfiguration; +import eu.eudat.model.tenantconfiguration.FileTransformerTenantConfiguration; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.censor.CensorFactory; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class FileTransformerTenantConfigurationCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerTenantConfigurationCensor.class)); + + protected final AuthorizationService authService; + + protected final CensorFactory censorFactory; + + + public FileTransformerTenantConfigurationCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) { + super(conventionService); + this.authService = authService; + this.censorFactory = censorFactory; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields == null || fields.isEmpty()) + return; + this.authService.authorize(Permission.BrowseTenantConfiguration); + + FieldSet sourcesFields = fields.extractPrefixed(this.asIndexerPrefix(FileTransformerTenantConfiguration._sources)); + this.censorFactory.censor(FileTransformerSourceCensor.class).censor(sourcesFields, userId); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/LogoTenantConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/LogoTenantConfigurationCensor.java new file mode 100644 index 000000000..9976bd9b1 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/LogoTenantConfigurationCensor.java @@ -0,0 +1,38 @@ +package eu.eudat.model.censorship.tenantconfiguration; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class LogoTenantConfigurationCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LogoTenantConfigurationCensor.class)); + + protected final AuthorizationService authService; + + + public LogoTenantConfigurationCensor(ConventionService conventionService, AuthorizationService authService) { + super(conventionService); + this.authService = authService; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields == null || fields.isEmpty()) + return; + this.authService.authorize(Permission.BrowseTenantConfiguration); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/TenantConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/TenantConfigurationCensor.java new file mode 100644 index 000000000..d414fb73c --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/tenantconfiguration/TenantConfigurationCensor.java @@ -0,0 +1,60 @@ +package eu.eudat.model.censorship.tenantconfiguration; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.Description; +import eu.eudat.model.censorship.BaseCensor; +import eu.eudat.model.censorship.DescriptionReferenceCensor; +import eu.eudat.model.tenantconfiguration.TenantConfiguration; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.censor.CensorFactory; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class TenantConfigurationCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantConfigurationCensor.class)); + + protected final AuthorizationService authService; + + protected final CensorFactory censorFactory; + + + public TenantConfigurationCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) { + super(conventionService); + this.authService = authService; + this.censorFactory = censorFactory; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields == null || fields.isEmpty()) + return; + this.authService.authorize(Permission.BrowseTenantConfiguration); + + FieldSet cssColorsFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._cssColors)); + this.censorFactory.censor(CssColorsTenantConfigurationCensor.class).censor(cssColorsFields, userId); + + FieldSet defaultUserLocaleFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._defaultUserLocale)); + this.censorFactory.censor(DefaultUserLocaleTenantConfigurationCensor.class).censor(defaultUserLocaleFields, userId); + + FieldSet depositPluginsFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._depositPlugins)); + this.censorFactory.censor(DepositTenantConfigurationCensor.class).censor(depositPluginsFields, userId); + + FieldSet fileTransformerPluginsFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._fileTransformerPlugins)); + this.censorFactory.censor(FileTransformerTenantConfigurationCensor.class).censor(fileTransformerPluginsFields, userId); + + FieldSet logoFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._logo)); + this.censorFactory.censor(LogoTenantConfigurationCensor.class).censor(logoFields, userId); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/deposit/DepositSource.java b/dmp-backend/core/src/main/java/eu/eudat/model/deposit/DepositSource.java new file mode 100644 index 000000000..3cc3ec775 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/deposit/DepositSource.java @@ -0,0 +1,85 @@ +package eu.eudat.model.deposit; + +public class DepositSource { + + private String repositoryId; + public static final String _repositoryId = "repositoryId"; + private String url; + public static final String _url = "url"; + private String issuerUrl; + public static final String _issuerUrl = "issuerUrl"; + private String clientId; + public static final String _clientId = "clientId"; + private String clientSecret; + public static final String _clientSecret = "clientSecret"; + private String scope; + public static final String _scope = "scope"; + private String pdfTransformerId; + public static final String _pdfTransformerId = "pdfTransformerId"; + private String rdaTransformerId; + public static final String _rdaTransformerId = "rdaTransformerId"; + + public String getRepositoryId() { + return repositoryId; + } + + public void setRepositoryId(String repositoryId) { + this.repositoryId = repositoryId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getIssuerUrl() { + return issuerUrl; + } + + public void setIssuerUrl(String issuerUrl) { + this.issuerUrl = issuerUrl; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getPdfTransformerId() { + return pdfTransformerId; + } + + public void setPdfTransformerId(String pdfTransformerId) { + this.pdfTransformerId = pdfTransformerId; + } + + public String getRdaTransformerId() { + return rdaTransformerId; + } + + public void setRdaTransformerId(String rdaTransformerId) { + this.rdaTransformerId = rdaTransformerId; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/filetransformer/FileTransformerSource.java b/dmp-backend/core/src/main/java/eu/eudat/model/filetransformer/FileTransformerSource.java new file mode 100644 index 000000000..d0e2cf8a8 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/filetransformer/FileTransformerSource.java @@ -0,0 +1,65 @@ +package eu.eudat.model.filetransformer; + +public class FileTransformerSource { + + private String url; + public static final String _url = "url"; + private String transformerId; + public static final String _transformerId = "transformerId"; + private String issuerUrl; + public static final String _issuerUrl = "issuerUrl"; + private String clientId; + public static final String _clientId = "clientId"; + private String clientSecret; + public static final String _clientSecret = "clientSecret"; + private String scope; + public static final String _scope = "scope"; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getTransformerId() { + return transformerId; + } + + public void setTransformerId(String transformerId) { + this.transformerId = transformerId; + } + + public String getIssuerUrl() { + return issuerUrl; + } + + public void setIssuerUrl(String issuerUrl) { + this.issuerUrl = issuerUrl; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } +} \ No newline at end of file diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/CssColorsTenantConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/CssColorsTenantConfiguration.java new file mode 100644 index 000000000..3319586ac --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/CssColorsTenantConfiguration.java @@ -0,0 +1,44 @@ +package eu.eudat.model.tenantconfiguration; + +public class CssColorsTenantConfiguration { + private String primaryColor; + public static final String _primaryColor = "primaryColor"; + private String primaryColor2; + public static final String _primaryColor2 = "primaryColor2"; + private String primaryColor3; + public static final String _primaryColor3 = "primaryColor3"; + private String secondaryColor; + public static final String _secondaryColor = "secondaryColor"; + + public String getPrimaryColor() { + return primaryColor; + } + + public void setPrimaryColor(String primaryColor) { + this.primaryColor = primaryColor; + } + + public String getPrimaryColor2() { + return primaryColor2; + } + + public void setPrimaryColor2(String primaryColor2) { + this.primaryColor2 = primaryColor2; + } + + public String getPrimaryColor3() { + return primaryColor3; + } + + public void setPrimaryColor3(String primaryColor3) { + this.primaryColor3 = primaryColor3; + } + + public String getSecondaryColor() { + return secondaryColor; + } + + public void setSecondaryColor(String secondaryColor) { + this.secondaryColor = secondaryColor; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/DefaultUserLocaleTenantConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/DefaultUserLocaleTenantConfiguration.java new file mode 100644 index 000000000..9b7b257c0 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/DefaultUserLocaleTenantConfiguration.java @@ -0,0 +1,35 @@ +package eu.eudat.model.tenantconfiguration; + +public class DefaultUserLocaleTenantConfiguration { + private String timezone; + public static final String _timezone = "timezone"; + private String language; + public static final String _language = "language"; + private String culture; + public static final String _culture = "culture"; + + public String getTimezone() { + return timezone; + } + + public void setTimezone(String timezone) { + this.timezone = timezone; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public String getCulture() { + return culture; + } + + public void setCulture(String culture) { + this.culture = culture; + } +} + diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/DepositTenantConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/DepositTenantConfiguration.java new file mode 100644 index 000000000..05d39f986 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/DepositTenantConfiguration.java @@ -0,0 +1,18 @@ +package eu.eudat.model.tenantconfiguration; + +import eu.eudat.commons.types.deposit.DepositSourceEntity; + +import java.util.List; + +public class DepositTenantConfiguration { + private List sources; + public static final String _sources = "sources"; + + public List getSources() { + return sources; + } + + public void setSources(List sources) { + this.sources = sources; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/FileTransformerTenantConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/FileTransformerTenantConfiguration.java new file mode 100644 index 000000000..78a9b1a7a --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/FileTransformerTenantConfiguration.java @@ -0,0 +1,19 @@ +package eu.eudat.model.tenantconfiguration; + +import eu.eudat.commons.types.filetransformer.FileTransformerSourceEntity; + +import java.util.List; + +public class FileTransformerTenantConfiguration { + + private List sources; + public static final String _sources = "sources"; + + public List getSources() { + return sources; + } + + public void setSources(List sources) { + this.sources = sources; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/LogoTenantConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/LogoTenantConfiguration.java new file mode 100644 index 000000000..a65fa3e23 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/LogoTenantConfiguration.java @@ -0,0 +1,16 @@ +package eu.eudat.model.tenantconfiguration; + +import java.util.UUID; + +public class LogoTenantConfiguration { + private UUID storageFileId; + public static final String _storageFileId = "storageFileId"; + + public UUID getStorageFileId() { + return storageFileId; + } + + public void setStorageFileId(UUID storageFileId) { + this.storageFileId = storageFileId; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/TenantConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/TenantConfiguration.java new file mode 100644 index 000000000..28db7f8df --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/tenantconfiguration/TenantConfiguration.java @@ -0,0 +1,129 @@ +package eu.eudat.model.tenantconfiguration; + +import eu.eudat.commons.enums.IsActive; + +import java.time.Instant; +import java.util.UUID; + +public class TenantConfiguration { + + private UUID id; + + public static final String _id = "id"; + + private Instant createdAt; + + public static final String _createdAt = "createdAt"; + + private CssColorsTenantConfiguration cssColors; + + public static final String _cssColors = "cssColors"; + + private DefaultUserLocaleTenantConfiguration defaultUserLocale; + + public static final String _defaultUserLocale = "defaultUserLocale"; + + private DepositTenantConfiguration depositPlugins; + + public static final String _depositPlugins = "depositPlugins"; + + private FileTransformerTenantConfiguration fileTransformerPlugins; + + public static final String _fileTransformerPlugins = "fileTransformerPlugins"; + + private LogoTenantConfiguration logo; + + public static final String _logo = "logo"; + + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + private IsActive isActive; + + public static final String _isActive = "isActive"; + + private String hash; + + public static final String _hash = "hash"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public CssColorsTenantConfiguration getCssColors() { + return cssColors; + } + + public void setCssColors(CssColorsTenantConfiguration cssColors) { + this.cssColors = cssColors; + } + + public DefaultUserLocaleTenantConfiguration getDefaultUserLocale() { + return defaultUserLocale; + } + + public void setDefaultUserLocale(DefaultUserLocaleTenantConfiguration defaultUserLocale) { + this.defaultUserLocale = defaultUserLocale; + } + + public DepositTenantConfiguration getDepositPlugins() { + return depositPlugins; + } + + public void setDepositPlugins(DepositTenantConfiguration depositPlugins) { + this.depositPlugins = depositPlugins; + } + + public FileTransformerTenantConfiguration getFileTransformerPlugins() { + return fileTransformerPlugins; + } + + public void setFileTransformerPlugins(FileTransformerTenantConfiguration fileTransformerPlugins) { + this.fileTransformerPlugins = fileTransformerPlugins; + } + + public LogoTenantConfiguration getLogo() { + return logo; + } + + public void setLogo(LogoTenantConfiguration logo) { + this.logo = logo; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/deposit/DepositProperties.java b/dmp-backend/core/src/main/java/eu/eudat/service/deposit/DepositProperties.java index df8380189..926f194f9 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/deposit/DepositProperties.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/deposit/DepositProperties.java @@ -1,96 +1,20 @@ package eu.eudat.service.deposit; +import eu.eudat.commons.types.deposit.DepositSourceEntity; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.bind.ConstructorBinding; import java.util.List; @ConfigurationProperties(prefix = "deposit") public class DepositProperties { - private List sources; + private List sources; - public List getSources() { + public List getSources() { return sources; } - public void setSources(List sources) { + public void setSources(List sources) { this.sources = sources; } - - public static class DepositSource { - - private String repositoryId; - private String url; - private String issuerUrl; - private String clientId; - private String clientSecret; - private String scope; - private String pdfTransformerId; - private String rdaTransformerId; - - public String getRepositoryId() { - return repositoryId; - } - - public void setRepositoryId(String repositoryId) { - this.repositoryId = repositoryId; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getIssuerUrl() { - return issuerUrl; - } - - public void setIssuerUrl(String issuerUrl) { - this.issuerUrl = issuerUrl; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getClientSecret() { - return clientSecret; - } - - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - - public String getScope() { - return scope; - } - - public void setScope(String scope) { - this.scope = scope; - } - - public String getPdfTransformerId() { - return pdfTransformerId; - } - - public void setPdfTransformerId(String pdfTransformerId) { - this.pdfTransformerId = pdfTransformerId; - } - - public String getRdaTransformerId() { - return rdaTransformerId; - } - - public void setRdaTransformerId(String rdaTransformerId) { - this.rdaTransformerId = rdaTransformerId; - } - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/deposit/DepositServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/deposit/DepositServiceImpl.java index 50362a9a6..88f819479 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/deposit/DepositServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/deposit/DepositServiceImpl.java @@ -11,6 +11,7 @@ import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.StorageType; import eu.eudat.commons.notification.NotificationProperties; import eu.eudat.commons.scope.user.UserScope; +import eu.eudat.commons.types.deposit.DepositSourceEntity; import eu.eudat.commons.types.notification.*; import eu.eudat.convention.ConventionService; import eu.eudat.data.DmpEntity; @@ -36,7 +37,7 @@ import eu.eudat.query.UserQuery; import eu.eudat.service.entitydoi.EntityDoiService; import eu.eudat.service.storage.StorageFileProperties; import eu.eudat.service.storage.StorageFileService; -import eu.eudat.service.transformer.FileTransformerService; +import eu.eudat.service.filetransformer.FileTransformerService; import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction; @@ -121,7 +122,7 @@ public class DepositServiceImpl implements DepositService { if (this.clients.containsKey(repositoryId)) return this.clients.get(repositoryId); //GK: It's register time - DepositProperties.DepositSource source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(repositoryId)).findFirst().orElse(null); + DepositSourceEntity source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(repositoryId)).findFirst().orElse(null); if (source != null) { String host = URI.create(source.getUrl()).getHost(); TokenExchangeModel tokenExchangeModel = new TokenExchangeModel("deposit:" + source.getRepositoryId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope()); @@ -141,7 +142,7 @@ public class DepositServiceImpl implements DepositService { List configurations = new ArrayList<>(); - for (DepositProperties.DepositSource depositSource : depositProperties.getSources()) { + for (DepositSourceEntity depositSource : depositProperties.getSources()) { DepositConfigurationCacheService.DepositConfigurationCacheValue cacheValue = this.depositConfigurationCacheService.lookup(this.depositConfigurationCacheService.buildKey(depositSource.getRepositoryId())); if (cacheValue == null){ DepositClient depositClient = getDepositClient(depositSource.getRepositoryId()); @@ -171,8 +172,8 @@ public class DepositServiceImpl implements DepositService { //GK: Forth make the required files to be uploaded with the deposit //TODO: Properly create required files - DepositProperties.DepositSource source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(dmpDepositModel.getRepositoryId())).findFirst().orElse(null); - if (source == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositProperties.DepositSource.class.getSimpleName()}, LocaleContextHolder.getLocale())); + DepositSourceEntity source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(dmpDepositModel.getRepositoryId())).findFirst().orElse(null); + if (source == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositSourceEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); eu.eudat.model.file.FileEnvelope pdfFile = this.fileTransformerService.exportDmp(dmpEntity.getId(), source.getPdfTransformerId(),"pdf"); eu.eudat.model.file.FileEnvelope rda = this.fileTransformerService.exportDmp(dmpEntity.getId(), source.getRdaTransformerId(),"json"); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java index 9c4680484..c04eea681 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java @@ -7,7 +7,6 @@ import eu.eudat.authorization.authorizationcontentresolver.AuthorizationContentR import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.enums.*; -import eu.eudat.commons.enums.notification.NotificationContactType; import eu.eudat.commons.scope.tenant.TenantScope; import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.types.description.*; @@ -41,7 +40,7 @@ import eu.eudat.query.*; import eu.eudat.service.elastic.ElasticService; import eu.eudat.service.storage.StorageFileProperties; import eu.eudat.service.storage.StorageFileService; -import eu.eudat.service.transformer.FileTransformerService; +import eu.eudat.service.filetransformer.FileTransformerService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.deleter.DeleterFactory; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java index 22dfeedd7..8479db672 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java @@ -48,7 +48,7 @@ import eu.eudat.query.*; import eu.eudat.service.actionconfirmation.ActionConfirmationService; import eu.eudat.service.description.DescriptionService; import eu.eudat.service.elastic.ElasticService; -import eu.eudat.service.transformer.FileTransformerService; +import eu.eudat.service.filetransformer.FileTransformerService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.deleter.DeleterFactory; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerCacheOptions.java b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerCacheOptions.java similarity index 85% rename from dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerCacheOptions.java rename to dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerCacheOptions.java index 38418c19a..76dda8b8d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerCacheOptions.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerCacheOptions.java @@ -1,4 +1,4 @@ -package eu.eudat.service.transformer; +package eu.eudat.service.filetransformer; import gr.cite.tools.cache.CacheOptions; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerConfiguration.java similarity index 87% rename from dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerConfiguration.java index a1883020d..0fa778b50 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.service.transformer; +package eu.eudat.service.filetransformer; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerConfigurationCache.java b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerConfigurationCache.java similarity index 93% rename from dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerConfigurationCache.java rename to dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerConfigurationCache.java index 357f4b67b..e94258db8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerConfigurationCache.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerConfigurationCache.java @@ -1,4 +1,4 @@ -package eu.eudat.service.transformer; +package eu.eudat.service.filetransformer; import eu.eudat.model.file.TransformerCacheModel; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerProperties.java b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerProperties.java new file mode 100644 index 000000000..46a02e265 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerProperties.java @@ -0,0 +1,20 @@ +package eu.eudat.service.filetransformer; + +import eu.eudat.commons.types.filetransformer.FileTransformerSourceEntity; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.List; + +@ConfigurationProperties(prefix = "file-transformer") +public class FileTransformerProperties { + + private List sources; + + public List getSources() { + return sources; + } + + public void setSources(List sources) { + this.sources = sources; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerRepository.java b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerRepository.java similarity index 98% rename from dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerRepository.java rename to dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerRepository.java index 20c8ec800..bb7687a77 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerRepository.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerRepository.java @@ -1,4 +1,4 @@ -package eu.eudat.service.transformer; +package eu.eudat.service.filetransformer; import eu.eudat.commonmodels.models.FileEnvelopeModel; import eu.eudat.commonmodels.models.description.DescriptionModel; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerService.java b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerService.java similarity index 81% rename from dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerService.java rename to dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerService.java index 487bd4347..a238ee76d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerService.java @@ -1,6 +1,5 @@ -package eu.eudat.service.transformer; +package eu.eudat.service.filetransformer; -import eu.eudat.file.transformer.models.misc.FileFormat; import eu.eudat.model.file.RepositoryFileFormat; import java.util.List; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerServiceImpl.java similarity index 97% rename from dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerServiceImpl.java rename to dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerServiceImpl.java index de891407e..3ecc56270 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/filetransformer/FileTransformerServiceImpl.java @@ -1,4 +1,4 @@ -package eu.eudat.service.transformer; +package eu.eudat.service.filetransformer; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.Permission; @@ -6,6 +6,7 @@ import eu.eudat.commonmodels.models.FileEnvelopeModel; import eu.eudat.commonmodels.models.description.DescriptionModel; import eu.eudat.commonmodels.models.dmp.DmpModel; import eu.eudat.commons.enums.StorageType; +import eu.eudat.commons.types.filetransformer.FileTransformerSourceEntity; import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration; import eu.eudat.model.Description; import eu.eudat.model.Dmp; @@ -68,7 +69,7 @@ public class FileTransformerServiceImpl implements FileTransformerService { if (this.clients.containsKey(repoId)) return this.clients.get(repoId); //GK: It's register time - FileTransformerProperties.TransformerSource source = fileTransformerProperties.getSources().stream().filter(depositSource -> depositSource.getTransformerId().equals(repoId)).findFirst().orElse(null); + FileTransformerSourceEntity source = fileTransformerProperties.getSources().stream().filter(depositSource -> depositSource.getTransformerId().equals(repoId)).findFirst().orElse(null); if (source != null) { String host = URI.create(source.getUrl()).getHost(); TokenExchangeModel tokenExchangeModel = new TokenExchangeModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope()); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerProperties.java b/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerProperties.java deleted file mode 100644 index fdb7da2ba..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerProperties.java +++ /dev/null @@ -1,65 +0,0 @@ -package eu.eudat.service.transformer; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.bind.ConstructorBinding; - -import java.util.List; - -@ConfigurationProperties(prefix = "file-transformer") -public class FileTransformerProperties { - - private final List sources; - - @ConstructorBinding - public FileTransformerProperties(List sources) { - this.sources = sources; - } - - public List getSources() { - return sources; - } - - public static class TransformerSource { - - private final String url; - private final String transformerId; - private final String issuerUrl; - private final String clientId; - private final String clientSecret; - private final String scope; - - @ConstructorBinding - public TransformerSource(String url, String transformerId, String issuerUrl, String clientId, String clientSecret, String scope) { - this.url = url; - this.transformerId = transformerId; - this.issuerUrl = issuerUrl; - this.clientId = clientId; - this.clientSecret = clientSecret; - this.scope = scope; - } - - public String getUrl() { - return url; - } - - public String getIssuerUrl() { - return issuerUrl; - } - - public String getClientId() { - return clientId; - } - - public String getClientSecret() { - return clientSecret; - } - - public String getScope() { - return scope; - } - - public String getTransformerId() { - return transformerId; - } - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/FileTransformerController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/FileTransformerController.java index 524f2fc7c..894aab4c7 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/FileTransformerController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/FileTransformerController.java @@ -4,7 +4,7 @@ import eu.eudat.audit.AuditableAction; import eu.eudat.model.file.ExportRequestModel; import eu.eudat.model.file.FileEnvelope; import eu.eudat.model.file.RepositoryFileFormat; -import eu.eudat.service.transformer.FileTransformerService; +import eu.eudat.service.filetransformer.FileTransformerService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; diff --git a/dmp-backend/web/src/main/resources/config/permissions.yml b/dmp-backend/web/src/main/resources/config/permissions.yml index 8900eb771..d2007ee8b 100644 --- a/dmp-backend/web/src/main/resources/config/permissions.yml +++ b/dmp-backend/web/src/main/resources/config/permissions.yml @@ -135,6 +135,26 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false + # TenantConfiguration + BrowseTenantConfiguration: + roles: + - TenantAdmin + claims: [ ] + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + EditTenantConfiguration: + roles: + - TenantAdmin + clients: [ ] + allowAnonymous: true + allowAuthenticated: true + DeleteTenantConfiguration: + roles: + - TenantAdmin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false # Language BrowseLanguage: roles: [ ] diff --git a/dmp-db-scema/updates/TenantConfiguration_add_tenant_configuration_table.sql b/dmp-db-scema/updates/TenantConfiguration_add_tenant_configuration_table.sql new file mode 100644 index 000000000..18eb96889 --- /dev/null +++ b/dmp-db-scema/updates/TenantConfiguration_add_tenant_configuration_table.sql @@ -0,0 +1,25 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.063'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + CREATE TABLE public."TenantConfiguration" + ( + id uuid NOT NULL, + value character varying NOT NULL, + type smallint NOT NULL, + is_active smallint NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + tenant uuid, + PRIMARY KEY (id), + FOREIGN KEY (tenant) + REFERENCES public."Tenant" (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION + NOT VALID + ); + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.063', '2024-04-19 12:00:00.000000+02', now(), 'Add TenantConfiguration Table.'); + +END$$; \ No newline at end of file