Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Efstratios Giannopoulos 2024-01-04 12:56:23 +02:00
commit 73b0272672
24 changed files with 1004 additions and 332 deletions

View File

@ -24,9 +24,10 @@ public class SupportiveMaterialEntity extends TenantScopedBaseEntity {
private SupportiveMaterialFieldType type;
public static final String _type = "type";
@Column(name = "language_code", length = 20, nullable = false)
@Column(name = "language_code", length = _languageCodeLength, nullable = false)
private String languageCode;
public static final String _languageCode = "languageCode";
public static final int _languageCodeLength = 20;
@Column(name = "payload", nullable = false)
private String payload;

View File

@ -17,13 +17,15 @@ public class TenantEntity {
private UUID id;
public final static String _id = "id";
@Column(name = "code", length = 200, nullable = false)
@Column(name = "code", length = _codeLength, nullable = false)
private String code;
public final static String _code = "code";
public final static int _codeLength = 200;
@Column(name = "name", length = 500, nullable = false)
@Column(name = "name", length = _nameLength, nullable = false)
private String name;
public final static String _name = "name";
public final static int _nameLength = 500;
@Column(name = "description", nullable = false)
private String description;

View File

@ -1,37 +1,40 @@
package eu.eudat.model.persist;
import eu.eudat.commons.enums.StorageType;
import eu.eudat.commons.validation.old.ValidEnum;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.StorageFileEntity;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class StorageFilePersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max = StorageFileEntity._nameLen, message = "{validation.largerthanmax}")
private String name;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max = StorageFileEntity._extensionLen, message = "{validation.largerthanmax}")
public static final String _name = "name";
private String extension;
public static final String _extension = "extension";
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max = StorageFileEntity._mimeTypeLen, message = "{validation.largerthanmax}")
private String mimeType;
@NotNull(message = "{validation.empty}")
@ValidEnum(message = "{validation.empty}")
public static final String _mimeType = "mimeType";
private StorageType storageType;
public static final String _storageType = "storageType";
private Duration lifetime;
private UUID ownerId;
@ -83,4 +86,54 @@ public class StorageFilePersist {
public void setLifetime(Duration lifetime) {
this.lifetime = lifetime;
}
@Component(StorageFilePersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class StorageFilePersistValidator extends BaseValidator<StorageFilePersist> {
public static final String ValidatorName = "StorageFilePersistValidator";
private final MessageSource messageSource;
protected StorageFilePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<StorageFilePersist> modelClass() {
return StorageFilePersist.class;
}
@Override
protected List<Specification> specifications(StorageFilePersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getName()))
.failOn(StorageFilePersist._name).failWith(messageSource.getMessage("Validation_Required", new Object[]{StorageFilePersist._name}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getName()))
.must(() -> this.lessEqualLength(item.getName(), StorageFileEntity._nameLen))
.failOn(StorageFilePersist._name).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{StorageFilePersist._name}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getExtension()))
.failOn(StorageFilePersist._extension).failWith(messageSource.getMessage("Validation_Required", new Object[]{StorageFilePersist._extension}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getExtension()))
.must(() -> this.lessEqualLength(item.getExtension(), StorageFileEntity._extensionLen))
.failOn(StorageFilePersist._extension).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{StorageFilePersist._extension}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getMimeType()))
.failOn(StorageFilePersist._mimeType).failWith(messageSource.getMessage("Validation_Required", new Object[]{StorageFilePersist._mimeType}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getMimeType()))
.must(() -> this.lessEqualLength(item.getMimeType(), StorageFileEntity._mimeTypeLen))
.failOn(StorageFilePersist._mimeType).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{StorageFilePersist._mimeType}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getStorageType()))
.failOn(StorageFilePersist._storageType).failWith(messageSource.getMessage("Validation_Required", new Object[]{StorageFilePersist._storageType}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -1,69 +1,125 @@
package eu.eudat.model.persist;
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
import eu.eudat.commons.validation.old.ValidEnum;
import eu.eudat.commons.validation.old.ValidId;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.SupportiveMaterialEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class SupportiveMaterialPersist {
@ValidId(message = "{validation.invalidid}")
private UUID id;
public class SupportiveMaterialPersist {
@ValidEnum(message = "{validation.empty}")
private SupportiveMaterialFieldType type;
private UUID id;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max = 20, message = "{validation.largerthanmax}")
private String languageCode;
private SupportiveMaterialFieldType type;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String payload;
public static final String _type = "type";
private String hash;
private String languageCode;
public UUID getId() {
return id;
}
public static final String _languageCode = "languageCode";
public void setId(UUID id) {
this.id = id;
}
private String payload;
public SupportiveMaterialFieldType getType() {
return type;
}
public static final String _payload = "payload";
public void setType(SupportiveMaterialFieldType type) {
this.type = type;
}
private String hash;
public String getLanguageCode() {
return languageCode;
}
public static final String _hash = "hash";
public void setLanguageCode(String languageCode) {
this.languageCode = languageCode;
}
public UUID getId() {
return id;
}
public String getPayload() {
return payload;
}
public void setId(UUID id) {
this.id = id;
}
public void setPayload(String payload) {
this.payload = payload;
}
public SupportiveMaterialFieldType getType() {
return type;
}
public String getHash() {
return hash;
}
public void setType(SupportiveMaterialFieldType type) {
this.type = type;
}
public String getLanguageCode() {
return languageCode;
}
public void setLanguageCode(String languageCode) {
this.languageCode = languageCode;
}
public String getPayload() {
return payload;
}
public void setPayload(String payload) {
this.payload = payload;
}
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
@Component(SupportiveMaterialPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class SupportiveMaterialPersistValidator extends BaseValidator<SupportiveMaterialPersist> {
public static final String ValidatorName = "SupportiveMaterialPersistValidator";
private final MessageSource messageSource;
protected SupportiveMaterialPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<SupportiveMaterialPersist> modelClass() {
return SupportiveMaterialPersist.class;
}
@Override
protected List<Specification> specifications(SupportiveMaterialPersist item) {
return Arrays.asList(
this.spec()
.iff(() -> this.isValidGuid(item.getId()))
.must(() -> this.isValidHash(item.getHash()))
.failOn(SupportiveMaterialPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{SupportiveMaterialPersist._hash}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isValidGuid(item.getId()))
.must(() -> !this.isValidHash(item.getHash()))
.failOn(SupportiveMaterialPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getType()))
.failOn(SupportiveMaterialPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{SupportiveMaterialPersist._type}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getLanguageCode()))
.failOn(SupportiveMaterialPersist._languageCode).failWith(messageSource.getMessage("Validation_Required", new Object[]{SupportiveMaterialPersist._languageCode}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getLanguageCode()))
.must(() -> this.lessEqualLength(item.getLanguageCode(), SupportiveMaterialEntity._languageCodeLength))
.failOn(SupportiveMaterialPersist._languageCode).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{SupportiveMaterialPersist._languageCode}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getPayload()))
.failOn(SupportiveMaterialPersist._payload).failWith(messageSource.getMessage("Validation_Required", new Object[]{SupportiveMaterialPersist._payload}, LocaleContextHolder.getLocale()))
);
}
}
public void setHash(String hash) {
this.hash = hash;
}
}

