use of com.epam.pipeline.entity.AbstractHierarchicalEntity in project cloud-pipeline by epam.
the class GrantPermissionManager method clearWriteExecutePermissions.
private void clearWriteExecutePermissions(AbstractSecuredEntity entity) {
int readBits = AclPermission.READ.getMask() | AclPermission.NO_READ.getMask();
MutableAcl acl = aclService.getOrCreateObjectIdentity(entity);
List<AccessControlEntry> newAces = new ArrayList<>();
List<AccessControlEntry> aces = acl.getEntries();
for (int i = 0; i < aces.size(); i++) {
AccessControlEntry ace = aces.get(i);
if (permissionsService.isPermissionSet(ace.getPermission().getMask(), (AclPermission) AclPermission.READ)) {
Permission updated = permissionFactory.buildFromMask(ace.getPermission().getMask() & readBits);
AccessControlEntry newAce = new AccessControlEntryImpl(ace.getId(), ace.getAcl(), ace.getSid(), updated, true, false, false);
newAces.add(newAce);
}
}
clearAces(acl);
for (int i = 0; i < newAces.size(); i++) {
AccessControlEntry newAce = newAces.get(i);
acl.insertAce(i, newAce.getPermission(), newAce.getSid(), true);
}
aclService.updateAcl(acl);
if (entity instanceof AbstractHierarchicalEntity) {
AbstractHierarchicalEntity tree = (AbstractHierarchicalEntity) entity;
if (!CollectionUtils.isEmpty(tree.getChildren())) {
tree.getChildren().forEach(this::clearWriteExecutePermissions);
}
if (!CollectionUtils.isEmpty(tree.getLeaves())) {
tree.getLeaves().forEach(this::clearWriteExecutePermissions);
}
}
}
use of com.epam.pipeline.entity.AbstractHierarchicalEntity in project cloud-pipeline by epam.
the class FolderManager method deleteForce.
/**
* Deletes a folder with all contents, specified by ID.
* @param id of {@link Folder} to delete
* @return deleted {@link Folder} instance
*/
public Folder deleteForce(Long id) {
Folder folder = crudManager.load(id);
if (!CollectionUtils.isEmpty(folder.getChildren())) {
for (AbstractHierarchicalEntity hierarchicalEntity : folder.getChildren()) {
deleteForce(hierarchicalEntity.getId());
}
}
deleteChildren(folder);
return folder;
}
Aggregations