description template new version tenant validation

This commit is contained in:
Efstratios Giannopoulos 2024-04-05 14:13:30 +03:00
parent efb816c627
commit 028b1e0c94
1 changed files with 3 additions and 5 deletions

View File

@ -66,11 +66,7 @@ import javax.xml.transform.TransformerException;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -666,6 +662,8 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
if (!this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt()).equals(model.getHash())) if (!this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt()).equals(model.getHash()))
throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
if (!this.tenantScope.isSet() || !Objects.equals(oldDescriptionTemplateEntity.getTenantId(), this.tenantScope.getTenant())) throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage());
List<DescriptionTemplateEntity> latestVersionDescriptionTemplates = this.queryFactory.query(DescriptionTemplateQuery.class) List<DescriptionTemplateEntity> latestVersionDescriptionTemplates = this.queryFactory.query(DescriptionTemplateQuery.class)
.versionStatuses(DescriptionTemplateVersionStatus.Current) .versionStatuses(DescriptionTemplateVersionStatus.Current)
.isActive(IsActive.Active) .isActive(IsActive.Active)