Class UserDirectoryPersistenceUtil
java.lang.Object
org.opencastproject.userdirectory.UserDirectoryPersistenceUtil
Utility class for user directory persistence methods
-
Method Summary
Modifier and TypeMethodDescriptioncountTotalGroupsQuery(String orgId, Optional<String> nameFilter, Optional<String> roleFilter, Optional<String> textFilter) Count how many groups there are in total fitting the filter criteria.Returns the total number of userscountUsersQuery(String organizationId) Returns the total of usersstatic ThrowingConsumer<javax.persistence.EntityManager, NotFoundException> deleteUserQuery(String username, String orgId) Delete the user with given name in the given organizationfindGroupByRoleQuery(String role, String orgId) Returns the persisted group by the group role name and organization idfindGroupQuery(String groupId, String orgId) Returns the persisted group by the group id and organization idfindGroupsByUserQuery(String userName, String orgId) Returns all user groups from the persistence unit as a listfindGroupsQuery(String organization, int limit, int offset) Returns all groups from the persistence unit as a listfindGroupsQuery(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.static Function<javax.persistence.EntityManager, Optional<JpaOrganization>> findOrganizationQuery(JpaOrganization organization) Returns the persisted organization by the given organizationfindRoleQuery(String name, String organization) Returns the persisted role by the name and organization idfindRolesByQuery(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 isnullfindRolesQuery(String organization, int limit, int offset) Returns all roles from the persistence unit as a listfindUserQuery(long id, String organizationId) Returns the persisted user by the user id and organization idfindUserQuery(String userName, String organizationId) Returns the persisted user by the user name and organization idfindUsersByQuery(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 isnullfindUsersByUserNameQuery(Collection<String> userNames, String organizationId) Return specific users by their user namesfindUsersQuery(String orgId, int limit, int offset) Returns a list of users by a search query if set or all users if search query isnullstatic ThrowingConsumer<javax.persistence.EntityManager, NotFoundException> removeGroupQuery(String groupId, String orgId) static Function<javax.persistence.EntityManager, JpaOrganization> saveOrganizationQuery(JpaOrganization organization) Persist an organizationsaveRolesQuery(Set<? extends Role> roles) Persist a set of rolessaveUserQuery(JpaUser user) Persist an user
-
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
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 organizationlimit- the limitoffset- 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 idnameFilter- 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 idlimit- 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 organizationlimit- the limitoffset- 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 isnull- Parameters:
orgId- the organization identifierquery- the query to searchlimit- the limitoffset- 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 nameorgId- 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
nullif 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 namesorganizationId- 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 nameorganizationId- the organization id- Returns:
- the user or
nullif 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 idorganizationId- the organization id- Returns:
- the user or
nullif not found
-
countUsersQuery
Returns the total of users- Parameters:
organizationId- the organization id- Returns:
- the total number of users
-
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 isnull- Parameters:
orgId- the organization identifierquery- the query to searchlimit- the limitoffset- 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 isnull- Parameters:
orgId- , the organization idlimit- the limitoffset- 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 nameorganization- the organization id- Returns:
- the user or
nullif 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 idorgId- the organization id- Returns:
- the group or
nullif 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 nameorgId- the organization id- Returns:
- the group or
nullif 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 deleteorgId- the organization id
-