Class DenormalisedSpacePermissionDao


  • public class DenormalisedSpacePermissionDao
    extends Object
    DAO for denormalised space permission table. It works with several tables - one table per each permission type. At this moment, two permission types, VIEWSPACE and EDITSPACE are supported.
    Since:
    7.10.0
    See Also:
    SpacePermissionType
    • Constructor Detail

      • DenormalisedSpacePermissionDao

        public DenormalisedSpacePermissionDao​(org.hibernate.SessionFactory sessionFactory)
    • Method Detail

      • findPermissionsForSpaces

        public Map<Long,​List<DenormalisedSpacePermission>> findPermissionsForSpaces​(Set<Long> spaceIds,
                                                                                          SpacePermissionType permissionType)
        Retrieves all denormalised space permissions for the provided set of space ids
        Parameters:
        spaceIds - set of space ids
        permissionType - permission type (view permissions or edit permissions)
        Returns:
        map where key is space id and value is a list of DenormalisedSpacePermission records
      • findPermittedSpaces

        public List<Space> findPermittedSpaces​(List<Long> sidList,
                                               SpacePermissionType permissionType)
        Retrieves all permitted spaces, filtered by space permissions and sid list
        Parameters:
        sidList - sid list
        permissionType - permission type
        Returns:
        permitted space list
      • findPermittedSpaceIds

        public Set<Long> findPermittedSpaceIds​(Set<Long> sids,
                                               Set<Long> spaceIds,
                                               SpacePermissionType permissionType)
        Receives a set of space ids and returns only permitted ones.
        Parameters:
        sids - user sids
        permissionType - permission type
        Returns:
        permitted space list
      • getAllSpacesKeysWithPermissionInfo

        public List<SpaceKeyWithPermission> getAllSpacesKeysWithPermissionInfo​(Set<Long> sids,
                                                                               SpacePermissionType permissionType)
        Retrieves all space keys. Each space key has a flag which indicates whether space is permitted or not
        Parameters:
        sids - sid list
        permissionType - permission type
        Returns:
        list if space keys with the corresponding permission statuses
      • getSpaces

        public List<Space> getSpaces​(Set<Long> sids,
                                     SpacePermissionType permissionType,
                                     SpacesQuery spaceQuery,
                                     int offset,
                                     int limit,
                                     boolean permissionExempt)
        Returns a list of permitted spaces Spaces could be additionally filtered by provided optional filters
        Parameters:
        sids - sid id list
        permissionType - permission type
        spaceQuery - space query
        offset - offset
        limit - limit
        permissionExempt - if true all spaces should be returned
        Returns:
        space list
      • getOrphanSpacesInFastPermissions

        public List<Long> getOrphanSpacesInFastPermissions​(SpacePermissionType spacePermissionType,
                                                           int limit)
        Returns the list of space id that do not exist in the DB anymore but fast space permissions still have references to them.
      • deleteFastSpacePermissionsForSpaces

        public void deleteFastSpacePermissionsForSpaces​(SpacePermissionType spacePermissionType,
                                                        Collection<Long> spaceIds)
        Removes all fast space permissions for the provided list of space ids.
        Parameters:
        spaceIds - space ids