Class UserDAO

All Implemented Interfaces:
Component, Contextualizable, LogEnabled, Serviceable

DAO for manipulating User
  • Field Details

  • Constructor Details

  • Method Details

    • contextualize

      public void contextualize(Context context) throws ContextException
      Specified by:
      contextualize in interface Contextualizable
      Throws:
      ContextException
    • service

      public void service(ServiceManager smanager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • getUsersByUserIdentitiesAndContexts

      public List<Map<String,Object>> getUsersByUserIdentitiesAndContexts(List<String> userIdentities, List<String> contexts, Boolean limitedToStoredUserData)
      Get the list of users for given user identities in given contexts
      Parameters:
      userIdentities - The user identities to search for
      contexts - The contexts The context in which to find the users. Can be null. Defaults to the current context. If no contexts are found, the current user need to have admin rights.
      limitedToStoredUserData - true to only retrieve the data from stored user, false to retrieve everything. Can be null. Defaults to "false"
      Returns:
      a non-null list of users
    • searchUsersByContexts

      public List<Map<String,Object>> searchUsersByContexts(List<String> contexts, Integer limit, Integer offset, String searchCriteria, Boolean limitedToStoredUserData)
      Search for users in given contexts
      Parameters:
      contexts - The context in which to find the users. Cannot be null.
      limit - The limit of results. Can be null. Defaults to value _DEFAULT_SEARCH_COUNT_VALUE.
      offset - The offset, where to start returning results (offset). Can be null. Defaults to value _DEFAULT_SEARCH_OFFSET_VALUE
      searchCriteria - The criteria (pattern) for the search. Can be null.
      limitedToStoredUserData - true to only retrieve the data from stored user, false to retrieve everything. Can be null. Defaults to "false"
      Returns:
      a non-null list of users
    • searchUsersByDirectory

      public List<Map<String,Object>> searchUsersByDirectory(String userDirectoryId, String userPopulationId, Integer limit, Integer offset, String searchCriteria, Boolean limitedToStoredUserData)
      Search for users in given user directory
      Parameters:
      userDirectoryId - The id of the user directory in which to find the users. Cannot be null.
      userPopulationId - The id of the user population in which to find the users. Cannot be null.
      limit - The limit of results. Can be null. Defaults to value _DEFAULT_SEARCH_COUNT_VALUE.
      offset - The offset, where to start returning results (offset). Can be null. Defaults to value _DEFAULT_SEARCH_OFFSET_VALUE
      searchCriteria - The criteria (pattern) for the search. Can be null.
      limitedToStoredUserData - true to only retrieve the data from stored user, false to retrieve everything. Can be null. Defaults to "false"
      Returns:
      a non-null list of users
    • searchUsersByPopulation

      public List<Map<String,Object>> searchUsersByPopulation(String userPopulationId, Integer limit, Integer offset, String searchCriteria, Boolean limitedToStoredUserData)
      Search for users in given user population
      Parameters:
      userPopulationId - The id of the user population in which to find the users. Cannot be null.
      limit - The limit of results. Can be null. Defaults to value _DEFAULT_SEARCH_COUNT_VALUE.
      offset - The offset, where to start returning results (offset). Can be null. Defaults to value _DEFAULT_SEARCH_OFFSET_VALUE
      searchCriteria - The criteria (pattern) for the search. Can be null.
      limitedToStoredUserData - true to only retrieve the data from stored user, false to retrieve everything. Can be null. Defaults to "false"
      Returns:
      a non-null list of users
    • _getSearchParameters

      protected Map<String,Object> _getSearchParameters(String searchCriteria)
      Get the search parameters
      Parameters:
      searchCriteria - The search pattern
      Returns:
      the search parameters
    • getUser

      public Map<String,Object> getUser(String login, String populationId)
      Get user's information
      Parameters:
      login - The user's login
      populationId - The id of the population
      Returns:
      The user's information
    • getStoredUser

      public Map<String,Object> getStoredUser(String login, String populationId)
      Get user's information
      Parameters:
      login - The user's login
      populationId - The id of the population
      Returns:
      The user's information
    • isModifiable

      public Map<String,Object> isModifiable(String login, String populationId)
      Checks if the user is modifiable and if current user is allowed to edit it
      Parameters:
      login - The users's login
      populationId - The id of the population of the user
      Returns:
      A map with the "isModifiable" at true if the user is modifiable
    • isRemovable

      public Map<String,Object> isRemovable(String login, String populationId)
      Checks if the user is removable and if current user is allowed to remove it
      Parameters:
      login - The users's login
      populationId - The id of the population of the user
      Returns:
      A map with the "isRemovable" at true if the user is removable
    • addUser

      public Map<String,Object> addUser(String populationId, String userDirectoryId, Map<String,String> untypedValues) throws InvalidModificationException
      Creates a User
      Parameters:
      populationId - The id of the user population
      userDirectoryId - The id of the user directory
      untypedValues - The untyped user's parameters
      Returns:
      The created user as JSON object
      Throws:
      InvalidModificationException - If modification is not possible
    • _canHandle

      protected boolean _canHandle(String populationId)
      Check current user can handle the population of users
      Parameters:
      populationId - the id of population
      Returns:
      true if user is allowed to handle this population
    • editUser

      public Map<String,Object> editUser(String populationId, Map<String,String> untypedValues) throws InvalidModificationException
      Edits a User
      Parameters:
      populationId - The id of the population of the user to edit
      untypedValues - The untyped user's parameters
      Returns:
      The update user as JSON object
      Throws:
      InvalidModificationException - If modification is not possible
    • deleteUsers

      Deletes users
      Parameters:
      users - The users to delete
      Returns:
      the result with deleted users and undeleted users
      Throws:
      InvalidModificationException - If modification is not possible
    • getEditionModelForUSer

      Get the users edition model
      Parameters:
      login - The user's login to edit
      populationId - The id of the population of the user to edit
      Returns:
      The edition model as an object
      Throws:
      InvalidModificationException - If modification is not possible
    • getEditionModelForDirectory

      public Map<String,Object> getEditionModelForDirectory(String populationId, String userDirectoryId) throws InvalidModificationException
      Get the users edition model
      Parameters:
      populationId - The id of the population where to add a user
      userDirectoryId - The id of the user directory where to add a user
      Returns:
      The edition model as an object
      Throws:
      InvalidModificationException - If modification is not possible
    • impersonate

      public Map<String,String> impersonate(String login, String populationId) throws AccessDeniedException
      Impersonate the selected user
      Parameters:
      login - the login of the user to impersonate
      populationId - The id of the population
      Returns:
      a map of information on the user
      Throws:
      AccessDeniedException - If the currently connected user has no right to do so
    • _getCurrentUser

      Provides the login of the current user.
      Returns:
      the login which cannot be null.