View File

@ -1,36 +1,46 @@
package eu.eudat.model.persist;
import eu.eudat.commons.validation.old.FieldNotNullIfOtherSet;
import eu.eudat.commons.validation.old.ValidId;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.TenantEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.persist.tenantconfig.TenantConfigPersist;
import jakarta.validation.constraints.*;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
public class TenantPersist {
@ValidId(message = "{validation.invalidid}")
private UUID id;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max= 200, message = "{validation.largerthanmax}")
private String code;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max= 500, message = "{validation.largerthanmax}")
public static final String _code = "code";
private String name;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
public static final String _name = "name";
private String description;
public static final String _description = "description";
private TenantConfigPersist config;
public static final String _config = "config";
private String hash;
public static final String _hash = "hash";
public UUID getId() {
return id;
}
@ -78,4 +88,64 @@ public class TenantPersist {
public void setHash(String hash) {
this.hash = hash;
}
@Component(TenantPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class TenantPersistValidator extends BaseValidator<TenantPersist> {
public static final String ValidatorName = "TenantPersistValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected TenantPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<TenantPersist> modelClass() {
return TenantPersist.class;
}
@Override
protected List<Specification> specifications(TenantPersist item) {
return Arrays.asList(
this.spec()
.iff(() -> this.isValidGuid(item.getId()))
.must(() -> this.isValidHash(item.getHash()))
.failOn(TenantPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantPersist._hash}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isValidGuid(item.getId()))
.must(() -> !this.isValidHash(item.getHash()))
.failOn(TenantPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getCode()))
.failOn(TenantPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantPersist._code}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getCode()))
.must(() -> this.lessEqualLength(item.getCode(), TenantEntity._codeLength))
.failOn(TenantPersist._code).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{TenantPersist._code}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getName()))
.failOn(TenantPersist._name).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantPersist._name}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getName()))
.must(() -> this.lessEqualLength(item.getName(), TenantEntity._nameLength))
.failOn(TenantPersist._name).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{TenantPersist._name}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getDescription()))
.failOn(TenantPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantPersist._description}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getConfig()))
.on(TenantPersist._config)
.over(item.getConfig())
.using(() -> this.validatorFactory.validator(TenantConfigPersist.TenantConfigPersistValidator.class))
);
}
}
}

View File

@ -1,77 +1,124 @@
package eu.eudat.model.persist;
import eu.eudat.commons.validation.old.ValidId;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class UserAdditionalInfoPersist {
private String avatarUrl;
private String avatarUrl;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String timezone;
private String timezone;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String culture;
public static final String _timezone = "timezone";
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String language;
private String roleOrganization;
private String culture;
@ValidId(message = "{validation.invalidid}")
private UUID organizationId;
public static final String _culture = "culture";
public String getAvatarUrl() {
return avatarUrl;
}
private String language;
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
public static final String _language = "language";
public String getTimezone() {
return timezone;
}
private String roleOrganization;
public void setTimezone(String timezone) {
this.timezone = timezone;
}
private UUID organizationId;
public String getCulture() {
return culture;
}
public static final String _organizationId = "organizationId";
public void setCulture(String culture) {
this.culture = culture;
}
public String getAvatarUrl() {
return avatarUrl;
}
public String getLanguage() {
return language;
}
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
public void setLanguage(String language) {
this.language = language;
}
public String getTimezone() {
return timezone;
}
public String getRoleOrganization() {
return roleOrganization;
}
public void setTimezone(String timezone) {
this.timezone = timezone;
}
public void setRoleOrganization(String roleOrganization) {
this.roleOrganization = roleOrganization;
}
public String getCulture() {
return culture;
}
public UUID getOrganizationId() {
return organizationId;
}
public void setCulture(String culture) {
this.culture = culture;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getRoleOrganization() {
return roleOrganization;
}
public void setRoleOrganization(String roleOrganization) {
this.roleOrganization = roleOrganization;
}
public UUID getOrganizationId() {
return organizationId;
}
public void setOrganizationId(UUID organizationId) {
this.organizationId = organizationId;
}
@Component(UserAdditionalInfoPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class UserAdditionalInfoPersistValidator extends BaseValidator<UserAdditionalInfoPersist> {
public static final String ValidatorName = "UserAdditionalInfoPersistValidator";
private final MessageSource messageSource;
protected UserAdditionalInfoPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<UserAdditionalInfoPersist> modelClass() {
return UserAdditionalInfoPersist.class;
}
@Override
protected List<Specification> specifications(UserAdditionalInfoPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getTimezone()))
.failOn(UserAdditionalInfoPersist._timezone).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserAdditionalInfoPersist._timezone}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getCulture()))
.failOn(UserAdditionalInfoPersist._culture).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserAdditionalInfoPersist._culture}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getLanguage()))
.failOn(UserAdditionalInfoPersist._language).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserAdditionalInfoPersist._language}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getOrganizationId()))
.failOn(UserAdditionalInfoPersist._organizationId).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserAdditionalInfoPersist._organizationId}, LocaleContextHolder.getLocale()))
);
}
}
public void setOrganizationId(UUID organizationId) {
this.organizationId = organizationId;
}
}

