Skip to content

Commit

Permalink
fix:fix process attachment wrong permissions - EXO-70208 (#362)
Browse files Browse the repository at this point in the history
Before this change, in a redactional space, the reactor did not have permission to edit space process attachment requests
After this change, when space is redactional only hosts and redactors can edit else all space members can edit
  • Loading branch information
GouadriaHanen authored Mar 19, 2024
1 parent ad0547e commit e093269
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,21 @@ private void moveOrCopyAttachmentsJcrNodes(List<Attachment> attachments,
permissions.put(GROUP_PROCESSES, PermissionType.ALL);
permissions.put(currentUser, PermissionType.ALL);
ProjectDto projectDto;
Space space = ProcessesUtils.getProjectParentSpace(projectId);
try {
projectDto = projectService.getProject(projectId);
projectDto.getManager().forEach(manager -> permissions.put(manager, PermissionType.ALL));
projectDto.getParticipator().forEach(participator -> permissions.put(participator, new String[] { PermissionType.READ }));
projectDto.getManager().forEach(manager -> permissions.put(manager, PermissionType.ALL));
if (space != null) {
String participator = projectDto.getParticipator().iterator().next();
String groupId = participator.substring(participator.indexOf(":") + 1);
boolean spaceHasARedactor = space != null && space.getRedactors() != null && space.getRedactors().length > 0;
if (spaceHasARedactor){
permissions.put("redactor:" + groupId, PermissionType.ALL);
} else {
permissions.put("*:" + groupId, PermissionType.ALL);
}
}
} catch (EntityNotFoundException e) {
LOG.error("Task project not found", e);
return;
Expand All @@ -158,7 +169,6 @@ private void moveOrCopyAttachmentsJcrNodes(List<Attachment> attachments,
IntStream.range(0, attachments.size()).forEach(index -> {
String attachmentId = attachments.get(index).getId();
try {
Space space = ProcessesUtils.getProjectParentSpace(projectId);
DriveData driveData;
Node rootNode;
if (space != null) {
Expand Down Expand Up @@ -191,7 +201,8 @@ private void moveOrCopyAttachmentsJcrNodes(List<Attachment> attachments,
if (destNode.canAddMixin(NodetypeConstant.EXO_PRIVILEGEABLE)) {
destNode.addMixin(NodetypeConstant.EXO_PRIVILEGEABLE);
}
((ExtendedNode) destNode).setPermissions(permissions);
Map<String, String[]> unmodifiablePermissions = Collections.unmodifiableMap(permissions);
((ExtendedNode) destNode).setPermissions(unmodifiablePermissions);
String destPath = destNode.getPath().concat("/").concat(attachmentNode.getName());
if (copy) {
session.save();
Expand Down

0 comments on commit e093269

Please sign in to comment.