tenant scope implementation

This commit is contained in:
Efstratios Giannopoulos 2024-04-01 18:36:03 +03:00
parent f4bf80aeb5
commit 9acc26667b
133 changed files with 1713 additions and 298 deletions

View File

@ -147,6 +147,7 @@ public class AuditableAction {
public static final EventId Maintenance_ClearElastic = new EventId(230000, "Maintenance_ClearElastic"); public static final EventId Maintenance_ClearElastic = new EventId(230000, "Maintenance_ClearElastic");
public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup"); public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup");
public static final EventId Principal_MyTenants = new EventId(240001, "Principal_MyTenants");
public static final EventId GetSemantics = new EventId(250000, "GetSemantics"); public static final EventId GetSemantics = new EventId(250000, "GetSemantics");

View File

@ -23,6 +23,7 @@ public final class Permission {
//Elastic //Elastic
public static String ManageElastic = "ManageElastic"; public static String ManageElastic = "ManageElastic";
//Deposit //Deposit
public static String BrowseDeposit = "BrowseDeposit"; public static String BrowseDeposit = "BrowseDeposit";
public static String EditDeposit = "BrowseDeposit"; public static String EditDeposit = "BrowseDeposit";

View File

@ -15,7 +15,7 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@Component @Component
//@RequestScope @RequestScope
public class TenantScope { public class TenantScope {
public static final String TenantReplaceParameter = "::TenantCode::"; public static final String TenantReplaceParameter = "::TenantCode::";
public static final String TenantCodesClaimName = "TenantCodes"; public static final String TenantCodesClaimName = "TenantCodes";

View File

@ -1,8 +1,11 @@
package eu.eudat.commons.scope.tenant; package eu.eudat.commons.scope.tenant;
import java.beans.Transient;
import java.util.UUID; import java.util.UUID;
public interface TenantScoped { public interface TenantScoped {
void setTenantId(UUID tenantId); void setTenantId(UUID tenantId);
UUID getTenantId(); UUID getTenantId();
@Transient
boolean allowNullTenant();
} }

View File

@ -140,4 +140,10 @@ public class ActionConfirmationEntity extends TenantScopedBaseEntity {
public void setIsActive(IsActive isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -188,5 +188,11 @@ public class DescriptionEntity extends TenantScopedBaseEntity {
public void setDescriptionTemplateId(UUID descriptionTemplateId) { public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId; this.descriptionTemplateId = descriptionTemplateId;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -104,4 +104,10 @@ public class DescriptionReferenceEntity extends TenantScopedBaseEntity {
public void setData(String data) { public void setData(String data) {
this.data = data; this.data = data;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -92,4 +92,10 @@ public class DescriptionTagEntity extends TenantScopedBaseEntity {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -162,4 +162,10 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity {
public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) { public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) {
this.versionStatus = versionStatus; this.versionStatus = versionStatus;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -95,4 +95,10 @@ public class DescriptionTemplateTypeEntity extends TenantScopedBaseEntity {
public void setStatus(DescriptionTemplateTypeStatus status) { public void setStatus(DescriptionTemplateTypeStatus status) {
this.status = status; this.status = status;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -154,4 +154,10 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity {
public void setIsActive(IsActive isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -104,4 +104,10 @@ public class DmpDescriptionTemplateEntity extends TenantScopedBaseEntity {
public void setIsActive(IsActive isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -244,4 +244,10 @@ public class DmpEntity extends TenantScopedBaseEntity {
public void setVersionStatus(DmpVersionStatus versionStatus) { public void setVersionStatus(DmpVersionStatus versionStatus) {
this.versionStatus = versionStatus; this.versionStatus = versionStatus;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -97,4 +97,10 @@ public class DmpReferenceEntity extends TenantScopedBaseEntity {
public void setIsActive(IsActive isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -119,4 +119,10 @@ public class DmpUserEntity extends TenantScopedBaseEntity {
public void setIsActive(IsActive isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -121,4 +121,10 @@ public class EntityDoiEntity extends TenantScopedBaseEntity {
this.entityId = entityId; this.entityId = entityId;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -98,4 +98,10 @@ public class LanguageEntity extends TenantScopedBaseEntity {
public void setOrdinal(Integer ordinal) { public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal; this.ordinal = ordinal;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -87,4 +87,10 @@ public class LockEntity extends TenantScopedBaseEntity {
public void setTouchedAt(Instant touchedAt) { public void setTouchedAt(Instant touchedAt) {
this.touchedAt = touchedAt; this.touchedAt = touchedAt;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -89,4 +89,10 @@ public class PrefillingSourceEntity extends TenantScopedBaseEntity {
public void setUpdatedAt(Instant updatedAt) { public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -204,4 +204,10 @@ public class ReferenceEntity extends TenantScopedBaseEntity {
this.createdById = createdById; this.createdById = createdById;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -108,4 +108,10 @@ public class ReferenceTypeEntity extends TenantScopedBaseEntity {
public void setUpdatedAt(Instant updatedAt) { public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -139,4 +139,10 @@ public class StorageFileEntity extends TenantScopedBaseEntity {
public void setOwnerId(UUID ownerId) { public void setOwnerId(UUID ownerId) {
this.ownerId = ownerId; this.ownerId = ownerId;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -101,4 +101,10 @@ public class SupportiveMaterialEntity extends TenantScopedBaseEntity {
public void setIsActive(IsActive isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -86,4 +86,10 @@ public class TagEntity extends TenantScopedBaseEntity {
public void setCreatedById(UUID createdById) { public void setCreatedById(UUID createdById) {
this.createdById = createdById; this.createdById = createdById;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -21,15 +21,12 @@ import java.util.UUID;
public class TenantEntityManager { public class TenantEntityManager {
@PersistenceContext @PersistenceContext
private EntityManager entityManager; private EntityManager entityManager;
private final CurrentPrincipalResolver currentPrincipalResolver; // private final CurrentPrincipalResolver currentPrincipalResolver;
private final ClaimExtractor claimExtractor; // private final ClaimExtractor claimExtractor;
private final AuthorizationService authorizationService; // private final AuthorizationService authorizationService;
private final TenantScope tenantScope; private final TenantScope tenantScope;
public TenantEntityManager(CurrentPrincipalResolver currentPrincipalResolver, ClaimExtractor claimExtractor, AuthorizationService authorizationService, TenantScope tenantScope) { public TenantEntityManager(TenantScope tenantScope) {
this.currentPrincipalResolver = currentPrincipalResolver;
this.claimExtractor = claimExtractor;
this.authorizationService = authorizationService;
this.tenantScope = tenantScope; this.tenantScope = tenantScope;
} }
@ -40,10 +37,11 @@ public class TenantEntityManager {
public <T> T merge(T entity) throws InvalidApplicationException { public <T> T merge(T entity) throws InvalidApplicationException {
if (tenantScope.isMultitenant() && (entity instanceof TenantScoped)) { if (tenantScope.isMultitenant() && (entity instanceof TenantScoped)) {
this.currentPrincipalResolver.currentPrincipal().isAuthenticated(); // this.currentPrincipalResolver.currentPrincipal().isAuthenticated();
this.claimExtractor.subjectUUID(this.currentPrincipalResolver.currentPrincipal()); // this.claimExtractor.subjectUUID(this.currentPrincipalResolver.currentPrincipal());
boolean isAllowedNoTenant = authorizationService.authorize(Permission.AllowNoTenant); // boolean isAllowedNoTenant = authorizationService.authorize(Permission.AllowNoTenant);
boolean isAllowedNoTenant = ((TenantScoped) entity).allowNullTenant();
final UUID tenantId = !isAllowedNoTenant ? tenantScope.getTenant() : null; final UUID tenantId = !isAllowedNoTenant ? tenantScope.getTenant() : null;
if (!isAllowedNoTenant && !tenantId.equals(((TenantScoped) entity).getTenantId())) throw new MyForbiddenException("tenant tampering"); if (!isAllowedNoTenant && !tenantId.equals(((TenantScoped) entity).getTenantId())) throw new MyForbiddenException("tenant tampering");
} }
@ -52,8 +50,9 @@ public class TenantEntityManager {
public void remove(Object entity) throws InvalidApplicationException { public void remove(Object entity) throws InvalidApplicationException {
if (tenantScope.isMultitenant() && (entity instanceof TenantScoped)) { if (tenantScope.isMultitenant() && (entity instanceof TenantScoped)) {
final UUID tenantId = tenantScope.getTenant(); boolean isAllowedNoTenant = ((TenantScoped) entity).allowNullTenant();
if (!tenantId.equals(((TenantScoped) entity).getTenantId())) throw new MyForbiddenException("tenant tampering"); final UUID tenantId = !isAllowedNoTenant ? tenantScope.getTenant() : null;
if (!isAllowedNoTenant && !tenantId.equals(((TenantScoped) entity).getTenantId())) throw new MyForbiddenException("tenant tampering");
} }
this.entityManager.remove(entity); this.entityManager.remove(entity);
} }
@ -62,10 +61,11 @@ public class TenantEntityManager {
T entity = this.entityManager.find(entityClass, primaryKey); T entity = this.entityManager.find(entityClass, primaryKey);
if (tenantScope.isMultitenant() && (entity instanceof TenantScoped)) { if (tenantScope.isMultitenant() && (entity instanceof TenantScoped)) {
this.currentPrincipalResolver.currentPrincipal().isAuthenticated(); // this.currentPrincipalResolver.currentPrincipal().isAuthenticated();
this.claimExtractor.subjectUUID(this.currentPrincipalResolver.currentPrincipal()); // this.claimExtractor.subjectUUID(this.currentPrincipalResolver.currentPrincipal());
boolean isAllowedNoTenant = authorizationService.authorize(Permission.AllowNoTenant); // boolean isAllowedNoTenant = authorizationService.authorize(Permission.AllowNoTenant);
boolean isAllowedNoTenant = ((TenantScoped) entity).allowNullTenant();
final UUID tenantId = !isAllowedNoTenant ? tenantScope.getTenant() : null; final UUID tenantId = !isAllowedNoTenant ? tenantScope.getTenant() : null;
if (!isAllowedNoTenant && !tenantId.equals(((TenantScoped) entity).getTenantId())) return null; if (!isAllowedNoTenant && !tenantId.equals(((TenantScoped) entity).getTenantId())) return null;
} }

View File

@ -2,13 +2,14 @@ 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.tenant.TenantScopedBaseEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"TenantUser\"") @Table(name = "\"TenantUser\"")
public class TenantUserEntity { public class TenantUserEntity extends TenantScopedBaseEntity {
@Id @Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id; private UUID id;
@ -82,4 +83,10 @@ public class TenantUserEntity {
public void setUpdatedAt(Instant updatedAt) { public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
@Override
@Transient
public boolean allowNullTenant() {
return false;
}
} }

View File

@ -10,7 +10,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"UserContactInfo\"") @Table(name = "\"UserContactInfo\"")
public class UserContactInfoEntity extends TenantScopedBaseEntity { public class UserContactInfoEntity {
@Id @Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)

View File

@ -11,7 +11,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"UserCredential\"") @Table(name = "\"UserCredential\"")
public class UserCredentialEntity extends TenantScopedBaseEntity { public class UserCredentialEntity {
@Id @Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)

View File

@ -100,4 +100,10 @@ public class UserDescriptionTemplateEntity extends TenantScopedBaseEntity {
public void setRole(UserDescriptionTemplateRole role) { public void setRole(UserDescriptionTemplateRole role) {
this.role = role; this.role = role;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -1,10 +1,7 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.data.tenant.TenantScopedBaseEntity; import eu.eudat.data.tenant.TenantScopedBaseEntity;
import jakarta.persistence.Column; import jakarta.persistence.*;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
@ -64,4 +61,10 @@ public class UserRoleEntity extends TenantScopedBaseEntity {
this.createdAt = createdAt; this.createdAt = createdAt;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -109,4 +109,10 @@ public class UserSettingsEntity extends TenantScopedBaseEntity {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
@Override
@Transient
public boolean allowNullTenant() {
return true;
}
} }

View File

@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
//@Aspect @Aspect
@Component @Component
public class TenantFilterAspect { public class TenantFilterAspect {

View File

@ -29,8 +29,14 @@ public class TenantListener {
@PrePersist @PrePersist
public void setTenantOnCreate(TenantScoped entity) throws InvalidApplicationException { public void setTenantOnCreate(TenantScoped entity) throws InvalidApplicationException {
if (tenantScope.isMultitenant()) { if (tenantScope.isMultitenant()) {
if (entity.getTenantId() != null && entity.getTenantId().compareTo(tenantScope.getTenant()) != 0) {
logger.error("somebody tried to set not login tenat");
throw new MyForbiddenException("tenant tampering");
}
if (!entity.allowNullTenant()) {
final UUID tenantId = tenantScope.getTenant(); final UUID tenantId = tenantScope.getTenant();
entity.setTenantId(tenantId); entity.setTenantId(tenantId);
}
} else { } else {
entity.setTenantId(null); entity.setTenantId(null);
} }
@ -40,6 +46,7 @@ public class TenantListener {
@PreRemove @PreRemove
public void setTenantOnUpdate(TenantScoped entity) throws InvalidApplicationException { public void setTenantOnUpdate(TenantScoped entity) throws InvalidApplicationException {
if (tenantScope.isMultitenant()) { if (tenantScope.isMultitenant()) {
if (!entity.allowNullTenant()){
if (entity.getTenantId() == null) { if (entity.getTenantId() == null) {
logger.error("somebody tried to set null tenant"); logger.error("somebody tried to set null tenant");
throw new MyForbiddenException("tenant tampering"); throw new MyForbiddenException("tenant tampering");
@ -51,6 +58,14 @@ public class TenantListener {
final UUID tenantId = tenantScope.getTenant(); final UUID tenantId = tenantScope.getTenant();
entity.setTenantId(tenantId); entity.setTenantId(tenantId);
} else {
if (entity.getTenantId() != null && entity.getTenantId().compareTo(tenantScope.getTenant()) != 0) {
logger.error("somebody tried to change an entries tenant");
throw new MyForbiddenException("tenant tampering");
}
}
} else { } else {
if (entity.getTenantId() != null) { if (entity.getTenantId() != null) {
logger.error("somebody tried to set non null tenant"); logger.error("somebody tried to set non null tenant");

View File

@ -15,8 +15,8 @@ import java.util.UUID;
//@Setter //@Setter
//@NoArgsConstructor //@NoArgsConstructor
@FilterDef(name = TenantScopedBaseEntity.tenantFilter, parameters = {@ParamDef(name = TenantScopedBaseEntity.tenantFilterTenantParam, type = String.class)}) @FilterDef(name = TenantScopedBaseEntity.tenantFilter, parameters = {@ParamDef(name = TenantScopedBaseEntity.tenantFilterTenantParam, type = String.class)})
@Filter(name = "tenantFilter", condition = "tenant = (cast(:tenantId as uuid))") @Filter(name = "tenantFilter", condition = "(tenant = (cast(:tenantId as uuid)) or tenant is null)")
//@EntityListeners(TenantListener.class) @EntityListeners(TenantListener.class)
public abstract class TenantScopedBaseEntity implements TenantScoped, Serializable { public abstract class TenantScopedBaseEntity implements TenantScoped, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static final String tenantFilter = "tenantFilter"; public static final String tenantFilter = "tenantFilter";

View File

@ -144,4 +144,24 @@ public class ErrorThesaurusProperties {
public void setDmpDescriptionTemplateCanNotRemove(ErrorDescription dmpDescriptionTemplateCanNotRemove) { public void setDmpDescriptionTemplateCanNotRemove(ErrorDescription dmpDescriptionTemplateCanNotRemove) {
this.dmpDescriptionTemplateCanNotRemove = dmpDescriptionTemplateCanNotRemove; this.dmpDescriptionTemplateCanNotRemove = dmpDescriptionTemplateCanNotRemove;
} }
private ErrorDescription missingTenant;
public ErrorDescription getMissingTenant() {
return missingTenant;
}
public void setMissingTenant(ErrorDescription missingTenant) {
this.missingTenant = missingTenant;
}
private ErrorDescription tenantNotAllowed;
public ErrorDescription getTenantNotAllowed() {
return tenantNotAllowed;
}
public void setTenantNotAllowed(ErrorDescription tenantNotAllowed) {
this.tenantNotAllowed = tenantNotAllowed;
}
} }

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.ActionConfirmationEntity; import eu.eudat.data.ActionConfirmationEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.ActionConfirmationQuery; import eu.eudat.query.ActionConfirmationQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -26,7 +26,7 @@ import java.util.UUID;
public class ActionConfirmationDeleter implements Deleter { public class ActionConfirmationDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ActionConfirmationDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ActionConfirmationDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -34,7 +34,7 @@ public class ActionConfirmationDeleter implements Deleter {
@Autowired @Autowired
public ActionConfirmationDeleter( public ActionConfirmationDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -4,6 +4,7 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionReferenceEntity; import eu.eudat.data.DescriptionReferenceEntity;
import eu.eudat.data.DescriptionTagEntity; import eu.eudat.data.DescriptionTagEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.DescriptionQuery; import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.DescriptionReferenceQuery; import eu.eudat.query.DescriptionReferenceQuery;
import eu.eudat.query.DescriptionTagQuery; import eu.eudat.query.DescriptionTagQuery;
@ -13,7 +14,6 @@ import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -34,7 +34,7 @@ public class DescriptionDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -43,7 +43,7 @@ public class DescriptionDeleter implements Deleter {
@Autowired @Autowired
public DescriptionDeleter( public DescriptionDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
ElasticService elasticService) { ElasticService elasticService) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionReferenceEntity; import eu.eudat.data.DescriptionReferenceEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.DescriptionReferenceQuery; import eu.eudat.query.DescriptionReferenceQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -27,7 +27,7 @@ public class DescriptionReferenceDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionReferenceDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionReferenceDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -35,7 +35,7 @@ public class DescriptionReferenceDeleter implements Deleter {
@Autowired @Autowired
public DescriptionReferenceDeleter( public DescriptionReferenceDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionTagEntity; import eu.eudat.data.DescriptionTagEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.DescriptionTagQuery; import eu.eudat.query.DescriptionTagQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -27,7 +27,7 @@ public class DescriptionTagDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTagDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTagDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -35,7 +35,7 @@ public class DescriptionTagDeleter implements Deleter {
@Autowired @Autowired
public DescriptionTagDeleter( public DescriptionTagDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -5,6 +5,7 @@ import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.DmpDescriptionTemplateEntity; import eu.eudat.data.DmpDescriptionTemplateEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.data.UserDescriptionTemplateEntity; import eu.eudat.data.UserDescriptionTemplateEntity;
import eu.eudat.query.DescriptionQuery; import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.DescriptionTemplateQuery; import eu.eudat.query.DescriptionTemplateQuery;
@ -16,7 +17,6 @@ import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -36,7 +36,7 @@ public class DescriptionTemplateDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -44,7 +44,7 @@ public class DescriptionTemplateDeleter implements Deleter {
@Autowired @Autowired
public DescriptionTemplateDeleter( public DescriptionTemplateDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -1,11 +1,9 @@
package eu.eudat.model.deleter; package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionTagEntity;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.DescriptionTemplateTypeEntity; import eu.eudat.data.DescriptionTemplateTypeEntity;
import eu.eudat.data.ReferenceEntity; import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.DescriptionTagQuery;
import eu.eudat.query.DescriptionTemplateQuery; import eu.eudat.query.DescriptionTemplateQuery;
import eu.eudat.query.DescriptionTemplateTypeQuery; import eu.eudat.query.DescriptionTemplateTypeQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
@ -13,7 +11,6 @@ import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -33,7 +30,7 @@ public class DescriptionTemplateTypeDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -41,7 +38,7 @@ public class DescriptionTemplateTypeDeleter implements Deleter {
@Autowired @Autowired
public DescriptionTemplateTypeDeleter( public DescriptionTemplateTypeDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.DmpBlueprintEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.DmpBlueprintQuery; import eu.eudat.query.DmpBlueprintQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -27,7 +27,7 @@ public class DmpBlueprintDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -35,7 +35,7 @@ public class DmpBlueprintDeleter implements Deleter {
@Autowired @Autowired
public DmpBlueprintDeleter( public DmpBlueprintDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -17,7 +17,6 @@ import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -37,7 +36,7 @@ public class DmpDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -46,7 +45,7 @@ public class DmpDeleter implements Deleter {
@Autowired @Autowired
public DmpDeleter( public DmpDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
ElasticService elasticService) { ElasticService elasticService) {

View File

@ -2,15 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DmpDescriptionTemplateEntity; import eu.eudat.data.DmpDescriptionTemplateEntity;
import eu.eudat.data.DmpReferenceEntity; import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.DmpDescriptionTemplateQuery; import eu.eudat.query.DmpDescriptionTemplateQuery;
import eu.eudat.query.DmpReferenceQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -28,7 +26,7 @@ import java.util.UUID;
public class DmpDescriptionTemplateDeleter implements Deleter { public class DmpDescriptionTemplateDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDescriptionTemplateDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDescriptionTemplateDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -36,7 +34,7 @@ public class DmpDescriptionTemplateDeleter implements Deleter {
@Autowired @Autowired
public DmpDescriptionTemplateDeleter( public DmpDescriptionTemplateDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DmpReferenceEntity; import eu.eudat.data.DmpReferenceEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.DmpReferenceQuery; import eu.eudat.query.DmpReferenceQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -26,7 +26,7 @@ import java.util.UUID;
public class DmpReferenceDeleter implements Deleter { public class DmpReferenceDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpReferenceDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpReferenceDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -34,7 +34,7 @@ public class DmpReferenceDeleter implements Deleter {
@Autowired @Autowired
public DmpReferenceDeleter( public DmpReferenceDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DmpUserEntity; import eu.eudat.data.DmpUserEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.DmpUserQuery; import eu.eudat.query.DmpUserQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -26,7 +26,7 @@ import java.util.UUID;
public class DmpUserDeleter implements Deleter { public class DmpUserDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpUserDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpUserDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -34,7 +34,7 @@ public class DmpUserDeleter implements Deleter {
@Autowired @Autowired
public DmpUserDeleter( public DmpUserDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionTemplateTypeEntity; import eu.eudat.data.DescriptionTemplateTypeEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.DescriptionTemplateTypeQuery; import eu.eudat.query.DescriptionTemplateTypeQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -27,7 +27,7 @@ public class EntityDoiDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -35,7 +35,7 @@ public class EntityDoiDeleter implements Deleter {
@Autowired @Autowired
public EntityDoiDeleter( public EntityDoiDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.LanguageEntity; import eu.eudat.data.LanguageEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.LanguageQuery; import eu.eudat.query.LanguageQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -26,7 +26,7 @@ import java.util.UUID;
public class LanguageDeleter implements Deleter { public class LanguageDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LanguageDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LanguageDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -34,7 +34,7 @@ public class LanguageDeleter implements Deleter {
@Autowired @Autowired
public LanguageDeleter( public LanguageDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -1,13 +1,13 @@
package eu.eudat.model.deleter; package eu.eudat.model.deleter;
import eu.eudat.data.LockEntity; import eu.eudat.data.LockEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.LockQuery; import eu.eudat.query.LockQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -24,7 +24,7 @@ import java.util.UUID;
public class LockDeleter implements Deleter { public class LockDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LockDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LockDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -32,7 +32,7 @@ public class LockDeleter implements Deleter {
@Autowired @Autowired
public LockDeleter( public LockDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.PrefillingSourceEntity; import eu.eudat.data.PrefillingSourceEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.PrefillingSourceQuery; import eu.eudat.query.PrefillingSourceQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -26,7 +26,7 @@ import java.util.UUID;
public class PrefillingSourceDeleter implements Deleter { public class PrefillingSourceDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PrefillingSourceDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PrefillingSourceDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -34,7 +34,7 @@ public class PrefillingSourceDeleter implements Deleter {
@Autowired @Autowired
public PrefillingSourceDeleter( public PrefillingSourceDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -1,10 +1,7 @@
package eu.eudat.model.deleter; package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionReferenceEntity; import eu.eudat.data.*;
import eu.eudat.data.DmpReferenceEntity;
import eu.eudat.data.ReferenceEntity;
import eu.eudat.data.TagEntity;
import eu.eudat.query.DescriptionReferenceQuery; import eu.eudat.query.DescriptionReferenceQuery;
import eu.eudat.query.DmpReferenceQuery; import eu.eudat.query.DmpReferenceQuery;
import eu.eudat.query.ReferenceQuery; import eu.eudat.query.ReferenceQuery;
@ -13,7 +10,6 @@ import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -32,7 +28,7 @@ import java.util.stream.Collectors;
public class ReferenceDeleter implements Deleter { public class ReferenceDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -40,7 +36,7 @@ public class ReferenceDeleter implements Deleter {
@Autowired @Autowired
public ReferenceDeleter( public ReferenceDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.ReferenceTypeEntity; import eu.eudat.data.ReferenceTypeEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.ReferenceTypeQuery; import eu.eudat.query.ReferenceTypeQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -26,7 +26,7 @@ import java.util.UUID;
public class ReferenceTypeDeleter implements Deleter { public class ReferenceTypeDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -34,7 +34,7 @@ public class ReferenceTypeDeleter implements Deleter {
@Autowired @Autowired
public ReferenceTypeDeleter( public ReferenceTypeDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.SupportiveMaterialEntity; import eu.eudat.data.SupportiveMaterialEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.SupportiveMaterialQuery; import eu.eudat.query.SupportiveMaterialQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -27,7 +27,7 @@ public class SupportiveMaterialDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(SupportiveMaterialDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(SupportiveMaterialDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -35,7 +35,7 @@ public class SupportiveMaterialDeleter implements Deleter {
@Autowired @Autowired
public SupportiveMaterialDeleter( public SupportiveMaterialDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -3,6 +3,7 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionTagEntity; import eu.eudat.data.DescriptionTagEntity;
import eu.eudat.data.TagEntity; import eu.eudat.data.TagEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.DescriptionTagQuery; import eu.eudat.query.DescriptionTagQuery;
import eu.eudat.query.TagQuery; import eu.eudat.query.TagQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
@ -10,7 +11,6 @@ import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -29,7 +29,7 @@ import java.util.stream.Collectors;
public class TagDeleter implements Deleter { public class TagDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -37,7 +37,7 @@ public class TagDeleter implements Deleter {
@Autowired @Autowired
public TagDeleter( public TagDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -2,13 +2,13 @@ package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.TenantEntity; import eu.eudat.data.TenantEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.TenantQuery; import eu.eudat.query.TenantQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -27,7 +27,7 @@ public class TenantDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -35,7 +35,7 @@ public class TenantDeleter implements Deleter {
@Autowired @Autowired
public TenantDeleter( public TenantDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -1,12 +1,12 @@
package eu.eudat.model.deleter; package eu.eudat.model.deleter;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.data.UserContactInfoEntity; import eu.eudat.data.UserContactInfoEntity;
import eu.eudat.query.UserContactInfoQuery; import eu.eudat.query.UserContactInfoQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -23,14 +23,14 @@ import java.util.UUID;
public class UserContactInfoDeleter implements Deleter { public class UserContactInfoDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserContactInfoDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserContactInfoDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@Autowired @Autowired
public UserContactInfoDeleter( public UserContactInfoDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory QueryFactory queryFactory
) { ) {
this.entityManager = entityManager; this.entityManager = entityManager;

View File

@ -1,12 +1,12 @@
package eu.eudat.model.deleter; package eu.eudat.model.deleter;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.data.UserCredentialEntity; import eu.eudat.data.UserCredentialEntity;
import eu.eudat.query.UserCredentialQuery; import eu.eudat.query.UserCredentialQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -23,14 +23,14 @@ import java.util.UUID;
public class UserCredentialDeleter implements Deleter { public class UserCredentialDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserCredentialDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserCredentialDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@Autowired @Autowired
public UserCredentialDeleter( public UserCredentialDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory QueryFactory queryFactory
) { ) {
this.entityManager = entityManager; this.entityManager = entityManager;

View File

@ -8,7 +8,6 @@ import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -27,7 +26,7 @@ import java.util.stream.Collectors;
public class UserDeleter implements Deleter { public class UserDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -35,7 +34,7 @@ public class UserDeleter implements Deleter {
@Autowired @Autowired
public UserDeleter( public UserDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -1,15 +1,14 @@
package eu.eudat.model.deleter; package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.data.UserDescriptionTemplateEntity; import eu.eudat.data.UserDescriptionTemplateEntity;
import eu.eudat.query.DescriptionTemplateQuery;
import eu.eudat.query.UserDescriptionTemplateQuery; import eu.eudat.query.UserDescriptionTemplateQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -28,7 +27,7 @@ public class UserDescriptionTemplateDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserDescriptionTemplateDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserDescriptionTemplateDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@ -36,7 +35,7 @@ public class UserDescriptionTemplateDeleter implements Deleter {
@Autowired @Autowired
public UserDescriptionTemplateDeleter( public UserDescriptionTemplateDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory, QueryFactory queryFactory,
DeleterFactory deleterFactory DeleterFactory deleterFactory
) { ) {

View File

@ -1,13 +1,12 @@
package eu.eudat.model.deleter; package eu.eudat.model.deleter;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.data.UserRoleEntity; import eu.eudat.data.UserRoleEntity;
import eu.eudat.query.UserRoleQuery; import eu.eudat.query.UserRoleQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -15,25 +14,23 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.time.Instant;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class UserRoleDeleter implements Deleter { public class UserRoleDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserRoleDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserRoleDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@Autowired @Autowired
public UserRoleDeleter( public UserRoleDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory QueryFactory queryFactory
) { ) {
this.entityManager = entityManager; this.entityManager = entityManager;

View File

@ -1,12 +1,12 @@
package eu.eudat.model.deleter; package eu.eudat.model.deleter;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.data.UserSettingsEntity; import eu.eudat.data.UserSettingsEntity;
import eu.eudat.query.UserSettingsQuery; import eu.eudat.query.UserSettingsQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -23,14 +23,14 @@ import java.util.UUID;
public class UserSettingsSettingsDeleter implements Deleter { public class UserSettingsSettingsDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserSettingsSettingsDeleter.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserSettingsSettingsDeleter.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@Autowired @Autowired
public UserSettingsSettingsDeleter( public UserSettingsSettingsDeleter(
EntityManager entityManager, TenantEntityManager entityManager,
QueryFactory queryFactory QueryFactory queryFactory
) { ) {
this.entityManager = entityManager; this.entityManager = entityManager;

View File

@ -4,22 +4,20 @@ import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity; import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.commons.validation.BaseValidator; import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.model.DescriptionTemplate;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionPersist; import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionPersist;
import jakarta.persistence.EntityManager; import gr.cite.tools.validation.specification.Specification;
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 javax.management.InvalidApplicationException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -151,14 +149,12 @@ public class DescriptionPersist {
private final MessageSource messageSource; private final MessageSource messageSource;
private final ValidatorFactory validatorFactory; private final TenantEntityManager entityManager;
private final EntityManager entityManager;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
protected DescriptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory, EntityManager entityManager, XmlHandlingService xmlHandlingService) { protected DescriptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, TenantEntityManager entityManager, XmlHandlingService xmlHandlingService) {
super(conventionService, errors); super(conventionService, errors);
this.messageSource = messageSource; this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
this.entityManager = entityManager; this.entityManager = entityManager;
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
} }
@ -170,7 +166,12 @@ public class DescriptionPersist {
@Override @Override
protected List<Specification> specifications(DescriptionPersist item) { protected List<Specification> specifications(DescriptionPersist item) {
DescriptionTemplateEntity descriptionTemplate = this.isValidGuid(item.getDescriptionTemplateId()) ? this.entityManager.find(DescriptionTemplateEntity.class, item.getDescriptionTemplateId()) : null; DescriptionTemplateEntity descriptionTemplate = null;
try {
descriptionTemplate = this.isValidGuid(item.getDescriptionTemplateId()) ? this.entityManager.find(DescriptionTemplateEntity.class, item.getDescriptionTemplateId()) : null;
} catch (InvalidApplicationException e) {
throw new RuntimeException(e);
}
DefinitionEntity definition = descriptionTemplate == null ? null : this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, descriptionTemplate.getDefinition()); DefinitionEntity definition = descriptionTemplate == null ? null : this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, descriptionTemplate.getDefinition());
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()

View File

@ -10,6 +10,7 @@ import eu.eudat.commons.types.actionconfirmation.MergeAccountConfirmationEntity;
import eu.eudat.commons.types.actionconfirmation.RemoveCredentialRequestEntity; import eu.eudat.commons.types.actionconfirmation.RemoveCredentialRequestEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.ActionConfirmationEntity; import eu.eudat.data.ActionConfirmationEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.ActionConfirmation; import eu.eudat.model.ActionConfirmation;
import eu.eudat.model.ReferenceType; import eu.eudat.model.ReferenceType;
@ -31,7 +32,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -49,7 +49,7 @@ import java.util.UUID;
public class ActionConfirmationServiceImpl implements ActionConfirmationService { public class ActionConfirmationServiceImpl implements ActionConfirmationService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory; private final DeleterFactory deleterFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
@ -60,7 +60,7 @@ public class ActionConfirmationServiceImpl implements ActionConfirmationService
private final UserScope userScope; private final UserScope userScope;
public ActionConfirmationServiceImpl( public ActionConfirmationServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory, TenantEntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
ConventionService conventionService, MessageSource messageSource, ConventionService conventionService, MessageSource messageSource,
XmlHandlingService xmlHandlingService, ErrorThesaurusProperties errors, UserScope userScope) { XmlHandlingService xmlHandlingService, ErrorThesaurusProperties errors, UserScope userScope) {
this.entityManager = entityManager; this.entityManager = entityManager;

View File

@ -27,11 +27,11 @@ public interface DescriptionService {
Map<UUID, List<String>> getDescriptionSectionPermissions(DescriptionSectionPermissionResolver model); Map<UUID, List<String>> getDescriptionSectionPermissions(DescriptionSectionPermissionResolver model);
Description persist(DescriptionPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException; Description persist(DescriptionPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException;
Description persistStatus(DescriptionStatusPersist model, FieldSet fields) throws IOException; Description persistStatus(DescriptionStatusPersist model, FieldSet fields) throws IOException, InvalidApplicationException;
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException, IOException; void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException, IOException;
List<DescriptionValidationResult> validate(List<UUID> descriptionIds); List<DescriptionValidationResult> validate(List<UUID> descriptionIds) throws InvalidApplicationException;
void clone(UUID dmpId, UUID descriptionId) throws InvalidApplicationException, IOException; void clone(UUID dmpId, UUID descriptionId) throws InvalidApplicationException, IOException;

View File

@ -52,7 +52,6 @@ import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.ValidatorFactory;
import jakarta.persistence.EntityManager;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -79,7 +78,7 @@ import java.util.stream.Collectors;
public class DescriptionServiceImpl implements DescriptionService { public class DescriptionServiceImpl implements DescriptionService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory; private final DeleterFactory deleterFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
@ -104,7 +103,7 @@ public class DescriptionServiceImpl implements DescriptionService {
@Autowired @Autowired
public DescriptionServiceImpl( public DescriptionServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,
@ -298,7 +297,7 @@ public class DescriptionServiceImpl implements DescriptionService {
} }
@Override @Override
public Description persistStatus(DescriptionStatusPersist model, FieldSet fields) throws IOException { public Description persistStatus(DescriptionStatusPersist model, FieldSet fields) throws IOException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting data dmp").And("model", model).And("fields", fields)); logger.debug(new MapLogEntry("persisting data dmp").And("model", model).And("fields", fields));
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.EditDescription); this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.EditDescription);
@ -329,7 +328,7 @@ public class DescriptionServiceImpl implements DescriptionService {
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Description._id), data); return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Description._id), data);
} }
public List<DescriptionValidationResult> validate(List<UUID> descriptionIds){ public List<DescriptionValidationResult> validate(List<UUID> descriptionIds) throws InvalidApplicationException {
List<DescriptionValidationResult> descriptionValidationResults = new ArrayList<>(); List<DescriptionValidationResult> descriptionValidationResults = new ArrayList<>();
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(descriptionIds).isActive(IsActive.Active).collect(); List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(descriptionIds).isActive(IsActive.Active).collect();
@ -349,7 +348,7 @@ public class DescriptionServiceImpl implements DescriptionService {
return descriptionValidationResults; return descriptionValidationResults;
} }
private @NotNull PropertyDefinitionEntity buildPropertyDefinitionEntity(PropertyDefinitionPersist persist, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition, Map<String, List<UUID>> fieldToReferenceMap){ private @NotNull PropertyDefinitionEntity buildPropertyDefinitionEntity(PropertyDefinitionPersist persist, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition, Map<String, List<UUID>> fieldToReferenceMap) throws InvalidApplicationException {
PropertyDefinitionEntity data = new PropertyDefinitionEntity(); PropertyDefinitionEntity data = new PropertyDefinitionEntity();
if (persist == null) return data; if (persist == null) return data;
if (persist.getFieldSets() != null && !persist.getFieldSets().isEmpty()){ if (persist.getFieldSets() != null && !persist.getFieldSets().isEmpty()){
@ -362,7 +361,7 @@ public class DescriptionServiceImpl implements DescriptionService {
return data; return data;
} }
private @NotNull PropertyDefinitionFieldSetEntity buildPropertyDefinitionFieldSetEntity(PropertyDefinitionFieldSetPersist persist, FieldSetEntity fieldSetEntity, Map<String, List<UUID>> fieldToReferenceMap){ private @NotNull PropertyDefinitionFieldSetEntity buildPropertyDefinitionFieldSetEntity(PropertyDefinitionFieldSetPersist persist, FieldSetEntity fieldSetEntity, Map<String, List<UUID>> fieldToReferenceMap) throws InvalidApplicationException {
PropertyDefinitionFieldSetEntity data = new PropertyDefinitionFieldSetEntity(); PropertyDefinitionFieldSetEntity data = new PropertyDefinitionFieldSetEntity();
if (persist == null) return data; if (persist == null) return data;
if (!this.conventionService.isListNullOrEmpty(persist.getItems())){ if (!this.conventionService.isListNullOrEmpty(persist.getItems())){
@ -374,7 +373,7 @@ public class DescriptionServiceImpl implements DescriptionService {
return data; return data;
} }
private @NotNull PropertyDefinitionFieldSetItemEntity buildPropertyDefinitionFieldSetItemEntity(PropertyDefinitionFieldSetItemPersist persist, FieldSetEntity fieldSetEntity, Map<String, List<UUID>> fieldToReferenceMap){ private @NotNull PropertyDefinitionFieldSetItemEntity buildPropertyDefinitionFieldSetItemEntity(PropertyDefinitionFieldSetItemPersist persist, FieldSetEntity fieldSetEntity, Map<String, List<UUID>> fieldToReferenceMap) throws InvalidApplicationException {
PropertyDefinitionFieldSetItemEntity data = new PropertyDefinitionFieldSetItemEntity(); PropertyDefinitionFieldSetItemEntity data = new PropertyDefinitionFieldSetItemEntity();
if (persist == null) return data; if (persist == null) return data;
if (persist.getFields() != null && !persist.getFields().isEmpty()){ if (persist.getFields() != null && !persist.getFields().isEmpty()){
@ -389,7 +388,7 @@ public class DescriptionServiceImpl implements DescriptionService {
return data; return data;
} }
private @NotNull FieldEntity buildFieldEntity(FieldPersist persist, eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity, Map<String, List<UUID>> fieldToReferenceMap){ private @NotNull FieldEntity buildFieldEntity(FieldPersist persist, eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity, Map<String, List<UUID>> fieldToReferenceMap) throws InvalidApplicationException {
FieldType fieldType = fieldEntity != null && fieldEntity.getData() != null ? fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT; FieldType fieldType = fieldEntity != null && fieldEntity.getData() != null ? fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
FieldEntity data = new FieldEntity(); FieldEntity data = new FieldEntity();
if (persist == null) return data; if (persist == null) return data;
@ -806,7 +805,7 @@ public class DescriptionServiceImpl implements DescriptionService {
//region build persist //region build persist
private @NotNull DescriptionPersist buildDescriptionPersist(DescriptionEntity data){ private @NotNull DescriptionPersist buildDescriptionPersist(DescriptionEntity data) throws InvalidApplicationException {
DescriptionPersist persist = new DescriptionPersist(); DescriptionPersist persist = new DescriptionPersist();
if (data == null) return persist; if (data == null) return persist;

View File

@ -49,7 +49,6 @@ import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.ValidatorFactory;
import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.NotImplementedException;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -79,7 +78,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final UserScope userScope; private final UserScope userScope;
@ -116,7 +115,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
@Autowired @Autowired
public DescriptionTemplateServiceImpl( public DescriptionTemplateServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
UserScope userScope, AuthorizationService authorizationService, UserScope userScope, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,
@ -206,7 +205,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data); return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);
} }
private void updateVersionStatusAndSave(DescriptionTemplateEntity data, DescriptionTemplateStatus previousStatus, DescriptionTemplateStatus newStatus) { private void updateVersionStatusAndSave(DescriptionTemplateEntity data, DescriptionTemplateStatus previousStatus, DescriptionTemplateStatus newStatus) throws InvalidApplicationException {
if (previousStatus.equals(newStatus)) if (previousStatus.equals(newStatus))
return; return;
if (previousStatus.equals(DescriptionTemplateStatus.Finalized)) if (previousStatus.equals(DescriptionTemplateStatus.Finalized))
@ -298,7 +297,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
this.entityManager.persist(data); this.entityManager.persist(data);
} }
private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist) { private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist) throws InvalidApplicationException {
DefinitionEntity data = new DefinitionEntity(); DefinitionEntity data = new DefinitionEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -313,7 +312,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data; return data;
} }
private @NotNull SectionEntity buildSectionEntity(SectionPersist persist) { private @NotNull SectionEntity buildSectionEntity(SectionPersist persist) throws InvalidApplicationException {
SectionEntity data = new SectionEntity(); SectionEntity data = new SectionEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -342,7 +341,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data; return data;
} }
private @NotNull FieldSetEntity buildFieldSetEntity(FieldSetPersist persist) { private @NotNull FieldSetEntity buildFieldSetEntity(FieldSetPersist persist) throws InvalidApplicationException {
FieldSetEntity data = new FieldSetEntity(); FieldSetEntity data = new FieldSetEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -367,7 +366,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data; return data;
} }
private @NotNull FieldEntity buildFieldEntity(FieldPersist persist) { private @NotNull FieldEntity buildFieldEntity(FieldPersist persist) throws InvalidApplicationException {
FieldEntity data = new FieldEntity(); FieldEntity data = new FieldEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -397,7 +396,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return this.fieldDataHelperServiceProvider.get(persist.getFieldType()).applyPersist(persist); return this.fieldDataHelperServiceProvider.get(persist.getFieldType()).applyPersist(persist);
} }
private @NotNull RuleEntity buildRuleEntity(RulePersist persist, FieldEntity fieldEntity){ private @NotNull RuleEntity buildRuleEntity(RulePersist persist, FieldEntity fieldEntity) throws InvalidApplicationException {
FieldType fieldType = fieldEntity != null && fieldEntity.getData() != null ? fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT; FieldType fieldType = fieldEntity != null && fieldEntity.getData() != null ? fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
RuleEntity data = new RuleEntity(); RuleEntity data = new RuleEntity();
if (persist == null) return data; if (persist == null) return data;
@ -444,7 +443,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data; return data;
} }
private List<UUID> patchAndSaveReferences(List<ReferencePersist> models, FieldEntity fieldEntity) { private List<UUID> patchAndSaveReferences(List<ReferencePersist> models, FieldEntity fieldEntity) throws InvalidApplicationException {
if (models == null) models = new ArrayList<>(); if (models == null) models = new ArrayList<>();
List<UUID> referenceIds = new ArrayList<>(); List<UUID> referenceIds = new ArrayList<>();
@ -520,7 +519,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data; return data;
} }
private @NotNull PageEntity buildPageEntity(PagePersist persist) { private @NotNull PageEntity buildPageEntity(PagePersist persist) throws InvalidApplicationException {
PageEntity data = new PageEntity(); PageEntity data = new PageEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -881,7 +880,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
//region Export //region Export
@Override @Override
public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting data").And("id", id)); logger.debug(new MapLogEntry("persisting data").And("id", id));
this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate); this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);

View File

@ -5,6 +5,7 @@ import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateTypeEntity; import eu.eudat.data.DescriptionTemplateTypeEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.event.DescriptionTemplateTypeTouchedEvent; import eu.eudat.event.DescriptionTemplateTypeTouchedEvent;
import eu.eudat.event.EventBroker; import eu.eudat.event.EventBroker;
@ -23,7 +24,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -40,7 +40,7 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@ -58,7 +58,7 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
@Autowired @Autowired
public DescriptionTemplateTypeServiceImpl( public DescriptionTemplateTypeServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,

View File

@ -60,7 +60,6 @@ import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.ValidatorFactory;
import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -84,7 +83,7 @@ public class DmpServiceImpl implements DmpService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@ -128,7 +127,7 @@ public class DmpServiceImpl implements DmpService {
@Autowired @Autowired
public DmpServiceImpl( public DmpServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,
@ -450,7 +449,7 @@ public class DmpServiceImpl implements DmpService {
return this.builderFactory.builder(DmpBuilder.class).build(BaseFieldSet.build(fields, Dmp._id), newDmp); return this.builderFactory.builder(DmpBuilder.class).build(BaseFieldSet.build(fields, Dmp._id), newDmp);
} }
private void updateVersionStatusAndSave(DmpEntity data, DmpStatus previousStatus, DmpStatus newStatus) { private void updateVersionStatusAndSave(DmpEntity data, DmpStatus previousStatus, DmpStatus newStatus) throws InvalidApplicationException {
if (previousStatus.equals(newStatus)) if (previousStatus.equals(newStatus))
return; return;
if (previousStatus.equals(DmpStatus.Finalized) && newStatus.equals(DmpStatus.Draft)){ if (previousStatus.equals(DmpStatus.Finalized) && newStatus.equals(DmpStatus.Draft)){
@ -1083,7 +1082,7 @@ public class DmpServiceImpl implements DmpService {
return persist.getToken(); return persist.getToken();
} }
public void dmpInvitationAccept(String token) { public void dmpInvitationAccept(String token) throws InvalidApplicationException {
ActionConfirmationEntity action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.DmpInvitation).isActive(IsActive.Active).first(); ActionConfirmationEntity action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.DmpInvitation).isActive(IsActive.Active).first();
if (action == null){ if (action == null){

View File

@ -28,7 +28,7 @@ public interface DmpBlueprintService {
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException; void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
boolean fieldInBlueprint(DmpBlueprintEntity dmpBlueprintEntity, DmpBlueprintSystemFieldType type); boolean fieldInBlueprint(DmpBlueprintEntity dmpBlueprintEntity, DmpBlueprintSystemFieldType type);
boolean fieldInBlueprint(UUID id, DmpBlueprintSystemFieldType type); boolean fieldInBlueprint(UUID id, DmpBlueprintSystemFieldType type) throws InvalidApplicationException;
DmpBlueprint buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException; DmpBlueprint buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException;

View File

@ -9,6 +9,7 @@ import eu.eudat.commons.types.dmpblueprint.*;
import eu.eudat.commons.types.dmpblueprint.importexport.*; import eu.eudat.commons.types.dmpblueprint.importexport.*;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.DmpBlueprintEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.DmpBlueprint; import eu.eudat.model.DmpBlueprint;
import eu.eudat.model.builder.DmpBlueprintBuilder; import eu.eudat.model.builder.DmpBlueprintBuilder;
@ -34,7 +35,6 @@ import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.ValidatorFactory;
import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -61,7 +61,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@ -85,7 +85,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
@Autowired @Autowired
public DmpBlueprintServiceImpl( public DmpBlueprintServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,
@ -162,7 +162,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, DmpBlueprint._id), data); return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, DmpBlueprint._id), data);
} }
private void updateVersionStatusAndSave(DmpBlueprintEntity data, DmpBlueprintStatus previousStatus, DmpBlueprintStatus newStatus) { private void updateVersionStatusAndSave(DmpBlueprintEntity data, DmpBlueprintStatus previousStatus, DmpBlueprintStatus newStatus) throws InvalidApplicationException {
if (previousStatus.equals(newStatus)) if (previousStatus.equals(newStatus))
return; return;
if (previousStatus.equals(DmpBlueprintStatus.Finalized)) if (previousStatus.equals(DmpBlueprintStatus.Finalized))
@ -320,7 +320,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
return false; return false;
} }
public boolean fieldInBlueprint(UUID id, DmpBlueprintSystemFieldType type) { public boolean fieldInBlueprint(UUID id, DmpBlueprintSystemFieldType type) throws InvalidApplicationException {
DmpBlueprintEntity data = this.entityManager.find(DmpBlueprintEntity.class, id); DmpBlueprintEntity data = this.entityManager.find(DmpBlueprintEntity.class, id);
if (data == null) if (data == null)
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));

View File

@ -3,6 +3,7 @@ package eu.eudat.service.elastic;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import javax.management.InvalidApplicationException;
import java.io.IOException; import java.io.IOException;
public interface ElasticService { public interface ElasticService {
@ -21,9 +22,9 @@ public interface ElasticService {
void deleteDmp(DmpEntity dmp) throws IOException; void deleteDmp(DmpEntity dmp) throws IOException;
void persistDescription(DescriptionEntity description) throws IOException; void persistDescription(DescriptionEntity description) throws IOException, InvalidApplicationException;
void deleteDescription(DescriptionEntity description) throws IOException; void deleteDescription(DescriptionEntity description) throws IOException, InvalidApplicationException;
void deleteDmpIndex() throws IOException; void deleteDmpIndex() throws IOException;

View File

@ -8,6 +8,7 @@ import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.elastic.data.DescriptionElasticEntity; import eu.eudat.elastic.data.DescriptionElasticEntity;
import eu.eudat.elastic.data.DmpElasticEntity; import eu.eudat.elastic.data.DmpElasticEntity;
import eu.eudat.elastic.data.nested.*; import eu.eudat.elastic.data.nested.*;
@ -28,7 +29,6 @@ import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
@ -41,6 +41,8 @@ import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException;
@Service @Service
public class ElasticServiceImpl implements ElasticService { public class ElasticServiceImpl implements ElasticService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
@ -49,11 +51,11 @@ public class ElasticServiceImpl implements ElasticService {
private final ElasticsearchTemplate elasticsearchTemplate; private final ElasticsearchTemplate elasticsearchTemplate;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final MessageSource messageSource; private final MessageSource messageSource;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
public ElasticServiceImpl(AppElasticProperties appElasticProperties, ElasticsearchClient restHighLevelClient, ElasticsearchTemplate elasticsearchTemplate, QueryFactory queryFactory, BuilderFactory builderFactory, EntityManager entityManager, MessageSource messageSource, AuthorizationService authorizationService) { public ElasticServiceImpl(AppElasticProperties appElasticProperties, ElasticsearchClient restHighLevelClient, ElasticsearchTemplate elasticsearchTemplate, QueryFactory queryFactory, BuilderFactory builderFactory, TenantEntityManager entityManager, MessageSource messageSource, AuthorizationService authorizationService) {
this.appElasticProperties = appElasticProperties; this.appElasticProperties = appElasticProperties;
this.restHighLevelClient = restHighLevelClient; this.restHighLevelClient = restHighLevelClient;
this.elasticsearchTemplate = elasticsearchTemplate; this.elasticsearchTemplate = elasticsearchTemplate;
@ -295,7 +297,7 @@ public class ElasticServiceImpl implements ElasticService {
} }
@Override @Override
public void persistDescription(DescriptionEntity description) throws IOException { public void persistDescription(DescriptionEntity description) throws IOException, InvalidApplicationException {
if (!this.enabled()) return; if (!this.enabled()) return;
this.ensureIndexes(); this.ensureIndexes();
@ -310,7 +312,7 @@ public class ElasticServiceImpl implements ElasticService {
} }
@Override @Override
public void deleteDescription(DescriptionEntity description) throws IOException { public void deleteDescription(DescriptionEntity description) throws IOException, InvalidApplicationException {
if (!this.enabled()) return; if (!this.enabled()) return;
this.ensureIndexes(); this.ensureIndexes();

View File

@ -6,6 +6,7 @@ import eu.eudat.commons.enums.EntityType;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.EntityDoiEntity; import eu.eudat.data.EntityDoiEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.event.EntityDoiTouchedEvent; import eu.eudat.event.EntityDoiTouchedEvent;
import eu.eudat.event.EventBroker; import eu.eudat.event.EventBroker;
@ -24,7 +25,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -41,7 +41,7 @@ public class EntityDoiServiceImpl implements EntityDoiService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(EntityDoiServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(EntityDoiServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@ -59,7 +59,7 @@ public class EntityDoiServiceImpl implements EntityDoiService {
@Autowired @Autowired
public EntityDoiServiceImpl( public EntityDoiServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,

View File

@ -5,6 +5,7 @@ import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.LanguageEntity; import eu.eudat.data.LanguageEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.Language; import eu.eudat.model.Language;
import eu.eudat.model.builder.LanguageBuilder; import eu.eudat.model.builder.LanguageBuilder;
@ -23,7 +24,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.hibernate.FlushMode; import org.hibernate.FlushMode;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -41,7 +41,7 @@ import java.util.UUID;
public class LanguageServiceImpl implements LanguageService { public class LanguageServiceImpl implements LanguageService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory; private final DeleterFactory deleterFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
@ -52,7 +52,7 @@ public class LanguageServiceImpl implements LanguageService {
public LanguageServiceImpl( public LanguageServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory, TenantEntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
ConventionService conventionService, MessageSource messageSource, ErrorThesaurusProperties errors, StorageFileService storageFileService){ ConventionService conventionService, MessageSource messageSource, ErrorThesaurusProperties errors, StorageFileService storageFileService){
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;

View File

@ -8,6 +8,7 @@ import eu.eudat.commons.enums.LockTargetType;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.LockEntity; import eu.eudat.data.LockEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.Lock; import eu.eudat.model.Lock;
import eu.eudat.model.LockStatus; import eu.eudat.model.LockStatus;
@ -27,7 +28,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -46,7 +46,7 @@ public class LockServiceImpl implements LockService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LockServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LockServiceImpl.class));
private final Comparator<LockEntity> compareByTouchedAt = Comparator.comparing(o -> o.getTouchedAt()); private final Comparator<LockEntity> compareByTouchedAt = Comparator.comparing(o -> o.getTouchedAt());
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final UserScope userScope; private final UserScope userScope;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory; private final DeleterFactory deleterFactory;
@ -60,7 +60,7 @@ public class LockServiceImpl implements LockService {
@Autowired @Autowired
public LockServiceImpl( public LockServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
UserScope userScope, UserScope userScope,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,

View File

@ -28,6 +28,6 @@ public interface PrefillingSourceService {
List<Prefilling> searchPrefillings(PrefillingSearchRequest model); List<Prefilling> searchPrefillings(PrefillingSearchRequest model);
Description getPrefilledDescription(DescriptionProfilingRequest model, FieldSet fields) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException; Description getPrefilledDescription(DescriptionProfilingRequest model, FieldSet fields) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
} }

View File

@ -17,6 +17,7 @@ import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionFixedVa
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.PrefillingSourceEntity; import eu.eudat.data.PrefillingSourceEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.*; import eu.eudat.model.*;
import eu.eudat.model.builder.DescriptionTemplateBuilder; import eu.eudat.model.builder.DescriptionTemplateBuilder;
@ -50,8 +51,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.ValidatorFactory;
import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -78,7 +77,7 @@ import java.util.stream.Stream;
public class PrefillingSourceServiceImpl implements PrefillingSourceService { public class PrefillingSourceServiceImpl implements PrefillingSourceService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PrefillingSourceServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PrefillingSourceServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory; private final DeleterFactory deleterFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
@ -88,16 +87,15 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private final ExternalFetcherService externalFetcherService; private final ExternalFetcherService externalFetcherService;
private final ErrorThesaurusProperties errors; private final ErrorThesaurusProperties errors;
private final ValidatorFactory validatorFactory;
private final JsonHandlingService jsonHandlingService; private final JsonHandlingService jsonHandlingService;
private final ReferenceService referenceService; private final ReferenceService referenceService;
private static final String Zenodo = "Zenodo"; private static final String Zenodo = "Zenodo";
public PrefillingSourceServiceImpl( public PrefillingSourceServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory, TenantEntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
QueryFactory queryFactory, ConventionService conventionService, MessageSource messageSource, QueryFactory queryFactory, ConventionService conventionService, MessageSource messageSource,
XmlHandlingService xmlHandlingService, ExternalFetcherService externalFetcherService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, JsonHandlingService jsonHandlingService, ReferenceService referenceService) { XmlHandlingService xmlHandlingService, ExternalFetcherService externalFetcherService, ErrorThesaurusProperties errors, JsonHandlingService jsonHandlingService, ReferenceService referenceService) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory; this.deleterFactory = deleterFactory;
@ -108,7 +106,6 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
this.externalFetcherService = externalFetcherService; this.externalFetcherService = externalFetcherService;
this.errors = errors; this.errors = errors;
this.validatorFactory = validatorFactory;
this.jsonHandlingService = jsonHandlingService; this.jsonHandlingService = jsonHandlingService;
this.referenceService = referenceService; this.referenceService = referenceService;
} }
@ -340,7 +337,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
return prefillings; return prefillings;
} }
public Description getPrefilledDescription(DescriptionProfilingRequest model, FieldSet fieldSet) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { public Description getPrefilledDescription(DescriptionProfilingRequest model, FieldSet fieldSet) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).first(); PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).first();
if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));

View File

@ -22,5 +22,5 @@ public interface ReferenceService {
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException; void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
List<Reference> searchReferenceData(ReferenceSearchLookup lookup) throws MyNotFoundException; List<Reference> searchReferenceData(ReferenceSearchLookup lookup) throws MyNotFoundException, InvalidApplicationException;
} }

View File

@ -13,6 +13,7 @@ import eu.eudat.commons.types.referencetype.*;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.ReferenceEntity; import eu.eudat.data.ReferenceEntity;
import eu.eudat.data.ReferenceTypeEntity; import eu.eudat.data.ReferenceTypeEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.model.Reference; import eu.eudat.model.Reference;
import eu.eudat.model.ReferenceType; import eu.eudat.model.ReferenceType;
import eu.eudat.model.builder.ReferenceBuilder; import eu.eudat.model.builder.ReferenceBuilder;
@ -57,7 +58,7 @@ import java.util.stream.Collectors;
public class ReferenceServiceImpl implements ReferenceService { public class ReferenceServiceImpl implements ReferenceService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory; private final DeleterFactory deleterFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
@ -68,7 +69,7 @@ public class ReferenceServiceImpl implements ReferenceService {
public final ExternalFetcherService externalFetcherService; public final ExternalFetcherService externalFetcherService;
public ReferenceServiceImpl( public ReferenceServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,
@ -159,7 +160,7 @@ public class ReferenceServiceImpl implements ReferenceService {
} }
@Override @Override
public List<Reference> searchReferenceData(ReferenceSearchLookup lookup) throws MyNotFoundException { public List<Reference> searchReferenceData(ReferenceSearchLookup lookup) throws MyNotFoundException, InvalidApplicationException {
int initialOffset = 0; int initialOffset = 0;
if (lookup.getPage() != null && !lookup.getPage().isEmpty()){ if (lookup.getPage() != null && !lookup.getPage().isEmpty()){
initialOffset = lookup.getPage().getOffset(); initialOffset = lookup.getPage().getOffset();

View File

@ -9,6 +9,7 @@ import eu.eudat.commons.types.externalfetcher.*;
import eu.eudat.commons.types.referencetype.*; import eu.eudat.commons.types.referencetype.*;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.ReferenceTypeEntity; import eu.eudat.data.ReferenceTypeEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.ReferenceType; import eu.eudat.model.ReferenceType;
import eu.eudat.model.builder.ReferenceTypeBuilder; import eu.eudat.model.builder.ReferenceTypeBuilder;
@ -27,7 +28,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -46,7 +46,7 @@ import java.util.UUID;
public class ReferenceTypeServiceImpl implements ReferenceTypeService { public class ReferenceTypeServiceImpl implements ReferenceTypeService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory; private final DeleterFactory deleterFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
@ -57,7 +57,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
public ReferenceTypeServiceImpl( public ReferenceTypeServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory, TenantEntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
ConventionService conventionService, MessageSource messageSource, ConventionService conventionService, MessageSource messageSource,
XmlHandlingService xmlHandlingService, ErrorThesaurusProperties errors) { XmlHandlingService xmlHandlingService, ErrorThesaurusProperties errors) {
this.entityManager = entityManager; this.entityManager = entityManager;

View File

@ -1,6 +1,7 @@
package eu.eudat.service.storage; package eu.eudat.service.storage;
import eu.eudat.commons.fake.FakeRequestScope; import eu.eudat.commons.fake.FakeRequestScope;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.data.StorageFileEntity; import eu.eudat.data.StorageFileEntity;
import eu.eudat.model.StorageFile; import eu.eudat.model.StorageFile;
import eu.eudat.query.StorageFileQuery; import eu.eudat.query.StorageFileQuery;
@ -117,6 +118,8 @@ public class StorageFileCleanupTask implements Closeable, ApplicationListener<A
StorageFileService storageFileService = this.applicationContext.getBean(StorageFileService.class); StorageFileService storageFileService = this.applicationContext.getBean(StorageFileService.class);
entityManager = entityManagerFactory.createEntityManager(); entityManager = entityManagerFactory.createEntityManager();
transaction = entityManager.getTransaction(); transaction = entityManager.getTransaction();
transaction.begin(); transaction.begin();

View File

@ -8,6 +8,7 @@ import gr.cite.tools.fieldset.FieldSet;
import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import javax.management.InvalidApplicationException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -24,7 +25,7 @@ public interface StorageFileService extends ApplicationListener<ApplicationReady
boolean fileRefExists(String fileRef, StorageType storageType); boolean fileRefExists(String fileRef, StorageType storageType);
void updatePurgeAt(UUID fileId, Instant purgeAt); void updatePurgeAt(UUID fileId, Instant purgeAt) throws InvalidApplicationException;
boolean purgeSafe(UUID fileId); boolean purgeSafe(UUID fileId);
String readAsTextSafe(UUID fileId, Charset charset); String readAsTextSafe(UUID fileId, Charset charset);
byte[] readAsBytesSafe(UUID fileId); byte[] readAsBytesSafe(UUID fileId);

View File

@ -7,6 +7,7 @@ import eu.eudat.commons.enums.StorageType;
import eu.eudat.commons.enums.SupportiveMaterialFieldType; import eu.eudat.commons.enums.SupportiveMaterialFieldType;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.StorageFileEntity; import eu.eudat.data.StorageFileEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.model.StorageFile; import eu.eudat.model.StorageFile;
import eu.eudat.model.builder.StorageFileBuilder; import eu.eudat.model.builder.StorageFileBuilder;
import eu.eudat.model.persist.StorageFilePersist; import eu.eudat.model.persist.StorageFilePersist;
@ -16,13 +17,13 @@ import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import javax.management.InvalidApplicationException;
import java.io.*; import java.io.*;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.file.FileAlreadyExistsException; import java.nio.file.FileAlreadyExistsException;
@ -37,7 +38,7 @@ import java.util.UUID;
public class StorageFileServiceImpl implements StorageFileService { public class StorageFileServiceImpl implements StorageFileService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(StorageFileServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(StorageFileServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final UserScope userScope; private final UserScope userScope;
@ -45,7 +46,7 @@ public class StorageFileServiceImpl implements StorageFileService {
@Autowired @Autowired
public StorageFileServiceImpl( public StorageFileServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
BuilderFactory builderFactory, BuilderFactory builderFactory,
UserScope userScope, UserScope userScope,
@ -219,7 +220,7 @@ public class StorageFileServiceImpl implements StorageFileService {
} }
@Override @Override
public void updatePurgeAt(UUID fileId, Instant purgeAt) { public void updatePurgeAt(UUID fileId, Instant purgeAt) throws InvalidApplicationException {
StorageFileEntity storageFile = this.entityManager.find(StorageFileEntity.class, fileId); StorageFileEntity storageFile = this.entityManager.find(StorageFileEntity.class, fileId);
if (storageFile == null) return; if (storageFile == null) return;

View File

@ -6,6 +6,7 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.SupportiveMaterialFieldType; import eu.eudat.commons.enums.SupportiveMaterialFieldType;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.SupportiveMaterialEntity; import eu.eudat.data.SupportiveMaterialEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.model.SupportiveMaterial; import eu.eudat.model.SupportiveMaterial;
import eu.eudat.model.builder.SupportiveMaterialBuilder; import eu.eudat.model.builder.SupportiveMaterialBuilder;
import eu.eudat.model.deleter.SupportiveMaterialDeleter; import eu.eudat.model.deleter.SupportiveMaterialDeleter;
@ -25,7 +26,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -42,7 +42,7 @@ import java.util.UUID;
public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory; private final DeleterFactory deleterFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
@ -53,7 +53,7 @@ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
private final StorageFileService storageFileService; private final StorageFileService storageFileService;
public SupportiveMaterialServiceImpl( public SupportiveMaterialServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory, TenantEntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
ConventionService conventionService, MessageSource messageSource, QueryFactory queryFactory, ConventionService conventionService, MessageSource messageSource, QueryFactory queryFactory,
SupportiveMaterialCacheService supportiveMaterialCacheService, StorageFileService storageFileService SupportiveMaterialCacheService supportiveMaterialCacheService, StorageFileService storageFileService
) { ) {

View File

@ -6,6 +6,7 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.TagEntity; import eu.eudat.data.TagEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.event.EventBroker; import eu.eudat.event.EventBroker;
import eu.eudat.event.TagTouchedEvent; import eu.eudat.event.TagTouchedEvent;
@ -24,7 +25,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -41,7 +41,7 @@ public class TagServiceImpl implements TagService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@ -62,7 +62,7 @@ public class TagServiceImpl implements TagService {
@Autowired @Autowired
public TagServiceImpl( public TagServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,

View File

@ -7,6 +7,7 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.types.tenant.*; import eu.eudat.commons.types.tenant.*;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.TenantEntity; import eu.eudat.data.TenantEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.Tenant; import eu.eudat.model.Tenant;
import eu.eudat.model.builder.TenantBuilder; import eu.eudat.model.builder.TenantBuilder;
@ -28,7 +29,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -52,7 +52,7 @@ public class TenantServiceImpl implements TenantService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@ -62,8 +62,6 @@ public class TenantServiceImpl implements TenantService {
private final ConventionService conventionService; private final ConventionService conventionService;
private final MessageSource messageSource; private final MessageSource messageSource;
private final QueryFactory queryFactory;
private final ResponseUtilsService responseUtilsService;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private final ErrorThesaurusProperties errors; private final ErrorThesaurusProperties errors;
private final EncryptionService encryptionService; private final EncryptionService encryptionService;
@ -72,13 +70,12 @@ public class TenantServiceImpl implements TenantService {
@Autowired @Autowired
public TenantServiceImpl( public TenantServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,
ConventionService conventionService, ConventionService conventionService,
MessageSource messageSource, QueryFactory queryFactory, MessageSource messageSource,
ResponseUtilsService responseUtilsService,
XmlHandlingService xmlHandlingService, XmlHandlingService xmlHandlingService,
ErrorThesaurusProperties errors, ErrorThesaurusProperties errors,
EncryptionService encryptionService, TenantProperties properties) { EncryptionService encryptionService, TenantProperties properties) {
@ -88,8 +85,6 @@ public class TenantServiceImpl implements TenantService {
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.conventionService = conventionService; this.conventionService = conventionService;
this.messageSource = messageSource; this.messageSource = messageSource;
this.queryFactory = queryFactory;
this.responseUtilsService = responseUtilsService;
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
this.errors = errors; this.errors = errors;
this.encryptionService = encryptionService; this.encryptionService = encryptionService;

View File

@ -23,9 +23,9 @@ public interface UserService {
void updateLanguageMine(String language) throws InvalidApplicationException, JsonProcessingException; void updateLanguageMine(String language) throws InvalidApplicationException, JsonProcessingException;
void updateTimezoneMine(String timezone) throws JsonProcessingException; void updateTimezoneMine(String timezone) throws JsonProcessingException, InvalidApplicationException;
void updateCultureMine(String culture) throws JsonProcessingException; void updateCultureMine(String culture) throws JsonProcessingException, InvalidApplicationException;
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException; void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;

View File

@ -54,7 +54,6 @@ import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.ValidatorFactory;
import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter; import org.apache.commons.csv.CSVPrinter;
@ -79,7 +78,7 @@ public class UserServiceImpl implements UserService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@ -111,7 +110,7 @@ public class UserServiceImpl implements UserService {
@Autowired @Autowired
public UserServiceImpl( public UserServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,
@ -282,7 +281,7 @@ public class UserServiceImpl implements UserService {
//region mine //region mine
@Override @Override
public void updateLanguageMine(String language) throws JsonProcessingException { public void updateLanguageMine(String language) throws JsonProcessingException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting User language").And("language", language)); logger.debug(new MapLogEntry("persisting User language").And("language", language));
UUID userId = this.userScope.getUserIdSafe(); UUID userId = this.userScope.getUserIdSafe();
@ -310,7 +309,7 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public void updateTimezoneMine(String timezone) throws JsonProcessingException { public void updateTimezoneMine(String timezone) throws JsonProcessingException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting User timezone").And("timezone", timezone)); logger.debug(new MapLogEntry("persisting User timezone").And("timezone", timezone));
UUID userId = this.userScope.getUserIdSafe(); UUID userId = this.userScope.getUserIdSafe();
@ -338,7 +337,7 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public void updateCultureMine(String culture) throws JsonProcessingException { public void updateCultureMine(String culture) throws JsonProcessingException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting User culture").And("culture", culture)); logger.debug(new MapLogEntry("persisting User culture").And("culture", culture));
UUID userId = this.userScope.getUserIdSafe(); UUID userId = this.userScope.getUserIdSafe();

View File

@ -2,16 +2,14 @@ package eu.eudat.service.user.settings;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.data.UserSettingsEntity; import eu.eudat.data.UserSettingsEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.UserSettings; import eu.eudat.model.UserSettings;
import eu.eudat.model.builder.UserSettingsBuilder; import eu.eudat.model.builder.UserSettingsBuilder;
import eu.eudat.model.persist.UserSettingsPersist; import eu.eudat.model.persist.UserSettingsPersist;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyNotFoundException;
@ -20,7 +18,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -35,34 +32,25 @@ import java.util.UUID;
public class UserSettingsServiceImpl implements UserSettingsService { public class UserSettingsServiceImpl implements UserSettingsService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserSettingsServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserSettingsServiceImpl.class));
private final EntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final ConventionService conventionService; private final ConventionService conventionService;
private final ErrorThesaurusProperties errors;
private final MessageSource messageSource; private final MessageSource messageSource;
private final UserScope userScope;
@Autowired @Autowired
public UserSettingsServiceImpl( public UserSettingsServiceImpl(
EntityManager entityManager, TenantEntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,
ConventionService conventionService, ConventionService conventionService,
ErrorThesaurusProperties errors, MessageSource messageSource) {
MessageSource messageSource,
UserScope userScope) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.conventionService = conventionService; this.conventionService = conventionService;
this.errors = errors;
this.messageSource = messageSource; this.messageSource = messageSource;
this.userScope = userScope;
} }
@Override @Override

View File

@ -1,6 +1,9 @@
package eu.eudat.configurations; package eu.eudat.configurations;
import eu.eudat.interceptors.UserInterceptor; import eu.eudat.interceptors.tenant.TenantInterceptor;
import eu.eudat.interceptors.tenant.TenantScopeClaimInterceptor;
import eu.eudat.interceptors.tenant.TenantScopeHeaderInterceptor;
import eu.eudat.interceptors.user.UserInterceptor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
@ -15,11 +18,17 @@ import java.util.List;
@Configuration @Configuration
@EnableScheduling @EnableScheduling
public class WebMVCConfiguration implements WebMvcConfigurer { public class WebMVCConfiguration implements WebMvcConfigurer {
private final TenantInterceptor tenantInterceptor;
private final UserInterceptor userInterceptor; private final UserInterceptor userInterceptor;
private final TenantScopeHeaderInterceptor scopeHeaderInterceptor;
private final TenantScopeClaimInterceptor scopeClaimInterceptor;
@Autowired @Autowired
public WebMVCConfiguration(UserInterceptor userInterceptor) { public WebMVCConfiguration(TenantInterceptor tenantInterceptor, UserInterceptor userInterceptor, TenantScopeHeaderInterceptor scopeHeaderInterceptor, TenantScopeClaimInterceptor scopeClaimInterceptor) {
this.tenantInterceptor = tenantInterceptor;
this.userInterceptor = userInterceptor; this.userInterceptor = userInterceptor;
this.scopeHeaderInterceptor = scopeHeaderInterceptor;
this.scopeClaimInterceptor = scopeClaimInterceptor;
} }
@Autowired @Autowired
@ -29,6 +38,10 @@ public class WebMVCConfiguration implements WebMvcConfigurer {
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addWebRequestInterceptor(userInterceptor).order(1); int order = 1;
registry.addWebRequestInterceptor(scopeHeaderInterceptor).order(order++);
registry.addWebRequestInterceptor(scopeClaimInterceptor).order(order++);
registry.addWebRequestInterceptor(userInterceptor).order(order++);
registry.addWebRequestInterceptor(tenantInterceptor).order(order++);
} }
} }

View File

@ -174,7 +174,7 @@ public class DescriptionController {
@PostMapping("persist-status") @PostMapping("persist-status")
@Transactional @Transactional
@ValidationFilterAnnotation(validator = DescriptionStatusPersist.DescriptionStatusPersistValidator.ValidatorName, argumentName = "model") @ValidationFilterAnnotation(validator = DescriptionStatusPersist.DescriptionStatusPersistValidator.ValidatorName, argumentName = "model")
public Description persistStatus(@RequestBody DescriptionStatusPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException { public Description persistStatus(@RequestBody DescriptionStatusPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
Description persisted = this.descriptionService.persistStatus(model, fieldSet); Description persisted = this.descriptionService.persistStatus(model, fieldSet);
@ -200,7 +200,7 @@ public class DescriptionController {
} }
@GetMapping("validate") @GetMapping("validate")
public List<DescriptionValidationResult> validate(@RequestParam(value="descriptionIds") List<UUID> descriptionIds) throws MyApplicationException, MyForbiddenException, MyNotFoundException { public List<DescriptionValidationResult> validate(@RequestParam(value="descriptionIds") List<UUID> descriptionIds) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
logger.debug(new MapLogEntry("validating" + Description.class.getSimpleName()).And("descriptionIds", descriptionIds)); logger.debug(new MapLogEntry("validating" + Description.class.getSimpleName()).And("descriptionIds", descriptionIds));
this.censorFactory.censor(DescriptionCensor.class).censor(null, null); this.censorFactory.censor(DescriptionCensor.class).censor(null, null);

View File

@ -163,7 +163,7 @@ public class PrefillingSourceController {
@PostMapping("generate") @PostMapping("generate")
@ValidationFilterAnnotation(validator = DescriptionProfilingRequest.DescriptionProfilingRequestValidator.ValidatorName, argumentName = "model") @ValidationFilterAnnotation(validator = DescriptionProfilingRequest.DescriptionProfilingRequestValidator.ValidatorName, argumentName = "model")
public Description generate(@RequestBody DescriptionProfilingRequest model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { public Description generate(@RequestBody DescriptionProfilingRequest model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting" + Prefilling.class.getSimpleName()).And("model", model)); logger.debug(new MapLogEntry("persisting" + Prefilling.class.getSimpleName()).And("model", model));
this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null); this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null);

View File

@ -1,21 +1,26 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction; import eu.eudat.audit.AuditableAction;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.models.Account; import eu.eudat.models.Account;
import eu.eudat.models.AccountBuilder; import eu.eudat.models.AccountBuilder;
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver; import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
import gr.cite.commons.web.oidc.principal.MyPrincipal; import gr.cite.commons.web.oidc.principal.MyPrincipal;
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractor;
import gr.cite.tools.auditing.AuditService; import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.util.List;
import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping(value = { "/api/principal/" }) @RequestMapping(value = { "/api/principal/" })
@ -25,15 +30,17 @@ public class PrincipalController {
private final CurrentPrincipalResolver currentPrincipalResolver; private final CurrentPrincipalResolver currentPrincipalResolver;
private final AccountBuilder accountBuilder; private final AccountBuilder accountBuilder;
private final ClaimExtractor claimExtractor;
@Autowired @Autowired
public PrincipalController( public PrincipalController(
CurrentPrincipalResolver currentPrincipalResolver, CurrentPrincipalResolver currentPrincipalResolver,
AccountBuilder accountBuilder, AccountBuilder accountBuilder,
AuditService auditService) { AuditService auditService, ClaimExtractor claimExtractor) {
this.currentPrincipalResolver = currentPrincipalResolver; this.currentPrincipalResolver = currentPrincipalResolver;
this.accountBuilder = accountBuilder; this.accountBuilder = accountBuilder;
this.auditService = auditService; this.auditService = auditService;
this.claimExtractor = claimExtractor;
} }
@RequestMapping(path = "me", method = RequestMethod.GET ) @RequestMapping(path = "me", method = RequestMethod.GET )
@ -71,4 +78,17 @@ public class PrincipalController {
return me; return me;
} }
@GetMapping("my-tenants")
public List<String> myTenants() {
logger.debug("my-tenants");
MyPrincipal principal = this.currentPrincipalResolver.currentPrincipal();
List<String> tenants = this.claimExtractor.asStrings(principal, TenantScope.TenantCodesClaimName);
this.auditService.track(AuditableAction.Principal_MyTenants);
//auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return tenants == null ? null : tenants.stream().distinct().collect(Collectors.toList());
}
} }

View File

@ -93,7 +93,7 @@ public class ReferenceController {
@PostMapping("search") @PostMapping("search")
public List<Reference> searchReferenceWithDefinition(@RequestBody ReferenceSearchLookup lookup) throws MyNotFoundException { public List<Reference> searchReferenceWithDefinition(@RequestBody ReferenceSearchLookup lookup) throws MyNotFoundException, InvalidApplicationException {
logger.debug("search with db definition {}", Reference.class.getSimpleName()); logger.debug("search with db definition {}", Reference.class.getSimpleName());
this.censorFactory.censor(ReferenceCensor.class).censor(lookup.getProject(), null); this.censorFactory.censor(ReferenceCensor.class).censor(lookup.getProject(), null);

View File

@ -0,0 +1,10 @@
package eu.eudat.interceptors.tenant;
import gr.cite.tools.cache.CacheOptions;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "cache.tenant-by-code")
public class TenantByCodeCacheOptions extends CacheOptions {
}

View File

@ -0,0 +1,78 @@
package eu.eudat.interceptors.tenant;
import eu.eudat.convention.ConventionService;
import eu.eudat.event.TenantTouchedEvent;
import gr.cite.tools.cache.CacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.UUID;
@Service
public class TenantByCodeCacheService extends CacheService<TenantByCodeCacheService.TenantByCodeCacheValue> {
public static class TenantByCodeCacheValue {
public TenantByCodeCacheValue() {
}
public TenantByCodeCacheValue(String tenantCode, UUID tenantId) {
this.tenantCode = tenantCode;
this.tenantId = tenantId;
}
private String tenantCode;
public String getTenantCode() {
return tenantCode;
}
public void setTenantCode(String tenantCode) {
this.tenantCode = tenantCode;
}
private UUID tenantId;
public UUID getTenantId() {
return tenantId;
}
public void setTenantId(UUID tenantId) {
this.tenantId = tenantId;
}
}
private final ConventionService conventionService;
@Autowired
public TenantByCodeCacheService(TenantByCodeCacheOptions options, ConventionService conventionService) {
super(options);
this.conventionService = conventionService;
}
@EventListener
public void handleTenantTouchedEvent(TenantTouchedEvent event) {
if (!this.conventionService.isNullOrEmpty(event.getTenantCode()))
this.evict(this.buildKey(event.getTenantCode()));
if (!this.conventionService.isNullOrEmpty(event.getPreviousTenantCode()))
this.evict(this.buildKey(event.getPreviousTenantCode()));
}
@Override
protected Class<TenantByCodeCacheValue> valueClass() {
return TenantByCodeCacheValue.class;
}
@Override
public String keyOf(TenantByCodeCacheValue value) {
return this.buildKey(value.getTenantCode());
}
public String buildKey(String code) {
HashMap<String, String> keyParts = new HashMap<>();
keyParts.put("$code$", code);
return this.generateKey(keyParts);
}
}

View File

@ -0,0 +1,10 @@
package eu.eudat.interceptors.tenant;
import gr.cite.tools.cache.CacheOptions;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "cache.tenant-by-id")
public class TenantByIdCacheOptions extends CacheOptions {
}

View File

@ -0,0 +1,77 @@
package eu.eudat.interceptors.tenant;
import eu.eudat.convention.ConventionService;
import eu.eudat.event.TenantTouchedEvent;
import gr.cite.tools.cache.CacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Locale;
import java.util.UUID;
@Service
public class TenantByIdCacheService extends CacheService<TenantByIdCacheService.TenantByIdCacheValue> {
public static class TenantByIdCacheValue {
public TenantByIdCacheValue() {
}
public TenantByIdCacheValue(String tenantCode, UUID tenantId) {
this.tenantCode = tenantCode;
this.tenantId = tenantId;
}
private String tenantCode;
public String getTenantCode() {
return tenantCode;
}
public void setTenantCode(String tenantCode) {
this.tenantCode = tenantCode;
}
private UUID tenantId;
public UUID getTenantId() {
return tenantId;
}
public void setTenantId(UUID tenantId) {
this.tenantId = tenantId;
}
}
private final ConventionService conventionService;
@Autowired
public TenantByIdCacheService(TenantByIdCacheOptions options, ConventionService conventionService) {
super(options);
this.conventionService = conventionService;
}
@EventListener
public void handleTenantTouchedEvent(TenantTouchedEvent event) {
if (!this.conventionService.isNullOrEmpty(event.getTenantCode()))
this.evict(this.buildKey(event.getTenantId()));
}
@Override
protected Class<TenantByIdCacheValue> valueClass() {
return TenantByIdCacheValue.class;
}
@Override
public String keyOf(TenantByIdCacheValue value) {
return this.buildKey(value.getTenantId());
}
public String buildKey(UUID id) {
HashMap<String, String> keyParts = new HashMap<>();
keyParts.put("$tenantId$", id.toString().toLowerCase(Locale.ROOT));
return this.generateKey(keyParts);
}
}

View File

@ -0,0 +1,222 @@
package eu.eudat.interceptors.tenant;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DmpReferenceEntity;
import eu.eudat.data.ReferenceEntity;
import eu.eudat.data.TenantUserEntity;
import eu.eudat.data.UserEntity;
import eu.eudat.data.tenant.TenantScopedBaseEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.query.utils.BuildSubQueryInput;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractor;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.logging.LoggerService;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.persistence.Tuple;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Root;
import jakarta.persistence.criteria.Subquery;
import org.hibernate.Session;
import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.ui.ModelMap;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor;
import javax.management.InvalidApplicationException;
import java.time.Instant;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
@Component
public class TenantInterceptor implements WebRequestInterceptor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantInterceptor.class));
private final TenantScope tenantScope;
private final UserScope userScope;
private final CurrentPrincipalResolver currentPrincipalResolver;
private final ClaimExtractor claimExtractor;
private final ApplicationContext applicationContext;
private final TenantScopeProperties tenantScopeProperties;
private final UserAllowedTenantCacheService userAllowedTenantCacheService;
private final PlatformTransactionManager transactionManager;
private final ErrorThesaurusProperties errors;
private final QueryUtilsService queryUtilsService;
@PersistenceContext
public EntityManager entityManager;
@Autowired
public TenantInterceptor(
TenantScope tenantScope,
UserScope userScope,
CurrentPrincipalResolver currentPrincipalResolver,
ClaimExtractor claimExtractor,
ApplicationContext applicationContext,
TenantScopeProperties tenantScopeProperties,
UserAllowedTenantCacheService userAllowedTenantCacheService,
PlatformTransactionManager transactionManager,
ErrorThesaurusProperties errors, QueryUtilsService queryUtilsService) {
this.tenantScope = tenantScope;
this.userScope = userScope;
this.currentPrincipalResolver = currentPrincipalResolver;
this.claimExtractor = claimExtractor;
this.applicationContext = applicationContext;
this.tenantScopeProperties = tenantScopeProperties;
this.userAllowedTenantCacheService = userAllowedTenantCacheService;
this.transactionManager = transactionManager;
this.errors = errors;
this.queryUtilsService = queryUtilsService;
}
@Override
public void preHandle(@NotNull WebRequest request) throws InvalidApplicationException {
if (!this.currentPrincipalResolver.currentPrincipal().isAuthenticated()) return;
if (!this.tenantScope.isMultitenant()) return;
boolean isAllowedNoTenant = this.applicationContext.getBean(AuthorizationService.class).authorize(Permission.AllowNoTenant);
if (tenantScope.isSet() && this.entityManager != null) {
List<String> currentPrincipalTenantCodes = this.claimExtractor.asStrings(this.currentPrincipalResolver.currentPrincipal(), TenantScope.TenantCodesClaimName);
if ((currentPrincipalTenantCodes == null || !currentPrincipalTenantCodes.contains(tenantScope.getTenantCode())) && !isAllowedNoTenant) {
logger.warn("tenant not allowed {}", this.tenantScope.getTenant());
throw new MyForbiddenException(this.errors.getTenantNotAllowed().getCode(), this.errors.getTenantNotAllowed().getMessage());
}
boolean isUserAllowedTenant = false;
UserAllowedTenantCacheService.UserAllowedTenantCacheValue cacheValue = this.userAllowedTenantCacheService.lookup(this.userAllowedTenantCacheService.buildKey(this.userScope.getUserId(), this.tenantScope.getTenant()));
if (cacheValue != null) {
isUserAllowedTenant = cacheValue.isAllowed();
} else {
isUserAllowedTenant = this.isUserAllowedTenant();
this.userAllowedTenantCacheService.put(new UserAllowedTenantCacheService.UserAllowedTenantCacheValue(this.userScope.getUserId(), this.tenantScope.getTenant(), isUserAllowedTenant));
}
if (isUserAllowedTenant) {
this.entityManager
.unwrap(Session.class)
.enableFilter(TenantScopedBaseEntity.tenantFilter).setParameter(TenantScopedBaseEntity.tenantFilterTenantParam, tenantScope.getTenant().toString());
} else {
if (isAllowedNoTenant || this.isWhiteListedEndpoint(request)) {
tenantScope.setTenant(null, null);
} else {
logger.warn("tenant not allowed {}", this.tenantScope.getTenant());
throw new MyForbiddenException(this.errors.getTenantNotAllowed().getCode(), this.errors.getTenantNotAllowed().getMessage());
}
}
} else {
if (!isAllowedNoTenant) {
if (!this.isWhiteListedEndpoint(request)) {
logger.warn("tenant scope not provided");
throw new MyForbiddenException(this.errors.getMissingTenant().getCode(), this.errors.getMissingTenant().getMessage());
}
}
}
}
private boolean isWhiteListedEndpoint(WebRequest request) {
String servletPath = ((ServletWebRequest) request).getRequest().getServletPath();
if (this.tenantScopeProperties.getWhiteListedEndpoints() != null) {
for (String whiteListedEndpoint : this.tenantScopeProperties.getWhiteListedEndpoints()) {
if (servletPath.toLowerCase(Locale.ROOT).startsWith(whiteListedEndpoint.toLowerCase(Locale.ROOT))) {
return true;
}
}
}
return false;
}
private boolean isUserAllowedTenant() throws InvalidApplicationException {
if (userScope.isSet()) {
CriteriaBuilder criteriaBuilder = this.entityManager.getCriteriaBuilder();
CriteriaQuery<Tuple> query = criteriaBuilder.createQuery(Tuple.class);
Root<UserEntity> root = query.from(UserEntity.class);
query.where(criteriaBuilder.and(
criteriaBuilder.equal(root.get(UserEntity._isActive), IsActive.Active),
criteriaBuilder.in(root.get(UserEntity._id)).value(queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(TenantUserEntity.class, UUID.class)
.query(query)
.criteriaBuilder(criteriaBuilder)
.keyPathFunc((subQueryRoot) -> subQueryRoot.get(TenantUserEntity._userId))
.filterFunc((subQueryRoot, cb) ->
{
try {
return cb.and(
criteriaBuilder.equal(subQueryRoot.get(TenantUserEntity._tenantId), this.tenantScope.getTenant()),
criteriaBuilder.equal(subQueryRoot.get(TenantUserEntity._userId), this.userScope.getUserId()),
criteriaBuilder.equal(subQueryRoot.get(TenantUserEntity._isActive), IsActive.Active)
);
} catch (InvalidApplicationException e) {
throw new RuntimeException(e);
}
}
)
))
)
));
query.multiselect(root.get(UserEntity._id).alias(UserEntity._id));
List<Tuple> results = this.entityManager.createQuery(query).getResultList();
if (results.isEmpty() && this.tenantScopeProperties.getAutoCreateTenantUser()) {
return this.createTenantUser();
} else {
return !results.isEmpty();
}
}
return false;
}
private boolean createTenantUser() throws InvalidApplicationException {
TenantUserEntity user = new TenantUserEntity();
user.setId(UUID.randomUUID());
user.setCreatedAt(Instant.now());
user.setUpdatedAt(Instant.now());
user.setIsActive(IsActive.Active);
user.setTenantId(this.tenantScope.getTenant());
user.setUserId(userScope.getUserId());
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
definition.setName(UUID.randomUUID().toString());
definition.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = null;
try {
status = transactionManager.getTransaction(definition);
this.entityManager.persist(user);
this.entityManager.flush();
transactionManager.commit(status);
} catch (Exception ex) {
if (status != null) transactionManager.rollback(status);
throw ex;
}
return true;
}
@Override
public void postHandle(@NonNull WebRequest request, ModelMap model) {
this.tenantScope.setTenant(null, null);
}
@Override
public void afterCompletion(@NonNull WebRequest request, Exception ex) {
}
}

View File

@ -0,0 +1,200 @@
package eu.eudat.interceptors.tenant;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.TenantEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
import gr.cite.commons.web.oidc.principal.MyPrincipal;
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractor;
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractorContext;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.logging.LoggerService;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.persistence.Tuple;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Root;
import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.ui.ModelMap;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor;
import javax.management.InvalidApplicationException;
import java.util.List;
import java.util.UUID;
@Component
public class TenantScopeClaimInterceptor implements WebRequestInterceptor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantScopeClaimInterceptor.class));
private final TenantScope tenantScope;
private final ConventionService conventionService;
private final TenantScopeProperties tenantScopeProperties;
private final ErrorThesaurusProperties errorThesaurusProperties;
private final ClaimExtractor claimExtractor;
private final CurrentPrincipalResolver currentPrincipalResolver;
private final String clientTenantClaimName;
private final ClaimExtractorContext claimExtractorContext;
private final TenantByCodeCacheService tenantByCodeCacheService;
private final TenantByIdCacheService tenantByIdCacheService;
@PersistenceContext
public EntityManager entityManager;
@Autowired
public TenantScopeClaimInterceptor(
TenantScope tenantScope,
ConventionService conventionService,
ClaimExtractor claimExtractor,
CurrentPrincipalResolver currentPrincipalResolver,
ErrorThesaurusProperties errorThesaurusProperties,
TenantScopeProperties tenantScopeProperties,
ClaimExtractorContext claimExtractorContext,
TenantByCodeCacheService tenantByCodeCacheService,
TenantByIdCacheService tenantByIdCacheService
) {
this.tenantScope = tenantScope;
this.conventionService = conventionService;
this.currentPrincipalResolver = currentPrincipalResolver;
this.claimExtractor = claimExtractor;
this.errorThesaurusProperties = errorThesaurusProperties;
this.tenantScopeProperties = tenantScopeProperties;
this.claimExtractorContext = claimExtractorContext;
this.tenantByCodeCacheService = tenantByCodeCacheService;
this.tenantByIdCacheService = tenantByIdCacheService;
this.clientTenantClaimName = this.tenantScopeProperties.getClientClaimsPrefix() + TenantScope.TenantClaimName;
}
@Override
public void preHandle(@NotNull WebRequest request) throws InvalidApplicationException {
if (!this.currentPrincipalResolver.currentPrincipal().isAuthenticated()) return;
if (!this.tenantScope.isMultitenant()) return;
MyPrincipal principal = this.currentPrincipalResolver.currentPrincipal();
if (principal != null && principal.isAuthenticated() /* principal.Claims.Any() */) {
Boolean scoped = this.scopeByPrincipal(this.tenantScope, principal);
if (!scoped) scoped = this.scopeByClient(this.tenantScope, principal);
if (!scoped && this.tenantScope.isSet() && this.tenantScopeProperties.getEnforceTrustedTenant())
throw new MyForbiddenException(this.errorThesaurusProperties.getMissingTenant().getCode(), this.errorThesaurusProperties.getMissingTenant().getMessage());
}
}
private Boolean scopeByPrincipal(TenantScope scope, MyPrincipal principal) {
String tenantCode = this.claimExtractor.tenantString(principal);
if (tenantCode == null || tenantCode.isBlank())
tenantCode = this.claimExtractor.asString(principal, this.clientTenantClaimName);
UUID tenantId = this.conventionService.parseUUIDSafe(tenantCode);
if (tenantId == null && tenantCode == null)
return Boolean.FALSE;
if (tenantId == null) {
TenantByCodeCacheService.TenantByCodeCacheValue cacheValue = this.tenantByCodeCacheService.lookup(this.tenantByCodeCacheService.buildKey(tenantCode));
if (cacheValue != null) {
tenantId = cacheValue.getTenantId();
} else {
tenantId = this.getTenantIdFromDatabase(tenantCode);
this.tenantByCodeCacheService.put(new TenantByCodeCacheService.TenantByCodeCacheValue(tenantCode, tenantId));
this.tenantByIdCacheService.put(new TenantByIdCacheService.TenantByIdCacheValue(tenantCode, tenantId));
}
} else {
logger.debug("tenant claim was set to {}", tenantId);
TenantByIdCacheService.TenantByIdCacheValue cacheValue = this.tenantByIdCacheService.lookup(this.tenantByIdCacheService.buildKey(tenantId));
if (cacheValue != null) {
tenantCode = cacheValue.getTenantCode();
} else {
tenantCode = this.getTenantCodeFromDatabase(tenantId);
this.tenantByCodeCacheService.put(new TenantByCodeCacheService.TenantByCodeCacheValue(tenantCode, tenantId));
this.tenantByIdCacheService.put(new TenantByIdCacheService.TenantByIdCacheValue(tenantCode, tenantId));
}
}
if (tenantId != null && tenantCode != null && !tenantCode.isBlank()) {
logger.debug("parsed tenant header and set tenant id to {}", tenantId);
this.tenantScope.setTenant(tenantId, tenantCode);
this.claimExtractorContext.putReplaceParameter(TenantScope.TenantReplaceParameter, tenantCode);
}
return tenantId != null;
}
private Boolean scopeByClient(TenantScope scope, MyPrincipal principal) throws InvalidApplicationException {
String client = this.claimExtractor.client(principal);
Boolean isWhiteListed = this.tenantScopeProperties.getWhiteListedClients() != null && !this.conventionService.isNullOrEmpty(client) && this.tenantScopeProperties.getWhiteListedClients().contains(client);
logger.debug("client is whitelisted : {}, scope is set: {}, with value {}", isWhiteListed, scope.isSet(), (scope.isSet() ? scope.getTenant() : null));
return isWhiteListed && scope.isSet();
}
private UUID getTenantIdFromDatabase(String tenantCode) {
CriteriaBuilder criteriaBuilder = this.entityManager.getCriteriaBuilder();
CriteriaQuery<Tuple> query = criteriaBuilder.createQuery(Tuple.class);
Root<TenantEntity> root = query.from(TenantEntity.class);
query = query.where(
criteriaBuilder.and(
criteriaBuilder.equal(root.get(TenantEntity._code), tenantCode),
criteriaBuilder.equal(root.get(TenantEntity._isActive), IsActive.Active)
)
).multiselect(root.get(TenantEntity._id).alias(TenantEntity._id));
List<Tuple> results = this.entityManager.createQuery(query).getResultList();
if (results.size() == 1) {
Object o;
try {
o = results.getFirst().get(TenantEntity._id);
} catch (IllegalArgumentException e) {
return null;
}
if (o == null) return null;
try {
return (UUID) o;
} catch (ClassCastException e) {
return null;
}
}
return null;
}
private String getTenantCodeFromDatabase(UUID tenantId) {
CriteriaBuilder criteriaBuilder = this.entityManager.getCriteriaBuilder();
CriteriaQuery<Tuple> query = criteriaBuilder.createQuery(Tuple.class);
Root<TenantEntity> root = query.from(TenantEntity.class);
query = query.where(
criteriaBuilder.and(
criteriaBuilder.equal(root.get(TenantEntity._id), tenantId),
criteriaBuilder.equal(root.get(TenantEntity._isActive), IsActive.Active)
)
).multiselect(root.get(TenantEntity._code).alias(TenantEntity._code));
List<Tuple> results = this.entityManager.createQuery(query).getResultList();
if (results.size() == 1) {
Object o;
try {
o = results.getFirst().get(TenantEntity._code);
} catch (IllegalArgumentException e) {
return null;
}
if (o == null) return null;
try {
return (String) o;
} catch (ClassCastException e) {
return null;
}
}
return null;
}
@Override
public void postHandle(@NonNull WebRequest request, ModelMap model) {
this.tenantScope.setTenant(null, null);
this.claimExtractorContext.removeReplaceParameter(TenantScope.TenantReplaceParameter);
}
@Override
public void afterCompletion(@NonNull WebRequest request, Exception ex) {
}
}

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