View File

@ -1,33 +1,37 @@
package eu.eudat.model.persist;
import eu.eudat.commons.validation.old.FieldNotNullIfOtherSet;
import eu.eudat.commons.validation.old.ValidId;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.UserEntity;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
public class UserPersist {
@ValidId(message = "{validation.invalidid}")
private UUID id;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max = UserEntity._nameLength, message = "{validation.largerthanmax}")
private String name;
public static final String _name = "name";
private String hash;
@Valid
public static final String _hash = "hash";
private UserAdditionalInfoPersist additionalInfo;
public static final String _additionalInfo = "additionalInfo";
public UUID getId() {
return id;
}
@ -59,5 +63,55 @@ public class UserPersist {
public void setAdditionalInfo(UserAdditionalInfoPersist additionalInfo) {
this.additionalInfo = additionalInfo;
}
@Component(UserPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class UserPersistValidator extends BaseValidator<UserPersist> {
public static final String ValidatorName = "UserPersistValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected UserPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<UserPersist> modelClass() {
return UserPersist.class;
}
@Override
protected List<Specification> specifications(UserPersist item) {
return Arrays.asList(
this.spec()
.iff(() -> this.isValidGuid(item.getId()))
.must(() -> this.isValidHash(item.getHash()))
.failOn(UserPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserPersist._hash}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isValidGuid(item.getId()))
.must(() -> !this.isValidHash(item.getHash()))
.failOn(UserPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getName()))
.failOn(UserPersist._name).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserPersist._name}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getName()))
.must(() -> this.lessEqualLength(item.getName(), UserEntity._nameLength))
.failOn(UserPersist._name).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{UserPersist._name}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getAdditionalInfo()))
.on(UserPersist._additionalInfo)
.over(item.getAdditionalInfo())
.using(() -> this.validatorFactory.validator(UserAdditionalInfoPersist.UserAdditionalInfoPersistValidator.class))
);
}
}
}

View File

@ -1,27 +1,31 @@
package eu.eudat.model.persist;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import eu.eudat.commons.validation.old.FieldNotNullIfOtherSet;
import eu.eudat.commons.validation.old.ValidId;
import jakarta.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
public class UserRolePatchPersist {
@NotNull(message = "{validation.empty}")
@ValidId(message = "{validation.invalidid}")
private UUID id;
@NotNull(message = "{validation.empty}")
private List<String> roles;
@NotNull(message = "{validation.empty}")
public static final String _roles = "roles";
private String hash;
public static final String _hash = "hash";
public UUID getId() {
return id;
}
@ -45,5 +49,42 @@ public class UserRolePatchPersist {
public void setHash(String hash) {
this.hash = hash;
}
@Component(UserRolePatchPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class UserRolePatchPersistValidator extends BaseValidator<UserRolePatchPersist> {
public static final String ValidatorName = "UserRolePatchPersistValidator";
private final MessageSource messageSource;
protected UserRolePatchPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<UserRolePatchPersist> modelClass() {
return UserRolePatchPersist.class;
}
@Override
protected List<Specification> specifications(UserRolePatchPersist item) {
return Arrays.asList(
this.spec()
.iff(() -> this.isValidGuid(item.getId()))
.must(() -> this.isValidHash(item.getHash()))
.failOn(UserRolePatchPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserRolePatchPersist._hash}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isValidGuid(item.getId()))
.must(() -> !this.isValidHash(item.getHash()))
.failOn(UserRolePatchPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getRoles()))
.failOn(UserRolePatchPersist._roles).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserRolePatchPersist._roles}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -1,80 +1,135 @@
package eu.eudat.model.persist;
import eu.eudat.commons.enums.UserSettingsType;
import eu.eudat.commons.validation.old.FieldNotNullIfOtherSet;
import eu.eudat.commons.validation.old.ValidId;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
public class UserSettingsPersist {
@ValidId(message = "{validation.invalidid}")
private UUID id;
private UUID id;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String key;
private String key;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String value;
public static final String _key = "key";
@ValidId(message = "{validation.invalidid}")
private UUID entityId;
private String value;
@NotNull(message = "{validation.empty}")
private UserSettingsType type;
public static final String _value = "value";
private String hash;
private UUID entityId;
public UUID getId() {
return id;
}
public static final String _entityId = "entityId";
public void setId(UUID id) {
this.id = id;
}
private UserSettingsType type;
public String getKey() {
return key;
}
public static final String _type = "type";
public void setKey(String key) {
this.key = key;
}
private String hash;
public UUID getEntityId() {
return entityId;
}
public static final String _hash = "hash";
public void setEntityId(UUID entityId) {
this.entityId = entityId;
}
public UUID getId() {
return id;
}
public UserSettingsType getType() {
return type;
}
public void setId(UUID id) {
this.id = id;
}
public void setType(UserSettingsType type) {
this.type = type;
}
public String getKey() {
return key;
}
public String getHash() {
return hash;
}
public void setKey(String key) {
this.key = key;
}
public void setHash(String hash) {
this.hash = hash;
}
public UUID getEntityId() {
return entityId;
}
public String getValue() {
return value;
}
public void setEntityId(UUID entityId) {
this.entityId = entityId;
}
public UserSettingsType getType() {
return type;
}
public void setType(UserSettingsType type) {
this.type = type;
}
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Component(UserSettingsPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class UserSettingsPersistValidator extends BaseValidator<UserSettingsPersist> {
public static final String ValidatorName = "UserSettingsPersistValidator";
private final MessageSource messageSource;
protected UserSettingsPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<UserSettingsPersist> modelClass() {
return UserSettingsPersist.class;
}
@Override
protected List<Specification> specifications(UserSettingsPersist item) {
return Arrays.asList(
this.spec()
.iff(() -> this.isValidGuid(item.getId()))
.must(() -> this.isValidHash(item.getHash()))
.failOn(UserSettingsPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserSettingsPersist._hash}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isValidGuid(item.getId()))
.must(() -> !this.isValidHash(item.getHash()))
.failOn(UserSettingsPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getKey()))
.failOn(UserSettingsPersist._key).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserSettingsPersist._key}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getValue()))
.failOn(UserSettingsPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserSettingsPersist._value}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> this.isValidGuid(item.getEntityId()))
.failOn(UserSettingsPersist._entityId).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserSettingsPersist._entityId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getType()))
.failOn(UserSettingsPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserSettingsPersist._type}, LocaleContextHolder.getLocale()))
);
}
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -8,6 +8,7 @@ import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
@ -108,7 +109,24 @@ public class AuthenticationConfigurationPersist {
@Override
protected List<Specification> specifications(AuthenticationConfigurationPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isNull(item.getEnabled()))
.failOn(AuthenticationConfigurationPersist._enabled).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._enabled}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getAuthUrl()))
.failOn(AuthenticationConfigurationPersist._authUrl).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._authUrl}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getAuthMethod()))
.failOn(AuthenticationConfigurationPersist._authMethod).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._authMethod}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getAuthTokenPath()))
.failOn(AuthenticationConfigurationPersist._authTokenPath).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._authTokenPath}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getAuthRequestBody()))
.failOn(AuthenticationConfigurationPersist._authRequestBody).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._authRequestBody}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getType()))
.failOn(AuthenticationConfigurationPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._type}, LocaleContextHolder.getLocale()))
);
}
}

