Class UserDirectoryPersistenceUtil

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

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

    Modifier and Type
    Method
    Description
    static Function<javax.persistence.EntityManager,Long>
    countTotalGroupsQuery(String orgId, Optional<String> nameFilter, Optional<String> textFilter)
    Count how many groups there are in total fitting the filter criteria.
    static Function<javax.persistence.EntityManager,Long>
    Returns the total number of users
    static Function<javax.persistence.EntityManager,Long>
    countUsersQuery(String organizationId)
    Returns the total of users
    static org.opencastproject.util.function.ThrowingConsumer<javax.persistence.EntityManager,org.opencastproject.util.NotFoundException>
    deleteUserQuery(String username, String orgId)
    Delete the user with given name in the given organization
    static Function<javax.persistence.EntityManager,Optional<org.opencastproject.security.impl.jpa.JpaGroup>>
    Returns the persisted group by the group role name and organization id
    static Function<javax.persistence.EntityManager,Optional<org.opencastproject.security.impl.jpa.JpaGroup>>
    findGroupQuery(String groupId, String orgId)
    Returns the persisted group by the group id and organization id
    static Function<javax.persistence.EntityManager,List<org.opencastproject.security.impl.jpa.JpaGroup>>
    Returns all user groups from the persistence unit as a list
    static Function<javax.persistence.EntityManager,List<org.opencastproject.security.impl.jpa.JpaGroup>>
    findGroupsQuery(String organization, int limit, int offset)
    Returns all groups from the persistence unit as a list
    static Function<javax.persistence.EntityManager,List<org.opencastproject.security.impl.jpa.JpaGroup>>
    findGroupsQuery(String orgId, Optional<Integer> limit, Optional<Integer> offset, Optional<String> nameFilter, Optional<String> textFilter, ArrayList<org.opencastproject.util.requests.SortCriterion> sortCriteria)
    Get group list by criteria.
    static Function<javax.persistence.EntityManager,Optional<org.opencastproject.security.impl.jpa.JpaOrganization>>
    findOrganizationQuery(org.opencastproject.security.impl.jpa.JpaOrganization organization)
    Returns the persisted organization by the given organization
    static Function<javax.persistence.EntityManager,Optional<org.opencastproject.security.impl.jpa.JpaRole>>
    findRoleQuery(String name, String organization)
    Returns the persisted role by the name and organization id
    static Function<javax.persistence.EntityManager,List<org.opencastproject.security.impl.jpa.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
    static Function<javax.persistence.EntityManager,List<org.opencastproject.security.impl.jpa.JpaRole>>
    findRolesQuery(String organization, int limit, int offset)
    Returns all roles from the persistence unit as a list
    static Function<javax.persistence.EntityManager,Optional<org.opencastproject.security.impl.jpa.JpaUser>>
    findUserQuery(long id, String organizationId)
    Returns the persisted user by the user id and organization id
    static Function<javax.persistence.EntityManager,Optional<org.opencastproject.security.impl.jpa.JpaUser>>
    findUserQuery(String userName, String organizationId)
    Returns the persisted user by the user name and organization id
    static Function<javax.persistence.EntityManager,List<org.opencastproject.security.impl.jpa.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
    static Function<javax.persistence.EntityManager,List<org.opencastproject.security.impl.jpa.JpaUser>>
    findUsersByUserNameQuery(Collection<String> userNames, String organizationId)
    Return specific users by their user names
    static Function<javax.persistence.EntityManager,List<org.opencastproject.security.impl.jpa.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
    static org.opencastproject.util.function.ThrowingConsumer<javax.persistence.EntityManager,org.opencastproject.util.NotFoundException>
    removeGroupQuery(String groupId, String orgId)
     
    static Function<javax.persistence.EntityManager,org.opencastproject.security.impl.jpa.JpaOrganization>
    saveOrganizationQuery(org.opencastproject.security.impl.jpa.JpaOrganization organization)
    Persist an organization
    static Function<javax.persistence.EntityManager,Set<org.opencastproject.security.impl.jpa.JpaRole>>
    saveRolesQuery(Set<? extends org.opencastproject.security.api.Role> roles)
    Persist a set of roles
    static Function<javax.persistence.EntityManager,org.opencastproject.security.impl.jpa.JpaUser>
    saveUserQuery(org.opencastproject.security.impl.jpa.JpaUser user)
    Persist an user

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • saveRolesQuery

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

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

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

      public static Function<javax.persistence.EntityManager,List<org.opencastproject.security.impl.jpa.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> 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<org.opencastproject.security.impl.jpa.JpaGroup>> findGroupsQuery(String orgId, Optional<Integer> limit, Optional<Integer> offset, Optional<String> nameFilter, Optional<String> textFilter, ArrayList<org.opencastproject.util.requests.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<org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.JpaOrganization>> findOrganizationQuery(org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.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<org.opencastproject.security.impl.jpa.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 org.opencastproject.util.function.ThrowingConsumer<javax.persistence.EntityManager,org.opencastproject.util.NotFoundException> removeGroupQuery(String groupId, String orgId)
    • deleteUserQuery

      public static org.opencastproject.util.function.ThrowingConsumer<javax.persistence.EntityManager,org.opencastproject.util.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