status workflow auth fixes

This commit is contained in:
CITE\amentis 2024-10-14 17:56:12 +03:00
parent 0689247781
commit b7bd667486
2 changed files with 4 additions and 4 deletions

View File

@ -32,9 +32,9 @@ import org.opencdmp.model.builder.plan.PlanBuilder;
import org.opencdmp.model.description.Description;
import org.opencdmp.model.descriptionreference.DescriptionReference;
import org.opencdmp.model.descriptionstatus.DescriptionStatus;
import org.opencdmp.model.descriptionstatus.DescriptionStatusDefinitionAuthorization;
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
import org.opencdmp.model.plan.Plan;
import org.opencdmp.model.planstatus.PlanStatusDefinitionAuthorization;
import org.opencdmp.model.user.User;
import org.opencdmp.query.*;
import org.opencdmp.service.custompolicy.CustomPolicyService;
@ -394,9 +394,9 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
if (description == null) return allowed;
String editPermission = this.customPolicyService.getDescriptionStatusCanEditStatusPermission(description.getStatusId());
AffiliatedResource affiliatedResource = this.authorizationContentResolver.planAffiliation(description.getPlanId());
AffiliatedResource affiliatedResource = this.authorizationContentResolver.descriptionAffiliation(description.getId());
for (String permission : statusAuthorizationFlags.getFields()) {
if (statusAuthorizationFlags.hasField(this.asIndexer(PlanStatusDefinitionAuthorization._edit))) {
if (statusAuthorizationFlags.hasField(this.asIndexer(DescriptionStatusDefinitionAuthorization._edit))) {
Boolean isAllowed = affiliatedResource == null ? this.authorizationService.authorize(editPermission) : this.authorizationService.authorizeAtLeastOne(List.of(affiliatedResource), editPermission);
if (isAllowed) allowed.add(permission);
}

View File

@ -186,7 +186,7 @@ public class DescriptionStatusServiceImpl implements DescriptionStatusService {
List<DescriptionStatusEntity> statusEntities = this.queryFactory.query(DescriptionStatusQuery.class).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(DescriptionStatus._id));
for (DescriptionEntity description: descriptionEntities) {
authorizedStatusMap.put(description.getId(), new ArrayList<>());
AffiliatedResource affiliatedResource = this.authorizationContentResolver.planAffiliation(description.getPlanId());
AffiliatedResource affiliatedResource = this.authorizationContentResolver.descriptionAffiliation(description.getId());
for (DescriptionStatusEntity status: statusEntities) {
List<DescriptionWorkflowDefinitionTransitionEntity> availableTransitions = definition.getStatusTransitions().stream().filter(x -> x.getFromStatusId().equals(description.getStatusId())).collect(Collectors.toList());