View File

@ -2,14 +2,14 @@ package eu.eudat.model.persist.referencetypedefinition;
import eu.eudat.commons.enums.ReferenceFieldDataType;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.old.ValidEnum;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import eu.eudat.model.persist.DescriptionPersist;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
@ -17,74 +17,85 @@ import java.util.List;
public class ReferenceTypeFieldPersist {
private String code = null;
private String code = null;
public static final String _code = "code";
public static final String _code = "code";
private String label = null;
private String label = null;
public static final String _label = "label";
public static final String _label = "label";
private String description;
private String description;
private ReferenceFieldDataType dataType;
private ReferenceFieldDataType dataType;
public static final String _dataType = "dataType";
public static final String _dataType = "dataType";
public String getCode() {
return code;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public void setCode(String code) {
this.code = code;
}
public String getLabel() {
return label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void setDescription(String description) {
this.description = description;
}
public ReferenceFieldDataType getDataType() {
return dataType;
}
public ReferenceFieldDataType getDataType() {
return dataType;
}
public void setDataType(ReferenceFieldDataType dataType) {
this.dataType = dataType;
}
public void setDataType(ReferenceFieldDataType dataType) {
this.dataType = dataType;
}
@Component(ReferenceTypeFieldPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeFieldPersistValidator extends BaseValidator<ReferenceTypeFieldPersist> {
@Component(ReferenceTypeFieldPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeFieldPersistValidator extends BaseValidator<ReferenceTypeFieldPersist> {
public static final String ValidatorName = "ReferenceTypeFieldPersistValidator";
public static final String ValidatorName = "ReferenceTypeFieldPersistValidator";
protected ReferenceTypeFieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors) {
super(conventionService, errors);
}
private final MessageSource messageSource;
@Override
protected Class<ReferenceTypeFieldPersist> modelClass() {
return ReferenceTypeFieldPersist.class;
}
protected ReferenceTypeFieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected List<Specification> specifications(ReferenceTypeFieldPersist item) {
return Arrays.asList(
@Override
protected Class<ReferenceTypeFieldPersist> modelClass() {
return ReferenceTypeFieldPersist.class;
}
);
}
}
@Override
protected List<Specification> specifications(ReferenceTypeFieldPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getCode()))
.failOn(ReferenceTypeFieldPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeFieldPersist._code}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getLabel()))
.failOn(ReferenceTypeFieldPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeFieldPersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getDataType()))
.failOn(ReferenceTypeFieldPersist._dataType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeFieldPersist._dataType}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -2,16 +2,13 @@ package eu.eudat.model.persist.referencetypedefinition;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.commons.validation.old.ValidEnum;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
@ -21,7 +18,7 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc
private String url;
public static final String _uri = "uri";
public static final String _url = "url";
private ResultsConfigurationPersist results;
@ -154,7 +151,46 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc
protected List<Specification> specifications(ReferenceTypeSourceExternalApiConfigurationPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.addAll(Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getUrl()))
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._url}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getPaginationPath()))
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._paginationPath).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._paginationPath}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getContentType()))
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._contentType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._contentType}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getFirstPage()))
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._firstPage).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._firstPage}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getHttpMethod()))
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._httpMethod).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._httpMethod}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getResults()))
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._results).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._results}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getResults()))
.on(ReferenceTypeSourceExternalApiConfigurationPersist._results)
.over(item.getResults())
.using(() -> this.validatorFactory.validator(ResultsConfigurationPersist.ResultsConfigurationPersistValidator.class)),
this.spec()
.must(() -> !this.isNull(item.getAuth()))
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._auth).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._auth}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getAuth()))
.on(ReferenceTypeSourceExternalApiConfigurationPersist._auth)
.over(item.getAuth())
.using(() -> this.validatorFactory.validator(AuthenticationConfigurationPersist.AuthenticationConfigurationPersistValidator.class)),
this.spec()
.must(() -> !this.isNull(item.getQueries()))
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._queries).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._queries}, LocaleContextHolder.getLocale())),
this.navSpec()
.iff(() -> !this.isNull(item.getQueries()))
.on(ReferenceTypeSourceExternalApiConfigurationPersist._queries)
.over(item.getQueries())
.using(() -> this.validatorFactory.validator(QueryConfigPersist.QueryConfigPersistValidator.class))
));
return specifications;
}

