RED-7439 - single transaction write for ace entries of a dossier #93
@ -17,11 +17,11 @@ public abstract class AbstractACLService<ID extends Serializable> {
|
||||
|
||||
public MutableAcl getOrCreateACL(Serializable id) {
|
||||
|
||||
ObjectIdentityImpl dossierIdentity = new ObjectIdentityImpl(getIdentifier(), id);
|
||||
var objectIdentity = new ObjectIdentityImpl(getIdentifier(), id);
|
||||
try {
|
||||
return (MutableAcl) mutableAclService.readAclById(dossierIdentity);
|
||||
return (MutableAcl) mutableAclService.readAclById(objectIdentity);
|
||||
} catch (NotFoundException e) {
|
||||
return mutableAclService.createAcl(dossierIdentity);
|
||||
return mutableAclService.createAcl(objectIdentity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -53,6 +53,11 @@ public abstract class ICustomPermissionService<T, ID extends Serializable> exten
|
||||
}
|
||||
|
||||
|
||||
public void applyCustomPermissions(CustomPermissionMappingModel customPermissionMappingModel, MutableAcl acl){
|
||||
applyAces(acl, customPermissionMappingModel);
|
||||
}
|
||||
|
||||
|
||||
protected void applyAces(MutableAcl acl, CustomPermissionMappingModel model) {
|
||||
|
||||
clearAces(acl);
|
||||
|
||||
@ -123,12 +123,12 @@ public class DossierACLService extends AbstractACLService<String> {
|
||||
}
|
||||
|
||||
members.forEach(member -> acl.insertAce(0, RedPermission.REVIEW, new PrincipalSid(member), true));
|
||||
|
||||
approvers.forEach(member -> acl.insertAce(0, RedPermission.APPROVE, new PrincipalSid(member), true));
|
||||
|
||||
customPermissionService.applyCustomPermissions(getIdentifier(), acl);
|
||||
|
||||
mutableAclService.updateAcl(acl);
|
||||
|
||||
customPermissionService.applyCustomPermissions(getIdentifier(), dossierId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.security.acls.model.MutableAcl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -110,6 +111,20 @@ public class CustomPermissionService {
|
||||
}
|
||||
|
||||
|
||||
public void applyCustomPermissions(String targetObject, MutableAcl acl) {
|
||||
var mappings = getCustomPermissionMappings(targetObject);
|
||||
applyToAcl(mappings, acl);
|
||||
}
|
||||
|
||||
public void applyToAcl(List<CustomPermissionMappingModel> customPermissionMappingModels, MutableAcl acl) {
|
||||
|
||||
customPermissionMappingModels.forEach(p -> customPermissionServices.forEach(s -> {
|
||||
if (p.getTargetPermission().getMask() == s.forPermission().getMask()) {
|
||||
s.applyCustomPermissions(p, acl);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void apply(List<CustomPermissionMappingModel> customPermissionMappingModels, Serializable objectId) {
|
||||
|
||||
customPermissionMappingModels.forEach(p -> customPermissionServices.forEach(s -> {
|
||||
@ -199,4 +214,7 @@ public class CustomPermissionService {
|
||||
this.apply(getCustomPermissionMappings(targetObject));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ public class SyncUserPermissionsJob implements Job {
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException{
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
|
||||
var singleTenant = context.getJobDetail().getJobDataMap() != null ? context.getJobDetail().getJobDataMap().get("tenantId") : null;
|
||||
tenantProvider.getTenants().forEach(tenant -> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user