use of com.epam.pipeline.controller.vo.security.EntityWithPermissionVO in project cloud-pipeline by epam.
the class GrantPermissionManager method loadAllPipelinesWithPermissions.
public PipelinesWithPermissionsVO loadAllPipelinesWithPermissions(Integer pageNum, Integer pageSize) {
// TODO: fully switch to common method loadAllEntitiesPermissions when client is ready
EntityWithPermissionVO entityWithPermissionVO = loadAllEntitiesPermissions(AclClass.PIPELINE, pageNum, pageSize, false, null);
PipelinesWithPermissionsVO result = new PipelinesWithPermissionsVO();
result.setTotalCount(entityWithPermissionVO.getTotalCount());
result.setPipelines(entityWithPermissionVO.getEntityPermissions().stream().map(e -> {
PipelineWithPermissions pipelineWithPermissions = pipelineWithPermissionsMapper.toPipelineWithPermissions((Pipeline) e.getEntity());
pipelineWithPermissions.setPermissions(e.getPermissions());
return pipelineWithPermissions;
}).collect(toSet()));
return result;
}
use of com.epam.pipeline.controller.vo.security.EntityWithPermissionVO in project cloud-pipeline by epam.
the class GrantPermissionManager method loadAllEntitiesPermissions.
public EntityWithPermissionVO loadAllEntitiesPermissions(AclClass aclClass, Integer page, Integer pageSize, boolean expandGroups, Integer filterMask) {
EntityWithPermissionVO result = new EntityWithPermissionVO();
Collection<? extends AbstractSecuredEntity> entities = entityManager.loadAllWithParents(aclClass, page, pageSize);
Map<AbstractSecuredEntity, List<AclPermissionEntry>> allPermissions = getEntitiesPermissions(entities);
result.setTotalCount(entityManager.loadTotalCount(aclClass));
List<EntityPermission> permissions = entities.stream().distinct().sorted(Comparator.comparingLong(BaseEntity::getId)).map(entity -> getEntityPermission(allPermissions, entity)).collect(toList());
if (expandGroups) {
expandGroups(permissions);
if (filterMask != null) {
permissions.forEach(entry -> {
Set<AclPermissionEntry> filtered = SetUtils.emptyIfNull(entry.getPermissions()).stream().filter(permission -> permissionsService.isMaskBitSet(permission.getMask(), filterMask)).collect(toSet());
entry.setPermissions(filtered);
});
}
}
result.setEntityPermissions(permissions);
return result;
}
Aggregations