View File

@ -5,7 +5,9 @@ import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
@ -43,8 +45,11 @@ public class ResultFieldsMappingConfigurationPersist {
public static final String ValidatorName = "ResultFieldsMappingConfigurationPersistValidator";
protected ResultFieldsMappingConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors) {
private final MessageSource messageSource;
protected ResultFieldsMappingConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
@ -55,7 +60,12 @@ public class ResultFieldsMappingConfigurationPersist {
@Override
protected List<Specification> specifications(ResultFieldsMappingConfigurationPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getCode()))
.failOn(ResultFieldsMappingConfigurationPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{ResultFieldsMappingConfigurationPersist._code}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getResponsePath()))
.failOn(ResultFieldsMappingConfigurationPersist._responsePath).failWith(messageSource.getMessage("Validation_Required", new Object[]{ResultFieldsMappingConfigurationPersist._responsePath}, LocaleContextHolder.getLocale()))
);
}
}

View File

@ -1,12 +1,14 @@
package eu.eudat.model.persist.referencetypedefinition;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
@ -46,9 +48,12 @@ public class ResultsConfigurationPersist {
private final MessageSource messageSource;
protected ResultsConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
private final ValidatorFactory validatorFactory;
protected ResultsConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
@ -59,7 +64,18 @@ public class ResultsConfigurationPersist {
@Override
protected List<Specification> specifications(ResultsConfigurationPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getResultsArrayPath()))
.failOn(ResultsConfigurationPersist._resultsArrayPath).failWith(messageSource.getMessage("Validation_Required", new Object[]{ResultsConfigurationPersist._resultsArrayPath}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getFieldsMapping()))
.failOn(ResultsConfigurationPersist._fieldsMapping).failWith(messageSource.getMessage("Validation_Required", new Object[]{ResultsConfigurationPersist._fieldsMapping}, LocaleContextHolder.getLocale())),
this.navSpec()
.iff(() -> !this.isNull(item.getFieldsMapping()))
.on(ResultsConfigurationPersist._fieldsMapping)
.over(item.getFieldsMapping())
.using(() -> this.validatorFactory.validator(ResultFieldsMappingConfigurationPersist.ResultFieldsMappingConfigurationPersistValidator.class))
);
}
}

View File

