Implementing validators for Tenant and other persist models (completed)
This commit is contained in:
parent
eb2b5d4df3
commit
18a4684859
|
@ -24,9 +24,10 @@ public class SupportiveMaterialEntity extends TenantScopedBaseEntity {
|
||||||
private SupportiveMaterialFieldType type;
|
private SupportiveMaterialFieldType type;
|
||||||
public static final String _type = "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;
|
private String languageCode;
|
||||||
public static final String _languageCode = "languageCode";
|
public static final String _languageCode = "languageCode";
|
||||||
|
public static final int _languageCodeLength = 20;
|
||||||
|
|
||||||
@Column(name = "payload", nullable = false)
|
@Column(name = "payload", nullable = false)
|
||||||
private String payload;
|
private String payload;
|
||||||
|
|
|
@ -17,13 +17,15 @@ public class TenantEntity {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
public final static String _id = "id";
|
public final static String _id = "id";
|
||||||
|
|
||||||
@Column(name = "code", length = 200, nullable = false)
|
@Column(name = "code", length = _codeLength, nullable = false)
|
||||||
private String code;
|
private String code;
|
||||||
public final static String _code = "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;
|
private String name;
|
||||||
public final static String _name = "name";
|
public final static String _name = "name";
|
||||||
|
public final static int _nameLength = 500;
|
||||||
|
|
||||||
@Column(name = "description", nullable = false)
|
@Column(name = "description", nullable = false)
|
||||||
private String description;
|
private String description;
|
||||||
|
|
|
@ -1,37 +1,40 @@
|
||||||
package eu.eudat.model.persist;
|
package eu.eudat.model.persist;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.StorageType;
|
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 eu.eudat.data.StorageFileEntity;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import jakarta.validation.constraints.Size;
|
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.time.Duration;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class StorageFilePersist {
|
public class StorageFilePersist {
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
@Size(max = StorageFileEntity._nameLen, message = "{validation.largerthanmax}")
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
public static final String _name = "name";
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
@Size(max = StorageFileEntity._extensionLen, message = "{validation.largerthanmax}")
|
|
||||||
private String extension;
|
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;
|
private String mimeType;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
public static final String _mimeType = "mimeType";
|
||||||
@ValidEnum(message = "{validation.empty}")
|
|
||||||
private StorageType storageType;
|
private StorageType storageType;
|
||||||
|
|
||||||
|
public static final String _storageType = "storageType";
|
||||||
|
|
||||||
private Duration lifetime;
|
private Duration lifetime;
|
||||||
|
|
||||||
private UUID ownerId;
|
private UUID ownerId;
|
||||||
|
@ -83,4 +86,54 @@ public class StorageFilePersist {
|
||||||
public void setLifetime(Duration lifetime) {
|
public void setLifetime(Duration lifetime) {
|
||||||
this.lifetime = 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()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,69 +1,125 @@
|
||||||
package eu.eudat.model.persist;
|
package eu.eudat.model.persist;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
|
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
|
||||||
import eu.eudat.commons.validation.old.ValidEnum;
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
import eu.eudat.commons.validation.old.ValidId;
|
import eu.eudat.commons.validation.specification.Specification;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import eu.eudat.convention.ConventionService;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import eu.eudat.data.SupportiveMaterialEntity;
|
||||||
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;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SupportiveMaterialPersist {
|
public class SupportiveMaterialPersist {
|
||||||
@ValidId(message = "{validation.invalidid}")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@ValidEnum(message = "{validation.empty}")
|
private UUID id;
|
||||||
private SupportiveMaterialFieldType type;
|
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
private SupportiveMaterialFieldType type;
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
@Size(max = 20, message = "{validation.largerthanmax}")
|
|
||||||
private String languageCode;
|
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
public static final String _type = "type";
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
private String payload;
|
|
||||||
|
|
||||||
private String hash;
|
private String languageCode;
|
||||||
|
|
||||||
public UUID getId() {
|
public static final String _languageCode = "languageCode";
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
private String payload;
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SupportiveMaterialFieldType getType() {
|
public static final String _payload = "payload";
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(SupportiveMaterialFieldType type) {
|
private String hash;
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLanguageCode() {
|
public static final String _hash = "hash";
|
||||||
return languageCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLanguageCode(String languageCode) {
|
public UUID getId() {
|
||||||
this.languageCode = languageCode;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPayload() {
|
public void setId(UUID id) {
|
||||||
return payload;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPayload(String payload) {
|
public SupportiveMaterialFieldType getType() {
|
||||||
this.payload = payload;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHash() {
|
public void setType(SupportiveMaterialFieldType type) {
|
||||||
return hash;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,46 @@
|
||||||
package eu.eudat.model.persist;
|
package eu.eudat.model.persist;
|
||||||
|
|
||||||
import eu.eudat.commons.validation.old.FieldNotNullIfOtherSet;
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
import eu.eudat.commons.validation.old.ValidId;
|
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 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;
|
import java.util.UUID;
|
||||||
|
|
||||||
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
|
|
||||||
public class TenantPersist {
|
public class TenantPersist {
|
||||||
|
|
||||||
@ValidId(message = "{validation.invalidid}")
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
@Size(max= 200, message = "{validation.largerthanmax}")
|
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
public static final String _code = "code";
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
@Size(max= 500, message = "{validation.largerthanmax}")
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
public static final String _name = "name";
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
public static final String _description = "description";
|
||||||
|
|
||||||
private TenantConfigPersist config;
|
private TenantConfigPersist config;
|
||||||
|
|
||||||
|
public static final String _config = "config";
|
||||||
|
|
||||||
private String hash;
|
private String hash;
|
||||||
|
|
||||||
|
public static final String _hash = "hash";
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -78,4 +88,64 @@ public class TenantPersist {
|
||||||
public void setHash(String hash) {
|
public void setHash(String hash) {
|
||||||
this.hash = 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))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,27 @@
|
||||||
package eu.eudat.model.persist.tenantconfig;
|
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 {
|
public class TenantConfigPersist {
|
||||||
|
|
||||||
private TenantDepositConfigPersist deposit;
|
private TenantDepositConfigPersist deposit;
|
||||||
|
|
||||||
|
public static final String _deposit = "deposit";
|
||||||
|
|
||||||
private TenantFileTransformersConfigPersist fileTransformers;
|
private TenantFileTransformersConfigPersist fileTransformers;
|
||||||
|
|
||||||
|
public static final String _fileTransformers = "fileTransformers";
|
||||||
|
|
||||||
public TenantDepositConfigPersist getDeposit() {
|
public TenantDepositConfigPersist getDeposit() {
|
||||||
return deposit;
|
return deposit;
|
||||||
}
|
}
|
||||||
|
@ -20,5 +37,41 @@ public class TenantConfigPersist {
|
||||||
public void setFileTransformers(TenantFileTransformersConfigPersist fileTransformers) {
|
public void setFileTransformers(TenantFileTransformersConfigPersist fileTransformers) {
|
||||||
this.fileTransformers = 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))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,23 @@
|
||||||
package eu.eudat.model.persist.tenantconfig;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
public class TenantDepositConfigPersist {
|
public class TenantDepositConfigPersist {
|
||||||
|
|
||||||
@Valid
|
|
||||||
private List<TenantSourcePersist> sources;
|
private List<TenantSourcePersist> sources;
|
||||||
|
|
||||||
|
public static final String _sources = "sources";
|
||||||
|
|
||||||
public List<TenantSourcePersist> getSources() {
|
public List<TenantSourcePersist> getSources() {
|
||||||
return sources;
|
return sources;
|
||||||
}
|
}
|
||||||
|
@ -17,4 +25,35 @@ public class TenantDepositConfigPersist {
|
||||||
public void setSources(List<TenantSourcePersist> sources) {
|
public void setSources(List<TenantSourcePersist> sources) {
|
||||||
this.sources = 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))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,23 @@
|
||||||
package eu.eudat.model.persist.tenantconfig;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
public class TenantFileTransformersConfigPersist {
|
public class TenantFileTransformersConfigPersist {
|
||||||
|
|
||||||
@Valid
|
|
||||||
private List<TenantSourcePersist> sources;
|
private List<TenantSourcePersist> sources;
|
||||||
|
|
||||||
|
public static final String _sources = "sources";
|
||||||
|
|
||||||
public List<TenantSourcePersist> getSources() {
|
public List<TenantSourcePersist> getSources() {
|
||||||
return sources;
|
return sources;
|
||||||
}
|
}
|
||||||
|
@ -17,4 +25,35 @@ public class TenantFileTransformersConfigPersist {
|
||||||
public void setSources(List<TenantSourcePersist> sources) {
|
public void setSources(List<TenantSourcePersist> sources) {
|
||||||
this.sources = 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))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +1,44 @@
|
||||||
package eu.eudat.model.persist.tenantconfig;
|
package eu.eudat.model.persist.tenantconfig;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import eu.eudat.commons.validation.specification.Specification;
|
||||||
import jakarta.validation.constraints.NotNull;
|
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.List;
|
||||||
|
|
||||||
public class TenantSourcePersist {
|
public class TenantSourcePersist {
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
public static final String _url = "url";
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
private List<String> codes;
|
private List<String> codes;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
public static final String _codes = "codes";
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
private String issuerUrl ;
|
private String issuerUrl;
|
||||||
|
|
||||||
|
public static final String _issuerUrl = "issuerUrl";
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
private String clientId;
|
private String clientId;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
public static final String _clientId = "clientId";
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
private String clientSecret;
|
private String clientSecret;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
public static final String _clientSecret = "clientSecret";
|
||||||
@NotEmpty(message = "{validation.empty}")
|
|
||||||
private String scope;
|
private String scope;
|
||||||
|
|
||||||
|
public static final String _scope = "scope";
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -79,4 +86,48 @@ public class TenantSourcePersist {
|
||||||
public void setScope(String scope) {
|
public void setScope(String scope) {
|
||||||
this.scope = 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()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.enums.*;
|
import eu.eudat.commons.enums.*;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.commons.validation.ValidatorFactory;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.StorageFileEntity;
|
import eu.eudat.data.StorageFileEntity;
|
||||||
import eu.eudat.model.*;
|
import eu.eudat.model.*;
|
||||||
|
@ -70,6 +71,7 @@ public class StorageFileController {
|
||||||
private final UserScope userScope;
|
private final UserScope userScope;
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
private final ConventionService conventionService;
|
private final ConventionService conventionService;
|
||||||
|
private final ValidatorFactory validatorFactory;
|
||||||
public StorageFileController(
|
public StorageFileController(
|
||||||
AuditService auditService,
|
AuditService auditService,
|
||||||
QueryFactory queryFactory,
|
QueryFactory queryFactory,
|
||||||
|
@ -77,7 +79,7 @@ public class StorageFileController {
|
||||||
StorageFileService storageFileService,
|
StorageFileService storageFileService,
|
||||||
StorageFileProperties config,
|
StorageFileProperties config,
|
||||||
UserScope userScope,
|
UserScope userScope,
|
||||||
AuthorizationService authorizationService, ConventionService conventionService) {
|
AuthorizationService authorizationService, ConventionService conventionService, ValidatorFactory validatorFactory) {
|
||||||
this.auditService = auditService;
|
this.auditService = auditService;
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
this.messageSource = messageSource;
|
this.messageSource = messageSource;
|
||||||
|
@ -86,6 +88,7 @@ public class StorageFileController {
|
||||||
this.userScope = userScope;
|
this.userScope = userScope;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.conventionService = conventionService;
|
this.conventionService = conventionService;
|
||||||
|
this.validatorFactory = validatorFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,6 +108,7 @@ public class StorageFileController {
|
||||||
storageFilePersist.setOwnerId(this.userScope.getUserIdSafe());
|
storageFilePersist.setOwnerId(this.userScope.getUserIdSafe());
|
||||||
storageFilePersist.setStorageType(StorageType.Temp);
|
storageFilePersist.setStorageType(StorageType.Temp);
|
||||||
storageFilePersist.setLifetime(Duration.ofSeconds(this.config.getTempStoreLifetimeSeconds()));
|
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));
|
StorageFile persisted = this.storageFileService.persistBytes(storageFilePersist, file.getBytes(), new BaseFieldSet(StorageFile._id, StorageFile._name));
|
||||||
|
|
||||||
addedFiles.add(persisted);
|
addedFiles.add(persisted);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.controllers.v2;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.audit.AuditableAction;
|
import eu.eudat.audit.AuditableAction;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.data.SupportiveMaterialEntity;
|
import eu.eudat.data.SupportiveMaterialEntity;
|
||||||
import eu.eudat.model.SupportiveMaterial;
|
import eu.eudat.model.SupportiveMaterial;
|
||||||
import eu.eudat.model.builder.SupportiveMaterialBuilder;
|
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.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.MyValidate;
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -50,14 +50,21 @@ import java.util.stream.Stream;
|
||||||
public class SupportiveMaterialController {
|
public class SupportiveMaterialController {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(SupportiveMaterialController.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(SupportiveMaterialController.class));
|
||||||
|
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
private final AuditService auditService;
|
private final AuditService auditService;
|
||||||
|
|
||||||
private final CensorFactory censorFactory;
|
private final CensorFactory censorFactory;
|
||||||
|
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
private final SupportiveMaterialService supportiveMaterialService;
|
private final SupportiveMaterialService supportiveMaterialService;
|
||||||
|
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -117,19 +124,19 @@ public class SupportiveMaterialController {
|
||||||
|
|
||||||
SupportiveMaterialQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
SupportiveMaterialQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
||||||
List<SupportiveMaterialEntity> data = query.collectAs(lookup.getProject());
|
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);
|
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);
|
return this.supportiveMaterialService.getResponseEntity(lookup.getLanguageCodes().get(0), paths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("persist")
|
@PostMapping("persist")
|
||||||
@Transactional
|
@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));
|
logger.debug(new MapLogEntry("persisting" + SupportiveMaterial.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
this.censorFactory.censor(SupportiveMaterialCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(SupportiveMaterialCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
@ -152,5 +159,4 @@ public class SupportiveMaterialController {
|
||||||
this.auditService.track(AuditableAction.SupportiveMaterial_Delete, "id", id);
|
this.auditService.track(AuditableAction.SupportiveMaterial_Delete, "id", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,12 @@ import java.util.*;
|
||||||
public class TagController {
|
public class TagController {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagController.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagController.class));
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiContext apiContext;
|
private ApiContext apiContext;
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
private final AuditService auditService;
|
private final AuditService auditService;
|
||||||
|
|
||||||
private final TagService tagService;
|
private final TagService tagService;
|
||||||
|
@ -80,7 +82,6 @@ public class TagController {
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Tag_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.Tag_Query, "lookup", lookup);
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
|
|
||||||
return new QueryResult<>(models, count);
|
return new QueryResult<>(models, count);
|
||||||
}
|
}
|
||||||
|
@ -100,14 +101,13 @@ public class TagController {
|
||||||
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
));
|
));
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("persist")
|
@PostMapping("persist")
|
||||||
@Transactional
|
@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 {
|
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));
|
logger.debug(new MapLogEntry("persisting" + Tag.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
Tag persisted = this.tagService.persist(model, 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>("model", model),
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
));
|
));
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
return persisted;
|
return persisted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +128,5 @@ public class TagController {
|
||||||
this.tagService.deleteAndSave(id);
|
this.tagService.deleteAndSave(id);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Tag_Delete, "id", id);
|
this.auditService.track(AuditableAction.Tag_Delete, "id", id);
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,13 @@ package eu.eudat.controllers.v2;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.audit.AuditableAction;
|
import eu.eudat.audit.AuditableAction;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.data.TenantEntity;
|
import eu.eudat.data.TenantEntity;
|
||||||
import eu.eudat.model.Tenant;
|
import eu.eudat.model.Tenant;
|
||||||
import eu.eudat.model.builder.TenantBuilder;
|
import eu.eudat.model.builder.TenantBuilder;
|
||||||
import eu.eudat.model.censorship.TenantCensor;
|
import eu.eudat.model.censorship.TenantCensor;
|
||||||
import eu.eudat.model.persist.TenantPersist;
|
import eu.eudat.model.persist.TenantPersist;
|
||||||
import eu.eudat.model.result.QueryResult;
|
import eu.eudat.model.result.QueryResult;
|
||||||
import eu.eudat.model.tenantconfig.TenantSource;
|
|
||||||
import eu.eudat.query.TenantQuery;
|
import eu.eudat.query.TenantQuery;
|
||||||
import eu.eudat.query.lookup.TenantLookup;
|
import eu.eudat.query.lookup.TenantLookup;
|
||||||
import eu.eudat.service.tenant.TenantService;
|
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.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.MyValidate;
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -44,7 +43,6 @@ import java.util.AbstractMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(path = "api/tenant")
|
@RequestMapping(path = "api/tenant")
|
||||||
|
@ -88,7 +86,7 @@ public class TenantController {
|
||||||
|
|
||||||
List<TenantEntity> data = query.collectAs(lookup.getProject());
|
List<TenantEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<Tenant> models = this.builderFactory.builder(TenantBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
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));
|
models.set(models.indexOf(model), this.tenantService.decryptTenant(model));
|
||||||
}
|
}
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
@ -121,7 +119,8 @@ public class TenantController {
|
||||||
|
|
||||||
@PostMapping("persist")
|
@PostMapping("persist")
|
||||||
@Transactional
|
@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));
|
logger.debug(new MapLogEntry("persisting" + Tenant.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
this.censorFactory.censor(TenantCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(TenantCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue