Class UserDirectoryPersistenceUtil

java.lang.Object
org.opencastproject.userdirectory.UserDirectoryPersistenceUtil

public final class UserDirectoryPersistenceUtil extends Object
Utility class for user directory persistence methods
  • Method Details

    • saveRolesQuery

      public static Function<javax.persistence.EntityManager,Set<JpaRole>> saveRolesQuery(Set<? extends Role> roles)
      Persist a set of roles
      Parameters:
      roles - the roles to persist
      Returns:
      the persisted roles
    • saveOrganizationQuery

      public static Function<javax.persistence.EntityManager,JpaOrganization> saveOrganizationQuery(JpaOrganization organization)
      Persist an organization
      Parameters:
      organization - the organization to persist
      Returns:
      the persisted organization
    • saveUserQuery

      public static Function<javax.persistence.EntityManager,JpaUser> saveUserQuery(JpaUser user)
      Persist an user
      Parameters:
      user - the user to persist
      Returns:
      the persisted organization
    • findGroupsQuery

      public static Function<javax.persistence.EntityManager,List<JpaGroup>> findGroupsQuery(String organization, int limit, int offset)
      Returns all groups from the persistence unit as a list
      Parameters:
      organization - the organization
      limit - the limit
      offset - the offset
      Returns:
      the group list
    • countTotalGroupsQuery

      public static Function<javax.persistence.EntityManager,Long> countTotalGroupsQuery(String orgId, Optional<String> nameFilter, Optional<String> roleFilter, Optional<String> textFilter)
      Count how many groups there are in total fitting the filter criteria.
      Parameters:
      orgId - the organization id
      nameFilter - filter by group name (optional)
      textFilter - fulltext filter (optional)
      Returns:
      the group list
      Throws:
      IllegalArgumentException
    • findGroupsQuery

      public static Function<javax.persistence.EntityManager,List<JpaGroup>> findGroupsQuery(String orgId, Optional<Integer> limit, Optional<Integer> offset, Optional<String> nameFilter, Optional<String> roleFilter, Optional<String> textFilter, ArrayList<SortCriterion> sortCriteria)
      Get group list by criteria.
      Parameters:
      orgId - the organization id
      limit - the limit (optional)
      offset - the offset (optional)
      nameFilter - filter by group name (optional)
      textFilter - fulltext filter (optional)
      sortCriteria - the sorting criteria (name, role or description)
      Returns:
      the group list
    • findRolesQuery

      public static Function<javax.persistence.EntityManager,List<JpaRole>> findRolesQuery(String organization, int limit, int offset)
      Returns all roles from the persistence unit as a list
      Parameters:
      organization - the organization
      limit - the limit
      offset - the offset
      Returns:
      the roles list
    • findRolesByQuery

      public static Function<javax.persistence.EntityManager,List<JpaRole>> findRolesByQuery(String orgId, String query, int limit, int offset)
      Returns a list of roles by a search query if set or all roles if search query is null
      Parameters:
      orgId - the organization identifier
      query - the query to search
      limit - the limit
      offset - the offset
      Returns:
      the roles list
    • findGroupsByUserQuery

      public static Function<javax.persistence.EntityManager,List<JpaGroup>> findGroupsByUserQuery(String userName, String orgId)
      Returns all user groups from the persistence unit as a list
      Parameters:
      userName - the user name
      orgId - the user's organization
      Returns:
      the group list
    • findOrganizationQuery

      public static Function<javax.persistence.EntityManager,Optional<JpaOrganization>> findOrganizationQuery(JpaOrganization organization)
      Returns the persisted organization by the given organization
      Parameters:
      organization - the organization
      Returns:
      the organization or null if not found
    • findUsersByUserNameQuery

      public static Function<javax.persistence.EntityManager,List<JpaUser>> findUsersByUserNameQuery(Collection<String> userNames, String organizationId)
      Return specific users by their user names
      Parameters:
      userNames - list of user names
      organizationId - organization to search for
      Returns:
      the list of users that was found
    • findUserQuery

      public static Function<javax.persistence.EntityManager,Optional<JpaUser>> findUserQuery(String userName, String organizationId)
      Returns the persisted user by the user name and organization id
      Parameters:
      userName - the user name
      organizationId - the organization id
      Returns:
      the user or null if not found
    • findUserQuery

      public static Function<javax.persistence.EntityManager,Optional<JpaUser>> findUserQuery(long id, String organizationId)
      Returns the persisted user by the user id and organization id
      Parameters:
      id - the user's unique id
      organizationId - the organization id
      Returns:
      the user or null if not found
    • countUsersQuery

      public static Function<javax.persistence.EntityManager,Long> countUsersQuery(String organizationId)
      Returns the total of users
      Parameters:
      organizationId - the organization id
      Returns:
      the total number of users
    • countUsersQuery

      public static Function<javax.persistence.EntityManager,Long> countUsersQuery()
      Returns the total number of users
      Returns:
      the total number of users
    • findUsersByQuery

      public static Function<javax.persistence.EntityManager,List<JpaUser>> findUsersByQuery(String orgId, String query, int limit, int offset)
      Returns a list of users by a search query if set or all users if search query is null
      Parameters:
      orgId - the organization identifier
      query - the query to search
      limit - the limit
      offset - the offset
      Returns:
      the users list
    • findUsersQuery

      public static Function<javax.persistence.EntityManager,List<JpaUser>> findUsersQuery(String orgId, int limit, int offset)
      Returns a list of users by a search query if set or all users if search query is null
      Parameters:
      orgId - , the organization id
      limit - the limit
      offset - the offset
      Returns:
      the users list
    • findRoleQuery

      public static Function<javax.persistence.EntityManager,Optional<JpaRole>> findRoleQuery(String name, String organization)
      Returns the persisted role by the name and organization id
      Parameters:
      name - the role name
      organization - the organization id
      Returns:
      the user or null if not found
    • findGroupQuery

      public static Function<javax.persistence.EntityManager,Optional<JpaGroup>> findGroupQuery(String groupId, String orgId)
      Returns the persisted group by the group id and organization id
      Parameters:
      groupId - the group id
      orgId - the organization id
      Returns:
      the group or null if not found
    • findGroupByRoleQuery

      public static Function<javax.persistence.EntityManager,Optional<JpaGroup>> findGroupByRoleQuery(String role, String orgId)
      Returns the persisted group by the group role name and organization id
      Parameters:
      role - the role name
      orgId - the organization id
      Returns:
      the group or null if not found
    • removeGroupQuery

      public static ThrowingConsumer<javax.persistence.EntityManager,NotFoundException> removeGroupQuery(String groupId, String orgId)
    • deleteUserQuery

      public static ThrowingConsumer<javax.persistence.EntityManager,NotFoundException> deleteUserQuery(String username, String orgId)
      Delete the user with given name in the given organization
      Parameters:
      username - the name of the user to delete
      orgId - the organization id