@ -1,10 +1,27 @@
package eu.eudat.model.persist.tenantconfig;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
public class TenantConfigPersist {
private TenantDepositConfigPersist deposit;
public static final String _deposit = "deposit";
private TenantFileTransformersConfigPersist fileTransformers;
public static final String _fileTransformers = "fileTransformers";
public TenantDepositConfigPersist getDeposit() {
return deposit;
}
@ -20,5 +37,41 @@ public class TenantConfigPersist {
public void setFileTransformers(TenantFileTransformersConfigPersist fileTransformers) {
this.fileTransformers = fileTransformers;
}
@Component(TenantConfigPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class TenantConfigPersistValidator extends BaseValidator<TenantConfigPersist> {
public static final String ValidatorName = "TenantConfigPersistValidator";
private final ValidatorFactory validatorFactory;
protected TenantConfigPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.validatorFactory = validatorFactory;
}
@Override
protected Class<TenantConfigPersist> modelClass() {
return TenantConfigPersist.class;
}
@Override
protected List<Specification> specifications(TenantConfigPersist item) {
return Arrays.asList(
this.refSpec()
.iff(() -> !this.isNull(item.getDeposit()))
.on(TenantConfigPersist._deposit)
.over(item.getDeposit())
.using(() -> this.validatorFactory.validator(TenantDepositConfigPersist.TenantDepositConfigPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getFileTransformers()))
.on(TenantConfigPersist._fileTransformers)
.over(item.getFileTransformers())
.using(() -> this.validatorFactory.validator(TenantFileTransformersConfigPersist.TenantFileTransformersConfigPersistValidator.class))
);
}
}
}

View File

@ -1,15 +1,23 @@
package eu.eudat.model.persist.tenantconfig;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import jakarta.validation.Valid;
import java.util.Collections;
import java.util.List;
public class TenantDepositConfigPersist {
@Valid
private List<TenantSourcePersist> sources;
public static final String _sources = "sources";
public List<TenantSourcePersist> getSources() {
return sources;
}
@ -17,4 +25,35 @@ public class TenantDepositConfigPersist {
public void setSources(List<TenantSourcePersist> sources) {
this.sources = sources;
}
@Component(TenantDepositConfigPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class TenantDepositConfigPersistValidator extends BaseValidator<TenantDepositConfigPersist> {
public static final String ValidatorName = "TenantDepositConfigPersistValidator";
private final ValidatorFactory validatorFactory;
protected TenantDepositConfigPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.validatorFactory = validatorFactory;
}
@Override
protected Class<TenantDepositConfigPersist> modelClass() {
return TenantDepositConfigPersist.class;
}
@Override
protected List<Specification> specifications(TenantDepositConfigPersist item) {
return Collections.singletonList(
this.refSpec()
.iff(() -> !this.isNull(item.getSources()))
.on(TenantDepositConfigPersist._sources)
.over(item.getSources())
.using(() -> this.validatorFactory.validator(TenantSourcePersist.TenantSourcePersistValidator.class))
);
}
}
}

View File

@ -1,15 +1,23 @@
package eu.eudat.model.persist.tenantconfig;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import jakarta.validation.Valid;
import java.util.Collections;
import java.util.List;
public class TenantFileTransformersConfigPersist {
@Valid
private List<TenantSourcePersist> sources;
public static final String _sources = "sources";
public List<TenantSourcePersist> getSources() {
return sources;
}
@ -17,4 +25,35 @@ public class TenantFileTransformersConfigPersist {
public void setSources(List<TenantSourcePersist> sources) {
this.sources = sources;
}
@Component(TenantFileTransformersConfigPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class TenantFileTransformersConfigPersistValidator extends BaseValidator<TenantFileTransformersConfigPersist> {
public static final String ValidatorName = "TenantFileTransformersConfigPersistValidator";
private final ValidatorFactory validatorFactory;
protected TenantFileTransformersConfigPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.validatorFactory = validatorFactory;
}
@Override
protected Class<TenantFileTransformersConfigPersist> modelClass() {
return TenantFileTransformersConfigPersist.class;
}
@Override
protected List<Specification> specifications(TenantFileTransformersConfigPersist item) {
return Collections.singletonList(
this.refSpec()
.iff(() -> !this.isNull(item.getSources()))
.on(TenantFileTransformersConfigPersist._sources)
.over(item.getSources())
.using(() -> this.validatorFactory.validator(TenantSourcePersist.TenantSourcePersistValidator.class))
);
}
}
}

View File

@ -1,37 +1,44 @@
package eu.eudat.model.persist.tenantconfig;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
public class TenantSourcePersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String url;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
public static final String _url = "url";
private List<String> codes;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String issuerUrl ;
public static final String _codes = "codes";
private String issuerUrl;
public static final String _issuerUrl = "issuerUrl";
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String clientId;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
public static final String _clientId = "clientId";
private String clientSecret;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
public static final String _clientSecret = "clientSecret";
private String scope;
public static final String _scope = "scope";
public String getUrl() {
return url;
}
@ -79,4 +86,48 @@ public class TenantSourcePersist {
public void setScope(String scope) {
this.scope = scope;
}
@Component(TenantSourcePersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class TenantSourcePersistValidator extends BaseValidator<TenantSourcePersist> {
public static final String ValidatorName = "TenantSourcePersistValidator";
private final MessageSource messageSource;
protected TenantSourcePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<TenantSourcePersist> modelClass() {
return TenantSourcePersist.class;
}
@Override
protected List<Specification> specifications(TenantSourcePersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getUrl()))
.failOn(TenantSourcePersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantSourcePersist._url}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getCodes()))
.failOn(TenantSourcePersist._codes).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantSourcePersist._codes}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getIssuerUrl()))
.failOn(TenantSourcePersist._issuerUrl).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantSourcePersist._issuerUrl}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getClientId()))
.failOn(TenantSourcePersist._clientId).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantSourcePersist._clientId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getClientSecret()))
.failOn(TenantSourcePersist._clientSecret).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantSourcePersist._clientSecret}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getScope()))
.failOn(TenantSourcePersist._scope).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantSourcePersist._scope}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -6,6 +6,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.*;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.StorageFileEntity;
import eu.eudat.model.*;
@ -70,6 +71,7 @@ public class StorageFileController {
private final UserScope userScope;
private final AuthorizationService authorizationService;
private final ConventionService conventionService;
private final ValidatorFactory validatorFactory;
public StorageFileController(
AuditService auditService,
QueryFactory queryFactory,
@ -77,7 +79,7 @@ public class StorageFileController {
StorageFileService storageFileService,
StorageFileProperties config,
UserScope userScope,
AuthorizationService authorizationService, ConventionService conventionService) {
AuthorizationService authorizationService, ConventionService conventionService, ValidatorFactory validatorFactory) {
this.auditService = auditService;
this.queryFactory = queryFactory;
this.messageSource = messageSource;
@ -86,6 +88,7 @@ public class StorageFileController {
this.userScope = userScope;
this.authorizationService = authorizationService;
this.conventionService = conventionService;
this.validatorFactory = validatorFactory;
}
@ -105,6 +108,7 @@ public class StorageFileController {
storageFilePersist.setOwnerId(this.userScope.getUserIdSafe());
storageFilePersist.setStorageType(StorageType.Temp);
storageFilePersist.setLifetime(Duration.ofSeconds(this.config.getTempStoreLifetimeSeconds()));
this.validatorFactory.validator(StorageFilePersist.StorageFilePersistValidator.class).validateForce(storageFilePersist);
StorageFile persisted = this.storageFileService.persistBytes(storageFilePersist, file.getBytes(), new BaseFieldSet(StorageFile._id, StorageFile._name));
addedFiles.add(persisted);

View File

@ -3,6 +3,7 @@ package eu.eudat.controllers.v2;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.validation.ValidationFilterAnnotation;
import eu.eudat.data.SupportiveMaterialEntity;
import eu.eudat.model.SupportiveMaterial;
import eu.eudat.model.builder.SupportiveMaterialBuilder;
@ -23,7 +24,6 @@ import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.MyValidate;
import jakarta.transaction.Transactional;
import jakarta.xml.bind.JAXBException;
import org.slf4j.LoggerFactory;
@ -50,14 +50,21 @@ import java.util.stream.Stream;
public class SupportiveMaterialController {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(SupportiveMaterialController.class));
private Environment environment;
private final BuilderFactory builderFactory;
private final AuditService auditService;
private final CensorFactory censorFactory;
private final QueryFactory queryFactory;
private final MessageSource messageSource;
private final SupportiveMaterialService supportiveMaterialService;
private final AuthorizationService authorizationService;
@Autowired
@ -117,19 +124,19 @@ public class SupportiveMaterialController {
SupportiveMaterialQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
List<SupportiveMaterialEntity> data = query.collectAs(lookup.getProject());
if (data.size() == 1){
if (data.size() == 1) {
return new ResponseEntity<>(data.get(0).getPayload().getBytes(), HttpStatus.OK);
}
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty(lookup.getTypes().stream().toList().get(0).name().toLowerCase() +".path"))))) {
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty(lookup.getTypes().stream().toList().get(0).name().toLowerCase() + ".path"))))) {
return this.supportiveMaterialService.getResponseEntity(lookup.getLanguageCodes().get(0), paths);
}
}
@PostMapping("persist")
@Transactional
public SupportiveMaterial persist(@MyValidate @RequestBody SupportiveMaterialPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
@ValidationFilterAnnotation(validator = SupportiveMaterialPersist.SupportiveMaterialPersistValidator.ValidatorName, argumentName = "model")
public SupportiveMaterial persist(@RequestBody SupportiveMaterialPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
logger.debug(new MapLogEntry("persisting" + SupportiveMaterial.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
this.censorFactory.censor(SupportiveMaterialCensor.class).censor(fieldSet, null);
@ -152,5 +159,4 @@ public class SupportiveMaterialController {
this.auditService.track(AuditableAction.SupportiveMaterial_Delete, "id", id);
}
}

View File

@ -38,10 +38,12 @@ import java.util.*;
public class TagController {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagController.class));
@Autowired
private ApiContext apiContext;
private final BuilderFactory builderFactory;
private final AuditService auditService;
private final TagService tagService;
@ -80,7 +82,6 @@ public class TagController {
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
this.auditService.track(AuditableAction.Tag_Query, "lookup", lookup);
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return new QueryResult<>(models, count);
}
@ -100,14 +101,13 @@ public class TagController {
new AbstractMap.SimpleEntry<String, Object>("id", id),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return model;
}
@PostMapping("persist")
@Transactional
@ValidationFilterAnnotation(validator = TagPersist.TagPersistValidator.ValidatorName, argumentName ="model")
@ValidationFilterAnnotation(validator = TagPersist.TagPersistValidator.ValidatorName, argumentName = "model")
public Tag Persist(@RequestBody TagPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting" + Tag.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
Tag persisted = this.tagService.persist(model, fieldSet);
@ -116,7 +116,7 @@ public class TagController {
new AbstractMap.SimpleEntry<String, Object>("model", model),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return persisted;
}
@ -128,6 +128,5 @@ public class TagController {
this.tagService.deleteAndSave(id);
this.auditService.track(AuditableAction.Tag_Delete, "id", id);
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
}
}

View File

@ -3,13 +3,13 @@ package eu.eudat.controllers.v2;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.validation.ValidationFilterAnnotation;
import eu.eudat.data.TenantEntity;
import eu.eudat.model.Tenant;
import eu.eudat.model.builder.TenantBuilder;
import eu.eudat.model.censorship.TenantCensor;
import eu.eudat.model.persist.TenantPersist;
import eu.eudat.model.result.QueryResult;
import eu.eudat.model.tenantconfig.TenantSource;
import eu.eudat.query.TenantQuery;
import eu.eudat.query.lookup.TenantLookup;
import eu.eudat.service.tenant.TenantService;
@ -23,7 +23,6 @@ import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.MyValidate;
import jakarta.transaction.Transactional;
import jakarta.xml.bind.JAXBException;
import org.slf4j.LoggerFactory;
@ -44,7 +43,6 @@ import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
@RestController
@RequestMapping(path = "api/tenant")
@ -88,7 +86,7 @@ public class TenantController {
List<TenantEntity> data = query.collectAs(lookup.getProject());
List<Tenant> models = this.builderFactory.builder(TenantBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
for (Tenant model: models) {
for (Tenant model : models) {
models.set(models.indexOf(model), this.tenantService.decryptTenant(model));
}
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
@ -121,10 +119,11 @@ public class TenantController {
@PostMapping("persist")
@Transactional
public Tenant persist(@MyValidate @RequestBody TenantPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
@ValidationFilterAnnotation(validator = TenantPersist.TenantPersistValidator.ValidatorName, argumentName = "model")
public Tenant persist(@RequestBody TenantPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
logger.debug(new MapLogEntry("persisting" + Tenant.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
this.censorFactory.censor(TenantCensor.class).censor(fieldSet, null);
Tenant persisted = this.tenantService.persist(model, fieldSet);
this.auditService.track(AuditableAction.Tenant_Persist, Map.ofEntries(

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.validation.ValidationFilterAnnotation;
import eu.eudat.data.UserEntity;
import eu.eudat.model.User;
import eu.eudat.model.UserRole;
@ -43,7 +44,10 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@RestController
@RequestMapping(path = "api/user")
@ -60,9 +64,11 @@ public class UserController {
private final CensorFactory censorFactory;
private final QueryFactory queryFactory;
private final UserScope userScope;
private final MessageSource messageSource;
private final ResponseUtilsService responseUtilsService;
public UserController(
@ -71,8 +77,8 @@ public class UserController {
UserService userTypeService,
CensorFactory censorFactory,
QueryFactory queryFactory,
UserScope userScope,
MessageSource messageSource,
UserScope userScope,
MessageSource messageSource,
ResponseUtilsService responseUtilsService) {
this.builderFactory = builderFactory;
this.auditService = auditService;
@ -97,7 +103,6 @@ public class UserController {
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
this.auditService.track(AuditableAction.User_Query, "lookup", lookup);
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return new QueryResult<>(models, count);
}
@ -117,7 +122,6 @@ public class UserController {
new AbstractMap.SimpleEntry<String, Object>("id", id),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return model;
}
@ -137,7 +141,6 @@ public class UserController {
new AbstractMap.SimpleEntry<String, Object>("email", email),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return model;
}
@ -149,10 +152,9 @@ public class UserController {
// this.censorFactory.censor(UserCensor.class).censor(fieldSet, null);
byte[] bytes = this.userTypeService.exportCsv();
this.auditService.track(AuditableAction.User_ExportCsv, Map.ofEntries(
));
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return this.responseUtilsService.buildResponseFileFromText(new String(bytes, StandardCharsets.UTF_8), "Users_dump.csv");
}
@ -171,7 +173,6 @@ public class UserController {
new AbstractMap.SimpleEntry<String, Object>("id", id),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return model;
}
@ -211,7 +212,8 @@ public class UserController {
@PostMapping("persist")
@Transactional
public User persist(@MyValidate @RequestBody UserPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
@ValidationFilterAnnotation(validator = UserPersist.UserPersistValidator.ValidatorName, argumentName = "model")
public User persist(@RequestBody UserPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
logger.debug(new MapLogEntry("persisting" + User.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
User persisted = this.userTypeService.persist(model, fieldSet);
@ -219,13 +221,14 @@ public class UserController {
new AbstractMap.SimpleEntry<String, Object>("model", model),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return persisted;
}
@PostMapping("persist/roles")
@Transactional
public User persistRoles(@MyValidate @RequestBody UserRolePatchPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
@ValidationFilterAnnotation(validator = UserRolePatchPersist.UserRolePatchPersistValidator.ValidatorName, argumentName = "model")
public User persistRoles(@RequestBody UserRolePatchPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
logger.debug(new MapLogEntry("persisting" + UserRole.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
User persisted = this.userTypeService.patchRoles(model, fieldSet);
@ -233,7 +236,7 @@ public class UserController {
new AbstractMap.SimpleEntry<String, Object>("model", model),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return persisted;
}
@ -245,12 +248,11 @@ public class UserController {
this.userTypeService.deleteAndSave(id);
this.auditService.track(AuditableAction.User_Delete, "id", id);
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
}
@GetMapping("mine/merge-account-request/{email}")
@Transactional
public ResponseEntity mergeAccount(@PathVariable("email") String email) throws InvalidApplicationException, JAXBException {
public ResponseEntity<ResponseItem<String>> mergeAccount(@PathVariable("email") String email) throws InvalidApplicationException, JAXBException {
logger.debug(new MapLogEntry("merge account to user").And("email", email));
this.userTypeService.sendMergeAccountConfirmation(email);
@ -264,7 +266,7 @@ public class UserController {
@GetMapping("mine/confirm-merge-account/token/{token}")
@Transactional
public ResponseEntity confirmMergeAccount(@PathVariable("token") String token) throws InvalidApplicationException, JAXBException {
public ResponseEntity<ResponseItem<String>> confirmMergeAccount(@PathVariable("token") String token) throws InvalidApplicationException, JAXBException {
logger.debug(new MapLogEntry("confirm merge account to user").And("token", token));
this.userTypeService.confirmMergeAccount(token);
@ -278,7 +280,7 @@ public class UserController {
@GetMapping("mine/remove-credential-request/{email}")
@Transactional
public ResponseEntity removeCredentialAccount(@PathVariable("email") String email) throws InvalidApplicationException, JAXBException {
public ResponseEntity<ResponseItem<String>> removeCredentialAccount(@PathVariable("email") String email) throws InvalidApplicationException, JAXBException {
logger.debug(new MapLogEntry("remove credential request to user").And("email", email));
this.userTypeService.sendRemoveCredentialConfirmation(email);
@ -292,7 +294,7 @@ public class UserController {
@GetMapping("mine/confirm-remove-credential/token/{token}")
@Transactional
public ResponseEntity confirmRemoveCredentialAccount(@PathVariable("token") String token) throws InvalidApplicationException, JAXBException {
public ResponseEntity<ResponseItem<String>> confirmRemoveCredentialAccount(@PathVariable("token") String token) throws InvalidApplicationException, JAXBException {
logger.debug(new MapLogEntry("confirm remove credential to user").And("token", token));
this.userTypeService.confirmRemoveCredential(token);

View File

@ -1,6 +1,8 @@
package eu.eudat.controllers.v2;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.validation.ValidationFilterAnnotation;
import eu.eudat.data.UserSettingsEntity;
import eu.eudat.model.UserSettings;
import eu.eudat.model.builder.UserSettingsBuilder;
@ -29,7 +31,10 @@ import org.springframework.context.MessageSource;
import org.springframework.web.bind.annotation.*;
import javax.management.InvalidApplicationException;
import java.util.*;
import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@RestController
@RequestMapping(path = "api/user-settings")
@ -38,10 +43,15 @@ public class UserSettingsController {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserSettingsController.class));
private final BuilderFactory builderFactory;
private final AuditService auditService;
private final UserSettingsService settingsService;
private final CensorFactory censorFactory;
private final QueryFactory queryFactory;
private final MessageSource messageSource;
@Autowired
@ -70,7 +80,6 @@ public class UserSettingsController {
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
this.auditService.track(AuditableAction.User_Settings_Query, "lookup", lookup);
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return new QueryResult<>(models, count);
}
@ -102,6 +111,7 @@ public class UserSettingsController {
@PostMapping("persist")
@Transactional
@ValidationFilterAnnotation(validator = UserSettingsPersist.UserSettingsPersistValidator.ValidatorName, argumentName = "model")
public UserSettings Persist(@MyValidate @RequestBody UserSettingsPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting" + UserSettings.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
@ -111,7 +121,7 @@ public class UserSettingsController {
new AbstractMap.SimpleEntry<String, Object>("model", model),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return persisted;
}